Skip to content

Commit f325c0d

Browse files
committed
NebulaGraph Java SDK 5.2.0
1 parent 3a840da commit f325c0d

20 files changed

Lines changed: 38 additions & 3344 deletions

File tree

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.vesoft</groupId>
88
<artifactId>nebula</artifactId>
9-
<version>5.3-SNAPSHOT</version>
9+
<version>5.2.0</version>
1010
</parent>
1111

1212
<artifactId>driver</artifactId>

client/src/main/java/com/vesoft/nebula/driver/graph/data/ResultSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public boolean isEmpty() {
176176

177177
/**
178178
* get error code of execute result
179-
* return {@link ErrorCode}
179+
* TODO return {@link ErrorCode}
180180
*
181181
* @return String
182182
*/

client/src/main/java/com/vesoft/nebula/driver/graph/data/ValueWrapper.java

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_LIST;
2222
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_LOCALDATETIME;
2323
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_LOCALTIME;
24-
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_MAP;
2524
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_NODE;
2625
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_PATH;
2726
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_RECORD;
28-
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_SET;
2927
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_STRING;
3028
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_UINT16;
3129
import static com.vesoft.nebula.driver.graph.decode.ColumnType.COLUMN_TYPE_UINT32;
@@ -44,9 +42,7 @@
4442
import java.time.ZonedDateTime;
4543
import java.time.format.DateTimeFormatter;
4644
import java.util.List;
47-
import java.util.Map;
4845
import java.util.Objects;
49-
import java.util.Set;
5046
import java.util.Vector;
5147

5248
public class ValueWrapper {
@@ -126,10 +122,6 @@ public String getDataTypeString() {
126122
return "ANY";
127123
case COLUMN_TYPE_GEOGRAPHY:
128124
return "GEOGRAPHY";
129-
case COLUMN_TYPE_SET:
130-
return "SET";
131-
case COLUMN_TYPE_MAP:
132-
return "MAP";
133125
default:
134126
throw new IllegalArgumentException("Unknown data type: " + type);
135127
}
@@ -338,24 +330,6 @@ public boolean isGeography() {
338330
return type == COLUMN_TYPE_GEOGRAPHY;
339331
}
340332

341-
/**
342-
* check if the Value is Set type
343-
*
344-
* @return true if Value's type is COLUMN_TYPE_SET
345-
*/
346-
public boolean isSet() {
347-
return type == COLUMN_TYPE_SET;
348-
}
349-
350-
/**
351-
* check if the Value is Map type
352-
*
353-
* @return true if Value's type is COLUMN_TYPE_MAP
354-
*/
355-
public boolean isMap() {
356-
return type == COLUMN_TYPE_MAP;
357-
}
358-
359333
/**
360334
* Convert the original Value to boolean
361335
*
@@ -652,34 +626,6 @@ public Geography asGeography() throws InvalidValueException {
652626
"cannot get field `geography` because value's type is " + getDataType());
653627
}
654628

655-
/**
656-
* Convert the original data type Value to Set
657-
*
658-
* @return {@link java.util.Set}
659-
* @throws InvalidValueException if the value type is not set
660-
*/
661-
public Set asSet() throws InvalidValueException {
662-
if (type == COLUMN_TYPE_SET) {
663-
return (Set) value;
664-
}
665-
throw new InvalidValueException(
666-
"cannot get field `set` because value's type is " + getDataType());
667-
}
668-
669-
/**
670-
* Convert the original data type Value to Map
671-
*
672-
* @return {@link java.util.Map}
673-
* @throws InvalidValueException if the value type is not map
674-
*/
675-
public Map asMap() throws InvalidValueException {
676-
if (type == COLUMN_TYPE_MAP) {
677-
return (Map) value;
678-
}
679-
throw new InvalidValueException(
680-
"cannot get field `map` because value's type is " + getDataType());
681-
}
682-
683629
@Override
684630
public boolean equals(Object o) {
685631
if (this == o) {
@@ -746,10 +692,6 @@ public String toString() {
746692
return asVector().toString();
747693
} else if (isGeography()) {
748694
return asGeography().toString();
749-
} else if (isSet()) {
750-
return asSet().toString();
751-
} else if (isMap()) {
752-
return asMap().toString();
753695
}
754696
return "Unknown type: " + getDataType();
755697
}

client/src/main/java/com/vesoft/nebula/driver/graph/decode/BytesReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
package com.vesoft.nebula.driver.graph.decode;
77

8-
import static com.vesoft.nebula.driver.graph.decode.DecodeUtils.bytesToUInt16;
8+
import static com.vesoft.nebula.driver.graph.decode.DecodeUtils.bytesToInt16;
99
import static com.vesoft.nebula.driver.graph.decode.DecodeUtils.charset;
1010
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE;
1111

@@ -31,7 +31,7 @@ public ByteString read(int len) {
3131
}
3232

3333
public String readSizedString(ByteOrder byteOrder) {
34-
int length = bytesToUInt16(read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
34+
int length = bytesToInt16(read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
3535
int startIndex = index;
3636
index += length;
3737
ByteString strBytes = data.substring(startIndex, startIndex + length);

client/src/main/java/com/vesoft/nebula/driver/graph/decode/ColumnType.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public enum ColumnType {
3939
// while Geometry is reserved for abstract spatial data not tied to Earth.
4040
// Geometry may be added in the future.
4141
COLUMN_TYPE_GEOGRAPHY(0x24),
42-
COLUMN_TYPE_SET(0x25),
43-
COLUMN_TYPE_MAP(0x26),
4442
COLUMN_TYPE_ANY(0xFE),
4543
COLUMN_TYPE_INVALID(0xFF),
4644
;
@@ -93,8 +91,6 @@ public static boolean isComposite(ColumnType type) {
9391
switch (type) {
9492
case COLUMN_TYPE_LIST:
9593
case COLUMN_TYPE_RECORD:
96-
case COLUMN_TYPE_SET:
97-
case COLUMN_TYPE_MAP:
9894
case COLUMN_TYPE_EMBEDDINGVECTOR:
9995
case COLUMN_TYPE_NODE:
10096
case COLUMN_TYPE_EDGE:

client/src/main/java/com/vesoft/nebula/driver/graph/decode/ValueParser.java

Lines changed: 5 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.DURATION_SIZE;
2929
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.EDGE_TYPE_ID_SIZE;
3030
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE;
31-
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.ELEMENT_NUMBER_SIZE_FOR_MAP;
32-
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.ELEMENT_NUMBER_SIZE_FOR_SET;
3331
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.ELEMENT_NUMBER_SIZE_FOR_VECTOR_VALUE;
3432
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.EMBEDDING_VECTOR_FLOAT_VALUE_SIZE;
3533
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.FLOAT_SIZE;
@@ -47,7 +45,6 @@
4745
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.INT8_SIZE;
4846
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.LIST_HEADER_SIZE;
4947
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.LOCAL_TIME_SIZE;
50-
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.MAP_HEADER_SIZE;
5148
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.MICRO_SECONDS_OF_DAY;
5249
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.MICRO_SECONDS_OF_HOUR;
5350
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.MICRO_SECONDS_OF_MINUTE;
@@ -56,7 +53,6 @@
5653
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.NODE_ID_SIZE;
5754
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.NODE_TYPE_ID_SIZE;
5855
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.RANK_SIZE;
59-
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.SET_HEADER_SIZE;
6056
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.STRING_MAX_VALUE_LENGTH_IN_HEADER;
6157
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.STRING_SIZE;
6258
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.STRING_VALUE_LENGTH_SIZE;
@@ -86,23 +82,19 @@
8682
import com.vesoft.nebula.driver.graph.decode.datatype.EdgeType;
8783
import com.vesoft.nebula.driver.graph.decode.datatype.EmbeddingVectorType;
8884
import com.vesoft.nebula.driver.graph.decode.datatype.ListType;
89-
import com.vesoft.nebula.driver.graph.decode.datatype.MapType;
9085
import com.vesoft.nebula.driver.graph.decode.datatype.NodeType;
9186
import com.vesoft.nebula.driver.graph.decode.datatype.PathType;
9287
import com.vesoft.nebula.driver.graph.decode.datatype.RecordType;
93-
import com.vesoft.nebula.driver.graph.decode.datatype.SetType;
9488
import com.vesoft.nebula.driver.graph.decode.struct.AnyHeader;
9589
import com.vesoft.nebula.driver.graph.decode.struct.AnyValue;
9690
import com.vesoft.nebula.driver.graph.decode.struct.EdgeHeader;
9791
import com.vesoft.nebula.driver.graph.decode.struct.ListHeader;
98-
import com.vesoft.nebula.driver.graph.decode.struct.MapHeader;
9992
import com.vesoft.nebula.driver.graph.decode.struct.NodeHeader;
10093
import com.vesoft.nebula.driver.graph.decode.struct.PathAdjHeader;
10194
import com.vesoft.nebula.driver.graph.decode.struct.PathHeader;
10295
import com.vesoft.nebula.driver.graph.decode.struct.PathSpecialMetaData;
10396
import com.vesoft.nebula.driver.graph.decode.struct.PathVectorPair;
10497
import com.vesoft.nebula.driver.graph.decode.struct.ResultGraphSchemas;
105-
import com.vesoft.nebula.driver.graph.decode.struct.SetHeader;
10698
import com.vesoft.nebula.proto.graph.NestedVector;
10799
import java.math.BigDecimal;
108100
import java.nio.ByteBuffer;
@@ -116,10 +108,8 @@
116108
import java.util.ArrayList;
117109
import java.util.Date;
118110
import java.util.HashMap;
119-
import java.util.HashSet;
120111
import java.util.List;
121112
import java.util.Map;
122-
import java.util.Set;
123113

124114
public class ValueParser {
125115

@@ -499,40 +489,6 @@ private Object decodeFlatValue(VectorWrapper vector,
499489
.getVectorData()
500490
.substring(chunkOffset);
501491
return bytesToGeography(new BytesReader(data));
502-
case COLUMN_TYPE_SET:
503-
// get the type for set element
504-
SetType setType = (SetType) type;
505-
Set<ValueWrapper> set = new HashSet<>();
506-
// parse set header:offset + set size
507-
valueData = getSubBytes(vectorData, SET_HEADER_SIZE, rowIndex);
508-
SetHeader setHeader = new SetHeader(valueData, byteOrder);
509-
510-
for (int i = 0; i < setHeader.getSize(); i++) {
511-
set.add(new ValueWrapper(decodeValue(vector.getVectorWrapper(0),
512-
setType.getValueType(),
513-
setHeader.getOffset() + i),
514-
setType.getValueType().getType()));
515-
}
516-
return set;
517-
case COLUMN_TYPE_MAP:
518-
MapType mapType = (MapType) type;
519-
Map<ValueWrapper, ValueWrapper> mapValue = new HashMap<>();
520-
// parse map header: offset + map size
521-
valueData = getSubBytes(vectorData, MAP_HEADER_SIZE, rowIndex);
522-
MapHeader mapHeader = new MapHeader(valueData, byteOrder);
523-
524-
for (int i = 0; i < mapHeader.getSize(); i++) {
525-
ValueWrapper key = new ValueWrapper(decodeValue(vector.getVectorWrapper(0),
526-
mapType.getKeyType(),
527-
mapHeader.getOffset() + i),
528-
mapType.getKeyType().getType());
529-
ValueWrapper value = new ValueWrapper(decodeValue(vector.getVectorWrapper(1),
530-
mapType.getKeyType(),
531-
mapHeader.getOffset() + i),
532-
mapType.getKeyType().getType());
533-
mapValue.put(key, value);
534-
}
535-
return mapValue;
536492
default:
537493
throw new RuntimeException("do not support type: " + type);
538494
}
@@ -1015,7 +971,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
1015971
case COLUMN_TYPE_LIST:
1016972
ColumnType eleType = ColumnType.getColumnType(
1017973
bytesToInt8(reader.read(VALUE_TYPE_SIZE)));
1018-
int listSize = bytesToUInt16(
974+
int listSize = bytesToInt16(
1019975
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
1020976
int nullBitSize = (listSize % 8 == 0) ? (listSize / 8) : (listSize / 8 + 1);
1021977
ByteString nullBitBytes = reader.read(nullBitSize);
@@ -1030,7 +986,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
1030986
}
1031987
return values;
1032988
case COLUMN_TYPE_RECORD:
1033-
int recordSize = bytesToUInt16(
989+
int recordSize = bytesToInt16(
1034990
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
1035991
Map<String, ValueWrapper> map = new HashMap<>();
1036992
for (int i = 0; i < recordSize; i++) {
@@ -1046,7 +1002,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
10461002
long nodeId = bytesToInt64(reader.read(NODE_ID_SIZE), byteOrder);
10471003
int nodeTypeId = getNodeTypeIdFromNodeId(nodeId);
10481004
int nodeGraphId = bytesToInt32(reader.read(GRAPH_ID_SIZE), byteOrder);
1049-
int nodePropNum = bytesToUInt16(
1005+
int nodePropNum = bytesToInt16(
10501006
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
10511007
Map<String, ValueWrapper> nodeProperties = new HashMap<>();
10521008
for (int i = 0; i < nodePropNum; i++) {
@@ -1064,7 +1020,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
10641020
long rank = bytesToInt64(reader.read(RANK_SIZE), byteOrder);
10651021
int edgeGraphId = bytesToInt32(reader.read(GRAPH_ID_SIZE), byteOrder);
10661022
int edgeTypeId = bytesToInt32(reader.read(EDGE_TYPE_ID_SIZE), byteOrder);
1067-
int edgePropNum = bytesToUInt16(
1023+
int edgePropNum = bytesToInt16(
10681024
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
10691025
Map<String, ValueWrapper> edgeProperties = new HashMap<>();
10701026
for (int i = 0; i < edgePropNum; i++) {
@@ -1082,7 +1038,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
10821038
edgeProperties,
10831039
graphSchemas);
10841040
case COLUMN_TYPE_PATH:
1085-
int elementNum = bytesToUInt16(
1041+
int elementNum = bytesToInt16(
10861042
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
10871043
List<ValueWrapper> eleValues = new ArrayList<>();
10881044
for (int i = 0; i < elementNum; i++) {
@@ -1096,62 +1052,6 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
10961052
int vectorEleNum = bytesToInt16(reader.read(ELEMENT_NUMBER_SIZE_FOR_VECTOR_VALUE),
10971053
byteOrder);
10981054
return bytesToEmbeddingVector(reader, vectorEleNum);
1099-
case COLUMN_TYPE_SET:
1100-
ColumnType setEleType = ColumnType.getColumnType(
1101-
bytesToInt8(reader.read(VALUE_TYPE_SIZE)));
1102-
int setSize = bytesToInt32(reader.read(ELEMENT_NUMBER_SIZE_FOR_SET), byteOrder);
1103-
int setNullBitSize = (setSize % 8 == 0) ? (setSize / 8) : (setSize / 8 + 1);
1104-
ByteString setNullBitBytes = reader.read(setNullBitSize);
1105-
Set<ValueWrapper> setValues = new HashSet<>();
1106-
for (int i = 0; i < setSize; i++) {
1107-
if ((setNullBitBytes.byteAt(i / 8) & (1 << (i % 8))) == 0) {
1108-
setValues.add(new ValueWrapper(null, ColumnType.COLUMN_TYPE_NULL));
1109-
} else {
1110-
setValues.add(new ValueWrapper(decodeCompositeValue(reader, setEleType),
1111-
setEleType));
1112-
}
1113-
}
1114-
return setValues;
1115-
case COLUMN_TYPE_MAP:
1116-
ColumnType mapKeyType = ColumnType.getColumnType(
1117-
bytesToInt8(reader.read(VALUE_TYPE_SIZE)));
1118-
int mapKeySize = bytesToInt32(reader.read(ELEMENT_NUMBER_SIZE_FOR_MAP), byteOrder);
1119-
int mapKeyNullBitSize =
1120-
(mapKeySize % 8 == 0) ? (mapKeySize / 8) : (mapKeySize / 8 + 1);
1121-
ByteString mapKeyNullBitBytes = reader.read(mapKeyNullBitSize);
1122-
1123-
List<ValueWrapper> keys = new ArrayList<>();
1124-
for (int i = 0; i < mapKeySize; i++) {
1125-
if ((mapKeyNullBitBytes.byteAt(i / 8) & (1 << (i % 8))) == 0) {
1126-
keys.add(new ValueWrapper(null, ColumnType.COLUMN_TYPE_NULL));
1127-
} else {
1128-
keys.add(new ValueWrapper(decodeCompositeValue(reader, mapKeyType),
1129-
mapKeyType));
1130-
}
1131-
}
1132-
ColumnType mapValueType = ColumnType.getColumnType(
1133-
bytesToInt8(reader.read(VALUE_TYPE_SIZE)));
1134-
int mapValueSize = bytesToInt32(reader.read(ELEMENT_NUMBER_SIZE_FOR_MAP),
1135-
byteOrder);
1136-
int mapValueNullBitSize =
1137-
(mapValueSize % 8 == 0) ? (mapValueSize / 8) : (mapValueSize / 8 + 1);
1138-
ByteString mapValueNullBitBytes = reader.read(mapValueNullBitSize);
1139-
1140-
List<ValueWrapper> mapValues = new ArrayList<>();
1141-
for (int i = 0; i < mapKeySize; i++) {
1142-
if ((mapValueNullBitBytes.byteAt(i / 8) & (1 << (i % 8))) == 0) {
1143-
mapValues.add(new ValueWrapper(null, ColumnType.COLUMN_TYPE_NULL));
1144-
} else {
1145-
mapValues.add(new ValueWrapper(decodeCompositeValue(reader, mapValueType),
1146-
mapValueType));
1147-
}
1148-
}
1149-
1150-
Map<ValueWrapper, ValueWrapper> mapInfo = new HashMap<>();
1151-
for (int i = 0; i < mapKeySize; i++) {
1152-
mapInfo.put(keys.get(i), mapValues.get(i));
1153-
}
1154-
return mapInfo;
11551055
default:
11561056
throw new RuntimeException("do not support type:" + type);
11571057
}

client/src/main/java/com/vesoft/nebula/driver/graph/decode/datatype/MapType.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)