Skip to content

Commit daca5d2

Browse files
birdstormZhexuan Yang
authored andcommitted
Add gradle build documents (#59)
1 parent 67112a9 commit daca5d2

File tree

7 files changed

+190
-132
lines changed

7 files changed

+190
-132
lines changed

README.md

Lines changed: 98 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,59 @@ It is supposed to:
99

1010
## How to build
1111

12+
### Gradle
13+
14+
Alternatively, you can build `tikv-client-java` with gradle.
15+
16+
The following command will build the project.
17+
18+
```
19+
gradle init
20+
gradle clean build -x test
21+
```
22+
23+
To make a jar with dependencies
24+
25+
```
26+
gradle clean fatJar -x test
27+
```
28+
29+
The jar can be found in `./build/libs/`
30+
31+
### Maven
32+
1233
The alternative way to build a usable jar for testing will be
34+
1335
```
1436
mvn clean install -Dmaven.test.skip=true
1537
```
1638

1739
The following command can install dependencies for you.
40+
1841
```
1942
mvn package
2043
```
2144

45+
The jar can be found in `./target/`
46+
47+
### Bazel
48+
2249
Alternatively, you can use `bazel` for much faster build. When you try this approach, you should run `git submodule update --init --recursive` before you build project.
2350

2451
Making a uber jar:
52+
2553
```
2654
make uber_jar
2755
```
56+
2857
run Main class:
58+
2959
```
3060
make run
3161
```
3262

3363
run test cases:
64+
3465
```
3566
make test
3667
```
@@ -39,8 +70,9 @@ this project is designed to hook with `pd` and `tikv` which you can find in `Pin
3970

4071
When you work with this project, you have to communicate with `pd` and `tikv`. Please run TiKV and PD in advance.
4172

42-
## Raw TiKV-Client in Java
43-
Java Implementation of Raw TiKV-Client
73+
## Component: Raw Ti-Client in Java
74+
75+
Java Implementation of Raw TiKV-Client to support RawKVClient commands.
4476

4577
Demo is avaliable in [KVRawClientTest](https://github.com/birdstorm/KVRawClientTest/)
4678

@@ -49,79 +81,94 @@ Demo is avaliable in [KVRawClientTest](https://github.com/birdstorm/KVRawClientT
4981
mvn clean install -Dmaven.test.skip=true
5082
```
5183

52-
### Use as maven dependency
53-
After building, add following lines into your `pom.xml`
84+
### Add to dependency
85+
86+
#### Use jar for binary
87+
88+
Add your jar built with all dependencies into you project's library to use `tikv-client-java` as dependency
89+
90+
#### Use as maven dependency
91+
92+
After building, add following lines into your `pom.xml` if you are using Maven
93+
5494
```xml
5595
<dependency>
56-
<groupId>org.tikv</groupId>
57-
<artifactId>tikv-client-java</artifactId>
58-
<version>2.0-SNAPSHOT</version>
96+
<groupId>org.tikv</groupId>
97+
<artifactId>tikv-client-java</artifactId>
98+
<version>2.0-SNAPSHOT</version>
5999
</dependency>
60100
```
61101

62102
### Entrance
63-
`com.pingcap.tikv.RawKVClient`
103+
`org.tikv.raw.RawKVClient`
64104

65-
### API
105+
### Create a RawKVClient
66106

67107
```java
68-
/**
69-
* create a RawKVClient using specific pd addresses
70-
*
71-
* @param address pd addresses(comma seperated)
72-
*/
73-
static RawKVClient create(String address)
108+
import org.tikv.common.TiSession;
109+
import org.tikv.raw.RawKVClient;
110+
111+
public class Main {
112+
public static void main() {
113+
// You MUST create a raw configuration if you are using RawKVClient.
114+
TiConfiguration conf = TiConfiguration.createRawDefault(YOUR_PD_ADDRESSES);
115+
TiSession session = TiSession.create(conf);
116+
RawKVClient = session.createRawKVClient();
117+
}
118+
}
74119
```
75120

121+
### API
122+
76123
```java
77-
/**
78-
* Put a raw key-value pair to TiKV
79-
*
80-
* @param key raw key
81-
* @param value raw value
82-
*/
83-
void put(ByteString key, ByteString value)
124+
/**
125+
* Put a raw key-value pair to TiKV
126+
*
127+
* @param key raw key
128+
* @param value raw value
129+
*/
130+
void put(ByteString key, ByteString value)
84131
```
85132

86133
```java
87-
/**
88-
* Get a raw key-value pair from TiKV if key exists
89-
*
90-
* @param key raw key
91-
* @return a ByteString value if key exists, ByteString.EMPTY if key does not exist
92-
*/
93-
ByteString get(ByteString key)
134+
/**
135+
* Get a raw key-value pair from TiKV if key exists
136+
*
137+
* @param key raw key
138+
* @return a ByteString value if key exists, ByteString.EMPTY if key does not exist
139+
*/
140+
ByteString get(ByteString key)
94141
```
95142

96143
```java
97-
/**
98-
* Scan raw key-value pairs from TiKV in range [startKey, endKey)
99-
*
100-
* @param startKey raw start key, inclusive
101-
* @param endKey raw end key, exclusive
102-
* @return list of key-value pairs in range
103-
*/
104-
List<Kvrpcpb.KvPair> scan(ByteString startKey, ByteString endKey)
144+
/**
145+
* Scan raw key-value pairs from TiKV in range [startKey, endKey)
146+
*
147+
* @param startKey raw start key, inclusive
148+
* @param endKey raw end key, exclusive
149+
* @return list of key-value pairs in range
150+
*/
151+
List<Kvrpcpb.KvPair> scan(ByteString startKey, ByteString endKey)
105152
```
106153

107154
```java
108-
/**
109-
* Scan raw key-value pairs from TiKV in range [startKey, endKey)
110-
*
111-
* @param startKey raw start key, inclusive
112-
* @param limit limit of key-value pairs
113-
* @return list of key-value pairs in range
114-
*/
115-
List<Kvrpcpb.KvPair> scan(ByteString startKey, int limit)
155+
/**
156+
* Scan raw key-value pairs from TiKV in range [startKey, endKey)
157+
*
158+
* @param startKey raw start key, inclusive
159+
* @param limit limit of key-value pairs
160+
* @return list of key-value pairs in range
161+
*/
162+
List<Kvrpcpb.KvPair> scan(ByteString startKey, int limit)
116163
```
117164

118165
```java
119-
/**
120-
* Delete a raw key-value pair from TiKV if key exists
121-
*
122-
* @param key raw key to be deleted
123-
*/
124-
void delete(ByteString key)
166+
/**
167+
* Delete a raw key-value pair from TiKV if key exists
168+
*
169+
* @param key raw key to be deleted
170+
*/
171+
void delete(ByteString key)
125172
```
126173

127174

0 commit comments

Comments
 (0)