github-code-scanning[bot] commented on code in PR #13652:
URL: https://github.com/apache/druid/pull/13652#discussion_r1067654576
##########
processing/src/main/java/org/apache/druid/query/rowsandcols/ArrayListRowsAndColumns.java:
##########
@@ -19,55 +19,130 @@
package org.apache.druid.query.rowsandcols;
+import it.unimi.dsi.fastutil.Arrays;
+import it.unimi.dsi.fastutil.ints.IntArrayList;
+import it.unimi.dsi.fastutil.ints.IntComparator;
+import it.unimi.dsi.fastutil.ints.IntList;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.query.operator.ColumnWithDirection;
import org.apache.druid.query.rowsandcols.column.Column;
import org.apache.druid.query.rowsandcols.column.ColumnAccessor;
+import org.apache.druid.query.rowsandcols.column.ColumnValueSwapper;
+import org.apache.druid.query.rowsandcols.column.DefaultVectorCopier;
+import org.apache.druid.query.rowsandcols.column.LimitedColumn;
+import org.apache.druid.query.rowsandcols.column.ObjectArrayColumn;
import org.apache.druid.query.rowsandcols.column.ObjectColumnAccessorBase;
+import org.apache.druid.query.rowsandcols.column.VectorCopier;
+import org.apache.druid.query.rowsandcols.semantic.AppendableRowsAndColumns;
+import org.apache.druid.query.rowsandcols.semantic.ClusteredGroupPartitioner;
+import
org.apache.druid.query.rowsandcols.semantic.DefaultClusteredGroupPartitioner;
+import org.apache.druid.query.rowsandcols.semantic.NaiveSortMaker;
import org.apache.druid.segment.RowAdapter;
import org.apache.druid.segment.column.ColumnType;
import org.apache.druid.segment.column.RowSignature;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import java.util.function.Function;
-public class ArrayListRowsAndColumns<RowType> implements RowsAndColumns
+/**
+ * ArrayListRowsAndColumns is a RowsAndColumns implementation that believes it
has all of its data on-heap.
+ * <p>
+ * It is an AppendableRowsAndColumns and, as with all RowsAndColumns, it is
not thread-safe for multiple writes.
+ * Under certain circumstances, concurrent reads from multiple threads can be
correct, but the code has to be follow
+ * a very strict ordering of code that ensures that reads only happen after
writes and once a value is read, it will
+ * never be overwritten.
+ * <p>
+ * Additionally, this object implements various of the semantic interfaces
directly to provide some degree
+ * of processing and memory optimization.
+ *
+ * @param <RowType>
+ */
+public class ArrayListRowsAndColumns<RowType> implements
AppendableRowsAndColumns
{
+ @SuppressWarnings("rawtypes")
+ private static final HashMap<Class<?>, Function<ArrayListRowsAndColumns, ?>>
AS_MAP = makeAsMap();
+
private final ArrayList<RowType> rows;
private final RowAdapter<RowType> rowAdapter;
private final RowSignature rowSignature;
+ private final Map<String, Column> extraColumns;
+ private final Set<String> columnNames;
+ private final int startOffset;
+ private final int endOffset;
+
public ArrayListRowsAndColumns(
ArrayList<RowType> rows,
RowAdapter<RowType> rowAdapter,
RowSignature rowSignature
)
{
+ this(
+ rows,
+ rowAdapter,
+ rowSignature,
+ new LinkedHashMap<>(),
+ new LinkedHashSet<>(rowSignature.getColumnNames()),
+ 0,
+ rows.size()
+ );
+ }
+
+ private ArrayListRowsAndColumns(
+ ArrayList<RowType> rows,
+ RowAdapter<RowType> rowAdapter,
+ RowSignature rowSignature,
+ Map<String, Column> extraColumns,
+ Set<String> columnNames,
+ int startOffset,
+ int endOffset
+ )
+ {
+ if (endOffset - startOffset < 0) {
+ throw new ISE("endOffset[%,d] - startOffset[%,d] was somehow
negative!?");
Review Comment:
## Missing format argument
This format call refers to 2 argument(s) but only supplies 0 argument(s).
[Show more
details](https://github.com/apache/druid/security/code-scanning/3656)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]