Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Deallocate row addresses and size arrays after exporting #246

Merged
merged 3 commits into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Comment on lines +35 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, these are writing operations, I don't think it's suitable to put them in the getters? Besides, the getNumRows may still access rowAddresses.

How about adding a new method?

def destructiveRowAddressAndSizes: (Array[Long], Array[Int])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They won't be accessed again after getRowAddresses and getRowSizes get called. Once they are called, they are exported to native side for spilling. After that, RowPartition will be reset.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e.,

long addrs[] = getRowAddresses();
long sizes[] = getRowSizes;
nativeSpilling(adds, sizes);
rowPartition.reset();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They won't be accessed again after getRowAddresses and getRowSizes get called

I see. Maybe I'm being nitpicking. I think caller would be surprise to see the state change of RowPartition after calling a getter method. A more appropriate method name or some comments would help.


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