KazydubB commented on a change in pull request #1870: DRILL-7359: Add support 
for DICT type in RowSet Framework
URL: https://github.com/apache/drill/pull/1870#discussion_r354303721
 
 

 ##########
 File path: 
exec/vector/src/main/java/org/apache/drill/exec/vector/accessor/reader/UnionReaderImpl.java
 ##########
 @@ -268,4 +274,51 @@ public String getAsString() {
     }
     return requireReader(type).getAsString();
   }
+
+  private UnionReaderImpl getNullReader() {
+    AbstractObjectReader[] nullVariants = new 
AbstractObjectReader[variants.length];
+    for (int i = 0; i < variants.length; i++) {
+      nullVariants[i] = variants[i].createNullReader();
+    }
+    return new NullUnionReader(schema(), unionAccessor, nullVariants);
+  }
+
+  private static class NullUnionReader extends UnionReaderImpl {
+
+    private NullUnionReader(ColumnMetadata metadata, VectorAccessor va, 
AbstractObjectReader[] variants) {
 
 Review comment:
   Yes, there is a need to have multiple methods for each key type to avoid 
invocation of generalized `keyReader.getObject()` which contains `switch` 
checking each type (really bad in production) - will fix it.
   
   *EDIT*: actually, there is another, rather more elegant, way to hadle this 
without the need to duplicate code/add many methods:
   an instance variable `private final Supplier<Object> keyObjectExtractor` can 
be defined in `DictReaderImpl` which will be initiated during creation as 
   ```
   private Supplier<Object> getKeyObjectExtractor() {
       switch (keyColumnType()) {
         case BOOLEAN:
           return keyReader::getBoolean;
         case BYTES:
           return keyReader::getBytes;
         ...
       }
     }
   ```
   This makes possible to use `Object` in `find(Object key)` thus making code 
cleaner.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to