This is an automated email from the ASF dual-hosted git repository.

bchapuis pushed a commit to branch geoparquet-filtering-and-simplification
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git

commit 17120aa0027e0b06639c3f18cb45569dcf53605f
Author: Bertil Chapuis <[email protected]>
AuthorDate: Tue Oct 8 22:31:12 2024 +0200

    Remove the wrappers
---
 .../apache/baremaps/geoparquet/BinaryValue.java    | 51 ------------------
 .../apache/baremaps/geoparquet/BooleanValue.java   | 44 ---------------
 .../apache/baremaps/geoparquet/DoubleValue.java    | 44 ---------------
 .../org/apache/baremaps/geoparquet/FloatValue.java | 44 ---------------
 .../baremaps/geoparquet/GeoParquetGroup.java       | 62 ++++++++++-----------
 .../org/apache/baremaps/geoparquet/Int96Value.java | 45 ----------------
 .../apache/baremaps/geoparquet/IntegerValue.java   | 45 ----------------
 .../org/apache/baremaps/geoparquet/LongValue.java  | 44 ---------------
 .../org/apache/baremaps/geoparquet/Primitive.java  | 63 ----------------------
 9 files changed, 29 insertions(+), 413 deletions(-)

diff --git 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/BinaryValue.java
 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/BinaryValue.java
deleted file mode 100644
index 5ab2fab7..00000000
--- 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/BinaryValue.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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;
-
-import org.apache.parquet.io.api.Binary;
-import org.apache.parquet.io.api.RecordConsumer;
-
-
-class BinaryValue extends Primitive {
-
-  private final Binary binary;
-
-  public BinaryValue(Binary binary) {
-    this.binary = binary;
-  }
-
-  @Override
-  public Binary getBinary() {
-    return binary;
-  }
-
-  @Override
-  public String getString() {
-    return binary.toStringUsingUTF8();
-  }
-
-  @Override
-  public void writeValue(RecordConsumer recordConsumer) {
-    recordConsumer.addBinary(binary);
-  }
-
-  @Override
-  public String toString() {
-    return getString();
-  }
-}
diff --git 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/BooleanValue.java
 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/BooleanValue.java
deleted file mode 100644
index b9ff75a8..00000000
--- 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/BooleanValue.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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;
-
-import org.apache.parquet.io.api.RecordConsumer;
-
-class BooleanValue extends Primitive {
-
-  private final boolean bool;
-
-  public BooleanValue(boolean bool) {
-    this.bool = bool;
-  }
-
-  @Override
-  public String toString() {
-    return String.valueOf(bool);
-  }
-
-  @Override
-  public boolean getBoolean() {
-    return bool;
-  }
-
-  @Override
-  public void writeValue(RecordConsumer recordConsumer) {
-    recordConsumer.addBoolean(bool);
-  }
-}
diff --git 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/DoubleValue.java
 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/DoubleValue.java
deleted file mode 100644
index 43bdf1b8..00000000
--- 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/DoubleValue.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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;
-
-import org.apache.parquet.io.api.RecordConsumer;
-
-class DoubleValue extends Primitive {
-
-  private final double value;
-
-  public DoubleValue(double value) {
-    this.value = value;
-  }
-
-  @Override
-  public double getDouble() {
-    return value;
-  }
-
-  @Override
-  public void writeValue(RecordConsumer recordConsumer) {
-    recordConsumer.addDouble(value);
-  }
-
-  @Override
-  public String toString() {
-    return String.valueOf(value);
-  }
-}
diff --git 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/FloatValue.java
 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/FloatValue.java
deleted file mode 100644
index 568cd005..00000000
--- 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/FloatValue.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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;
-
-import org.apache.parquet.io.api.RecordConsumer;
-
-class FloatValue extends Primitive {
-
-  private final float value;
-
-  public FloatValue(float value) {
-    this.value = value;
-  }
-
-  @Override
-  public float getFloat() {
-    return value;
-  }
-
-  @Override
-  public void writeValue(RecordConsumer recordConsumer) {
-    recordConsumer.addFloat(value);
-  }
-
-  @Override
-  public String toString() {
-    return String.valueOf(value);
-  }
-}
diff --git 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetGroup.java
 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetGroup.java
index 8108b11c..ddf7a11e 100644
--- 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetGroup.java
+++ 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/GeoParquetGroup.java
@@ -83,44 +83,40 @@ public class GeoParquetGroup {
     }
   }
 
-  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();
+    return getBinary(fieldIndex, index).toString();
   }
 
   public int getInteger(int fieldIndex, int index) {
-    return ((IntegerValue) getValue(fieldIndex, index)).getInteger();
+    return (int) getValue(fieldIndex, index);
   }
 
   public long getLong(int fieldIndex, int index) {
-    return ((LongValue) getValue(fieldIndex, index)).getLong();
+    return (long) getValue(fieldIndex, index);
   }
 
   public double getDouble(int fieldIndex, int index) {
-    return ((DoubleValue) getValue(fieldIndex, index)).getDouble();
+    return (double) getValue(fieldIndex, index);
   }
 
   public float getFloat(int fieldIndex, int index) {
-    return ((FloatValue) getValue(fieldIndex, index)).getFloat();
+    return (float) getValue(fieldIndex, index);
   }
 
   public boolean getBoolean(int fieldIndex, int index) {
-    return ((BooleanValue) getValue(fieldIndex, index)).getBoolean();
+    return (boolean) getValue(fieldIndex, index);
   }
 
   public Binary getBinary(int fieldIndex, int index) {
-    return ((BinaryValue) getValue(fieldIndex, index)).getBinary();
+    return (Binary) getValue(fieldIndex, index);
   }
 
   public Binary getInt96(int fieldIndex, int index) {
-    return ((Int96Value) getValue(fieldIndex, index)).getInt96();
+    return (Binary) getValue(fieldIndex, index);
   }
 
   public Geometry getGeometry(int fieldIndex, int index) {
-    byte[] bytes = ((BinaryValue) getValue(fieldIndex, 
index)).getBinary().getBytes();
+    byte[] bytes = getBinary(fieldIndex, index).getBytes();
     try {
       return new WKBReader().read(bytes);
     } catch (ParseException e) {
@@ -155,28 +151,28 @@ public class GeoParquetGroup {
   }
 
   public void add(int fieldIndex, int value) {
-    addValue(fieldIndex, new IntegerValue(value));
+    addValue(fieldIndex, value);
   }
 
   public void add(int fieldIndex, long value) {
-    addValue(fieldIndex, new LongValue(value));
+    addValue(fieldIndex, value);
   }
 
   public void add(int fieldIndex, String value) {
-    addValue(fieldIndex, new BinaryValue(Binary.fromString(value)));
+    addValue(fieldIndex, Binary.fromString(value));
   }
 
   public void add(int fieldIndex, boolean value) {
-    addValue(fieldIndex, new BooleanValue(value));
+    addValue(fieldIndex, value);
   }
 
   public void add(int fieldIndex, Binary value) {
     switch 
(getParquetSchema().getType(fieldIndex).asPrimitiveType().getPrimitiveTypeName())
 {
       case BINARY, FIXED_LEN_BYTE_ARRAY:
-        addValue(fieldIndex, new BinaryValue(value));
+        addValue(fieldIndex, value);
         break;
       case INT96:
-        addValue(fieldIndex, new Int96Value(value));
+        addValue(fieldIndex, value);
         break;
       default:
         throw new UnsupportedOperationException(
@@ -185,11 +181,11 @@ public class GeoParquetGroup {
   }
 
   public void add(int fieldIndex, float value) {
-    addValue(fieldIndex, new FloatValue(value));
+    addValue(fieldIndex, value);
   }
 
   public void add(int fieldIndex, double value) {
-    addValue(fieldIndex, new DoubleValue(value));
+    addValue(fieldIndex, value);
   }
 
   public void add(int fieldIndex, GeoParquetGroup value) {
@@ -282,22 +278,22 @@ public class GeoParquetGroup {
     }
   }
 
-  private Primitive getValue(int fieldIndex) {
+  private Object getValue(int fieldIndex) {
     Field field = geoParquetSchema.fields().get(fieldIndex);
     if (field.cardinality() == Cardinality.REPEATED) {
       throw new IllegalStateException("Field " + fieldIndex + " (" + 
field.name()
           + ") is repeated. Use getValues() instead.");
     }
-    return (Primitive) data[fieldIndex];
+    return data[fieldIndex];
   }
 
-  public List<Primitive> getValues(int fieldIndex) {
+  public List<Object> getValues(int fieldIndex) {
     Field field = geoParquetSchema.fields().get(fieldIndex);
     if (field.cardinality() != Cardinality.REPEATED) {
       throw new IllegalStateException("Field " + fieldIndex + " (" + 
field.name()
           + ") is not repeated. Use getValue() instead.");
     }
-    return (List<Primitive>) data[fieldIndex];
+    return (List<Object>) data[fieldIndex];
   }
 
 
@@ -340,7 +336,7 @@ public class GeoParquetGroup {
   }
 
   public List<Binary> getBinaryValues(int fieldIndex) {
-    return getValues(fieldIndex).stream().map(Primitive::getBinary).toList();
+    return getValues(fieldIndex).stream().map(Binary.class::cast).toList();
   }
 
   public Boolean getBooleanValue(int fieldIndex) {
@@ -348,7 +344,7 @@ public class GeoParquetGroup {
   }
 
   public List<Boolean> getBooleanValues(int fieldIndex) {
-    return getValues(fieldIndex).stream().map(Primitive::getBoolean).toList();
+    return getValues(fieldIndex).stream().map(Boolean.class::cast).toList();
   }
 
   public Double getDoubleValue(int fieldIndex) {
@@ -356,7 +352,7 @@ public class GeoParquetGroup {
   }
 
   public List<Double> getDoubleValues(int fieldIndex) {
-    return getValues(fieldIndex).stream().map(Primitive::getDouble).toList();
+    return getValues(fieldIndex).stream().map(Double.class::cast).toList();
   }
 
   public Float getFloatValue(int fieldIndex) {
@@ -364,7 +360,7 @@ public class GeoParquetGroup {
   }
 
   public List<Float> getFloatValues(int fieldIndex) {
-    return getValues(fieldIndex).stream().map(Primitive::getFloat).toList();
+    return getValues(fieldIndex).stream().map(Float.class::cast).toList();
   }
 
   public Integer getIntegerValue(int fieldIndex) {
@@ -372,7 +368,7 @@ public class GeoParquetGroup {
   }
 
   public List<Integer> getIntegerValues(int fieldIndex) {
-    return getValues(fieldIndex).stream().map(Primitive::getInteger).toList();
+    return getValues(fieldIndex).stream().map(Integer.class::cast).toList();
   }
 
   public Binary getInt96Value(int fieldIndex) {
@@ -380,7 +376,7 @@ public class GeoParquetGroup {
   }
 
   public List<Binary> getInt96Values(int fieldIndex) {
-    return getValues(fieldIndex).stream().map(Primitive::getBinary).toList();
+    return getValues(fieldIndex).stream().map(Binary.class::cast).toList();
   }
 
   public Long getLongValue(int fieldIndex) {
@@ -388,7 +384,7 @@ public class GeoParquetGroup {
   }
 
   public List<Long> getLongValues(int fieldIndex) {
-    return getValues(fieldIndex).stream().map(Primitive::getLong).toList();
+    return getValues(fieldIndex).stream().map(Long.class::cast).toList();
   }
 
   public String getStringValue(int fieldIndex) {
@@ -396,7 +392,7 @@ public class GeoParquetGroup {
   }
 
   public List<String> getStringValues(int fieldIndex) {
-    return getValues(fieldIndex).stream().map(Primitive::getString).toList();
+    return getValues(fieldIndex).stream().map(String.class::cast).toList();
   }
 
   public Geometry getGeometryValue(int fieldIndex) {
diff --git 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/Int96Value.java
 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/Int96Value.java
deleted file mode 100644
index 160cde64..00000000
--- 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/Int96Value.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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;
-
-import org.apache.parquet.io.api.Binary;
-import org.apache.parquet.io.api.RecordConsumer;
-
-class Int96Value extends Primitive {
-
-  private final Binary value;
-
-  public Int96Value(Binary value) {
-    this.value = value;
-  }
-
-  @Override
-  public Binary getInt96() {
-    return value;
-  }
-
-  @Override
-  public void writeValue(RecordConsumer recordConsumer) {
-    recordConsumer.addBinary(value);
-  }
-
-  @Override
-  public String toString() {
-    return "Int96Value{" + value + "}";
-  }
-}
diff --git 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/IntegerValue.java
 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/IntegerValue.java
deleted file mode 100644
index e740b541..00000000
--- 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/IntegerValue.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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;
-
-import org.apache.parquet.io.api.RecordConsumer;
-
-
-class IntegerValue extends Primitive {
-
-  private final int value;
-
-  public IntegerValue(int value) {
-    this.value = value;
-  }
-
-  @Override
-  public String toString() {
-    return String.valueOf(value);
-  }
-
-  @Override
-  public int getInteger() {
-    return value;
-  }
-
-  @Override
-  public void writeValue(RecordConsumer recordConsumer) {
-    recordConsumer.addInteger(value);
-  }
-}
diff --git 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/LongValue.java
 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/LongValue.java
deleted file mode 100644
index 67b7c7f3..00000000
--- 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/LongValue.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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;
-
-import org.apache.parquet.io.api.RecordConsumer;
-
-class LongValue extends Primitive {
-
-  private final long value;
-
-  public LongValue(long value) {
-    this.value = value;
-  }
-
-  @Override
-  public String toString() {
-    return String.valueOf(value);
-  }
-
-  @Override
-  public long getLong() {
-    return value;
-  }
-
-  @Override
-  public void writeValue(RecordConsumer recordConsumer) {
-    recordConsumer.addLong(value);
-  }
-}
diff --git 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/Primitive.java
 
b/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/Primitive.java
deleted file mode 100644
index 46ee4e8a..00000000
--- 
a/baremaps-geoparquet/src/main/java/org/apache/baremaps/geoparquet/Primitive.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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;
-
-import org.apache.parquet.io.api.Binary;
-import org.apache.parquet.io.api.RecordConsumer;
-import org.locationtech.jts.geom.Geometry;
-
-abstract class Primitive {
-
-  public String getString() {
-    throw new UnsupportedOperationException();
-  }
-
-  public int getInteger() {
-    throw new UnsupportedOperationException();
-  }
-
-  public long getLong() {
-    throw new UnsupportedOperationException();
-  }
-
-  public boolean getBoolean() {
-    throw new UnsupportedOperationException();
-  }
-
-  public Binary getBinary() {
-    throw new UnsupportedOperationException();
-  }
-
-  public Binary getInt96() {
-    throw new UnsupportedOperationException();
-  }
-
-  public float getFloat() {
-    throw new UnsupportedOperationException();
-  }
-
-  public double getDouble() {
-    throw new UnsupportedOperationException();
-  }
-
-  public Geometry getGeometry() {
-    throw new UnsupportedOperationException();
-  }
-
-  public abstract void writeValue(RecordConsumer recordConsumer);
-}

Reply via email to