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

[SPARK-24564][TEST] Add test suite for RecordBinaryComparator #21570

Closed
wants to merge 4 commits into from

Conversation

jiangxb1987
Copy link
Contributor

What changes were proposed in this pull request?

Add a new test suite to test RecordBinaryComparator.

How was this patch tested?

New test suite.

@SparkQA
Copy link

SparkQA commented Jun 15, 2018

Test build #91872 has finished for PR 21570 at commit 79508ec.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • public class RecordBinaryComparatorSuite

private long relativeOffset(int numFields) {
// All the UnsafeRows in this suite contains less than 64 columns, so the bitSetSize shall
// always be 8.
return 8 + numFields * Long.BYTES;
Copy link
Member

@kiszk kiszk Jun 15, 2018

Choose a reason for hiding this comment

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

nit: Is the multiplication factor related to Long.BYTES? It is just 8L as computeSizeInBytes uses.


UnsafeRow row1 = new UnsafeRow(numFields);
byte[] data1 = new byte[100];
row1.pointTo(data1, computeSizeInBytes(numFields * Double.BYTES));
Copy link
Member

Choose a reason for hiding this comment

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

nit: ditto. Regardless of data type, width is always 8.

UnsafeRow row1 = new UnsafeRow(numFields);
byte[] data1 = new byte[100];
UTF8String str1 = UTF8String.fromString("Milk tea");
row1.pointTo(data1, computeSizeInBytes(numFields * Long.BYTES + str1.numBytes()));
Copy link
Member

Choose a reason for hiding this comment

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

nit: ditto. Regardless of data type, width is always 8.

@jiangxb1987
Copy link
Contributor Author

@kiszk Thanks, updated!

private long relativeOffset(int numFields) {
// All the UnsafeRows in this suite contains less than 64 columns, so the bitSetSize shall
// always be 8.
return 8 + numFields * 8;
Copy link
Member

@kiszk kiszk Jun 15, 2018

Choose a reason for hiding this comment

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

super nit: My suggestion is to use * 8L. Although we know numFields is less than 64, it would be good to use long multiplication to avoid possible integer overflow in general.

package test.org.apache.spark.sql.execution.sort;

import org.apache.spark.SparkConf;
import org.apache.spark.memory.TaskMemoryManager;
Copy link
Member

Choose a reason for hiding this comment

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

Since this is duplicated, it should be deleted.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry but which duplicated line do you mention?

Copy link
Member

Choose a reason for hiding this comment

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

I am sorry. Nvm, I thought lines 21 and 23 are duplicated.

import org.apache.spark.unsafe.memory.MemoryBlock;
import org.apache.spark.unsafe.types.UTF8String;
import org.apache.spark.util.collection.unsafe.sort.*;
import org.junit.After;
Copy link
Member

@kiszk kiszk Jun 15, 2018

Choose a reason for hiding this comment

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

nit: is it better to insert an empty line between L32 and L33?

@SparkQA
Copy link

SparkQA commented Jun 15, 2018

Test build #91890 has finished for PR 21570 at commit 2b8df98.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jun 15, 2018

Test build #91887 has finished for PR 21570 at commit 7d43900.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@kiszk
Copy link
Member

kiszk commented Jun 15, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Jun 15, 2018

Test build #91910 has finished for PR 21570 at commit 2b8df98.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@jiangxb1987
Copy link
Contributor Author

cc @JoshRosen @gatorsmile

@@ -43,6 +45,12 @@ void free(long size) {
used -= size;
taskMemoryManager.releaseExecutionMemory(size, this);
}

// Exposed for testing
Copy link
Member

Choose a reason for hiding this comment

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

super nit: we need this comment? This class itself is used for test use only?

Copy link
Member

Choose a reason for hiding this comment

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

How about using @VisibleForTesting annotation?

*/
public class RecordBinaryComparatorSuite {

private final TaskMemoryManager memoryManager = new TaskMemoryManager(
Copy link
Member

Choose a reason for hiding this comment

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

We need to use TaskMemoryManager for this test? Is not simple tests (e.g., just comparing unsafe rows) enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both way shall work. I choose to implement it in low level so the result won't be affected by the UnsafeProjection code.

@SparkQA
Copy link

SparkQA commented Jun 19, 2018

Test build #92090 has finished for PR 21570 at commit 5be5a7a.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member

ping @JoshRosen

@kiszk
Copy link
Member

kiszk commented Jun 26, 2018

LGTM

@@ -43,6 +47,12 @@ void free(long size) {
used -= size;
taskMemoryManager.releaseExecutionMemory(size, this);
}

@VisibleForTesting
Copy link
Contributor

Choose a reason for hiding this comment

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

it's already in the test package, we don't need this tag.

@cloud-fan
Copy link
Contributor

LGTM, merging to master!

@asfgit asfgit closed this in 5b05966 Jun 28, 2018
bersprockets pushed a commit to bersprockets/spark that referenced this pull request Aug 21, 2018
## What changes were proposed in this pull request?

Add a new test suite to test RecordBinaryComparator.

## How was this patch tested?

New test suite.

Author: Xingbo Jiang <xingbo.jiang@databricks.com>

Closes apache#21570 from jiangxb1987/rbc-test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants