diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/AbstractColumn.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/AbstractColumn.java index b03fdc7..e400631 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/AbstractColumn.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/AbstractColumn.java @@ -14,6 +14,11 @@ package com.timeplus.data; +import java.io.IOException; +import java.sql.SQLException; + +import com.timeplus.serde.BinarySerializer; + public abstract class AbstractColumn implements IColumn { protected final String name; @@ -63,4 +68,15 @@ public void setColumnWriterBuffer(ColumnWriterBuffer buffer) { public ColumnWriterBuffer getColumnWriterBuffer() { return buffer; } + + @Override + public void SerializeBulkPrefix(BinarySerializer serializer) throws IOException, SQLException { + + } + + @Override + public void SerializeBulkSuffix(BinarySerializer serializer) throws IOException, SQLException { + + } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/Block.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/Block.java index 753f641..c83337d 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/Block.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/Block.java @@ -44,7 +44,9 @@ public static Block readFrom(BinaryDeserializer deserializer, String type = deserializer.readUTF8StringBinary(); IDataType dataType = DataTypeFactory.get(type, serverContext); + dataType.deserializeBinaryPrefix(rowCnt, deserializer); Object[] arr = dataType.deserializeBinaryBulk(rowCnt, deserializer); + dataType.deserializeBinarySuffix(rowCnt, deserializer); columns[i] = ColumnFactory.createColumn(name, dataType, arr); } @@ -124,7 +126,11 @@ public void writeTo(BinarySerializer serializer) throws IOException, SQLExceptio serializer.writeVarInt(rowCnt); for (IColumn column : columns) { - column.flushToSerializer(serializer, true); + serializer.writeUTF8StringBinary(column.name()); + serializer.writeUTF8StringBinary(column.type().name()); + column.SerializeBulkPrefix(serializer); + column.SerializeBulk(serializer, true); + column.SerializeBulkSuffix(serializer); } } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/Column.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/Column.java index c3b4c5e..010576c 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/Column.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/Column.java @@ -32,14 +32,10 @@ public void write(Object object) throws IOException, SQLException { } @Override - public void flushToSerializer(BinarySerializer serializer, boolean now) throws IOException, SQLException { - if (isExported()) { - serializer.writeUTF8StringBinary(name); - serializer.writeUTF8StringBinary(type.name()); - } - + public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException { if (now) { buffer.writeTo(serializer); } } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnArray.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnArray.java index c284328..36201b2 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnArray.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnArray.java @@ -17,7 +17,6 @@ import com.timeplus.jdbc.TimeplusArray; import com.timeplus.data.type.complex.DataTypeArray; import com.timeplus.serde.BinarySerializer; - import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; @@ -27,12 +26,12 @@ public class ColumnArray extends AbstractColumn { private final List offsets; // data represents nested column in ColumnArray - private final IColumn data; + private final IColumn nestedColumn; public ColumnArray(String name, DataTypeArray type, Object[] values) { super(name, type, values); offsets = new ArrayList<>(); - data = ColumnFactory.createColumn(null, type.getElemDataType(), null); + nestedColumn = ColumnFactory.createColumn(null, type.getElemDataType(), null); } @Override @@ -41,22 +40,7 @@ public void write(Object object) throws IOException, SQLException { offsets.add(offsets.isEmpty() ? arr.length : offsets.get((offsets.size() - 1)) + arr.length); for (Object field : arr) { - data.write(field); - } - } - - @Override - public void flushToSerializer(BinarySerializer serializer, boolean immediate) throws SQLException, IOException { - if (isExported()) { - serializer.writeUTF8StringBinary(name); - serializer.writeUTF8StringBinary(type.name()); - } - - flushOffsets(serializer); - data.flushToSerializer(serializer, false); - - if (immediate) { - buffer.writeTo(serializer); + nestedColumn.write(field); } } @@ -69,12 +53,34 @@ public void flushOffsets(BinarySerializer serializer) throws IOException { @Override public void setColumnWriterBuffer(ColumnWriterBuffer buffer) { super.setColumnWriterBuffer(buffer); - data.setColumnWriterBuffer(buffer); + nestedColumn.setColumnWriterBuffer(buffer); } @Override public void clear() { offsets.clear(); - data.clear(); + nestedColumn.clear(); + } + + @Override + public void SerializeBulkPrefix(BinarySerializer serializer) throws SQLException, IOException { + nestedColumn.SerializeBulkPrefix(serializer); + } + + @Override + public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException { + flushOffsets(serializer); + nestedColumn.SerializeBulk(serializer, false); + + if (now) { + buffer.writeTo(serializer); + } + } + + @Override + public void SerializeBulkSuffix(BinarySerializer serializer) throws SQLException, IOException { + nestedColumn.SerializeBulkSuffix(serializer); } + + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnLowCardinality.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnLowCardinality.java index d7bb598..c986420 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnLowCardinality.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnLowCardinality.java @@ -24,11 +24,11 @@ public class ColumnLowCardinality extends AbstractColumn { - private IColumn data; private final List indexes; private final List dict; private final Long version = 1L; private boolean nested_is_nullable; + private IDataType nested_type; public ColumnLowCardinality(String name, DataTypeLowCardinality type, Object[] values) { super(name, type, values); @@ -37,13 +37,12 @@ public ColumnLowCardinality(String name, DataTypeLowCardinality type, Object[] v nested_is_nullable = type.getNestedTypes().nullable(); /// If a nested type is nullable, always add two hard dictionary keys in front: [0]: null, [1]: default value if (nested_is_nullable) { - IDataType nested_type = ((DataTypeNullable) type.getNestedTypes()).getNestedDataType(); - data = ColumnFactory.createColumn(null, nested_type, null); + nested_type = ((DataTypeNullable) type.getNestedTypes()).getNestedDataType(); dict.add(type.getNestedTypes().defaultValue()); dict.add(type.getNestedTypes().defaultValue()); } else { - data = ColumnFactory.createColumn(null, type.getNestedTypes(), null); + nested_type = type.getNestedTypes(); } } @@ -70,37 +69,32 @@ public void write(Object object) throws IOException, SQLException { } @Override - public void flushToSerializer(BinarySerializer serializer, boolean immediate) throws IOException, SQLException { - if (isExported()) { - serializer.writeUTF8StringBinary(name); - serializer.writeUTF8StringBinary(type.name()); - } - - if (immediate) { - /// The data layout: [version][index_type][dictionary][indexes] - serializer.writeLong(version); - serializer.writeLong(IndexType.UInt64.getValue() | IndexType.HasAdditionalKeysBit.getValue()); - - serializer.writeLong(dict.size()); - for (int i = 0; i < dict.size(); i++) { - data.write(dict.get(i)); - } - data.flushToSerializer(serializer, true); + public void setColumnWriterBuffer(ColumnWriterBuffer buffer) { + super.setColumnWriterBuffer(buffer); + } - serializer.writeLong(indexes.size()); // give index type size - for (int i = 0; i < indexes.size(); i++) { - serializer.writeLong(indexes.get(i)); - } - } + @Override + public void clear() { } @Override - public void setColumnWriterBuffer(ColumnWriterBuffer buffer) { - super.setColumnWriterBuffer(buffer); - data.setColumnWriterBuffer(buffer); + public void SerializeBulkPrefix(BinarySerializer serializer) throws IOException, SQLException { + serializer.writeLong(version); } @Override - public void clear() { + public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException { + /// The data layout: [index_type][dictionary][indexes] + serializer.writeLong(IndexType.UInt64.getValue() | IndexType.HasAdditionalKeysBit.getValue()); + serializer.writeLong(dict.size()); + + nested_type.serializeBinaryBulk(dict.toArray(), serializer); + + serializer.writeLong(indexes.size()); // give index type size + for (int i = 0; i < indexes.size(); i++) { + serializer.writeLong(indexes.get(i)); + } + } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnMap.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnMap.java index e0d5fa0..c09b5ac 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnMap.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnMap.java @@ -56,24 +56,6 @@ public void write(Object object) throws IOException, SQLException { } - @Override - public void flushToSerializer(BinarySerializer serializer, boolean now) throws IOException, SQLException { - if (isExported()) { - serializer.writeUTF8StringBinary(name); - serializer.writeUTF8StringBinary(type.name()); - } - - flushOffsets(serializer); - - for (IColumn data : columnDataArray) { - data.flushToSerializer(serializer, true); - } - - if (now) { - buffer.writeTo(serializer); - } - } - public void flushOffsets(BinarySerializer serializer) throws IOException { for (long offsetList : offsets) { serializer.writeLong(offsetList); @@ -84,16 +66,38 @@ public void flushOffsets(BinarySerializer serializer) throws IOException { public void setColumnWriterBuffer(ColumnWriterBuffer buffer) { super.setColumnWriterBuffer(buffer); - for (IColumn data : columnDataArray) { - data.setColumnWriterBuffer(new ColumnWriterBuffer()); + for (IColumn nestedColumn : columnDataArray) { + nestedColumn.setColumnWriterBuffer(new ColumnWriterBuffer()); } } @Override public void clear() { offsets.clear(); - for (IColumn data : columnDataArray) { - data.clear(); + for (IColumn nestedColumn : columnDataArray) { + nestedColumn.clear(); } } + + @Override + public void SerializeBulkPrefix(BinarySerializer serializer) throws SQLException, IOException { + for (IColumn nestedColumn : columnDataArray) { + nestedColumn.SerializeBulkPrefix(serializer); + } + } + + @Override + public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException { + + flushOffsets(serializer); + + for (IColumn nestedColumn : columnDataArray) { + nestedColumn.SerializeBulk(serializer, true); + } + + if (now) { + buffer.writeTo(serializer); + } + } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnNullable.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnNullable.java index 7e47fd0..d9d35d1 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnNullable.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnNullable.java @@ -27,43 +27,40 @@ public class ColumnNullable extends AbstractColumn { private final List nullableSign; // data represents nested column in ColumnArray - private final IColumn data; + private final IColumn nestedColumn; public ColumnNullable(String name, DataTypeNullable type, Object[] values) { super(name, type, values); nullableSign = new ArrayList<>(); - data = ColumnFactory.createColumn(null, type.getNestedDataType(), null); + nestedColumn = ColumnFactory.createColumn(null, type.getNestedDataType(), null); } @Override public void write(@Nullable Object object) throws IOException, SQLException { if (object == null) { nullableSign.add((byte) 1); - data.write(type.defaultValue()); // write whatever for padding + nestedColumn.write(type.defaultValue()); // write whatever for padding } else { nullableSign.add((byte) 0); - data.write(object); + nestedColumn.write(object); } } @Override - public void flushToSerializer(BinarySerializer serializer, boolean immediate) throws IOException { - if (isExported()) { - serializer.writeUTF8StringBinary(name); - serializer.writeUTF8StringBinary(type.name()); - } + public void setColumnWriterBuffer(ColumnWriterBuffer buffer) { + super.setColumnWriterBuffer(buffer); + nestedColumn.setColumnWriterBuffer(buffer); + } + + @Override + public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException { for (byte sign : nullableSign) { serializer.writeByte(sign); } - if (immediate) + if (now) buffer.writeTo(serializer); } - @Override - public void setColumnWriterBuffer(ColumnWriterBuffer buffer) { - super.setColumnWriterBuffer(buffer); - data.setColumnWriterBuffer(buffer); - } } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnTuple.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnTuple.java index 4875d62..6ef402d 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnTuple.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/ColumnTuple.java @@ -45,33 +45,36 @@ public void write(Object object) throws IOException, SQLException { } @Override - public void flushToSerializer(BinarySerializer serializer, boolean now) throws SQLException, IOException { - if (isExported()) { - serializer.writeUTF8StringBinary(name); - serializer.writeUTF8StringBinary(type.name()); - } - - // we should to flush all the nested data to serializer - // because they are using separate buffers. - for (IColumn data : columnDataArray) { - data.flushToSerializer(serializer, true); - } + public void setColumnWriterBuffer(ColumnWriterBuffer buffer) { + super.setColumnWriterBuffer(buffer); - if (now) { - buffer.writeTo(serializer); + for (IColumn nestedColumn : columnDataArray) { + nestedColumn.setColumnWriterBuffer(new ColumnWriterBuffer()); } } @Override - public void setColumnWriterBuffer(ColumnWriterBuffer buffer) { - super.setColumnWriterBuffer(buffer); + public void clear() { + } - for (IColumn data : columnDataArray) { - data.setColumnWriterBuffer(new ColumnWriterBuffer()); + @Override + public void SerializeBulkPrefix(BinarySerializer serializer) throws SQLException, IOException { + for (IColumn nestedColumn : columnDataArray) { + nestedColumn.SerializeBulkPrefix(serializer); } } @Override - public void clear() { + public void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException { + // we should to flush all the nested data to serializer + // because they are using separate buffers. + for (IColumn nestedColumn : columnDataArray) { + nestedColumn.SerializeBulk(serializer, true); + } + + if (now) { + buffer.writeTo(serializer); + } } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/IColumn.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/IColumn.java index ee7a217..ad37202 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/IColumn.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/IColumn.java @@ -31,19 +31,23 @@ public interface IColumn { void write(Object object) throws IOException, SQLException; + void clear(); + + void setColumnWriterBuffer(ColumnWriterBuffer buffer); + + ColumnWriterBuffer getColumnWriterBuffer(); /** * Flush to socket output stream * * @param serializer is serializer wrapper of tcp socket * @param now means we should flush all the buffer to serializer now */ - void flushToSerializer(BinarySerializer serializer, boolean now) throws IOException, SQLException; + void SerializeBulkPrefix(BinarySerializer serializer) throws IOException, SQLException; - void clear(); - - void setColumnWriterBuffer(ColumnWriterBuffer buffer); + void SerializeBulk(BinarySerializer serializer, Boolean now) throws IOException, SQLException; - ColumnWriterBuffer getColumnWriterBuffer(); + void SerializeBulkSuffix(BinarySerializer serializer) throws IOException, SQLException; } + diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/IDataType.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/IDataType.java index 1e62d8a..bf36c58 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/IDataType.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/IDataType.java @@ -83,4 +83,13 @@ default Object[] deserializeBinaryBulk(int rows, BinaryDeserializer deserializer } return data; } + + default void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { + + } + + default void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { + + } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeBool.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeBool.java index 8371f84..636c614 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeBool.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeBool.java @@ -12,59 +12,60 @@ * limitations under the License. */ - package com.timeplus.data.type; +package com.timeplus.data.type; - import com.timeplus.misc.SQLLexer; - import com.timeplus.serde.BinaryDeserializer; - import com.timeplus.serde.BinarySerializer; - - import java.io.IOException; - import java.sql.SQLException; - - public class DataTypeBool implements BaseDataTypeBool { - - @Override - public String name() { - return "bool"; - } - - @Override - public Byte defaultValue() { - return 0; - } - - @Override - public Class javaType() { - return Byte.class; - } - - @Override - public int getPrecision() { - return 4; - } - - @Override - public void serializeBinary(Byte data, BinarySerializer serializer) throws SQLException, IOException { - serializer.writeByte(data); - } - - @Override - public Byte deserializeBinary(BinaryDeserializer deserializer) throws IOException { - return deserializer.readByte(); - } - - @Override - public String[] getAliases() { - return new String[]{"TINYINT"}; - } - - @Override - public Byte deserializeText(SQLLexer lexer) throws SQLException { - return lexer.numberLiteral().byteValue(); - } - - @Override - public boolean isSigned() { - return true; - } - } +import com.timeplus.misc.SQLLexer; +import com.timeplus.serde.BinaryDeserializer; +import com.timeplus.serde.BinarySerializer; + +import java.io.IOException; +import java.sql.SQLException; + +public class DataTypeBool implements BaseDataTypeBool { + + @Override + public String name() { + return "bool"; + } + + @Override + public Byte defaultValue() { + return 0; + } + + @Override + public Class javaType() { + return Byte.class; + } + + @Override + public int getPrecision() { + return 4; + } + + @Override + public void serializeBinary(Byte data, BinarySerializer serializer) throws SQLException, IOException { + serializer.writeByte(data); + } + + @Override + public Byte deserializeBinary(BinaryDeserializer deserializer) throws IOException { + return deserializer.readByte(); + } + + @Override + public String[] getAliases() { + return new String[]{"TINYINT"}; + } + + @Override + public Byte deserializeText(SQLLexer lexer) throws SQLException { + return lexer.numberLiteral().byteValue(); + } + + @Override + public boolean isSigned() { + return true; + } + +} diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeDate.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeDate.java index 7983d46..9aa48a4 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeDate.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeDate.java @@ -97,4 +97,5 @@ public LocalDate deserializeText(SQLLexer lexer) throws SQLException { return LocalDate.of(year, month, day); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeDate32.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeDate32.java index f7b3a09..f2c626e 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeDate32.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeDate32.java @@ -98,4 +98,5 @@ public LocalDate deserializeText(SQLLexer lexer) throws SQLException { return LocalDate.of(year, month, day); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeFloat32.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeFloat32.java index 9f001f1..c46cd96 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeFloat32.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeFloat32.java @@ -79,4 +79,5 @@ public Float deserializeText(SQLLexer lexer) throws SQLException { public boolean isSigned() { return true; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeFloat64.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeFloat64.java index 8395d66..a6f09c4 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeFloat64.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeFloat64.java @@ -79,4 +79,5 @@ public Double deserializeText(SQLLexer lexer) throws SQLException { public boolean isSigned() { return true; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeIPv4.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeIPv4.java index e40f591..cc9c3d3 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeIPv4.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeIPv4.java @@ -74,4 +74,5 @@ public String[] getAliases() { public Long deserializeText(SQLLexer lexer) throws SQLException { return lexer.numberLiteral().longValue() & 0xffffffffL; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeIPv6.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeIPv6.java index 43e8d0d..0841331 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeIPv6.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeIPv6.java @@ -87,4 +87,5 @@ public BigInteger deserializeText(SQLLexer lexer) throws SQLException { private static String convertIPv6ToHexadecimalString(String ipv6) { return ipv6.replace(":", ""); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt128.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt128.java index 4598b59..33a4668 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt128.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt128.java @@ -73,4 +73,5 @@ public BigInteger deserializeText(SQLLexer lexer) throws SQLException { return new BigInteger(Integer128, 10); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt16.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt16.java index 90191b9..ffcd9a5 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt16.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt16.java @@ -68,4 +68,5 @@ public Short deserializeText(SQLLexer lexer) throws SQLException { public boolean isSigned() { return true; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt32.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt32.java index 609d8df..4178575 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt32.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt32.java @@ -67,4 +67,5 @@ public Integer deserializeText(SQLLexer lexer) throws SQLException { public boolean isSigned() { return true; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt64.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt64.java index 33385fe..18af489 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt64.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt64.java @@ -67,4 +67,5 @@ public Long deserializeText(SQLLexer lexer) throws SQLException { public boolean isSigned() { return true; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt8.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt8.java index 5f4dd02..ba027d6 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt8.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeInt8.java @@ -67,4 +67,5 @@ public Byte deserializeText(SQLLexer lexer) throws SQLException { public boolean isSigned() { return true; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt128.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt128.java index 393927e..1b3f0c2 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt128.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt128.java @@ -69,4 +69,5 @@ public BigInteger deserializeText(SQLLexer lexer) throws SQLException { String Uinteger128 = lexer.stringLiteral(); return new BigInteger(Uinteger128, 10); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt16.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt16.java index af3074c..a105e4f 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt16.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt16.java @@ -58,4 +58,5 @@ public Integer deserializeBinary(BinaryDeserializer deserializer) throws SQLExce public Integer deserializeText(SQLLexer lexer) throws SQLException { return lexer.numberLiteral().intValue(); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt256.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt256.java index 28da77e..2503464 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt256.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt256.java @@ -69,4 +69,5 @@ public BigInteger deserializeText(SQLLexer lexer) throws SQLException { String Uinteger256 = lexer.stringLiteral(); return new BigInteger(Uinteger256, 10); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt32.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt32.java index 8f15fa6..055f053 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt32.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt32.java @@ -58,4 +58,5 @@ public Long deserializeBinary(BinaryDeserializer deserializer) throws SQLExcepti public Long deserializeText(SQLLexer lexer) throws SQLException { return lexer.numberLiteral().longValue(); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt64.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt64.java index 2b9db5c..a18ea2e 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt64.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt64.java @@ -68,4 +68,5 @@ public String[] getAliases() { public BigInteger deserializeText(SQLLexer lexer) throws SQLException { return BigInteger.valueOf(lexer.numberLiteral().longValue()); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt8.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt8.java index 90f4df0..fe7b775 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt8.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUInt8.java @@ -58,4 +58,5 @@ public Short deserializeBinary(BinaryDeserializer deserializer) throws IOExcepti public Short deserializeText(SQLLexer lexer) throws SQLException { return lexer.numberLiteral().shortValue(); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUUID.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUUID.java index 4fbc419..d5d0a71 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUUID.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/DataTypeUUID.java @@ -76,4 +76,5 @@ public void serializeBinary(UUID data, BinarySerializer serializer) throws SQLEx public UUID deserializeBinary(BinaryDeserializer deserializer) throws SQLException, IOException { return new UUID(deserializer.readLong(), deserializer.readLong()); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeArray.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeArray.java index 5046eda..22fe82e 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeArray.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeArray.java @@ -152,4 +152,14 @@ public TimeplusArray[] deserializeBinaryBulk(int rows, BinaryDeserializer deseri public IDataType getElemDataType() { return elemDataType; } + + @Override + public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { + getElemDataType().deserializeBinaryPrefix(rows, deserializer); + } + + @Override + public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { + getElemDataType().deserializeBinarySuffix(rows, deserializer); + } } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDateTime64.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDateTime64.java index e00314e..9c45c05 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDateTime64.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDateTime64.java @@ -151,4 +151,5 @@ public ZonedDateTime deserializeBinary(BinaryDeserializer deserializer) throws I return DateTimeUtil.toZonedDateTime(epochSeconds, nanos, tz); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDecimal.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDecimal.java index eb491af..5bd8646 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDecimal.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeDecimal.java @@ -195,4 +195,5 @@ public BigDecimal deserializeBinary(BinaryDeserializer deserializer) throws SQLE public boolean isSigned() { return true; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeEnum16.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeEnum16.java index 028dcf0..22daa63 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeEnum16.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeEnum16.java @@ -132,4 +132,5 @@ public String deserializeBinary(BinaryDeserializer deserializer) throws SQLExcep } throw new SQLException(""); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeEnum8.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeEnum8.java index 41fec64..031fe04 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeEnum8.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeEnum8.java @@ -129,4 +129,5 @@ public String deserializeBinary(BinaryDeserializer deserializer) throws SQLExcep } throw new SQLException(""); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeFixedString.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeFixedString.java index f1298c9..9c2e562 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeFixedString.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeFixedString.java @@ -125,4 +125,5 @@ public CharSequence deserializeText(SQLLexer lexer) throws SQLException { public String[] getAliases() { return new String[]{"BINARY"}; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeLowCardinality.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeLowCardinality.java index 667068d..94f8156 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeLowCardinality.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeLowCardinality.java @@ -18,8 +18,6 @@ import com.timeplus.data.IDataType; import com.timeplus.data.IndexType; import com.timeplus.data.type.DataTypeUInt8; -import com.timeplus.log.Logger; -import com.timeplus.log.LoggerFactory; import com.timeplus.data.type.DataTypeUInt16; import com.timeplus.data.type.DataTypeUInt32; import com.timeplus.data.type.DataTypeUInt64; @@ -45,7 +43,6 @@ public class DataTypeLowCardinality implements IDataType { private final IDataType nestedDataType; private final Long version = 1L; private final Long IndexTypeMask = 0b11111111L; - private static final Logger LOG = LoggerFactory.getLogger(DataTypeLowCardinality.class); private boolean nested_is_nullable; public DataTypeLowCardinality(String name, IDataType nestedDataType) { @@ -123,12 +120,6 @@ public Object[] deserializeBinaryBulk(int rows, BinaryDeserializer deserializer) return data; } else { - Long version = deserializer.readLong(); - - if (version != this.version) { - throw new SQLException("version error in type low_cardinality"); - } - Long index_type = deserializer.readLong() & IndexTypeMask; Long key_nums = deserializer.readLong(); Object[] dictionary = new Object[key_nums.intValue()]; @@ -142,7 +133,7 @@ public Object[] deserializeBinaryBulk(int rows, BinaryDeserializer deserializer) inner_type = getNestedTypes(); } dictionary = inner_type.deserializeBinaryBulk(key_nums.intValue(), deserializer); - + dictionary[0] = null; Long row_nums = deserializer.readLong(); if (row_nums != rows) { @@ -190,4 +181,15 @@ public IDataType getNestedTypes() { return nestedDataType; } + @Override + public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { + if (rows != 0) { + Long version = deserializer.readLong(); + + if (version != this.version) { + throw new SQLException("version error in type low_cardinality"); + } + } + } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeMap.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeMap.java index e9ba07f..f3cc1b3 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeMap.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeMap.java @@ -172,4 +172,16 @@ public Object[] deserializeBinaryBulk(int rows, BinaryDeserializer deserializer) public IDataType[] getNestedTypes() { return nestedTypes; } + + @Override + public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { + getNestedTypes()[0].deserializeBinaryPrefix(rows, deserializer); + getNestedTypes()[1].deserializeBinaryPrefix(rows, deserializer); + } + + @Override + public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { + getNestedTypes()[0].deserializeBinarySuffix(rows, deserializer); + getNestedTypes()[1].deserializeBinarySuffix(rows, deserializer); + } } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeNothing.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeNothing.java index 45f5421..b405b06 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeNothing.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeNothing.java @@ -83,4 +83,5 @@ public String[] getAliases() { public Object deserializeText(SQLLexer lexer) throws SQLException { throw new InvalidOperationException("Nothing datatype can't deserializeText"); } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeString.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeString.java index 55b25af..652bff0 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeString.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeString.java @@ -108,4 +108,5 @@ public String[] getAliases() { "LONGTEXT", "BLOB"}; } + } diff --git a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeTuple.java b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeTuple.java index b96c835..219fe7c 100644 --- a/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeTuple.java +++ b/timeplus-native-jdbc/src/main/java/com/timeplus/data/type/complex/DataTypeTuple.java @@ -165,4 +165,18 @@ public TimeplusStruct deserializeText(SQLLexer lexer) throws SQLException { public IDataType[] getNestedTypes() { return nestedTypes; } + + @Override + public void deserializeBinaryPrefix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { + for (int i = 0; i < getNestedTypes().length; i++) { + getNestedTypes()[i].deserializeBinaryPrefix(rows, deserializer); + } + } + + @Override + public void deserializeBinarySuffix(int rows, BinaryDeserializer deserializer) throws SQLException, IOException { + for (int i = 0; i < getNestedTypes().length; i++) { + getNestedTypes()[i].deserializeBinarySuffix(rows, deserializer); + } + } } diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/type/LowCardinalityTypeTest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/type/LowCardinalityTypeTest.java index 9e943f9..bdbb5d2 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/type/LowCardinalityTypeTest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/type/LowCardinalityTypeTest.java @@ -15,10 +15,14 @@ package com.timeplus.jdbc.type; import com.timeplus.jdbc.AbstractITest; +import com.timeplus.jdbc.TimeplusStruct; import com.timeplus.misc.BytesHelper; import org.junit.jupiter.api.Test; import java.sql.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; import static org.junit.jupiter.api.Assertions.*; @@ -198,4 +202,110 @@ public void testNullLowCardinalityTypes() throws Exception { statement.execute("DROP STREAM IF EXISTS low_cardinality_test"); }, "allow_suspicious_low_cardinality_types", "1"); } + + @Test + public void testMapNestedType() throws Exception { + withStatement(statement -> { + statement.execute("DROP STREAM IF EXISTS nested_test"); + statement.execute( + "CREATE STREAM IF NOT EXISTS nested_test (value map(low_cardinality(string), low_cardinality(int32))) Engine=Memory()"); + + Integer rowCnt = 300; + try (PreparedStatement pstmt = statement.getConnection().prepareStatement( + "INSERT INTO nested_test (value) values(?);")) { + + Map map = new HashMap<>(); + map.put("key", 1); + map.put("key2", 2); + map.put("key3", 3); + for (int i = 0; i < rowCnt; i++) { + pstmt.setObject(1, map); + pstmt.addBatch(); + } + pstmt.executeBatch(); + } + + ResultSet rs = statement.executeQuery("SELECT * FROM nested_test;"); + int size = 0; + while (rs.next()) { + size++; + Map value = (Map) rs.getObject(1); + assertEquals(value.get("key"), 1); + assertEquals(value.get("key2"), 2); + assertEquals(value.get("key3"), 3); + + } + assertEquals(size, rowCnt); + statement.execute("DROP STREAM IF EXISTS nested_test"); + }); + } + + @Test + public void testTupleNestedType() throws Exception { + withStatement(statement -> { + statement.execute("DROP STREAM IF EXISTS nested_test"); + statement.execute( + "CREATE STREAM IF NOT EXISTS nested_test (value tuple(low_cardinality(string), low_cardinality(int32))) Engine=Memory()"); + + Integer rowCnt = 300; + try (PreparedStatement pstmt = statement.getConnection().prepareStatement( + "INSERT INTO nested_test (value) values(?);")) { + + Object[] tupleValue = new Object[]{"test", 1}; + TimeplusStruct tuple = new TimeplusStruct("tuple", tupleValue); + for (int i = 0; i < rowCnt; i++) { + pstmt.setObject(1, tuple); + pstmt.addBatch(); + } + pstmt.executeBatch(); + } + + ResultSet rs = statement.executeQuery("SELECT * FROM nested_test;"); + int size = 0; + while (rs.next()) { + size++; + Object obj1 = rs.getObject(1); + TimeplusStruct tuple = (TimeplusStruct) obj1; + Object[] tupleValue = (Object[]) tuple.getAttributes(); + assertEquals(tupleValue[0], "test"); + assertEquals(tupleValue[1], 1); + + } + assertEquals(size, rowCnt); + statement.execute("DROP STREAM IF EXISTS nested_test"); + }); + } + + @Test + public void testArrayStringNestedType() throws Exception { + withStatement(statement -> { + statement.execute("DROP STREAM IF EXISTS nested_test"); + statement.execute( + "CREATE STREAM IF NOT EXISTS nested_test (value array(low_cardinality(string))) Engine=Memory()"); + + Integer rowCnt = 1; + try (PreparedStatement pstmt = statement.getConnection().prepareStatement( + "INSERT INTO nested_test (value) values(?);")) { + + Array innerArray1 = statement.getConnection().createArrayOf("low_cardinality(string)", new String[]{"100", "2", "3"}); + for (int i = 0; i < rowCnt; i++) { + pstmt.setArray(1, innerArray1); + pstmt.addBatch(); + } + pstmt.executeBatch(); + } + + ResultSet rs = statement.executeQuery("SELECT * FROM nested_test;"); + int size = 0; + while (rs.next()) { + size++; + Object[] objArray = (Object[]) rs.getArray(1).getArray(); + String[] value = Arrays.stream(objArray).map(String.class::cast).toArray(String[]::new); + assertTrue(Arrays.equals(value, new String[]{"100", "2", "3"})); + } + assertEquals(size, rowCnt); + statement.execute("DROP STREAM IF EXISTS nested_test"); + }); + } + } diff --git a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/type/NestedTypeTest.java b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/type/NestedTypeTest.java index b02cf83..3bb2308 100644 --- a/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/type/NestedTypeTest.java +++ b/timeplus-native-jdbc/src/test/java/com/timeplus/jdbc/type/NestedTypeTest.java @@ -30,31 +30,31 @@ public class NestedTypeTest extends AbstractITest implements BytesHelper { // test for nested type, array of array, array of tuple, tuple of array, tuple of tuple, nullable type involved @Test - public void testNestedType() throws Exception { + public void testNestedArrayTupleType() throws Exception { withStatement(statement -> { statement.execute("DROP STREAM IF EXISTS nested_test"); statement.execute( - "CREATE STREAM IF NOT EXISTS nested_test (value array(array(nullable(int))), " - +"value2 array(tuple(nullable(int), nullable(string))), " - +"value3 tuple(array(nullable(int)), nullable(string))) Engine=Memory()"); + "CREATE STREAM IF NOT EXISTS nested_test (value array(array(low_cardinality(nullable(int)))), " + +"value2 array(tuple(low_cardinality(nullable(int)), low_cardinality(nullable(string)))), " + +"value3 tuple(array(low_cardinality(nullable(int))), low_cardinality(nullable(string)))) Engine=Memory()"); Integer rowCnt = 300; try (PreparedStatement pstmt = statement.getConnection().prepareStatement( "INSERT INTO nested_test (value, value2, value3) values(?, ?, ?);")) { for (int i = 0; i < rowCnt; i++) { // array of array - Array innerArray1 = statement.getConnection().createArrayOf("nullable(int32)", new Object[]{1, 2, null}); - Array innerArray2 = statement.getConnection().createArrayOf("nullable(int32)", new Object[]{4, 5, null}); - pstmt.setObject(1, statement.getConnection().createArrayOf("array(nullable(int32))", new Object[]{innerArray1, innerArray2})); + Array innerArray1 = statement.getConnection().createArrayOf("low_cardinality(nullable(int32))", new Object[]{1, 2, null}); + Array innerArray2 = statement.getConnection().createArrayOf("low_cardinality(nullable(int32))", new Object[]{4, 5, null}); + pstmt.setObject(1, statement.getConnection().createArrayOf("array(low_cardinality(nullable(int32)))", new Object[]{innerArray1, innerArray2})); // array of tuple TimeplusStruct tuple1 = new TimeplusStruct("tuple", new Object[]{1, null}); TimeplusStruct tuple2 = new TimeplusStruct("tuple", new Object[]{null, "test2"}); - pstmt.setObject(2, statement.getConnection().createArrayOf("tuple(nullable(int), nullable(string))", new Object[]{tuple1, tuple2})); + pstmt.setObject(2, statement.getConnection().createArrayOf("tuple(low_cardinality(nullable(int)), low_cardinality(nullable(string)))", new Object[]{tuple1, tuple2})); // tuple (array, string) - Array array = statement.getConnection().createArrayOf("nullable(int)", new Integer[]{1, 2, null}); - TimeplusStruct tuple3 = new TimeplusStruct("tuple(array(nullable(int)), nullable(string))", new Object[]{array, null}); + Array array = statement.getConnection().createArrayOf("low_cardinality(nullable(int))", new Integer[]{1, 2, null}); + TimeplusStruct tuple3 = new TimeplusStruct("tuple(array(low_cardinality(nullable(int))), low_cardinality(nullable(string)))", new Object[]{array, null}); pstmt.setObject(3, tuple3); pstmt.addBatch(); @@ -113,4 +113,6 @@ public void testNestedType() throws Exception { statement.execute("DROP STREAM IF EXISTS nested_test"); }); } + + }