use of org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl in project drill by apache.
the class TestBsonRecordReader method testBooleanType.
@Test
public void testBooleanType() throws IOException {
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.append("booleanKey", new BsonBoolean(true));
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertTrue(mapReader.reader("booleanKey").readBoolean());
}
use of org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl in project drill by apache.
the class TestBsonRecordReader method testTimeStampType.
@Test
public void testTimeStampType() throws IOException {
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.append("ts_small", new BsonTimestamp(1000, 10));
bsonDoc.append("ts_large", new BsonTimestamp(1000000000, 10));
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertEquals(1000000L, mapReader.reader("ts_small").readLocalDateTime().atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli());
assertEquals(1000000000000L, mapReader.reader("ts_large").readLocalDateTime().atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli());
}
use of org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl in project drill by axbaretto.
the class TestBsonRecordReader method testBinaryTypes.
@Test
public void testBinaryTypes() throws IOException {
// test with different binary types
BsonDocument bsonDoc = new BsonDocument();
// Binary
// String
byte[] bytes = "binaryValue".getBytes();
bsonDoc.append("binaryKey", new BsonBinary(BsonBinarySubType.BINARY, bytes));
// String
byte[] bytesString = "binaryStringValue".getBytes();
bsonDoc.append("binaryStringKey", new BsonBinary((byte) 2, bytesString));
// Double
byte[] bytesDouble = new byte[8];
java.nio.ByteBuffer.wrap(bytesDouble).putDouble(23.0123);
BsonBinary bsonDouble = new BsonBinary((byte) 1, bytesDouble);
bsonDoc.append("binaryDouble", bsonDouble);
// Boolean
byte[] booleanBytes = new byte[8];
java.nio.ByteBuffer.wrap(booleanBytes).put((byte) 1);
BsonBinary bsonBoolean = new BsonBinary((byte) 8, booleanBytes);
bsonDoc.append("bsonBoolean", bsonBoolean);
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertTrue(Arrays.equals(bytes, mapReader.reader("binaryKey").readByteArray()));
assertEquals("binaryStringValue", mapReader.reader("binaryStringKey").readText().toString());
assertEquals(23.0123, mapReader.reader("binaryDouble").readDouble().doubleValue(), 0);
FieldReader reader = mapReader.reader("bsonBoolean");
assertEquals(true, reader.readBoolean().booleanValue());
}
use of org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl in project drill by axbaretto.
the class TestBsonRecordReader method testStringType.
@Test
public void testStringType() throws IOException {
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.append("stringKey", new BsonString("test_string"));
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertEquals("test_string", mapReader.reader("stringKey").readText().toString());
}
use of org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl in project drill by axbaretto.
the class TestBsonRecordReader method testDoubleType.
@Test
public void testDoubleType() throws IOException {
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.append("doubleKey", new BsonDouble(12.35));
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertEquals(12.35d, mapReader.reader("doubleKey").readDouble().doubleValue(), 0.00001);
}
Aggregations