From 8d4bd1610450fbc9d751c220bfca845d58f65c37 Mon Sep 17 00:00:00 2001 From: adeet1 Date: Fri, 31 May 2024 19:43:55 +0000 Subject: [PATCH] invoke callback in onClose method --- .../parquet/io/SimpleFeatureWriteSupport.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/geomesa-fs/geomesa-fs-storage/geomesa-fs-storage-parquet/src/main/scala/org/locationtech/geomesa/fs/storage/parquet/io/SimpleFeatureWriteSupport.scala b/geomesa-fs/geomesa-fs-storage/geomesa-fs-storage-parquet/src/main/scala/org/locationtech/geomesa/fs/storage/parquet/io/SimpleFeatureWriteSupport.scala index 40063cb1ae0c..3faf4f83f53b 100644 --- a/geomesa-fs/geomesa-fs-storage/geomesa-fs-storage-parquet/src/main/scala/org/locationtech/geomesa/fs/storage/parquet/io/SimpleFeatureWriteSupport.scala +++ b/geomesa-fs/geomesa-fs-storage/geomesa-fs-storage-parquet/src/main/scala/org/locationtech/geomesa/fs/storage/parquet/io/SimpleFeatureWriteSupport.scala @@ -59,7 +59,11 @@ class SimpleFeatureWriteSupport(callback: (Envelope, Long) => Unit) extends Writ def getCount: Long = count - override protected def onClose(bounds: Envelope, count: Long): Unit = {} + // Invoke the callback function for adding bounds to the storage metadata partition + override protected def onClose(bounds: Envelope, count: Long): Unit = { + println("MultipleGeometriesObserver onClose") + callback(bounds, count) + } } private val observer = new MultipleGeometriesObserver @@ -84,10 +88,7 @@ class SimpleFeatureWriteSupport(callback: (Envelope, Long) => Unit) extends Writ override def finalizeWrite(): FinalizedWriteContext = { // Get the bounding boxes that span each geometry type val bboxes = observer.getBoundingBoxes - - for (bbox <- bboxes) { - callback(bbox, observer.getCount) - } + observer.close() // If the SFT has no geometries, then there's no need to create GeoParquet metadata if (bboxes.isEmpty) {