Package org.apache.druid.frame.key
Class FrameComparisonWidgetImpl
- java.lang.Object
-
- org.apache.druid.frame.key.FrameComparisonWidgetImpl
-
- All Implemented Interfaces:
FrameComparisonWidget
@NotThreadSafe public class FrameComparisonWidgetImpl extends Object implements FrameComparisonWidget
Implementation ofFrameComparisonWidgetfor pairs ofFrameType.ROW_BASEDframes. Comparison logic in this class is very similar toRowKeyComparator, but is different because it works on Frames instead of byte[].
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(int row, FrameComparisonWidget otherWidget, int otherRow)Compare a specific row of this frame to a specific row of another frame.intcompare(int row, RowKey key)Compare a specific row of this frame to the provided key.static FrameComparisonWidgetImplcreate(Frame frame, RowSignature signature, List<KeyColumn> keyColumns, List<FieldReader> keyColumnReaders)Create aFrameComparisonWidgetfor the given frame.booleanhasNonNullKeyParts(int row, int[] keyParts)Whether particular key parts in a particular row are non-null.RowKeyreadKey(int row)CreatesRowKeyfrom a row in the frame.
-
-
-
Method Detail
-
create
public static FrameComparisonWidgetImpl create(Frame frame, RowSignature signature, List<KeyColumn> keyColumns, List<FieldReader> keyColumnReaders)
Create aFrameComparisonWidgetfor the given frame. Only possible for frames of typeFrameType.ROW_BASED. The provided keyColumns must be a prefix ofFrameReader.signature().- Parameters:
frame- frame, must beFrameType.ROW_BASEDsignature- signature for the framekeyColumns- columns to sort bykeyColumnReaders- readers for key columns
-
readKey
public RowKey readKey(int row)
- Specified by:
readKeyin interfaceFrameComparisonWidget
-
hasNonNullKeyParts
public boolean hasNonNullKeyParts(int row, int[] keyParts)Description copied from interface:FrameComparisonWidgetWhether particular key parts in a particular row are non-null. WhenNullHandling.replaceWithDefault(), default values (like empty strings and numeric zeroes) are considered null for purposes of this method. This behavior is inherited fromFieldReader.isNull(Memory, long)and enables join code to behave similarly in MSQ and native queries.- Specified by:
hasNonNullKeyPartsin interfaceFrameComparisonWidget- Parameters:
row- row numberkeyParts- parts to check
-
compare
public int compare(int row, RowKey key)Description copied from interface:FrameComparisonWidgetCompare a specific row of this frame to the provided key. The key must have been created with sortColumns that match the ones used to create this widget, or else results are undefined. Comparison considers null to be equal to null. Callers that need to determine if key parts are null (perhaps because they *don't* want to consider null to be equal to null) should useFrameComparisonWidget.hasNonNullKeyParts(int, int[])to check the relevant parts.- Specified by:
comparein interfaceFrameComparisonWidget
-
compare
public int compare(int row, FrameComparisonWidget otherWidget, int otherRow)Description copied from interface:FrameComparisonWidgetCompare a specific row of this frame to a specific row of another frame. The other frame must have the same sort key, or else results are undefined. The other frame may be the same object as this frame; for example, this is used byFrameSortto sort frames in-place. Comparison considers null to be equal to null. Callers that need to determine if key parts are null (perhaps because they *don't* want to consider null to be equal to null) should useFrameComparisonWidget.hasNonNullKeyParts(int, int[])to check the relevant parts.- Specified by:
comparein interfaceFrameComparisonWidget
-
-