uros-db commented on code in PR #54040:
URL: https://github.com/apache/spark/pull/54040#discussion_r2806250676


##########
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedDeltaByteArrayReader.java:
##########
@@ -100,6 +102,48 @@ public void readBinary(int total, WritableColumnVector c, 
int rowId) {
     readValues(total, c, rowId);
   }
 
+  @Override
+  public void readGeometry(int total, WritableColumnVector c, int rowId) {
+    assert(c.dataType() instanceof GeometryType);
+    int srid = ((GeometryType) c.dataType()).srid();
+    readGeoData(total, c, rowId, srid, WKBToGeometryConverter.INSTANCE);
+  }
+
+  @Override
+  public void readGeography(int total, WritableColumnVector c, int rowId) {
+    assert(c.dataType() instanceof GeographyType);
+    int srid = ((GeographyType) c.dataType()).srid();
+    readGeoData(total, c, rowId, srid, WKBToGeographyConverter.INSTANCE);
+  }
+
+  private void readGeoData(int total, WritableColumnVector c, int rowId, int 
srid,
+     WKBConverterStrategy converter) {
+    for (int i = 0; i < total; i++) {
+      int prefixLength = prefixLengthVector.getInt(currentRow);
+      ByteBuffer suffix = suffixReader.getBytes(currentRow);
+      int suffixLength = suffix.limit() - suffix.position();
+      int length = prefixLength + suffixLength;
+
+      byte[] wkb = new byte[length];
+      if (prefixLength > 0) {
+        previous.get(wkb, 0, prefixLength);
+      }
+      suffix.get(wkb, prefixLength, suffixLength);
+
+      // Converts WKB into a physical representation of geometry/geography.

Review Comment:
   So here's the main idea - it doesn't (and shouldn't) matter what the format 
is. Format itself can change and we don't guarantee/rely on it directly, but we 
instead use the `WKBConverterStrategy` to interface with geo types using 
appropriate conversion logic.



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