提交 2b824814 authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 609: the spatial index did not support NULL.

上级 8e0f7f73
...@@ -83,6 +83,10 @@ public class SpatialDataType implements DataType { ...@@ -83,6 +83,10 @@ public class SpatialDataType implements DataType {
@Override @Override
public void write(WriteBuffer buff, Object obj) { public void write(WriteBuffer buff, Object obj) {
if (obj == null) {
buff.putVarInt(-1);
return;
}
SpatialKey k = (SpatialKey) obj; SpatialKey k = (SpatialKey) obj;
int flags = 0; int flags = 0;
for (int i = 0; i < dimensions; i++) { for (int i = 0; i < dimensions; i++) {
...@@ -103,6 +107,9 @@ public class SpatialDataType implements DataType { ...@@ -103,6 +107,9 @@ public class SpatialDataType implements DataType {
@Override @Override
public Object read(ByteBuffer buff) { public Object read(ByteBuffer buff) {
int flags = DataUtils.readVarInt(buff); int flags = DataUtils.readVarInt(buff);
if (flags == -1) {
return null;
}
float[] minMax = new float[dimensions * 2]; float[] minMax = new float[dimensions * 2];
for (int i = 0; i < dimensions; i++) { for (int i = 0; i < dimensions; i++) {
float min = buff.getFloat(); float min = buff.getFloat();
......
...@@ -924,8 +924,17 @@ public class TestSpatial extends TestBase { ...@@ -924,8 +924,17 @@ public class TestSpatial extends TestBase {
assertTrue(rs.next()); assertTrue(rs.next());
assertEquals(1, rs.getInt(1)); assertEquals(1, rs.getInt(1));
assertNull(rs.getObject(2)); assertNull(rs.getObject(2));
stat.execute("drop table test");
conn.close(); conn.close();
if (!config.memory) {
conn = getConnection(url);
stat = conn.createStatement();
rs = stat.executeQuery("select * from test");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertNull(rs.getObject(2));
conn.close();
}
deleteDb("spatial"); deleteDb("spatial");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论