Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10820#discussion_r50892329
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/vectorized/ColumnarBatchBenchmark.scala
 ---
    @@ -314,8 +338,60 @@ object ColumnarBatchBenchmark {
         benchmark.run()
       }
     
    +  def stringAccess(iters: Long): Unit = {
    +    val chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    +    val random = new Random(0)
    +
    +    def randomString(min: Int, max: Int): String = {
    +      val len = random.nextInt(max - min) + min
    +      val sb = new StringBuilder(len)
    +      var i = 0
    +      while (i < len) {
    +        sb.append(chars.charAt(random.nextInt(chars.length())));
    +        i += 1
    +      }
    +      return sb.toString
    +    }
    +
    +    val minString = 3
    +    val maxString = 32
    +    val count = 4 * 1000
    +
    +    val data = Seq.fill(count)(randomString(minString, 
maxString)).map(_.getBytes).toArray
    +
    +    def column(memoryMode: MemoryMode) = { i: Int =>
    +      val column = ColumnVector.allocate(count, BinaryType, memoryMode)
    +      var sum = 0L
    +      for (n <- 0L until iters) {
    +        var i = 0
    +        while (i < count) {
    +          column.putByteArray(i, data(i))
    +          i += 1
    +        }
    +        i = 0
    +        while (i < count) {
    +          sum += column.getByteArray(i).length
    +          i += 1
    +        }
    +        column.reset()
    +      }
    +    }
    +
    +    /*
    +    String Read/Write:                       Avg Time(ms)    Avg Rate(M/s) 
 Relative Rate
    +    
-------------------------------------------------------------------------------------
    +    On Heap                                         457.0            35.85 
        1.00 X
    +    Off Heap                                       1206.0            13.59 
        0.38 X
    --- End diff --
    
    utf8string supports reading offheap too so you can probably improve this 
substantially.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to