Skip to content

Commit

Permalink
fix: Deallocate row addresses and size arrays after exporting (apache…
Browse files Browse the repository at this point in the history
…#246)

When we export row addresses and sizes to native, they are copied to separate arrays. We should deallocate array buffers after exporting them to reduce memory allocation.
  • Loading branch information
viirya authored and Steve Vaughan Jr committed Apr 9, 2024
1 parent a92b53b commit 2b71b36
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@ class RowPartition(initialSize: Int) {

def getNumRows: Int = rowAddresses.size

def getRowAddresses: Array[Long] = rowAddresses.toArray
def getRowSizes: Array[Int] = rowSizes.toArray
def getRowAddresses: Array[Long] = {
val array = rowAddresses.toArray
rowAddresses = null
array
}

def getRowSizes: Array[Int] = {
val array = rowSizes.toArray
rowSizes = null
array
}

def reset(): Unit = {
rowAddresses = new ArrayBuffer[Long](initialSize)
Expand Down

0 comments on commit 2b71b36

Please sign in to comment.