paul-rogers commented on issue #1870: DRILL-7359: Add support for DICT type in 
RowSet Framework
URL: https://github.com/apache/drill/pull/1870#issuecomment-541442192
 
 
   On, read, we can access the `DICT` as a dictionary and as an array. This 
means we need to be a bit clever about designing the `DictReader()` interface.
   
   We can get our `DictReader` similar to the write case:
   
   ```
      DictReader dictReader = rowReader.dict("myDict");
   ```
   
   Now, we have two ways to proceed. Either we want key/value lookups, or array 
access.
   
   For array access, we want an iterator, much like the `ArrayReader`, but that 
gives us access to both the key and value. Something like:
   
   ```
   interface DictReader ...
      ScalarReader key();
      ObjectReader value();
      boolean next();
   ```
   
   For key/value, we have a challenge. We need a way to specify the key that is 
type-specific. Then, we need to access the key in a type-specific way. This is 
the first time we've had such an issue.
   
   Maybe we can build this on the array iterator. In addition to the `next()` 
method, we can provide a `findFoo()` method, with one for each supported key 
type.
   
   ```
      int findString(String key);
      int findInt(int key);
      ...
   ```
   
   The semantics might be that the array index is set to the (first) index of 
the requested value, and that index is returned.
   
   If not found, the return value is -1 and the array index is one past the end 
of the array.
   
   ```
      DictReader dictReader = ...
      if (dictReader.findString("barney")) {
        value = dictReader.value().scalar().getDouble();
      }
   ```
   
   There are probably other variations. Think how you expect to use the reader 
(for testing, yes, but what other operations)?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to