-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reform java client to combine with TiSpark's java client (#91)
- Loading branch information
Showing
190 changed files
with
24,697 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# TiSpark Dev Tools Guide | ||
|
||
## Formatting | ||
|
||
### Java Format | ||
|
||
TiKV Java Client formats its code using [Google-Java-Format Maven Plugin](https://github.com/coveooss/fmt-maven-plugin) which follows Google's code styleguide. It is also checked on CI before build. | ||
|
||
1. In Intellij IDEA | ||
|
||
1. you should download the [Google-Java-format Plugin](https://plugins.jetbrains.com/plugin/8527-google-java-format) via marketplace. Restart IDE, and enable google-java-format by checking the box in `Other Settings`. | ||
|
||
2. you may also use [Java-Google-style xml file](./intellij-java-google-style.xml) and export the schema to Intellij: | ||
|
||
`Preferences`->`Editor`->`Code Style`->`Import Scheme`->`Intellij IDEA Code Style XML`. | ||
|
||
2. You may also run [Java format script](./javafmt) before you commit & push to corresponding dev branch. | ||
|
||
```shell script | ||
./dev/javafmt | ||
``` |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo $MAVEN_HOME | ||
|
||
mvn com.coveo:fmt-maven-plugin:format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2020 PingCAP, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.tikv.common; | ||
|
||
public class BytePairWrapper { | ||
private final byte[] key; | ||
private final byte[] value; | ||
|
||
public BytePairWrapper(byte[] key, byte[] value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
public byte[] getKey() { | ||
return key; | ||
} | ||
|
||
public byte[] getValue() { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2020 PingCAP, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.tikv.common; | ||
|
||
import java.util.Arrays; | ||
|
||
public class ByteWrapper { | ||
private final byte[] bytes; | ||
|
||
public ByteWrapper(byte[] bytes) { | ||
this.bytes = bytes; | ||
} | ||
|
||
public byte[] getBytes() { | ||
return this.bytes; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
ByteWrapper that = (ByteWrapper) o; | ||
|
||
return Arrays.equals(bytes, that.bytes); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Arrays.hashCode(bytes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* | ||
* Copyright 2019 PingCAP, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.tikv.common; | ||
|
||
import java.sql.Timestamp; | ||
import org.joda.time.DateTime; | ||
|
||
/** Extend joda DateTime to support micro second */ | ||
public class ExtendedDateTime { | ||
|
||
private final DateTime dateTime; | ||
private final int microsOfMillis; | ||
|
||
/** | ||
* if timestamp = 2019-11-11 11:11:11 123456, then dateTime = 2019-11-11 11:11:11 123 | ||
* microInMillis = 456 | ||
* | ||
* @param dateTime | ||
* @param microsOfMillis | ||
*/ | ||
public ExtendedDateTime(DateTime dateTime, int microsOfMillis) { | ||
this.dateTime = dateTime; | ||
this.microsOfMillis = microsOfMillis; | ||
} | ||
|
||
public ExtendedDateTime(DateTime dateTime) { | ||
this.dateTime = dateTime; | ||
this.microsOfMillis = 0; | ||
} | ||
|
||
public DateTime getDateTime() { | ||
return dateTime; | ||
} | ||
|
||
public int getMicrosOfSeconds() { | ||
return dateTime.getMillisOfSecond() * 1000 + microsOfMillis; | ||
} | ||
|
||
public int getMicrosOfMillis() { | ||
return microsOfMillis; | ||
} | ||
|
||
public Timestamp toTimeStamp() { | ||
Timestamp timestamp = new Timestamp(dateTime.getMillis() / 1000 * 1000); | ||
timestamp.setNanos(dateTime.getMillisOfSecond() * 1000000 + microsOfMillis * 1000); | ||
return timestamp; | ||
} | ||
|
||
public long toEpochMicro() { | ||
return toTimeStamp().getTime() * 1000 + getMicrosOfMillis(); | ||
} | ||
} |
Oops, something went wrong.