Search in sources :

Example 11 with SingleMapReaderImpl

use of org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl in project drill by apache.

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());
}
Also used : BsonDocument(org.bson.BsonDocument) SingleMapReaderImpl(org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl) BsonString(org.bson.BsonString) BsonDocumentReader(org.bson.BsonDocumentReader) Test(org.junit.Test)

Example 12 with SingleMapReaderImpl

use of org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl in project drill by apache.

the class TestBsonRecordReader method testDateTimeType.

@Test
public void testDateTimeType() throws IOException {
    BsonDocument bsonDoc = new BsonDocument();
    bsonDoc.append("dateTimeKey", new BsonDateTime(5262729712L));
    writer.reset();
    bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
    SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
    assertEquals(5262729712L, mapReader.reader("dateTimeKey").readDateTime().getMillis());
}
Also used : BsonDocument(org.bson.BsonDocument) SingleMapReaderImpl(org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl) BsonDateTime(org.bson.BsonDateTime) BsonDocumentReader(org.bson.BsonDocumentReader) Test(org.junit.Test)

Example 13 with SingleMapReaderImpl

use of org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl in project drill by apache.

the class TestBsonRecordReader method testArrayType.

@Test
public void testArrayType() throws IOException {
    BsonDocument bsonDoc = new BsonDocument();
    BsonWriter bw = new BsonDocumentWriter(bsonDoc);
    bw.writeStartDocument();
    bw.writeName("arrayKey");
    bw.writeStartArray();
    bw.writeInt32(1);
    bw.writeInt32(2);
    bw.writeInt32(3);
    bw.writeEndArray();
    bw.writeEndDocument();
    bw.flush();
    bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
    SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
    FieldReader reader = mapReader.reader("arrayKey");
    assertEquals(3, reader.size());
}
Also used : BsonDocument(org.bson.BsonDocument) BsonDocumentWriter(org.bson.BsonDocumentWriter) SingleMapReaderImpl(org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl) BsonWriter(org.bson.BsonWriter) BsonDocumentReader(org.bson.BsonDocumentReader) FieldReader(org.apache.drill.exec.vector.complex.reader.FieldReader) Test(org.junit.Test)

Example 14 with SingleMapReaderImpl

use of org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl in project drill by apache.

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());
}
Also used : BsonDocument(org.bson.BsonDocument) SingleMapReaderImpl(org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl) BsonString(org.bson.BsonString) BsonDocumentReader(org.bson.BsonDocumentReader) Test(org.junit.Test)

Aggregations

SingleMapReaderImpl (org.apache.drill.exec.vector.complex.impl.SingleMapReaderImpl)14 BsonDocument (org.bson.BsonDocument)14 BsonDocumentReader (org.bson.BsonDocumentReader)14 Test (org.junit.Test)14 FieldReader (org.apache.drill.exec.vector.complex.reader.FieldReader)3 BsonDocumentWriter (org.bson.BsonDocumentWriter)3 BsonWriter (org.bson.BsonWriter)3 BsonString (org.bson.BsonString)2 BsonBinary (org.bson.BsonBinary)1 BsonBoolean (org.bson.BsonBoolean)1 BsonDateTime (org.bson.BsonDateTime)1 BsonDouble (org.bson.BsonDouble)1 BsonInt64 (org.bson.BsonInt64)1 BsonNull (org.bson.BsonNull)1 BsonObjectId (org.bson.BsonObjectId)1 BsonSymbol (org.bson.BsonSymbol)1 BsonTimestamp (org.bson.BsonTimestamp)1 ObjectId (org.bson.types.ObjectId)1