提交 fd71364c authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add row value storage format for temporary storages

上级 c6933120
...@@ -31,6 +31,7 @@ import org.h2.value.ValueArray; ...@@ -31,6 +31,7 @@ import org.h2.value.ValueArray;
import org.h2.value.ValueBoolean; import org.h2.value.ValueBoolean;
import org.h2.value.ValueByte; import org.h2.value.ValueByte;
import org.h2.value.ValueBytes; import org.h2.value.ValueBytes;
import org.h2.value.ValueCollectionBase;
import org.h2.value.ValueDate; import org.h2.value.ValueDate;
import org.h2.value.ValueDecimal; import org.h2.value.ValueDecimal;
import org.h2.value.ValueDouble; import org.h2.value.ValueDouble;
...@@ -43,6 +44,7 @@ import org.h2.value.ValueLobDb; ...@@ -43,6 +44,7 @@ import org.h2.value.ValueLobDb;
import org.h2.value.ValueLong; import org.h2.value.ValueLong;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
import org.h2.value.ValueResultSet; import org.h2.value.ValueResultSet;
import org.h2.value.ValueRow;
import org.h2.value.ValueShort; import org.h2.value.ValueShort;
import org.h2.value.ValueString; import org.h2.value.ValueString;
import org.h2.value.ValueStringFixed; import org.h2.value.ValueStringFixed;
...@@ -72,6 +74,7 @@ public class ValueDataType implements DataType { ...@@ -72,6 +74,7 @@ public class ValueDataType implements DataType {
private static final int BYTES_0_31 = 100; private static final int BYTES_0_31 = 100;
private static final int SPATIAL_KEY_2D = 132; private static final int SPATIAL_KEY_2D = 132;
private static final int CUSTOM_DATA_TYPE = 133; private static final int CUSTOM_DATA_TYPE = 133;
private static final int ROW = 27;
final DataHandler handler; final DataHandler handler;
final CompareMode compareMode; final CompareMode compareMode;
...@@ -393,9 +396,10 @@ public class ValueDataType implements DataType { ...@@ -393,9 +396,10 @@ public class ValueDataType implements DataType {
} }
break; break;
} }
case Value.ARRAY: { case Value.ARRAY:
Value[] list = ((ValueArray) v).getList(); case Value.ROW: {
buff.put((byte) type).putVarInt(list.length); Value[] list = ((ValueCollectionBase) v).getList();
buff.put((byte) (type == Value.ARRAY ? Value.ARRAY : ROW)).putVarInt(list.length);
for (Value x : list) { for (Value x : list) {
writeValue(buff, x); writeValue(buff, x);
} }
...@@ -610,13 +614,14 @@ public class ValueDataType implements DataType { ...@@ -610,13 +614,14 @@ public class ValueDataType implements DataType {
"lob type: " + smallLen); "lob type: " + smallLen);
} }
} }
case Value.ARRAY: { case Value.ARRAY:
case ROW: {
int len = readVarInt(buff); int len = readVarInt(buff);
Value[] list = new Value[len]; Value[] list = new Value[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
list[i] = (Value) readValue(buff); list[i] = (Value) readValue(buff);
} }
return ValueArray.get(list); return type == Value.ARRAY ? ValueArray.get(list) : ValueRow.get(list);
} }
case Value.RESULT_SET: { case Value.RESULT_SET: {
SimpleResult rs = new SimpleResult(); SimpleResult rs = new SimpleResult();
......
...@@ -32,6 +32,7 @@ import org.h2.value.ValueArray; ...@@ -32,6 +32,7 @@ import org.h2.value.ValueArray;
import org.h2.value.ValueBoolean; import org.h2.value.ValueBoolean;
import org.h2.value.ValueByte; import org.h2.value.ValueByte;
import org.h2.value.ValueBytes; import org.h2.value.ValueBytes;
import org.h2.value.ValueCollectionBase;
import org.h2.value.ValueDate; import org.h2.value.ValueDate;
import org.h2.value.ValueDecimal; import org.h2.value.ValueDecimal;
import org.h2.value.ValueDouble; import org.h2.value.ValueDouble;
...@@ -45,6 +46,7 @@ import org.h2.value.ValueLobDb; ...@@ -45,6 +46,7 @@ import org.h2.value.ValueLobDb;
import org.h2.value.ValueLong; import org.h2.value.ValueLong;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
import org.h2.value.ValueResultSet; import org.h2.value.ValueResultSet;
import org.h2.value.ValueRow;
import org.h2.value.ValueShort; import org.h2.value.ValueShort;
import org.h2.value.ValueString; import org.h2.value.ValueString;
import org.h2.value.ValueStringFixed; import org.h2.value.ValueStringFixed;
...@@ -90,6 +92,7 @@ public class Data { ...@@ -90,6 +92,7 @@ public class Data {
private static final int LOCAL_DATE = 133; private static final int LOCAL_DATE = 133;
private static final int LOCAL_TIMESTAMP = 134; private static final int LOCAL_TIMESTAMP = 134;
private static final byte CUSTOM_DATA_TYPE = (byte)135; private static final byte CUSTOM_DATA_TYPE = (byte)135;
private static final int ROW = 27;
private static final long MILLIS_PER_MINUTE = 1000 * 60; private static final long MILLIS_PER_MINUTE = 1000 * 60;
...@@ -617,9 +620,10 @@ public class Data { ...@@ -617,9 +620,10 @@ public class Data {
} }
break; break;
} }
case Value.ARRAY: { case Value.ARRAY:
writeByte((byte) type); case Value.ROW: {
Value[] list = ((ValueArray) v).getList(); writeByte((byte) (type == Value.ARRAY ? Value.ARRAY : ROW));
Value[] list = ((ValueCollectionBase) v).getList();
writeVarInt(list.length); writeVarInt(list.length);
for (Value x : list) { for (Value x : list) {
writeValue(x); writeValue(x);
...@@ -848,13 +852,14 @@ public class Data { ...@@ -848,13 +852,14 @@ public class Data {
objectId, precision, compression); objectId, precision, compression);
} }
} }
case Value.ARRAY: { case Value.ARRAY:
case ROW: {
int len = readVarInt(); int len = readVarInt();
Value[] list = new Value[len]; Value[] list = new Value[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
list[i] = readValue(); list[i] = readValue();
} }
return ValueArray.get(list); return type == Value.ARRAY ? ValueArray.get(list) : ValueRow.get(list);
} }
case Value.RESULT_SET: { case Value.RESULT_SET: {
SimpleResult rs = new SimpleResult(); SimpleResult rs = new SimpleResult();
...@@ -1082,8 +1087,9 @@ public class Data { ...@@ -1082,8 +1087,9 @@ public class Data {
} }
return len; return len;
} }
case Value.ARRAY: { case Value.ARRAY:
Value[] list = ((ValueArray) v).getList(); case Value.ROW: {
Value[] list = ((ValueCollectionBase) v).getList();
int len = 1 + getVarIntLen(list.length); int len = 1 + getVarIntLen(list.length);
for (Value x : list) { for (Value x : list) {
len += getValueLen(x, handler); len += getValueLen(x, handler);
......
...@@ -71,3 +71,11 @@ SELECT (1, ARRAY[1]) IN (SELECT 1, ARRAY[2]); ...@@ -71,3 +71,11 @@ SELECT (1, ARRAY[1]) IN (SELECT 1, ARRAY[2]);
SELECT (1, ARRAY[NULL]) IN (SELECT 1, ARRAY[NULL]); SELECT (1, ARRAY[NULL]) IN (SELECT 1, ARRAY[NULL]);
>> null >> null
-- The next tests should be at the of this file
SET MAX_MEMORY_ROWS = 2;
> ok
SELECT (X, X) FROM SYSTEM_RANGE(1, 100000) ORDER BY -X FETCH FIRST ROW ONLY;
>> ROW (100000, 100000)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论