コード例 #1
0
 public void write(ComplexWriter writer, BsonReader reader) throws IOException {
   reader.readStartDocument();
   BsonType readBsonType = reader.getCurrentBsonType();
   switch (readBsonType) {
     case DOCUMENT:
       writeToListOrMap(reader, new MapOrListWriterImpl(writer.rootAsMap()), false, null);
       break;
     default:
       throw new DrillRuntimeException(
           "Root object must be DOCUMENT type. Found: " + readBsonType);
   }
 }
コード例 #2
0
 public void ensureAtLeastOneField(ComplexWriter writer) {
   if (!atLeastOneWrite) {
     // if we had no columns, create one empty one so we can return some data
     // for count purposes.
     SchemaPath sp = columns.get(0);
     PathSegment root = sp.getRootSegment();
     BaseWriter.MapWriter fieldWriter = writer.rootAsMap();
     while (root.getChild() != null && !root.getChild().isArray()) {
       fieldWriter = fieldWriter.map(root.getNameSegment().getPath());
       root = root.getChild();
     }
     fieldWriter.integer(root.getNameSegment().getPath());
   }
 }