gortiz commented on code in PR #13916: URL: https://github.com/apache/pinot/pull/13916#discussion_r1738295072
########## pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/ArrayLiteralTransformFunction.java: ########## @@ -48,12 +48,15 @@ public class ArrayLiteralTransformFunction implements TransformFunction { private final double[] _doubleArrayLiteral; private final String[] _stringArrayLiteral; - // literals may be shared but values are intentionally not volatile as assignment races are benign - private int[][] _intArrayResult; - private long[][] _longArrayResult; - private float[][] _floatArrayResult; - private double[][] _doubleArrayResult; - private String[][] _stringArrayResult; + // NOTE: + // This class can be shared across multiple threads, and the result arrays are lazily initialized and cached. They + // need to be declared as volatile to ensure instructions are not reordered, or some threads might see uninitialized + // arrays. + private volatile int[][] _intArrayResult; + private volatile long[][] _longArrayResult; + private volatile float[][] _floatArrayResult; + private volatile double[][] _doubleArrayResult; + private volatile String[][] _stringArrayResult; Review Comment: nit: Do we need so many attributes? Wouldn't be better to have a single `private volatile Object _cachedResult;` and cast to the specific type on each method? Also another question: do we expect to receive calls to `transformToWhateverValuesMV` with different types and different `ValueBlock`? -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org