diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/TsBlockBuilder.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/TsBlockBuilder.java index 918551d9b..e341248cb 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/TsBlockBuilder.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/TsBlockBuilder.java @@ -116,13 +116,17 @@ private TsBlockBuilder(int initialExpectedEntries, int maxTsBlockBytes, List types) { case DATE: valueColumnBuilders[i] = new IntColumnBuilder( - tsBlockBuilderStatus.createColumnBuilderStatus(), initialExpectedEntries); + tsBlockBuilderStatus.createColumnBuilderStatus(), + initialExpectedEntries, + types.get(i)); break; case INT64: case TIMESTAMP: valueColumnBuilders[i] = new LongColumnBuilder( - tsBlockBuilderStatus.createColumnBuilderStatus(), initialExpectedEntries); + tsBlockBuilderStatus.createColumnBuilderStatus(), + initialExpectedEntries, + types.get(i)); break; case FLOAT: valueColumnBuilders[i] = @@ -211,7 +221,9 @@ public void buildValueColumnBuilders(List types) { case STRING: valueColumnBuilders[i] = new BinaryColumnBuilder( - tsBlockBuilderStatus.createColumnBuilderStatus(), initialExpectedEntries); + tsBlockBuilderStatus.createColumnBuilderStatus(), + initialExpectedEntries, + types.get(i)); break; default: throw new IllegalArgumentException("Unknown data type: " + types.get(i)); diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryArrayColumnEncoder.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryArrayColumnEncoder.java index c4bb38336..90a5f506d 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryArrayColumnEncoder.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryArrayColumnEncoder.java @@ -68,7 +68,7 @@ public Column readColumn(ByteBuffer input, TSDataType dataType, int positionCoun } } } - return new BinaryColumn(0, positionCount, nullIndicators, values); + return new BinaryColumn(0, positionCount, nullIndicators, values, dataType); } @Override diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumn.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumn.java index 0be88efe2..6d046845f 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumn.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumn.java @@ -44,16 +44,23 @@ public class BinaryColumn implements Column { private final Binary[] values; private final long retainedSizeInBytes; + private final TSDataType dataType; - public BinaryColumn(int initialCapacity) { - this(0, 0, null, new Binary[initialCapacity]); + public BinaryColumn(int initialCapacity, TSDataType dataType) { + this(0, 0, null, new Binary[initialCapacity], dataType); } - public BinaryColumn(int positionCount, Optional valueIsNull, Binary[] values) { - this(0, positionCount, valueIsNull.orElse(null), values); + public BinaryColumn( + int positionCount, Optional valueIsNull, Binary[] values, TSDataType dataType) { + this(0, positionCount, valueIsNull.orElse(null), values, dataType); } - BinaryColumn(int arrayOffset, int positionCount, boolean[] valueIsNull, Binary[] values) { + BinaryColumn( + int arrayOffset, + int positionCount, + boolean[] valueIsNull, + Binary[] values, + TSDataType dataType) { if (arrayOffset < 0) { throw new IllegalArgumentException("arrayOffset is negative"); } @@ -76,11 +83,12 @@ public BinaryColumn(int positionCount, Optional valueIsNull, Binary[] // TODO we need to sum up all the Binary's retainedSize here retainedSizeInBytes = INSTANCE_SIZE + sizeOfBooleanArray(positionCount) + sizeOfObjectArray(positionCount); + this.dataType = dataType; } @Override public TSDataType getDataType() { - return TSDataType.TEXT; + return dataType; } @Override @@ -141,7 +149,7 @@ public long getRetainedSizeInBytes() { @Override public Column getRegion(int positionOffset, int length) { checkValidRegion(getPositionCount(), positionOffset, length); - return new BinaryColumn(positionOffset + arrayOffset, length, valueIsNull, values); + return new BinaryColumn(positionOffset + arrayOffset, length, valueIsNull, values, dataType); } @Override @@ -154,7 +162,7 @@ public Column getRegionCopy(int positionOffset, int length) { valueIsNull != null ? Arrays.copyOfRange(valueIsNull, from, to) : null; Binary[] valuesCopy = Arrays.copyOfRange(values, from, to); - return new BinaryColumn(0, length, valueIsNullCopy, valuesCopy); + return new BinaryColumn(0, length, valueIsNullCopy, valuesCopy, dataType); } @Override @@ -163,7 +171,7 @@ public Column subColumn(int fromIndex) { throw new IllegalArgumentException("fromIndex is not valid"); } return new BinaryColumn( - arrayOffset + fromIndex, positionCount - fromIndex, valueIsNull, values); + arrayOffset + fromIndex, positionCount - fromIndex, valueIsNull, values, dataType); } @Override @@ -178,7 +186,7 @@ public Column subColumnCopy(int fromIndex) { Binary[] valuesCopy = Arrays.copyOfRange(values, from, positionCount); int length = positionCount - fromIndex; - return new BinaryColumn(0, length, valueIsNullCopy, valuesCopy); + return new BinaryColumn(0, length, valueIsNullCopy, valuesCopy, dataType); } @Override diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumnBuilder.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumnBuilder.java index 917c6e5f3..cb5111cd0 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumnBuilder.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/BinaryColumnBuilder.java @@ -41,8 +41,13 @@ public class BinaryColumnBuilder implements ColumnBuilder { RamUsageEstimator.shallowSizeOfInstance(BinaryColumnBuilder.class); private final ColumnBuilderStatus columnBuilderStatus; - public static final BinaryColumn NULL_VALUE_BLOCK = - new BinaryColumn(0, 1, new boolean[] {true}, new Binary[1]); + private final TSDataType dataType; + public static final BinaryColumn NULL_STRING_BLOCK = + new BinaryColumn(0, 1, new boolean[] {true}, new Binary[1], TSDataType.STRING); + public static final BinaryColumn NULL_TEXT_BLOCK = + new BinaryColumn(0, 1, new boolean[] {true}, new Binary[1], TSDataType.TEXT); + public static final BinaryColumn NULL_BLOB_BLOCK = + new BinaryColumn(0, 1, new boolean[] {true}, new Binary[1], TSDataType.BLOB); private boolean initialized; private final int initialEntryCount; @@ -57,9 +62,11 @@ public class BinaryColumnBuilder implements ColumnBuilder { private long arraysRetainedSizeInBytes; - public BinaryColumnBuilder(ColumnBuilderStatus columnBuilderStatus, int expectedEntries) { + public BinaryColumnBuilder( + ColumnBuilderStatus columnBuilderStatus, int expectedEntries, TSDataType dataType) { this.initialEntryCount = max(expectedEntries, 1); this.columnBuilderStatus = columnBuilderStatus; + this.dataType = dataType; updateArraysDataSize(); } @@ -112,14 +119,20 @@ public ColumnBuilder appendNull() { @Override public Column build() { if (!hasNonNullValue) { - return new RunLengthEncodedColumn(NULL_VALUE_BLOCK, positionCount); + if (dataType == TSDataType.STRING) { + return new RunLengthEncodedColumn(NULL_STRING_BLOCK, positionCount); + } else if (dataType == TSDataType.TEXT) { + return new RunLengthEncodedColumn(NULL_TEXT_BLOCK, positionCount); + } else if (dataType == TSDataType.BLOB) { + return new RunLengthEncodedColumn(NULL_BLOB_BLOCK, positionCount); + } } - return new BinaryColumn(0, positionCount, hasNullValue ? valueIsNull : null, values); + return new BinaryColumn(0, positionCount, hasNullValue ? valueIsNull : null, values, dataType); } @Override public TSDataType getDataType() { - return TSDataType.TEXT; + return dataType; } @Override @@ -135,7 +148,8 @@ public long getRetainedSizeInBytes() { @Override public ColumnBuilder newColumnBuilderLike(ColumnBuilderStatus columnBuilderStatus) { // TODO we should take retain size into account here - return new BinaryColumnBuilder(columnBuilderStatus, calculateBlockResetSize(positionCount)); + return new BinaryColumnBuilder( + columnBuilderStatus, calculateBlockResetSize(positionCount), dataType); } private void growCapacity() { diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/ColumnFactory.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/ColumnFactory.java index 88a401131..9e0faf358 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/ColumnFactory.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/ColumnFactory.java @@ -27,7 +27,7 @@ public static Column create(TSDataType dataType, int initialCapacity) { switch (dataType) { case INT64: case TIMESTAMP: - return new LongColumn(initialCapacity); + return new LongColumn(initialCapacity, dataType); case DOUBLE: return new DoubleColumn(initialCapacity); case FLOAT: @@ -35,10 +35,10 @@ public static Column create(TSDataType dataType, int initialCapacity) { case TEXT: case STRING: case BLOB: - return new BinaryColumn(initialCapacity); + return new BinaryColumn(initialCapacity, dataType); case INT32: case DATE: - return new IntColumn(initialCapacity); + return new IntColumn(initialCapacity, dataType); case BOOLEAN: return new BooleanColumn(initialCapacity); default: diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/Int32ArrayColumnEncoder.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/Int32ArrayColumnEncoder.java index cc727fb7c..186c63358 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/Int32ArrayColumnEncoder.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/Int32ArrayColumnEncoder.java @@ -55,7 +55,7 @@ public Column readColumn(ByteBuffer input, TSDataType dataType, int positionCoun } } } - return new IntColumn(0, positionCount, nullIndicators, intValues); + return new IntColumn(0, positionCount, nullIndicators, intValues, dataType); case FLOAT: float[] floatValues = new float[positionCount]; if (nullIndicators == null) { diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/Int64ArrayColumnEncoder.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/Int64ArrayColumnEncoder.java index 446adaf47..99a5ddae5 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/Int64ArrayColumnEncoder.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/Int64ArrayColumnEncoder.java @@ -54,7 +54,7 @@ public Column readColumn(ByteBuffer input, TSDataType dataType, int positionCoun } } } - return new LongColumn(0, positionCount, nullIndicators, values); + return new LongColumn(0, positionCount, nullIndicators, values, dataType); case DOUBLE: double[] doubleValues = new double[positionCount]; if (nullIndicators == null) { diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/IntColumn.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/IntColumn.java index 2c3c35c12..d43fa7f31 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/IntColumn.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/IntColumn.java @@ -44,16 +44,23 @@ public class IntColumn implements Column { private final int[] values; private final long retainedSizeInBytes; + private final TSDataType dataType; - public IntColumn(int initialCapacity) { - this(0, 0, null, new int[initialCapacity]); + public IntColumn(int initialCapacity, TSDataType dataType) { + this(0, 0, null, new int[initialCapacity], dataType); } - public IntColumn(int positionCount, Optional valueIsNull, int[] values) { - this(0, positionCount, valueIsNull.orElse(null), values); + public IntColumn( + int positionCount, Optional valueIsNull, int[] values, TSDataType dataType) { + this(0, positionCount, valueIsNull.orElse(null), values, dataType); } - IntColumn(int arrayOffset, int positionCount, boolean[] valueIsNull, int[] values) { + IntColumn( + int arrayOffset, + int positionCount, + boolean[] valueIsNull, + int[] values, + TSDataType dataType) { if (arrayOffset < 0) { throw new IllegalArgumentException("arrayOffset is negative"); } @@ -75,11 +82,12 @@ public IntColumn(int positionCount, Optional valueIsNull, int[] value retainedSizeInBytes = INSTANCE_SIZE + sizeOfIntArray(positionCount) + sizeOfBooleanArray(positionCount); + this.dataType = dataType; } @Override public TSDataType getDataType() { - return TSDataType.INT32; + return dataType; } @Override @@ -140,7 +148,7 @@ public long getRetainedSizeInBytes() { @Override public Column getRegion(int positionOffset, int length) { checkValidRegion(getPositionCount(), positionOffset, length); - return new IntColumn(positionOffset + arrayOffset, length, valueIsNull, values); + return new IntColumn(positionOffset + arrayOffset, length, valueIsNull, values, dataType); } @Override @@ -153,7 +161,7 @@ public Column getRegionCopy(int positionOffset, int length) { valueIsNull != null ? Arrays.copyOfRange(valueIsNull, from, to) : null; int[] valuesCopy = Arrays.copyOfRange(values, from, to); - return new IntColumn(0, length, valueIsNullCopy, valuesCopy); + return new IntColumn(0, length, valueIsNullCopy, valuesCopy, dataType); } @Override @@ -161,7 +169,8 @@ public Column subColumn(int fromIndex) { if (fromIndex > positionCount) { throw new IllegalArgumentException("fromIndex is not valid"); } - return new IntColumn(arrayOffset + fromIndex, positionCount - fromIndex, valueIsNull, values); + return new IntColumn( + arrayOffset + fromIndex, positionCount - fromIndex, valueIsNull, values, dataType); } @Override @@ -176,7 +185,7 @@ public Column subColumnCopy(int fromIndex) { int[] valuesCopy = Arrays.copyOfRange(values, from, positionCount); int length = positionCount - fromIndex; - return new IntColumn(0, length, valueIsNullCopy, valuesCopy); + return new IntColumn(0, length, valueIsNullCopy, valuesCopy, dataType); } @Override diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/IntColumnBuilder.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/IntColumnBuilder.java index e78eac1db..f276ac9b8 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/IntColumnBuilder.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/IntColumnBuilder.java @@ -23,10 +23,12 @@ import org.apache.tsfile.block.column.ColumnBuilder; import org.apache.tsfile.block.column.ColumnBuilderStatus; import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.utils.DateUtils; import org.apache.tsfile.utils.RamUsageEstimator; import org.apache.tsfile.utils.TsPrimitiveType; import org.apache.tsfile.write.UnSupportedDataTypeException; +import java.time.LocalDate; import java.util.Arrays; import static java.lang.Math.max; @@ -37,10 +39,13 @@ public class IntColumnBuilder implements ColumnBuilder { private static final int INSTANCE_SIZE = (int) RamUsageEstimator.shallowSizeOfInstance(IntColumnBuilder.class); - public static final IntColumn NULL_VALUE_BLOCK = - new IntColumn(0, 1, new boolean[] {true}, new int[1]); + public static final IntColumn NULL_INT_BLOCK = + new IntColumn(0, 1, new boolean[] {true}, new int[1], TSDataType.INT32); + public static final IntColumn NULL_DATE_BLOCK = + new IntColumn(0, 1, new boolean[] {true}, new int[1], TSDataType.DATE); private final ColumnBuilderStatus columnBuilderStatus; + private final TSDataType dataType; private boolean initialized; private final int initialEntryCount; @@ -54,8 +59,10 @@ public class IntColumnBuilder implements ColumnBuilder { private long retainedSizeInBytes; - public IntColumnBuilder(ColumnBuilderStatus columnBuilderStatus, int expectedEntries) { + public IntColumnBuilder( + ColumnBuilderStatus columnBuilderStatus, int expectedEntries, TSDataType dataType) { this.columnBuilderStatus = columnBuilderStatus; + this.dataType = dataType; this.initialEntryCount = max(expectedEntries, 1); updateDataSize(); @@ -83,6 +90,9 @@ public ColumnBuilder writeObject(Object value) { if (value instanceof Integer) { writeInt((Integer) value); return this; + } else if (value instanceof LocalDate) { + writeInt(DateUtils.parseDateExpressionToInt((LocalDate) value)); + return this; } throw new UnSupportedDataTypeException("IntegerColumn only support Integer data type"); } @@ -116,14 +126,15 @@ public ColumnBuilder appendNull() { @Override public Column build() { if (!hasNonNullValue) { - return new RunLengthEncodedColumn(NULL_VALUE_BLOCK, positionCount); + return new RunLengthEncodedColumn( + TSDataType.DATE == dataType ? NULL_DATE_BLOCK : NULL_INT_BLOCK, positionCount); } - return new IntColumn(0, positionCount, hasNullValue ? valueIsNull : null, values); + return new IntColumn(0, positionCount, hasNullValue ? valueIsNull : null, values, dataType); } @Override public TSDataType getDataType() { - return TSDataType.INT32; + return dataType; } @Override @@ -133,7 +144,8 @@ public long getRetainedSizeInBytes() { @Override public ColumnBuilder newColumnBuilderLike(ColumnBuilderStatus columnBuilderStatus) { - return new IntColumnBuilder(columnBuilderStatus, calculateBlockResetSize(positionCount)); + return new IntColumnBuilder( + columnBuilderStatus, calculateBlockResetSize(positionCount), dataType); } private void growCapacity() { diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/LongColumn.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/LongColumn.java index 1c022369d..d867af32b 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/LongColumn.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/LongColumn.java @@ -44,16 +44,23 @@ public class LongColumn implements Column { private final long[] values; private final long retainedSizeInBytes; + private final TSDataType dataType; - public LongColumn(int initialCapacity) { - this(0, 0, null, new long[initialCapacity]); + public LongColumn(int initialCapacity, TSDataType dataType) { + this(0, 0, null, new long[initialCapacity], dataType); } - public LongColumn(int positionCount, Optional valueIsNull, long[] values) { - this(0, positionCount, valueIsNull.orElse(null), values); + public LongColumn( + int positionCount, Optional valueIsNull, long[] values, TSDataType dataType) { + this(0, positionCount, valueIsNull.orElse(null), values, dataType); } - LongColumn(int arrayOffset, int positionCount, boolean[] valueIsNull, long[] values) { + LongColumn( + int arrayOffset, + int positionCount, + boolean[] valueIsNull, + long[] values, + TSDataType dataType) { if (arrayOffset < 0) { throw new IllegalArgumentException("arrayOffset is negative"); } @@ -75,11 +82,12 @@ public LongColumn(int positionCount, Optional valueIsNull, long[] val retainedSizeInBytes = INSTANCE_SIZE + sizeOfLongArray(positionCount) + sizeOfBooleanArray(positionCount); + this.dataType = dataType; } @Override public TSDataType getDataType() { - return TSDataType.INT64; + return dataType; } @Override @@ -140,7 +148,7 @@ public long getRetainedSizeInBytes() { @Override public Column getRegion(int positionOffset, int length) { checkValidRegion(getPositionCount(), positionOffset, length); - return new LongColumn(positionOffset + arrayOffset, length, valueIsNull, values); + return new LongColumn(positionOffset + arrayOffset, length, valueIsNull, values, dataType); } @Override @@ -153,7 +161,7 @@ public Column getRegionCopy(int positionOffset, int length) { valueIsNull != null ? Arrays.copyOfRange(valueIsNull, from, to) : null; long[] valuesCopy = Arrays.copyOfRange(values, from, to); - return new LongColumn(0, length, valueIsNullCopy, valuesCopy); + return new LongColumn(0, length, valueIsNullCopy, valuesCopy, dataType); } @Override @@ -161,7 +169,8 @@ public Column subColumn(int fromIndex) { if (fromIndex > positionCount) { throw new IllegalArgumentException("fromIndex is not valid"); } - return new LongColumn(arrayOffset + fromIndex, positionCount - fromIndex, valueIsNull, values); + return new LongColumn( + arrayOffset + fromIndex, positionCount - fromIndex, valueIsNull, values, dataType); } @Override @@ -176,7 +185,7 @@ public Column subColumnCopy(int fromIndex) { long[] valuesCopy = Arrays.copyOfRange(values, from, positionCount); int length = positionCount - fromIndex; - return new LongColumn(0, length, valueIsNullCopy, valuesCopy); + return new LongColumn(0, length, valueIsNullCopy, valuesCopy, dataType); } @Override diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/LongColumnBuilder.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/LongColumnBuilder.java index b0f4d952f..6d441032d 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/LongColumnBuilder.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/LongColumnBuilder.java @@ -37,10 +37,13 @@ public class LongColumnBuilder implements ColumnBuilder { private static final int INSTANCE_SIZE = (int) RamUsageEstimator.shallowSizeOfInstance(LongColumnBuilder.class); - public static final LongColumn NULL_VALUE_BLOCK = - new LongColumn(0, 1, new boolean[] {true}, new long[1]); + public static final LongColumn NULL_LONG_BLOCK = + new LongColumn(0, 1, new boolean[] {true}, new long[1], TSDataType.INT64); + public static final LongColumn NULL_TIMESTAMP_BLOCK = + new LongColumn(0, 1, new boolean[] {true}, new long[1], TSDataType.TIMESTAMP); private final ColumnBuilderStatus columnBuilderStatus; + private final TSDataType dataType; private boolean initialized; private final int initialEntryCount; @@ -54,10 +57,11 @@ public class LongColumnBuilder implements ColumnBuilder { private long retainedSizeInBytes; - public LongColumnBuilder(ColumnBuilderStatus columnBuilderStatus, int expectedEntries) { + public LongColumnBuilder( + ColumnBuilderStatus columnBuilderStatus, int expectedEntries, TSDataType dataType) { this.columnBuilderStatus = columnBuilderStatus; this.initialEntryCount = max(expectedEntries, 1); - + this.dataType = dataType; updateDataSize(); } @@ -116,14 +120,15 @@ public ColumnBuilder appendNull() { @Override public Column build() { if (!hasNonNullValue) { - return new RunLengthEncodedColumn(NULL_VALUE_BLOCK, positionCount); + return new RunLengthEncodedColumn( + TSDataType.TIMESTAMP == dataType ? NULL_TIMESTAMP_BLOCK : NULL_LONG_BLOCK, positionCount); } - return new LongColumn(0, positionCount, hasNullValue ? valueIsNull : null, values); + return new LongColumn(0, positionCount, hasNullValue ? valueIsNull : null, values, dataType); } @Override public TSDataType getDataType() { - return TSDataType.INT64; + return dataType; } @Override @@ -133,7 +138,8 @@ public long getRetainedSizeInBytes() { @Override public ColumnBuilder newColumnBuilderLike(ColumnBuilderStatus columnBuilderStatus) { - return new LongColumnBuilder(columnBuilderStatus, calculateBlockResetSize(positionCount)); + return new LongColumnBuilder( + columnBuilderStatus, calculateBlockResetSize(positionCount), dataType); } private void growCapacity() { diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/NullColumn.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/NullColumn.java index 9b2a7bccd..02e8e420d 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/NullColumn.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/NullColumn.java @@ -118,19 +118,23 @@ public static Column create(TSDataType dataType, int positionCount) { case BOOLEAN: return new RunLengthEncodedColumn(BooleanColumnBuilder.NULL_VALUE_BLOCK, positionCount); case INT32: + return new RunLengthEncodedColumn(IntColumnBuilder.NULL_INT_BLOCK, positionCount); case DATE: - return new RunLengthEncodedColumn(IntColumnBuilder.NULL_VALUE_BLOCK, positionCount); + return new RunLengthEncodedColumn(IntColumnBuilder.NULL_DATE_BLOCK, positionCount); case INT64: + return new RunLengthEncodedColumn(LongColumnBuilder.NULL_LONG_BLOCK, positionCount); case TIMESTAMP: - return new RunLengthEncodedColumn(LongColumnBuilder.NULL_VALUE_BLOCK, positionCount); + return new RunLengthEncodedColumn(LongColumnBuilder.NULL_TIMESTAMP_BLOCK, positionCount); case FLOAT: return new RunLengthEncodedColumn(FloatColumnBuilder.NULL_VALUE_BLOCK, positionCount); case DOUBLE: return new RunLengthEncodedColumn(DoubleColumnBuilder.NULL_VALUE_BLOCK, positionCount); case TEXT: + return new RunLengthEncodedColumn(BinaryColumnBuilder.NULL_TEXT_BLOCK, positionCount); case BLOB: + return new RunLengthEncodedColumn(BinaryColumnBuilder.NULL_BLOB_BLOCK, positionCount); case STRING: - return new RunLengthEncodedColumn(BinaryColumnBuilder.NULL_VALUE_BLOCK, positionCount); + return new RunLengthEncodedColumn(BinaryColumnBuilder.NULL_STRING_BLOCK, positionCount); default: throw new IllegalArgumentException("Unknown data type: " + dataType); } diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractIntType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractIntType.java index 8425a8793..9367138ab 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractIntType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractIntType.java @@ -21,7 +21,6 @@ import org.apache.tsfile.block.column.Column; import org.apache.tsfile.block.column.ColumnBuilder; -import org.apache.tsfile.read.common.block.column.IntColumnBuilder; import java.util.Collections; import java.util.List; @@ -68,11 +67,6 @@ public void writeDouble(ColumnBuilder builder, double value) { builder.writeInt((int) value); } - @Override - public ColumnBuilder createColumnBuilder(int expectedEntries) { - return new IntColumnBuilder(null, expectedEntries); - } - @Override public boolean isComparable() { return true; diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractLongType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractLongType.java index e8e1ecbc3..97454f04b 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractLongType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractLongType.java @@ -21,7 +21,6 @@ import org.apache.tsfile.block.column.Column; import org.apache.tsfile.block.column.ColumnBuilder; -import org.apache.tsfile.read.common.block.column.LongColumnBuilder; import java.util.Collections; import java.util.List; @@ -68,11 +67,6 @@ public void writeDouble(ColumnBuilder builder, double value) { builder.writeLong((long) value); } - @Override - public ColumnBuilder createColumnBuilder(int expectedEntries) { - return new LongColumnBuilder(null, expectedEntries); - } - @Override public boolean isComparable() { return true; diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractVarcharType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractVarcharType.java index d09ed07c6..0ca1d3ee9 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractVarcharType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/AbstractVarcharType.java @@ -21,7 +21,6 @@ import org.apache.tsfile.block.column.Column; import org.apache.tsfile.block.column.ColumnBuilder; -import org.apache.tsfile.read.common.block.column.BinaryColumnBuilder; import org.apache.tsfile.utils.Binary; import java.util.Collections; @@ -38,11 +37,6 @@ public void writeBinary(ColumnBuilder builder, Binary value) { builder.writeBinary(value); } - @Override - public ColumnBuilder createColumnBuilder(int expectedEntries) { - return new BinaryColumnBuilder(null, expectedEntries); - } - @Override public boolean isComparable() { return true; diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/BinaryType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/BinaryType.java index 68c874998..1c3e504c2 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/BinaryType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/BinaryType.java @@ -19,11 +19,20 @@ package org.apache.tsfile.read.common.type; +import org.apache.tsfile.block.column.ColumnBuilder; +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.block.column.BinaryColumnBuilder; + public class BinaryType extends AbstractVarcharType { public static final BinaryType TEXT = new BinaryType(); private BinaryType() {} + @Override + public ColumnBuilder createColumnBuilder(int expectedEntries) { + return new BinaryColumnBuilder(null, expectedEntries, TSDataType.TEXT); + } + @Override public TypeEnum getTypeEnum() { return TypeEnum.TEXT; diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/BlobType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/BlobType.java index d02ca7168..4558a71a6 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/BlobType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/BlobType.java @@ -21,6 +21,7 @@ import org.apache.tsfile.block.column.Column; import org.apache.tsfile.block.column.ColumnBuilder; +import org.apache.tsfile.enums.TSDataType; import org.apache.tsfile.read.common.block.column.BinaryColumnBuilder; import org.apache.tsfile.utils.Binary; @@ -45,7 +46,7 @@ public void writeBinary(ColumnBuilder builder, Binary value) { @Override public ColumnBuilder createColumnBuilder(int expectedEntries) { - return new BinaryColumnBuilder(null, expectedEntries); + return new BinaryColumnBuilder(null, expectedEntries, TSDataType.BLOB); } @Override diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/DateType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/DateType.java index 88d17e242..03b870f32 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/DateType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/DateType.java @@ -19,12 +19,21 @@ package org.apache.tsfile.read.common.type; +import org.apache.tsfile.block.column.ColumnBuilder; +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.block.column.IntColumnBuilder; + public class DateType extends AbstractIntType { public static final DateType DATE = new DateType(); private DateType() {} + @Override + public ColumnBuilder createColumnBuilder(int expectedEntries) { + return new IntColumnBuilder(null, expectedEntries, TSDataType.DATE); + } + @Override public TypeEnum getTypeEnum() { return TypeEnum.DATE; diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/IntType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/IntType.java index e4d36c2a3..948ea4811 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/IntType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/IntType.java @@ -19,12 +19,21 @@ package org.apache.tsfile.read.common.type; +import org.apache.tsfile.block.column.ColumnBuilder; +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.block.column.IntColumnBuilder; + public class IntType extends AbstractIntType { public static final IntType INT32 = new IntType(); private IntType() {} + @Override + public ColumnBuilder createColumnBuilder(int expectedEntries) { + return new IntColumnBuilder(null, expectedEntries, TSDataType.INT32); + } + @Override public TypeEnum getTypeEnum() { return TypeEnum.INT32; diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/LongType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/LongType.java index a1ed2a1c9..8f6b5e29c 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/LongType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/LongType.java @@ -19,12 +19,21 @@ package org.apache.tsfile.read.common.type; +import org.apache.tsfile.block.column.ColumnBuilder; +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.block.column.LongColumnBuilder; + public class LongType extends AbstractLongType { public static final LongType INT64 = new LongType(); private LongType() {} + @Override + public ColumnBuilder createColumnBuilder(int expectedEntries) { + return new LongColumnBuilder(null, expectedEntries, TSDataType.INT64); + } + @Override public TypeEnum getTypeEnum() { return TypeEnum.INT64; diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/StringType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/StringType.java index 725ae9e3b..d2c813f87 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/StringType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/StringType.java @@ -19,12 +19,21 @@ package org.apache.tsfile.read.common.type; +import org.apache.tsfile.block.column.ColumnBuilder; +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.block.column.BinaryColumnBuilder; + public class StringType extends AbstractVarcharType { public static final StringType STRING = new StringType(); private StringType() {} + @Override + public ColumnBuilder createColumnBuilder(int expectedEntries) { + return new BinaryColumnBuilder(null, expectedEntries, TSDataType.STRING); + } + @Override public TypeEnum getTypeEnum() { return TypeEnum.STRING; diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/TimestampType.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/TimestampType.java index c4e5e8434..49e58f283 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/TimestampType.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/type/TimestampType.java @@ -19,12 +19,21 @@ package org.apache.tsfile.read.common.type; +import org.apache.tsfile.block.column.ColumnBuilder; +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.read.common.block.column.LongColumnBuilder; + public class TimestampType extends AbstractLongType { public static final TimestampType TIMESTAMP = new TimestampType(); private TimestampType() {} + @Override + public ColumnBuilder createColumnBuilder(int expectedEntries) { + return new LongColumnBuilder(null, expectedEntries, TSDataType.TIMESTAMP); + } + @Override public TypeEnum getTypeEnum() { return TypeEnum.TIMESTAMP; diff --git a/java/tsfile/src/test/java/org/apache/tsfile/common/block/BinaryArrayColumnEncoderTest.java b/java/tsfile/src/test/java/org/apache/tsfile/common/block/BinaryArrayColumnEncoderTest.java index dfbda8e63..635d299dc 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/common/block/BinaryArrayColumnEncoderTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/common/block/BinaryArrayColumnEncoderTest.java @@ -54,7 +54,8 @@ public void testBinaryColumn() { values[i] = new Binary(value); } } - BinaryColumn input = new BinaryColumn(positionCount, Optional.of(nullIndicators), values); + BinaryColumn input = + new BinaryColumn(positionCount, Optional.of(nullIndicators), values, TSDataType.TEXT); long expectedRetainedSize = input.getRetainedSizeInBytes(); ColumnEncoder encoder = ColumnEncoderFactory.get(ColumnEncoding.BINARY_ARRAY); diff --git a/java/tsfile/src/test/java/org/apache/tsfile/common/block/Int32ArrayColumnEncoderTest.java b/java/tsfile/src/test/java/org/apache/tsfile/common/block/Int32ArrayColumnEncoderTest.java index 8c82a11dc..efbababb8 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/common/block/Int32ArrayColumnEncoderTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/common/block/Int32ArrayColumnEncoderTest.java @@ -51,7 +51,8 @@ public void testIntColumn() { values[i] = random.nextInt(); } } - IntColumn input = new IntColumn(positionCount, Optional.of(nullIndicators), values); + IntColumn input = + new IntColumn(positionCount, Optional.of(nullIndicators), values, TSDataType.INT32); long expectedRetainedSize = input.getRetainedSizeInBytes(); ColumnEncoder encoder = ColumnEncoderFactory.get(ColumnEncoding.INT32_ARRAY); diff --git a/java/tsfile/src/test/java/org/apache/tsfile/common/block/Int64ArrayColumnEncoderTest.java b/java/tsfile/src/test/java/org/apache/tsfile/common/block/Int64ArrayColumnEncoderTest.java index d9eac8415..72001e4f5 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/common/block/Int64ArrayColumnEncoderTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/common/block/Int64ArrayColumnEncoderTest.java @@ -52,7 +52,8 @@ public void testLongColumn() { values[i] = random.nextLong(); } } - LongColumn input = new LongColumn(positionCount, Optional.of(nullIndicators), values); + LongColumn input = + new LongColumn(positionCount, Optional.of(nullIndicators), values, TSDataType.INT64); long expectedRetainedSize = input.getRetainedSizeInBytes(); ColumnEncoder encoder = ColumnEncoderFactory.get(ColumnEncoding.INT64_ARRAY); diff --git a/java/tsfile/src/test/java/org/apache/tsfile/common/block/RunLengthColumnEncoderTest.java b/java/tsfile/src/test/java/org/apache/tsfile/common/block/RunLengthColumnEncoderTest.java index f02d32c08..7ecc33896 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/common/block/RunLengthColumnEncoderTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/common/block/RunLengthColumnEncoderTest.java @@ -22,6 +22,7 @@ import org.apache.tsfile.block.column.Column; import org.apache.tsfile.block.column.ColumnEncoding; import org.apache.tsfile.common.conf.TSFileConfig; +import org.apache.tsfile.enums.TSDataType; import org.apache.tsfile.read.common.block.column.BinaryColumn; import org.apache.tsfile.read.common.block.column.BooleanColumn; import org.apache.tsfile.read.common.block.column.ColumnEncoder; @@ -77,12 +78,12 @@ public void testBooleanColumn() { @Test public void testIntColumn() { - testInternal(new IntColumn(1, Optional.empty(), new int[] {0})); + testInternal(new IntColumn(1, Optional.empty(), new int[] {0}, TSDataType.INT32)); } @Test public void testLongColumn() { - testInternal(new LongColumn(1, Optional.empty(), new long[] {0L})); + testInternal(new LongColumn(1, Optional.empty(), new long[] {0L}, TSDataType.INT64)); } @Test @@ -99,6 +100,9 @@ public void testDoubleColumn() { public void testTextColumn() { testInternal( new BinaryColumn( - 1, Optional.empty(), new Binary[] {new Binary("foo", TSFileConfig.STRING_CHARSET)})); + 1, + Optional.empty(), + new Binary[] {new Binary("foo", TSFileConfig.STRING_CHARSET)}, + TSDataType.TEXT)); } } diff --git a/java/tsfile/src/test/java/org/apache/tsfile/common/block/TsBlockSerdeTest.java b/java/tsfile/src/test/java/org/apache/tsfile/common/block/TsBlockSerdeTest.java index cfedb3809..14bfa95cf 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/common/block/TsBlockSerdeTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/common/block/TsBlockSerdeTest.java @@ -137,7 +137,10 @@ public void testSerializeAndDeserialize2() { new TsBlock( new TimeColumn(1, new long[] {0}), new BinaryColumn( - 1, Optional.empty(), new Binary[] {new Binary(outputStream.toByteArray())})); + 1, + Optional.empty(), + new Binary[] {new Binary(outputStream.toByteArray())}, + TSDataType.TEXT)); TsBlockSerde tsBlockSerde = new TsBlockSerde(); try { @@ -172,7 +175,8 @@ public void testSerializeAndDeserialize3() { new BinaryColumn( 1, Optional.of(new boolean[] {false}), - new Binary[] {new Binary(outputStream.toByteArray())})); + new Binary[] {new Binary(outputStream.toByteArray())}, + TSDataType.TEXT)); TsBlockSerde tsBlockSerde = new TsBlockSerde(); try { diff --git a/java/tsfile/src/test/java/org/apache/tsfile/common/block/TsBlockTest.java b/java/tsfile/src/test/java/org/apache/tsfile/common/block/TsBlockTest.java index 47db65626..bb714981f 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/common/block/TsBlockTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/common/block/TsBlockTest.java @@ -400,7 +400,7 @@ public void ColumnInsertTest() { targetValue[i] = i; } - Column targetColumn = new IntColumn(19, Optional.empty(), targetValue); + Column targetColumn = new IntColumn(19, Optional.empty(), targetValue, TSDataType.INT32); tsBlock = tsBlock.insertValueColumn(1, new Column[] {targetColumn}); for (int i = 0; i < 19; i++) { assertEquals(i, tsBlock.getColumn(0).getLong(i)); @@ -420,7 +420,7 @@ public void MultiColumnInsertTest() { } Column[] targetColumn = new Column[] { - new IntColumn(19, Optional.empty(), targetValue1), + new IntColumn(19, Optional.empty(), targetValue1, TSDataType.INT32), new DoubleColumn(19, Optional.empty(), targetValue2) }; tsBlock = tsBlock.insertValueColumn(1, targetColumn); @@ -443,8 +443,8 @@ public void ColumnAppendTest() { } Column[] targetColumn = new Column[] { - new IntColumn(19, Optional.empty(), targetValue), - new LongColumn(19, Optional.empty(), targetValue2) + new IntColumn(19, Optional.empty(), targetValue, TSDataType.INT32), + new LongColumn(19, Optional.empty(), targetValue2, TSDataType.INT64) }; tsBlock = tsBlock.appendValueColumns(targetColumn); for (int i = 0; i < 19; i++) { diff --git a/java/tsfile/src/test/java/org/apache/tsfile/read/common/ColumnTest.java b/java/tsfile/src/test/java/org/apache/tsfile/read/common/ColumnTest.java index 80ac44828..cb8738178 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/read/common/ColumnTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/read/common/ColumnTest.java @@ -20,6 +20,7 @@ package org.apache.tsfile.read.common; import org.apache.tsfile.block.column.Column; +import org.apache.tsfile.enums.TSDataType; import org.apache.tsfile.read.common.block.column.BinaryColumn; import org.apache.tsfile.read.common.block.column.BinaryColumnBuilder; import org.apache.tsfile.read.common.block.column.BooleanColumn; @@ -85,7 +86,7 @@ public void timeColumnSubColumnCopyTest() { @Test public void binaryColumnSubColumnTest() { - BinaryColumnBuilder columnBuilder = new BinaryColumnBuilder(null, 10); + BinaryColumnBuilder columnBuilder = new BinaryColumnBuilder(null, 10, TSDataType.TEXT); for (int i = 0; i < 10; i++) { columnBuilder.writeBinary(BytesUtils.valueOf(String.valueOf(i))); } @@ -105,7 +106,7 @@ public void binaryColumnSubColumnTest() { @Test public void binaryColumnSubColumnCopyTest() { - BinaryColumnBuilder columnBuilder = new BinaryColumnBuilder(null, 10); + BinaryColumnBuilder columnBuilder = new BinaryColumnBuilder(null, 10, TSDataType.TEXT); for (int i = 0; i < 10; i++) { columnBuilder.writeBinary(BytesUtils.valueOf(String.valueOf(i))); } @@ -247,7 +248,7 @@ public void floatColumnSubColumnCopyTest() { @Test public void intColumnSubColumnTest() { - IntColumnBuilder columnBuilder = new IntColumnBuilder(null, 10); + IntColumnBuilder columnBuilder = new IntColumnBuilder(null, 10, TSDataType.INT32); for (int i = 0; i < 10; i++) { columnBuilder.writeInt(i); } @@ -267,7 +268,7 @@ public void intColumnSubColumnTest() { @Test public void intColumnSubColumnCopyTest() { - IntColumnBuilder columnBuilder = new IntColumnBuilder(null, 10); + IntColumnBuilder columnBuilder = new IntColumnBuilder(null, 10, TSDataType.INT32); for (int i = 0; i < 10; i++) { columnBuilder.writeInt(i); } @@ -287,7 +288,7 @@ public void intColumnSubColumnCopyTest() { @Test public void longColumnSubColumnTest() { - LongColumnBuilder columnBuilder = new LongColumnBuilder(null, 10); + LongColumnBuilder columnBuilder = new LongColumnBuilder(null, 10, TSDataType.INT64); for (int i = 0; i < 10; i++) { columnBuilder.writeLong(i); } @@ -307,7 +308,7 @@ public void longColumnSubColumnTest() { @Test public void longColumnSubColumnCopyTest() { - LongColumnBuilder columnBuilder = new LongColumnBuilder(null, 10); + LongColumnBuilder columnBuilder = new LongColumnBuilder(null, 10, TSDataType.INT64); for (int i = 0; i < 10; i++) { columnBuilder.writeLong(i); } @@ -337,7 +338,7 @@ public void nullColumnTest() { @Test public void runLengthEncodedColumnSubColumnTest() { - LongColumnBuilder longColumnBuilder = new LongColumnBuilder(null, 1); + LongColumnBuilder longColumnBuilder = new LongColumnBuilder(null, 1, TSDataType.INT64); longColumnBuilder.writeLong(1); RunLengthEncodedColumn column = new RunLengthEncodedColumn(longColumnBuilder.build(), 10); column = (RunLengthEncodedColumn) column.subColumn(5); @@ -353,7 +354,7 @@ public void runLengthEncodedColumnSubColumnTest() { @Test public void runLengthEncodedColumnSubColumnCopyTest() { - LongColumnBuilder longColumnBuilder = new LongColumnBuilder(null, 1); + LongColumnBuilder longColumnBuilder = new LongColumnBuilder(null, 1, TSDataType.INT64); longColumnBuilder.writeLong(1); RunLengthEncodedColumn column = new RunLengthEncodedColumn(longColumnBuilder.build(), 10); column = (RunLengthEncodedColumn) column.subColumnCopy(5); diff --git a/java/tsfile/src/test/java/org/apache/tsfile/read/filter/TsBlockFilterTest.java b/java/tsfile/src/test/java/org/apache/tsfile/read/filter/TsBlockFilterTest.java index a4b7f3c8d..75b9332f9 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/read/filter/TsBlockFilterTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/read/filter/TsBlockFilterTest.java @@ -88,18 +88,24 @@ public void before() { BooleanColumn booleanColumn = new BooleanColumn(booleans.length, Optional.of(valueIsNull), booleans); - IntColumn intColumn = new IntColumn(ints.length, Optional.of(valueIsNull), ints); - LongColumn longColumn = new LongColumn(longs.length, Optional.of(valueIsNull), longs); + IntColumn intColumn = + new IntColumn(ints.length, Optional.of(valueIsNull), ints, TSDataType.INT32); + LongColumn longColumn = + new LongColumn(longs.length, Optional.of(valueIsNull), longs, TSDataType.INT64); FloatColumn floatColumn = new FloatColumn(floats.length, Optional.of(valueIsNull), floats); DoubleColumn doubleColumn = new DoubleColumn(doubles.length, Optional.of(valueIsNull), doubles); BinaryColumn binaryColumn = new BinaryColumn( - binaries.length, Optional.of(new boolean[] {false, true, false}), binaries); + binaries.length, + Optional.of(new boolean[] {false, true, false}), + binaries, + TSDataType.TEXT); BinaryColumn nullColumn = new BinaryColumn( 3, Optional.of(new boolean[] {true, false, true}), - new Binary[] {null, new Binary("a", STRING_CHARSET), null}); + new Binary[] {null, new Binary("a", STRING_CHARSET), null}, + TSDataType.TEXT); timeColumn = new TimeColumn(timestamps.length, timestamps); valueColumn[getMeasurementId(TSDataType.BOOLEAN)] = booleanColumn;