github-advanced-security[bot] commented on code in PR #16322:
URL: https://github.com/apache/druid/pull/16322#discussion_r1590585739
##########
processing/src/main/java/org/apache/druid/frame/read/FrameReaderUtils.java:
##########
@@ -216,6 +219,65 @@
return Integer.compare(length1, length2);
}
+ // TODO(laksh): There's an implicit contract that if a field isn't
comparable by bytes, then it must be serded using
+ // the CopmlexMetricSerde.toBytes()
+ public static int compareComplexTypes(
+ final byte[] array1,
+ final int position1,
+ final int length1,
+ final byte[] array2,
+ final int position2,
+ final int length2,
+ final ColumnType columnType,
+ final ComplexMetricSerde complexMetricSerde
+ )
+ {
+ return compareComplexTypes(
+ Memory.wrap(array1),
+ position1,
+ Memory.wrap(array2),
+ position2,
+ columnType,
+ complexMetricSerde
+ );
+ }
+
+ public static int compareComplexTypes(
+ final Memory memory,
+ final long position1,
+ final byte[] array,
+ final int position2,
+ final int length2,
Review Comment:
## Useless parameter
The parameter 'length2' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7334)
##########
processing/src/test/java/org/apache/druid/frame/write/FrameWriterTest.java:
##########
@@ -500,24 +500,21 @@
capabilitiesAdjustFn,
rows,
signature,
- computeSortColumns(sortColumns)
+ computeSortColumns(sortColumns, signature)
);
}
/**
* Converts the provided column names into {@link KeyColumn} according to
the current {@link #sortedness}
* parameter.
*/
- private List<KeyColumn> computeSortColumns(final List<String>
sortColumnNames)
+ private List<KeyColumn> computeSortColumns(final List<String>
sortColumnNames, final RowSignature rowSignature)
Review Comment:
## Useless parameter
The parameter 'rowSignature' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7337)
##########
processing/src/main/java/org/apache/druid/frame/read/FrameReaderUtils.java:
##########
@@ -216,6 +219,65 @@
return Integer.compare(length1, length2);
}
+ // TODO(laksh): There's an implicit contract that if a field isn't
comparable by bytes, then it must be serded using
+ // the CopmlexMetricSerde.toBytes()
+ public static int compareComplexTypes(
+ final byte[] array1,
+ final int position1,
+ final int length1,
+ final byte[] array2,
+ final int position2,
+ final int length2,
Review Comment:
## Useless parameter
The parameter 'length2' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7336)
##########
processing/src/main/java/org/apache/druid/frame/key/RowKeyComparisonRunLengths.java:
##########
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.frame.key;
+
+import org.apache.druid.error.DruidException;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.column.RowSignature;
+import org.apache.druid.segment.column.ValueType;
+
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+public class RowKeyComparisonRunLengths
+{
+
+ public static RowKeyComparisonRunLengths create(final List<KeyColumn>
keyColumns, RowSignature rowSignature)
+ {
+ final List<RunLengthEntry> runLengthEntries = new ArrayList<>();
+ for (KeyColumn keyColumn : keyColumns) {
+
+ if (keyColumn.order() == KeyOrder.NONE) {
+ throw DruidException.defensive("Cannot sort on column [%s] and type
[%s] when the sorting order isn't provided");
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/7333)
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/groupby/GroupByQueryKit.java:
##########
@@ -380,6 +380,7 @@
static ClusterBy computeClusterByForResults(final GroupByQuery query)
{
if (query.getLimitSpec() instanceof DefaultLimitSpec) {
+ final RowSignature resultSignature = computeResultSignature(query);
Review Comment:
## Unread local variable
Variable 'RowSignature resultSignature' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7338)
##########
processing/src/main/java/org/apache/druid/frame/read/FrameReaderUtils.java:
##########
@@ -216,6 +219,65 @@
return Integer.compare(length1, length2);
}
+ // TODO(laksh): There's an implicit contract that if a field isn't
comparable by bytes, then it must be serded using
+ // the CopmlexMetricSerde.toBytes()
+ public static int compareComplexTypes(
+ final byte[] array1,
+ final int position1,
+ final int length1,
Review Comment:
## Useless parameter
The parameter 'length1' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7335)
##########
processing/src/main/java/org/apache/druid/frame/key/FrameComparisonWidgetImpl.java:
##########
@@ -230,39 +284,92 @@
int comparableBytesStartPositionInRow = firstFieldPosition;
int otherComparableBytesStartPositionInRow =
otherWidgetImpl.firstFieldPosition;
- boolean ascending = true;
- int field = 0;
+ // boolean ascending = true;
+
+ // Number of fields compared till now, which is equivalent to the index of
the field to compare next
+ int fieldsComparedTillNow = 0;
+
+ // Memoize the serde instead of calling ComplexMetrics.getSerdeForType
everytime
+ final Map<String, ComplexMetricSerde> serdeMap = new HashMap<>();
Review Comment:
## Unread local variable
Variable 'Map<String,ComplexMetricSerde> serdeMap' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7339)
--
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]