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

felixybw pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 86f2d2c871 Use single formatter instance across all files (#11843)
86f2d2c871 is described below

commit 86f2d2c8710765f40ddadda5009e1c43b8d2d03c
Author: Ankita Victor <[email protected]>
AuthorDate: Fri Apr 10 05:10:48 2026 +0530

    Use single formatter instance across all files (#11843)
    
    This PR moves DateFormatter and TimestampFormatter instantiation out of the 
inner file iteration loops in CHIteratorApi and VeloxIteratorApi so a single 
instance is reused across all files.
---
 .../org/apache/gluten/backendsapi/clickhouse/CHIteratorApi.scala  | 8 ++++----
 .../org/apache/gluten/backendsapi/velox/VeloxIteratorApi.scala    | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git 
a/backends-clickhouse/src/main/scala/org/apache/gluten/backendsapi/clickhouse/CHIteratorApi.scala
 
b/backends-clickhouse/src/main/scala/org/apache/gluten/backendsapi/clickhouse/CHIteratorApi.scala
index a705675e2d..f9820178c2 100644
--- 
a/backends-clickhouse/src/main/scala/org/apache/gluten/backendsapi/clickhouse/CHIteratorApi.scala
+++ 
b/backends-clickhouse/src/main/scala/org/apache/gluten/backendsapi/clickhouse/CHIteratorApi.scala
@@ -163,6 +163,8 @@ class CHIteratorApi extends IteratorApi with Logging with 
LogLevelUtil {
         val partitionColumns = new JArrayList[JMap[String, String]]
         val metadataColumns = new JArrayList[JMap[String, String]]
         val otherMetadataColumns = new JArrayList[JMap[String, Object]]
+        val dateFormatter = DateFormatter()
+        val timestampFormatter = 
TimestampFormatter.getFractionFormatter(ZoneOffset.UTC)
         f.files.foreach {
           file =>
             paths.add(new URI(file.filePath.toString()).toASCIIString)
@@ -183,13 +185,11 @@ class CHIteratorApi extends IteratorApi with Logging with 
LogLevelUtil {
                   case _: BinaryType =>
                     new String(pn.asInstanceOf[Array[Byte]], 
StandardCharsets.UTF_8)
                   case _: DateType =>
-                    DateFormatter.apply().format(pn.asInstanceOf[Integer])
+                    dateFormatter.format(pn.asInstanceOf[Integer])
                   case _: DecimalType =>
                     pn.asInstanceOf[Decimal].toJavaBigInteger.toString
                   case _: TimestampType =>
-                    TimestampFormatter
-                      .getFractionFormatter(ZoneOffset.UTC)
-                      .format(pn.asInstanceOf[java.lang.Long])
+                    timestampFormatter.format(pn.asInstanceOf[java.lang.Long])
                   case _ => pn.toString
                 }
               }
diff --git 
a/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxIteratorApi.scala
 
b/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxIteratorApi.scala
index 60018554dd..8a80023244 100644
--- 
a/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxIteratorApi.scala
+++ 
b/backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxIteratorApi.scala
@@ -147,6 +147,8 @@ class VeloxIteratorApi extends IteratorApi with Logging {
   private def getPartitionColumns(
       schema: StructType,
       partitionedFiles: Seq[PartitionedFile]): Seq[Map[String, String]] = {
+    val dateFormatter = DateFormatter()
+    val timestampFormatter = 
TimestampFormatter.getFractionFormatter(ZoneOffset.UTC)
     partitionedFiles.map {
       partitionedFile =>
         val partitionColumn = mutable.Map[String, String]()
@@ -159,13 +161,11 @@ class VeloxIteratorApi extends IteratorApi with Logging {
               case _: BinaryType =>
                 new String(pv.asInstanceOf[Array[Byte]], 
StandardCharsets.UTF_8)
               case _: DateType =>
-                DateFormatter.apply().format(pv.asInstanceOf[Integer])
+                dateFormatter.format(pv.asInstanceOf[Integer])
               case _: DecimalType =>
                 
pv.asInstanceOf[Decimal].toJavaBigDecimal.unscaledValue().toString
               case _: TimestampType =>
-                TimestampFormatter
-                  .getFractionFormatter(ZoneOffset.UTC)
-                  .format(pv.asInstanceOf[java.lang.Long])
+                timestampFormatter.format(pv.asInstanceOf[java.lang.Long])
               case _ => pv.toString
             }
           }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to