1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.tikv.common.util;
19
20 import com.google.protobuf.ByteString;
21
22
23 public class ScanOption {
24 private final ByteString startKey;
25 private final ByteString endKey;
26 private final int limit;
27 private final boolean keyOnly;
28
29 private ScanOption(ByteString startKey, ByteString endKey, int limit, boolean keyOnly) {
30 this.startKey = startKey;
31 this.endKey = endKey;
32 this.limit = limit;
33 this.keyOnly = keyOnly;
34 }
35
36 public static ScanOptionBuilder newBuilder() {
37 return new ScanOptionBuilder();
38 }
39
40 public ByteString getStartKey() {
41 return startKey;
42 }
43
44 public ByteString getEndKey() {
45 return endKey;
46 }
47
48 public int getLimit() {
49 return limit;
50 }
51
52 public boolean isKeyOnly() {
53 return keyOnly;
54 }
55
56 public static class ScanOptionBuilder {
57 private ByteString startKey;
58 private ByteString endKey;
59 private int limit;
60 private boolean keyOnly;
61
62 private ScanOptionBuilder() {
63 this.startKey = ByteString.EMPTY;
64 this.endKey = ByteString.EMPTY;
65 this.limit = 0;
66 this.keyOnly = false;
67 }
68
69 public ScanOption build() {
70 return new ScanOption(startKey, endKey, limit, keyOnly);
71 }
72
73 public ScanOptionBuilder setStartKey(ByteString startKey) {
74 this.startKey = startKey;
75 return this;
76 }
77
78 public ScanOptionBuilder setEndKey(ByteString endKey) {
79 this.endKey = endKey;
80 return this;
81 }
82
83 public ScanOptionBuilder setLimit(int limit) {
84 this.limit = limit;
85 return this;
86 }
87
88 public ScanOptionBuilder setKeyOnly(boolean keyOnly) {
89 this.keyOnly = keyOnly;
90 return this;
91 }
92 }
93 }