github-advanced-security[bot] commented on code in PR #855:
URL: 
https://github.com/apache/incubator-baremaps/pull/855#discussion_r1609543001


##########
baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/data/GeoParquetGroupConverter.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.baremaps.geoparquet.data;
+
+import org.apache.parquet.io.api.Converter;
+import org.apache.parquet.io.api.GroupConverter;
+import org.apache.parquet.schema.GroupType;
+import org.apache.parquet.schema.Type;
+
+class GeoParquetGroupConverter extends GroupConverter {
+
+  private final GeoParquetFileInfo fileInfo;
+  private final GeoParquetGroupConverter parent;
+  private final int index;
+  protected GeoParquetGroup current;
+  private Converter[] converters;
+
+  GeoParquetGroupConverter(GeoParquetFileInfo fileInfo, 
GeoParquetGroupConverter parent, int index,
+      GroupType schema) {
+    this.fileInfo = fileInfo;
+    this.parent = parent;
+    this.index = index;
+
+    converters = new Converter[schema.getFieldCount()];
+
+    for (int i = 0; i < converters.length; i++) {
+      final String name = schema.getName();

Review Comment:
   ## Unread local variable
   
   Variable 'String name' is never read.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1411)



##########
baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/data/GeoParquetGroup.java:
##########
@@ -0,0 +1,302 @@
+/*
+ * 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.baremaps.geoparquet.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.parquet.io.api.Binary;
+import org.apache.parquet.io.api.RecordConsumer;
+import org.apache.parquet.schema.GroupType;
+import org.apache.parquet.schema.Type;
+
+public class GeoParquetGroup {
+
+  private final GeoParquetFileInfo fileInfo;
+  private final GroupType schema;
+  private final List<Object>[] data;
+
+  @SuppressWarnings("unchecked")
+  public GeoParquetGroup(GeoParquetFileInfo fileInfo, GroupType schema) {
+    this.fileInfo = fileInfo;
+    this.schema = schema;
+    this.data = new List[schema.getFields().size()];
+    for (int i = 0; i < schema.getFieldCount(); i++) {
+      this.data[i] = new ArrayList<>();
+    }
+  }
+
+  @Override
+  public String toString() {
+    return toString("");
+  }
+
+  private void appendToString(StringBuilder builder, String indent) {
+    int i = 0;
+    for (Type field : schema.getFields()) {
+      String name = field.getName();
+      List<Object> values = data[i];
+      ++i;
+      if (values != null && !values.isEmpty()) {
+        for (Object value : values) {
+          builder.append(indent).append(name);
+          if (value == null) {
+            builder.append(": NULL\n");
+          } else if (value instanceof GeoParquetGroup) {
+            builder.append('\n');
+            ((GeoParquetGroup) value).appendToString(builder, indent + "  ");
+          } else {
+            builder.append(": ").append(value.toString()).append('\n');
+          }
+        }
+      }
+    }
+  }
+
+  public String toString(String indent) {
+    StringBuilder builder = new StringBuilder();
+    appendToString(builder, indent);
+    return builder.toString();
+  }
+
+  public GeoParquetGroup addGroup(int fieldIndex) {
+    GeoParquetGroup g = new GeoParquetGroup(fileInfo, 
schema.getType(fieldIndex).asGroupType());
+    add(fieldIndex, g);
+    return g;
+  }
+
+  public GeoParquetGroup getGroup(int fieldIndex, int index) {
+    return (GeoParquetGroup) getValue(fieldIndex, index);
+  }
+
+  private Object getValue(int fieldIndex, int index) {
+    List<Object> list;
+    try {
+      list = data[fieldIndex];
+    } catch (IndexOutOfBoundsException e) {
+      throw new RuntimeException("not found " + fieldIndex + "(" + 
schema.getFieldName(fieldIndex)
+          + ") in group:\n" + this);
+    }
+    try {
+      return list.get(index);
+    } catch (IndexOutOfBoundsException e) {
+      throw new RuntimeException("not found " + fieldIndex + "(" + 
schema.getFieldName(fieldIndex)
+          + ") element number " + index + " in group:\n" + this);
+    }
+  }
+
+  private void add(int fieldIndex, Primitive value) {
+    Type type = schema.getType(fieldIndex);
+    List<Object> list = data[fieldIndex];
+    if (!type.isRepetition(Type.Repetition.REPEATED)
+        && !list.isEmpty()) {
+      throw new IllegalStateException("field " + fieldIndex + " (" + 
type.getName()
+          + ") can not have more than one value: " + list);
+    }
+    list.add(value);
+  }
+
+  public int getFieldRepetitionCount(int fieldIndex) {
+    List<Object> list = data[fieldIndex];
+    return list == null ? 0 : list.size();
+  }
+
+  public String getValueToString(int fieldIndex, int index) {
+    return String.valueOf(getValue(fieldIndex, index));
+  }
+
+  public String getString(int fieldIndex, int index) {
+    return ((BinaryValue) getValue(fieldIndex, index)).getString();
+  }
+
+  public int getInteger(int fieldIndex, int index) {
+    return ((IntegerValue) getValue(fieldIndex, index)).getInteger();
+  }
+
+  public long getLong(int fieldIndex, int index) {
+    return ((LongValue) getValue(fieldIndex, index)).getLong();
+  }
+
+  public double getDouble(int fieldIndex, int index) {
+    return ((DoubleValue) getValue(fieldIndex, index)).getDouble();
+  }
+
+  public float getFloat(int fieldIndex, int index) {
+    return ((FloatValue) getValue(fieldIndex, index)).getFloat();
+  }
+
+  public boolean getBoolean(int fieldIndex, int index) {
+    return ((BooleanValue) getValue(fieldIndex, index)).getBoolean();
+  }
+
+  public Binary getBinary(int fieldIndex, int index) {
+    return ((BinaryValue) getValue(fieldIndex, index)).getBinary();
+  }
+
+  public NanoTime getTimeNanos(int fieldIndex, int index) {
+    return NanoTime.fromInt96((Int96Value) getValue(fieldIndex, index));
+  }
+
+  public Binary getInt96(int fieldIndex, int index) {
+    return ((Int96Value) getValue(fieldIndex, index)).getInt96();
+  }
+
+  public void add(int fieldIndex, int value) {
+    add(fieldIndex, new IntegerValue(value));
+  }
+
+  public void add(int fieldIndex, long value) {
+    add(fieldIndex, new LongValue(value));
+  }
+
+  public void add(int fieldIndex, String value) {
+    add(fieldIndex, new BinaryValue(Binary.fromString(value)));
+  }
+
+  public void add(int fieldIndex, NanoTime value) {

Review Comment:
   ## Confusing overloading of methods
   
   Method GeoParquetGroup.add(..) could be confused with overloaded method 
[add](1), since dispatch depends on static types.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1410)



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

Reply via email to