From 72800c23fc1f25e53ec5471b5cc5605ab5f472b3 Mon Sep 17 00:00:00 2001 From: Tian Jiang Date: Mon, 13 Jan 2025 13:11:05 +0800 Subject: [PATCH] add column compatibility (cherry picked from commit 8dd5f1c18b0b0c0e0268ea3fe04f5c9ed953058c) --- .../read/common/block/column/FloatColumn.java | 15 +++++++ .../read/common/block/column/IntColumn.java | 43 +++++++++++++++++++ .../read/common/block/column/LongColumn.java | 15 +++++++ 3 files changed, 73 insertions(+) diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/FloatColumn.java b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/FloatColumn.java index 98bcd90e5..c008d9353 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/FloatColumn.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/common/block/column/FloatColumn.java @@ -34,6 +34,7 @@ import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfBooleanArray; import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfFloatArray; +@SuppressWarnings("java:S3012") public class FloatColumn implements Column { private static final int INSTANCE_SIZE = @@ -94,11 +95,25 @@ public float getFloat(int position) { return values[position + arrayOffset]; } + @Override + public double getDouble(int position) { + return values[position + arrayOffset]; + } + @Override public float[] getFloats() { return values; } + @Override + public double[] getDoubles() { + double[] doubles = new double[values.length]; + for (int i = 0; i < values.length; i++) { + doubles[i] = values[i]; + } + return doubles; + } + @Override public Object getObject(int position) { return getFloat(position); 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 3e0caa91c..c2065ee32 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 @@ -34,6 +34,7 @@ import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfBooleanArray; import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfIntArray; +@SuppressWarnings("java:S3012") public class IntColumn implements Column { private static final int INSTANCE_SIZE = @@ -94,11 +95,53 @@ public int getInt(int position) { return values[position + arrayOffset]; } + @Override + public long getLong(int position) { + return values[position + arrayOffset]; + } + + @Override + public float getFloat(int position) { + return values[position + arrayOffset]; + } + + @Override + public double getDouble(int position) { + return values[position + arrayOffset]; + } + @Override public int[] getInts() { return values; } + @Override + public float[] getFloats() { + float[] result = new float[values.length]; + for (int i = 0; i < values.length; i++) { + result[i] = values[i]; + } + return result; + } + + @Override + public long[] getLongs() { + long[] result = new long[values.length]; + for (int i = 0; i < values.length; i++) { + result[i] = values[i]; + } + return result; + } + + @Override + public double[] getDoubles() { + double[] result = new double[values.length]; + for (int i = 0; i < values.length; i++) { + result[i] = values[i]; + } + return result; + } + @Override public Object getObject(int position) { return getInt(position); 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 bbbb06631..ecba9013d 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 @@ -34,6 +34,7 @@ import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfBooleanArray; import static org.apache.tsfile.utils.RamUsageEstimator.sizeOfLongArray; +@SuppressWarnings("java:S3012") public class LongColumn implements Column { private static final int INSTANCE_SIZE = @@ -94,11 +95,25 @@ public long getLong(int position) { return values[position + arrayOffset]; } + @Override + public double getDouble(int position) { + return values[position + arrayOffset]; + } + @Override public long[] getLongs() { return values; } + @Override + public double[] getDoubles() { + double[] doubles = new double[values.length]; + for (int i = 0; i < values.length; i++) { + doubles[i] = values[i]; + } + return doubles; + } + @Override public Object getObject(int position) { return getLong(position);