Copilot commented on code in PR #188:
URL: https://github.com/apache/hbase-connectors/pull/188#discussion_r4773684702
##########
spark4/hbase-spark4/src/main/scala/org/apache/hadoop/hbase/spark/HBaseContext.scala:
##########
@@ -954,6 +945,26 @@ class HBaseContext(@transient val sc: SparkContext,
@transient val config: Confi
}
}
+private[spark] object HBaseContext {
+
+ /** Converts a Result into a Row for [[HBaseContext#hbaseRDDAsRows]]. */
+ def resultToRow(result: Result, columns: Array[String]): Option[Row] = {
+ // Cursor results (Scan#setNeedCursorResult) mark scan progress and carry
no cells.
+ if (result.isEmpty) return None
+ val values = new java.util.HashMap[String, String](columns.length)
+ // Cells are sorted by family, then qualifier, then newest version first,
so the first cell
+ // seen for a qualifier holds its latest version in the first family that
has it.
+ result.rawCells().foreach {
+ cell =>
+ val qualifier = Bytes.toString(CellUtil.cloneQualifier(cell))
+ if (!values.containsKey(qualifier) && columns.contains(qualifier)) {
Review Comment:
`columns.contains` linearly scans the requested-column array for every
unseen qualifier. Because the supplied Scan is forwarded without projection,
wide rows with unmapped qualifiers now take O(cells × requested columns)
membership work rather than the previous linear conversion; unmapped versions
repeat this work too. Build a hash set once before iterating cells and retain
the array only for output ordering.
--
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]