use of org.bson.BsonDocumentReader in project drill by axbaretto.
the class TestBsonRecordReader method testTimeStampType.
@Test
public void testTimeStampType() throws IOException {
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.append("ts", new BsonTimestamp(1000, 10));
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertEquals(1000l, mapReader.reader("ts").readDateTime().getMillis());
}
use of org.bson.BsonDocumentReader in project drill by axbaretto.
the class TestBsonRecordReader method testSpecialCharStringType.
@Test
public void testSpecialCharStringType() throws IOException {
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.append("stringKey", new BsonString("§§§§§§§§§1"));
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertEquals("§§§§§§§§§1", mapReader.reader("stringKey").readText().toString());
}
use of org.bson.BsonDocumentReader in project drill by axbaretto.
the class TestBsonRecordReader method testIntType.
@Test
public void testIntType() throws IOException {
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.append("seqNo", new BsonInt64(10));
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertEquals(10l, mapReader.reader("seqNo").readLong().longValue());
}
use of org.bson.BsonDocumentReader in project drill by axbaretto.
the class TestBsonRecordReader method testRecursiveDocuments.
@Test
public void testRecursiveDocuments() throws IOException {
BsonDocument topDoc = new BsonDocument();
final int count = 3;
for (int i = 0; i < count; ++i) {
BsonDocument bsonDoc = new BsonDocument();
BsonWriter bw = new BsonDocumentWriter(bsonDoc);
bw.writeStartDocument();
bw.writeName("k1" + i);
bw.writeString("drillMongo1" + i);
bw.writeName("k2" + i);
bw.writeString("drillMongo2" + i);
bw.writeEndDocument();
bw.flush();
topDoc.append("doc" + i, bsonDoc);
}
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(topDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
for (int i = 0; i < count; ++i) {
SingleMapReaderImpl reader = (SingleMapReaderImpl) mapReader.reader("doc" + i);
assertEquals("drillMongo1" + i, reader.reader("k1" + i).readText().toString());
assertEquals("drillMongo2" + i, reader.reader("k2" + i).readText().toString());
}
}
use of org.bson.BsonDocumentReader in project drill by axbaretto.
the class TestBsonRecordReader method testSymbolType.
@Test
public void testSymbolType() throws IOException {
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.append("symbolKey", new BsonSymbol("test_symbol"));
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertEquals("test_symbol", mapReader.reader("symbolKey").readText().toString());
}
Aggregations