github-code-scanning[bot] commented on code in PR #13952:
URL: https://github.com/apache/druid/pull/13952#discussion_r1170844067


##########
processing/src/main/java/org/apache/druid/query/scan/ConcatCursor.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.query.scan;
+
+import org.apache.druid.segment.ColumnSelectorFactory;
+import org.apache.druid.segment.Cursor;
+import org.joda.time.DateTime;
+
+import java.util.List;
+
+/**
+ * Combines multiple cursors and iterates over them. It skips over the empty 
cursors
+ */
+public class ConcatCursor implements Cursor
+{
+
+  private final List<Cursor> cursors;
+  private int currentCursor;
+
+  public ConcatCursor(
+      List<Cursor> cursors
+  )
+  {
+    this.cursors = cursors;
+    currentCursor = 0;
+    skipEmptyCursors();
+  }
+
+  @Override
+  public ColumnSelectorFactory getColumnSelectorFactory()
+  {
+    return cursors.get(currentCursor).getColumnSelectorFactory();
+  }
+
+  @Override
+  public DateTime getTime()
+  {
+    return cursors.get(currentCursor).getTime();
+  }
+
+  @Override
+  public void advance()
+  {
+    if (currentCursor < cursors.size()) {
+      cursors.get(currentCursor).advance();
+      advanceCursor();
+    }
+  }
+
+  @Override
+  public void advanceUninterruptibly()
+  {
+    if (currentCursor < cursors.size()) {
+      cursors.get(currentCursor).advanceUninterruptibly();
+      advanceCursor();
+    }
+  }
+
+  @Override
+  public boolean isDone()
+  {
+    return currentCursor == cursors.size();
+  }
+
+  @Override
+  public boolean isDoneOrInterrupted()
+  {
+    return isDone() || Thread.currentThread().isInterrupted();
+  }
+
+  @Override
+  public void reset()
+  {
+    while (currentCursor >= 0) {
+      if (currentCursor < cursors.size()) {
+        cursors.get(currentCursor).reset();
+      }
+      --currentCursor;
+    }
+    currentCursor = 0;
+    skipEmptyCursors();
+  }
+
+  /**
+   * This method should be called whenever the currentCursor gets updated. It 
skips over the empty cursors so that the
+   * current pointer is pointing to a valid cursor
+   */
+  private void skipEmptyCursors()
+  {
+    while (currentCursor < cursors.size() && 
cursors.get(currentCursor).isDone()) {
+      ++currentCursor;
+    }
+  }
+
+  /**
+   * This method updates the current cursor. This is used to update the 
current cursor under question.
+   */
+  private void advanceCursor()
+  {
+    if (cursors.get(currentCursor).isDone()) {
+      ++currentCursor;

Review Comment:
   ## User-controlled data in arithmetic expression
   
   This arithmetic expression depends on a [user-provided value](1), 
potentially causing an overflow.
   This arithmetic expression depends on a [user-provided value](2), 
potentially causing an overflow.
   This arithmetic expression depends on a [user-provided value](3), 
potentially causing an overflow.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/4832)



##########
processing/src/main/java/org/apache/druid/query/FramesBackedInlineDataSourceSerializer.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.query;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import org.apache.druid.java.util.common.RE;
+import org.apache.druid.java.util.common.jackson.JacksonUtils;
+import org.apache.druid.segment.column.ColumnType;
+import org.apache.druid.segment.column.RowSignature;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+/**
+ * Serializes {@link FramesBackedInlineDataSource} to the representation of 
{@link InlineDataSource}
+ * so that the servers' on wire transfer data doesn't change. {@link 
FramesBackedInlineDataSource} is currently limited
+ * to the brokers only and therefore this aids in conversion of the object to 
a representation that the data servers
+ * can recognize
+ */
+public class FramesBackedInlineDataSourceSerializer extends 
StdSerializer<FramesBackedInlineDataSource>
+{
+  public FramesBackedInlineDataSourceSerializer()
+  {
+    super(FramesBackedInlineDataSource.class);
+  }
+
+  @Override
+  public void serialize(FramesBackedInlineDataSource value, JsonGenerator jg, 
SerializerProvider serializers)
+      throws IOException
+  {
+    jg.writeStartObject();
+    jg.writeStringField("type", "inline");
+
+    RowSignature rowSignature = value.getRowSignature();
+    jg.writeObjectField("columnNames", rowSignature.getColumnNames());
+    List<ColumnType> columnTypes = IntStream.range(0, rowSignature.size())
+                                            .mapToObj(i -> 
rowSignature.getColumnType(i).orElse(null))
+                                            .collect(Collectors.toList());
+    jg.writeObjectField("columnTypes", columnTypes);
+
+    jg.writeArrayFieldStart("rows");
+
+    value.getRowsAsSequence().forEach(row -> {
+      try {
+        JacksonUtils.writeObjectUsingSerializerProvider(jg, serializers, row);
+      }
+      catch (IOException e) {
+        // Ideally, this shouldn't be reachable.
+        // Wrap the IO exception in the runtime exception and propogate it 
forward
+        throw new RE(
+            e,
+            "Exception encountered while serializing [%s] in [%s]",
+            row,

Review Comment:
   ## Implicit conversion from array to string
   
   Implicit conversion from Array to String.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/4831)



-- 
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]

Reply via email to