LakshSingla commented on code in PR #16068:
URL: https://github.com/apache/druid/pull/16068#discussion_r1534737144
##########
processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/RowBasedGrouperHelper.java:
##########
@@ -1531,32 +1548,136 @@ private RowBasedKeySerdeHelper makeNumericSerdeHelper(
}
}
- private class ArrayNumericRowBasedKeySerdeHelper implements
RowBasedKeySerdeHelper
+ private abstract class
DictionaryBuildingSingleValuedRowBasedKeySerdeHelper implements
RowBasedKeySerdeHelper
+ {
+ private final int keyBufferPosition;
+
+ public DictionaryBuildingSingleValuedRowBasedKeySerdeHelper(final int
keyBufferPosition)
+ {
+ this.keyBufferPosition = keyBufferPosition;
+ }
+
+ @Override
+ public int getKeyBufferValueSize()
+ {
+ return Integer.BYTES;
+ }
+
+ @Override
+ public boolean putToKeyBuffer(RowBasedKey key, int idx)
+ {
+ final Object obj = key.getKey()[idx];
+ int id = getReverseDictionary().getInt(obj);
+ if (id == DimensionDictionary.ABSENT_VALUE_ID) {
+ id = getDictionary().size();
+ getReverseDictionary().put(obj, id);
+ getDictionary().add(obj);
+ }
+ keyBuffer.putInt(id);
+ return true;
+ }
+
+ @Override
+ public void getFromByteBuffer(ByteBuffer buffer, int initialOffset, int
dimValIdx, Object[] dimValues)
+ {
+ dimValues[dimValIdx] = getDictionary().get(buffer.getInt(initialOffset
+ keyBufferPosition));
+ }
+
+ /**
+ * Raw type used because arrays and object dictionaries differ
+ */
+ @SuppressWarnings("rawtypes")
+ public abstract List getDictionary();
+
+ /**
+ * Raw types used because arrays and object dictionaries differ
+ */
+ @SuppressWarnings("rawtypes")
+ public abstract Object2IntMap getReverseDictionary();
+ }
+
+ private class ComplexRowBasedKeySerdeHelper extends
DictionaryBuildingSingleValuedRowBasedKeySerdeHelper
{
final int keyBufferPosition;
final BufferComparator bufferComparator;
- final TypeSignature<ValueType> elementType;
+ final ColumnType complexType;
+ final String complexTypeName;
+
+ final List<Object> complexTypeDictionary;
+ final Object2IntMap<Object> complexTypeReverseDictionary;
+
+ public ComplexRowBasedKeySerdeHelper(
+ int keyBufferPosition,
+ ColumnType complexType
+ )
+ {
+ super(keyBufferPosition);
+ this.keyBufferPosition = keyBufferPosition;
+ this.complexType = complexType;
+ this.complexTypeName =
Preconditions.checkNotNull(complexType.getComplexTypeName(), "complex type name
expected");
Review Comment:
I kept it separate in case we wanna revisit using the hashmaps instead of
sortedMaps for them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]