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