jt2594838 commented on code in PR #560:
URL: https://github.com/apache/tsfile/pull/560#discussion_r2269020385
##########
java/tsfile/src/main/java/org/apache/tsfile/encoding/decoder/CamelDecoder.java:
##########
@@ -194,21 +185,27 @@ public GorillaDecoder getGorillaDecoder() {
return gorillaDecoder;
}
- /** Read all values until stream is exhausted. */
- public List<Double> getValues() throws IOException {
- List<Double> list = new LinkedList<>();
- Double val;
- while ((val = next()) != null) {
- list.add(val);
+ /** Read all values until the stream is exhausted. */
+ public double[] getValues() throws IOException {
+ // Dynamically expanding array, initial capacity set to 16
+ double[] arr = new double[16];
+ int count = 0;
+ while (in.availableBits() > 0) {
+ double val = next();
+ if (count == arr.length) {
+ // Double the capacity when full
+ arr = Arrays.copyOf(arr, arr.length * 2);
+ }
+ arr[count++] = val;
}
- return list;
+ // Copy only the valid portion to a new array
+ double[] result = new double[count];
+ System.arraycopy(arr, 0, result, 0, count);
+ return result;
Review Comment:
Is it possible to read into valueCache directly and reuse it throughout the
decoding process?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]