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 issue with random Byte column generation in unit test #3577

Merged
merged 1 commit into from
Mar 21, 2023
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 @@ -40,8 +40,8 @@ private static void testNaturalJoinRandomStatic(int seed, int leftSize, int righ
boolean grouped, boolean flattenLeft, @Nullable JoinControl control) {
final Random random = new Random(seed);

final TestDataGenerator leftGenerator;
final TestDataGenerator rightGenerator;
final TestDataGenerator<?, ?> leftGenerator;
final TestDataGenerator<?, ?> rightGenerator;

if (dataType == int.class) {
leftGenerator = new IntGenerator(1, 10 * rightSize);
Expand All @@ -50,11 +50,11 @@ private static void testNaturalJoinRandomStatic(int seed, int leftSize, int righ
leftGenerator = new ShortGenerator((short) 1, (short) (2 * rightSize));
rightGenerator = new UniqueShortGenerator((short) 1, (short) (2 * rightSize));
} else if (dataType == byte.class) {
leftGenerator = new ByteGenerator((byte) 1, (byte) rightSize);
rightGenerator = new UniqueByteGenerator((byte) 1, (byte) rightSize);
leftGenerator = new ByteGenerator((byte) 1, (byte) Math.min(2 * rightSize, Byte.MAX_VALUE));
rightGenerator = new UniqueByteGenerator((byte) 1, (byte) Math.min(2 * rightSize, Byte.MAX_VALUE));
} else if (dataType == char.class) {
leftGenerator = new CharGenerator((char) 1, (char) rightSize);
rightGenerator = new UniqueCharGenerator((char) 1, (char) rightSize);
leftGenerator = new CharGenerator((char) 1, (char) (2 * rightSize));
rightGenerator = new UniqueCharGenerator((char) 1, (char) (2 * rightSize));
} else if (dataType == String.class) {
final UniqueStringGenerator uniqueStringGenerator = new UniqueStringGenerator();

Expand Down Expand Up @@ -101,9 +101,7 @@ private static void testNaturalJoinRandomStatic(int seed, int leftSize, int righ
if (dataType == int.class) {
final TIntIntMap rightMap = new TIntIntHashMap(rightTable.intSize(), 0.5f, -1, NULL_INT);

// noinspection unchecked
final ColumnSource<Integer> rightKey = rightTable.getColumnSource("JoinKey");
// noinspection unchecked
final ColumnSource<Integer> rightSentinel = rightTable.getColumnSource("RightSentinel");
for (final RowSet.Iterator it = rightTable.getRowSet().iterator(); it.hasNext();) {
final long next = it.nextLong();
Expand All @@ -114,9 +112,7 @@ private static void testNaturalJoinRandomStatic(int seed, int leftSize, int righ
} else if (dataType == short.class) {
final TShortIntMap rightMap = new TShortIntHashMap(rightTable.intSize(), 0.5f, (short) -1, NULL_INT);

// noinspection unchecked
final ColumnSource<Short> rightKey = rightTable.getColumnSource("JoinKey");
// noinspection unchecked
final ColumnSource<Integer> rightSentinel = rightTable.getColumnSource("RightSentinel");
for (final RowSet.Iterator it = rightTable.getRowSet().iterator(); it.hasNext();) {
final long next = it.nextLong();
Expand All @@ -127,9 +123,7 @@ private static void testNaturalJoinRandomStatic(int seed, int leftSize, int righ
} else if (dataType == byte.class) {
final TByteIntMap rightMap = new TByteIntHashMap(rightTable.intSize(), 0.5f, (byte) -1, NULL_INT);

// noinspection unchecked
final ColumnSource<Byte> rightKey = rightTable.getColumnSource("JoinKey");
// noinspection unchecked
final ColumnSource<Integer> rightSentinel = rightTable.getColumnSource("RightSentinel");
for (final RowSet.Iterator it = rightTable.getRowSet().iterator(); it.hasNext();) {
final long next = it.nextLong();
Expand All @@ -140,9 +134,7 @@ private static void testNaturalJoinRandomStatic(int seed, int leftSize, int righ
} else if (dataType == char.class) {
final TCharIntMap rightMap = new TCharIntHashMap(rightTable.intSize(), 0.5f, (char) -1, NULL_INT);

// noinspection unchecked
final ColumnSource<Character> rightKey = rightTable.getColumnSource("JoinKey");
// noinspection unchecked
final ColumnSource<Integer> rightSentinel = rightTable.getColumnSource("RightSentinel");
for (final RowSet.Iterator it = rightTable.getRowSet().iterator(); it.hasNext();) {
final long next = it.nextLong();
Expand All @@ -153,9 +145,7 @@ private static void testNaturalJoinRandomStatic(int seed, int leftSize, int righ
} else if (dataType == String.class) {
final Map<String, Integer> rightMap = new HashMap<>();

// noinspection unchecked
final ColumnSource<String> rightKey = rightTable.getColumnSource("JoinKey");
// noinspection unchecked
final ColumnSource<Integer> rightSentinel = rightTable.getColumnSource("RightSentinel");
for (final RowSet.Iterator it = rightTable.getRowSet().iterator(); it.hasNext();) {
final long next = it.nextLong();
Expand All @@ -167,9 +157,7 @@ private static void testNaturalJoinRandomStatic(int seed, int leftSize, int righ
if (dataType == ArrayTuple.class) {
final Map<ArrayTuple, Integer> rightMap = new HashMap<>();

// noinspection unchecked
final ColumnSource<ArrayTuple> rightKey = rightTable.getColumnSource("JoinKey");
// noinspection unchecked
final ColumnSource<Integer> rightSentinel = rightTable.getColumnSource("RightSentinel");
for (final RowSet.Iterator it = rightTable.getRowSet().iterator(); it.hasNext();) {
final long next = it.nextLong();
Expand Down Expand Up @@ -228,7 +216,7 @@ public void testNaturalJoinRandomStatic() {
for (int leftSize = 10; leftSize <= 100_000; leftSize *= 10) {
for (int rightSize = 10; rightSize <= 100_000; rightSize *= 10) {
for (int seed = 0; seed < 2; ++seed) {
for (Class dataType : Arrays.asList(String.class, int.class, ArrayTuple.class)) {
for (Class<?> dataType : Arrays.asList(String.class, int.class, ArrayTuple.class)) {
for (boolean grouped : Arrays.asList(Boolean.TRUE, Boolean.FALSE)) {
System.out.println("Seed = " + seed + ", leftSize=" + leftSize + ", rightSize=" + rightSize
+ ", type=" + dataType + ", grouped=" + grouped);
Expand All @@ -244,7 +232,7 @@ public void testNaturalJoinRandomSmallTypes() {
for (int leftSize = 10; leftSize <= 100_000; leftSize *= 10) {
final int rightSize = 100;
for (int seed = 0; seed < 2; ++seed) {
for (Class dataType : Arrays.asList(byte.class, char.class, short.class)) {
for (Class<?> dataType : Arrays.asList(byte.class, char.class, short.class)) {
for (boolean grouped : Arrays.asList(Boolean.TRUE, Boolean.FALSE)) {
System.out.println("Seed = " + seed + ", leftSize=" + leftSize + ", rightSize=" + rightSize
+ ", type=" + dataType + ", grouped=" + grouped);
Expand All @@ -260,7 +248,7 @@ public void testNaturalJoinRandomStaticRedirectionBuild() {
for (int leftSize = 10_000; leftSize <= 10_000; leftSize *= 10) {
for (int rightSize = 10_000; rightSize <= 10_000; rightSize *= 10) {
for (int seed = 0; seed < 2; ++seed) {
for (Class dataType : Collections.singletonList(int.class)) {
for (Class<?> dataType : Collections.singletonList(int.class)) {
for (boolean grouped : Arrays.asList(Boolean.TRUE, Boolean.FALSE)) {
for (JoinControl.RedirectionType redirectionType : JoinControl.RedirectionType.values()) {
System.out.println("Seed = " + seed + ", leftSize=" + leftSize + ", rightSize="
Expand Down