Skip to content

Commit

Permalink
Fix infinite loop during planning caused by PickTableLayout
Browse files Browse the repository at this point in the history
Replaces #16627

Co-authored-by: Brian Li <librian415@gmail.com>
  • Loading branch information
2 people authored and rschlussel committed May 10, 2022
1 parent 521c7c3 commit bd48fc3
Show file tree
Hide file tree
Showing 14 changed files with 405 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.lang.invoke.MethodHandle;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;

Expand Down Expand Up @@ -499,6 +500,26 @@ public void loadHashTables(int positionCount, int[] offsets, boolean[] mapIsNull
}
set(hashTables);
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
HashTables other = (HashTables) obj;
return Arrays.equals(this.hashTables, other.hashTables) &&
this.expectedHashTableCount == other.expectedHashTableCount;
}

@Override
public int hashCode()
{
return Objects.hash(Arrays.hashCode(hashTables), expectedHashTableCount);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import javax.annotation.Nullable;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.function.ObjLongConsumer;

Expand Down Expand Up @@ -240,4 +242,37 @@ public Block getSingleValueBlock(int position)

return getSingleValueBlockInternal(position);
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
ArrayBlock other = (ArrayBlock) obj;
return this.arrayOffset == other.arrayOffset &&
this.positionCount == other.positionCount &&
Arrays.equals(this.valueIsNull, other.valueIsNull) &&
Objects.equals(this.values, other.values) &&
Arrays.equals(this.offsets, other.offsets) &&
this.sizeInBytes == other.sizeInBytes &&
this.logicalSizeInBytes == other.logicalSizeInBytes &&
this.retainedSizeInBytes == other.retainedSizeInBytes;
}

@Override
public int hashCode()
{
return Objects.hash(arrayOffset,
positionCount,
Arrays.hashCode(valueIsNull),
values,
Arrays.hashCode(offsets),
sizeInBytes,
logicalSizeInBytes,
retainedSizeInBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import javax.annotation.Nullable;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.function.ObjLongConsumer;
Expand Down Expand Up @@ -271,4 +273,31 @@ public Block appendNull()

return new ByteArrayBlock(arrayOffset, positionCount + 1, newValueIsNull, newValues);
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
ByteArrayBlock other = (ByteArrayBlock) obj;
return this.arrayOffset == other.arrayOffset &&
this.positionCount == other.positionCount &&
Arrays.equals(this.valueIsNull, other.valueIsNull) &&
Arrays.equals(this.values, other.values) &&
this.retainedSizeInBytes == other.retainedSizeInBytes;
}

@Override
public int hashCode()
{
return Objects.hash(arrayOffset,
positionCount,
Arrays.hashCode(valueIsNull),
Arrays.hashCode(values),
retainedSizeInBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.OptionalInt;
import java.util.function.ObjLongConsumer;

Expand Down Expand Up @@ -671,4 +672,39 @@ public Block appendNull()

return new DictionaryBlock(idsOffset, positionCount + 1, newDictionary, newIds, isCompact(), getDictionarySourceId());
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
DictionaryBlock other = (DictionaryBlock) obj;
return this.positionCount == other.positionCount &&
Objects.equals(this.dictionary, other.dictionary) &&
this.idsOffset == other.idsOffset &&
Arrays.equals(this.ids, other.ids) &&
this.retainedSizeInBytes == other.retainedSizeInBytes &&
this.sizeInBytes == other.sizeInBytes &&
this.logicalSizeInBytes == other.logicalSizeInBytes &&
this.uniqueIds == other.uniqueIds &&
Objects.equals(this.dictionarySourceId, other.dictionarySourceId);
}

@Override
public int hashCode()
{
return Objects.hash(positionCount,
dictionary,
idsOffset,
Arrays.hashCode(ids),
retainedSizeInBytes,
sizeInBytes,
logicalSizeInBytes,
uniqueIds,
dictionarySourceId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import javax.annotation.Nullable;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.function.ObjLongConsumer;
Expand Down Expand Up @@ -366,4 +368,31 @@ public Block appendNull()
long[] newValues = ensureCapacity(values, (positionOffset + positionCount + 1) * 2, SMALL, PRESERVE);
return new Int128ArrayBlock(positionOffset, positionCount + 1, newValueIsNull, newValues);
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Int128ArrayBlock other = (Int128ArrayBlock) obj;
return this.positionOffset == other.positionOffset &&
this.positionCount == other.positionCount &&
Arrays.equals(this.valueIsNull, other.valueIsNull) &&
Arrays.equals(this.values, other.values) &&
this.retainedSizeInBytes == other.retainedSizeInBytes;
}

@Override
public int hashCode()
{
return Objects.hash(positionOffset,
positionCount,
Arrays.hashCode(valueIsNull),
Arrays.hashCode(values),
retainedSizeInBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import javax.annotation.Nullable;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.function.ObjLongConsumer;
Expand Down Expand Up @@ -309,4 +311,31 @@ public Block appendNull()

return new LongArrayBlock(arrayOffset, positionCount + 1, newValueIsNull, newValues);
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
LongArrayBlock other = (LongArrayBlock) obj;
return this.arrayOffset == other.arrayOffset &&
this.positionCount == other.positionCount &&
Arrays.equals(this.valueIsNull, other.valueIsNull) &&
Arrays.equals(this.values, other.values) &&
this.retainedSizeInBytes == other.retainedSizeInBytes;
}

@Override
public int hashCode()
{
return Objects.hash(arrayOffset,
positionCount,
Arrays.hashCode(valueIsNull),
Arrays.hashCode(values),
retainedSizeInBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import javax.annotation.Nullable;

import java.lang.invoke.MethodHandle;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.function.ObjLongConsumer;

Expand Down Expand Up @@ -303,4 +305,39 @@ protected void ensureHashTableLoaded(MethodHandle keyBlockHashCode)
}
}
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
MapBlock other = (MapBlock) obj;
return this.startOffset == other.startOffset &&
this.positionCount == other.positionCount &&
Arrays.equals(this.mapIsNull, other.mapIsNull) &&
Arrays.equals(this.offsets, other.offsets) &&
Objects.equals(this.keyBlock, other.keyBlock) &&
Objects.equals(this.valueBlock, other.valueBlock) &&
Objects.equals(this.hashTables, other.hashTables) &&
this.retainedSizeInBytesExceptHashtable == other.retainedSizeInBytesExceptHashtable &&
this.sizeInBytes == other.sizeInBytes;
}

@Override
public int hashCode()
{
return Objects.hash(startOffset,
positionCount,
Arrays.hashCode(mapIsNull),
Arrays.hashCode(offsets),
keyBlock,
valueBlock,
hashTables,
retainedSizeInBytesExceptHashtable,
sizeInBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import javax.annotation.Nullable;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.function.ObjLongConsumer;

Expand Down Expand Up @@ -268,4 +270,37 @@ public Block getLoadedBlock()
fieldBlockOffsets,
loadedFieldBlocks);
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
RowBlock other = (RowBlock) obj;
return this.startOffset == other.startOffset &&
this.positionCount == other.positionCount &&
Arrays.equals(this.rowIsNull, other.rowIsNull) &&
Arrays.equals(this.fieldBlockOffsets, other.fieldBlockOffsets) &&
Arrays.equals(this.fieldBlocks, other.fieldBlocks) &&
this.sizeInBytes == other.sizeInBytes &&
this.logicalSizeInBytes == other.logicalSizeInBytes &&
this.retainedSizeInBytes == other.retainedSizeInBytes;
}

@Override
public int hashCode()
{
return Objects.hash(startOffset,
positionCount,
Arrays.hashCode(rowIsNull),
Arrays.hashCode(fieldBlockOffsets),
Arrays.hashCode(fieldBlocks),
sizeInBytes,
logicalSizeInBytes,
retainedSizeInBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import javax.annotation.Nullable;

import java.util.Objects;
import java.util.OptionalInt;
import java.util.function.ObjLongConsumer;

Expand Down Expand Up @@ -427,4 +428,24 @@ public Block appendNull()
return new DictionaryBlock(dictionary, ids);
}
}

@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
RunLengthEncodedBlock other = (RunLengthEncodedBlock) obj;
return Objects.equals(this.value, other.value) &&
this.positionCount == other.positionCount;
}

@Override
public int hashCode()
{
return Objects.hash(value, positionCount);
}
}
Loading

0 comments on commit bd48fc3

Please sign in to comment.