Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jievince committed Nov 9, 2021
1 parent 8225a5b commit b3a2ba3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 15 additions & 2 deletions client/src/main/java/com/vesoft/nebula/encoder/RowWriterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.codec.binary.Hex;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.io.ByteOrderValues;
import org.locationtech.jts.io.WKBWriter;

public class RowWriterImpl implements RowWriter {
Expand Down Expand Up @@ -636,6 +638,7 @@ public void write(int index, DateTime v) {

@Override
public void write(int index, Geography v) {
System.out.println("write(index, geography), " + index);
SchemaProvider.Field field = schema.field(index);
PropertyType typeEnum = PropertyType.findByValue(field.type());
if (typeEnum == null) {
Expand All @@ -651,8 +654,15 @@ public void write(int index, Geography v) {
throw new RuntimeException("Value: " + v + "'s type is unexpected");
}
org.locationtech.jts.geom.Geometry jtsGeom = convertGeographyToJTSGeometry(v);
byte[] wkb = new org.locationtech.jts.io.WKBWriter().write(jtsGeom);
byte[] wkb = new org.locationtech.jts.io
.WKBWriter(2, ByteOrderValues.LITTLE_ENDIAN)
.write(jtsGeom);
write(index, wkb);
String hexedWKb = Hex.encodeHexString(wkb);
System.out.println("write(index, geography), wkb.size()=" + wkb.length
+ ", wkb.content=" + wkb);
System.out.println("write(index, geography), hexedWKb.size()=" + hexedWKb.length()
+ ", hexedWKb.content=" + hexedWKb);
}

@Override
Expand Down Expand Up @@ -697,6 +707,7 @@ public void setValue(int index, Object value) {
} else if (value instanceof DateTime) {
write(index, (DateTime)value);
} else if (value instanceof Geography) {
System.out.println("jie, " + index + ", setValue(index, Object) for geography");
write(index, (Geography)value);
} else {
throw new RuntimeException("Unsupported value object `" + value.getClass() + "\"");
Expand Down Expand Up @@ -741,6 +752,7 @@ public void setValue(int index, Value value) {
write(index, value.getDtVal());
break;
case Value.GGVAL:
System.out.println("jie, " + index + ", setValue(index, value) for geography");
write(index, value.getGgVal());
break;
default:
Expand Down Expand Up @@ -859,7 +871,8 @@ public ByteBuffer processOutOfSpace() {
if (typeEnum == null) {
throw new RuntimeException("Incorrect field type " + field.type());
}
if (typeEnum != PropertyType.STRING) {
if (typeEnum != PropertyType.STRING
&& typeEnum != PropertyType.GEOGRAPHY) {
continue;
}
int offset = headerLen + numNullBytes + field.offset();
Expand Down
17 changes: 9 additions & 8 deletions client/src/test/java/com/vesoft/nebula/encoder/TestEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ public class TestEncoder {
private final NebulaCodecImpl codec = new NebulaCodecImpl();

final String allTypeValueExpectResult = "090cc001081000200000004000000000000000db0f494069"
+ "57148b0abf05405d0000000c0000004e6562756c61204772617068bb334e5e000000"
+ "57148b0abf0540750000000c0000004e6562756c61204772617068bb334e5e000000"
+ "00e40702140a1e2d00000000e40702140a1e2d00000000000000000000000000000000"
+ "48656c6c6f20776f726c6421010100000000000000006066409a999999997956400102"
+ "000000030000000000000000000000000000000000f03f000000000000f03f00000000"
+ "0000004000000000000008400000000000001c4001030000000200000004000000cdcc"
+ "cccccc2c5bc0000000000080414000000000000059c00000000000404740cdcccccccc"
+ "ac56c03333333333734140cdcccccccc2c5bc000000000008041400400000066666666"
+ "660659c03333333333b344409a99999999b959c0cdcccccccccc424033333333333358"
+ "c00000000000c0424066666666660659c03333333333b34440fe148c1853d00500";
+ "81000000150000009600000039000000cf0000009100000048656c6c6f20776f726c6421"
+ "010100000000000000006066409a99999999795640010200000003000000000000000000"
+ "0000000000000000f03f000000000000f03f000000000000004000000000000008400000"
+ "000000001c4001030000000200000004000000cdcccccccc2c5bc0000000000080414000"
+ "000000000059c00000000000404740cdccccccccac56c03333333333734140cdcccccccc"
+ "2c5bc000000000008041400400000066666666660659c03333333333b344409a99999999"
+ "b959c0cdcccccccccc424033333333333358c00000000000c0424066666666660659c033"
+ "33333333b34440";

private List<String> getCols() {
return Arrays.asList("Col01","Col02", "Col03", "Col04", "Col05", "Col06",
Expand Down

0 comments on commit b3a2ba3

Please sign in to comment.