1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.tikv.common.meta;
19
20 import com.fasterxml.jackson.annotation.JsonCreator;
21 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
22 import com.fasterxml.jackson.annotation.JsonProperty;
23 import java.io.Serializable;
24 import org.tikv.common.types.DataType;
25
26 @JsonIgnoreProperties(ignoreUnknown = true)
27 public class TiIndexColumn implements Serializable {
28 private final String name;
29 private final int offset;
30 private final long length;
31
32 @JsonCreator
33 public TiIndexColumn(
34 @JsonProperty("name") org.tikv.common.meta.CIStr name,
35 @JsonProperty("offset") int offset,
36 @JsonProperty("length") long length) {
37 this.name = name.getL();
38 this.offset = offset;
39 this.length = length;
40 }
41
42 public String getName() {
43 return name;
44 }
45
46 public int getOffset() {
47 return offset;
48 }
49
50 public long getLength() {
51 return length;
52 }
53
54 public boolean isLengthUnspecified() {
55 return DataType.isLengthUnSpecified(length);
56 }
57
58 public boolean isPrefixIndex() {
59 return !isLengthUnspecified();
60 }
61
62 public boolean matchName(String otherName) {
63 return name.equalsIgnoreCase(otherName);
64 }
65
66 @Override
67 public String toString() {
68 return String.format(
69 "%s {name: %s, offset: %d, length: %d}", getClass().getSimpleName(), name, offset, length);
70 }
71 }