Skip to content

Commit

Permalink
add column compatibility
Browse files Browse the repository at this point in the history
(cherry picked from commit 8dd5f1c)
  • Loading branch information
jt2594838 committed Jan 15, 2025
1 parent f65a1f6 commit 72800c2
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 72800c2

Please sign in to comment.