Search in sources :

Example 6 with MapWriter

use of org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter in project drill by apache.

the class HttpdLogRecord method setWildcard.

/**
   * This method is referenced and called via reflection. When the parser processes a field like:
   * HTTP.URI:request.firstline.uri.query.* where star is an arbitrary field that the parser found this method will be
   * invoked. <br>
   *
   * @param field name of field
   * @param value value of field
   */
@SuppressWarnings("unused")
public void setWildcard(final String field, final Double value) {
    if (value != null) {
        final MapWriter mapWriter = getWildcardWriter(field);
        LOG.trace("Parsed wildcard field: {}, as double: {}", field, value);
        final Float8Writer w = mapWriter.float8(cleanExtensions.get(field));
        w.writeFloat8(value);
    }
}
Also used : MapWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter) Float8Writer(org.apache.drill.exec.vector.complex.writer.Float8Writer)

Example 7 with MapWriter

use of org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter in project drill by apache.

the class HttpdLogRecord method setWildcard.

/**
   * This method is referenced and called via reflection. When the parser processes a field like:
   * HTTP.URI:request.firstline.uri.query.* where star is an arbitrary field that the parser found this method will be
   * invoked. <br>
   *
   * @param field name of field
   * @param value value of field
   */
@SuppressWarnings("unused")
public void setWildcard(final String field, final String value) {
    if (value != null) {
        final MapWriter mapWriter = getWildcardWriter(field);
        LOG.trace("Parsed wildcard field: {}, as string: {}", field, value);
        final VarCharWriter w = mapWriter.varChar(cleanExtensions.get(field));
        writeString(w, value);
    }
}
Also used : MapWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter) VarCharWriter(org.apache.drill.exec.vector.complex.writer.VarCharWriter)

Example 8 with MapWriter

use of org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter in project drill by apache.

the class TestPromotableWriter method list.

@Test
public void list() throws Exception {
    BufferAllocator allocator = RootAllocatorFactory.newRoot(DrillConfig.create());
    TestOutputMutator output = new TestOutputMutator(allocator);
    ComplexWriter rootWriter = new VectorContainerWriter(output, true);
    MapWriter writer = rootWriter.rootAsMap();
    rootWriter.setPosition(0);
    {
        writer.map("map").bigInt("a").writeBigInt(1);
    }
    rootWriter.setPosition(1);
    {
        writer.map("map").float4("a").writeFloat4(2.0f);
    }
    rootWriter.setPosition(2);
    {
        writer.map("map").list("a").startList();
        writer.map("map").list("a").endList();
    }
    rootWriter.setPosition(3);
    {
        writer.map("map").list("a").startList();
        writer.map("map").list("a").bigInt().writeBigInt(3);
        writer.map("map").list("a").float4().writeFloat4(4);
        writer.map("map").list("a").endList();
    }
    rootWriter.setValueCount(4);
    BatchPrinter.printBatch(output.getContainer());
}
Also used : MapWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter) ComplexWriter(org.apache.drill.exec.vector.complex.writer.BaseWriter.ComplexWriter) VectorContainerWriter(org.apache.drill.exec.vector.complex.impl.VectorContainerWriter) TestOutputMutator(org.apache.drill.exec.store.TestOutputMutator) BufferAllocator(org.apache.drill.exec.memory.BufferAllocator) Test(org.junit.Test)

Aggregations

MapWriter (org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter)8 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 DrillBuf (io.netty.buffer.DrillBuf)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Map (java.util.Map)1 BigIntHolder (org.apache.drill.exec.expr.holders.BigIntHolder)1 IntHolder (org.apache.drill.exec.expr.holders.IntHolder)1 BufferAllocator (org.apache.drill.exec.memory.BufferAllocator)1 TestOutputMutator (org.apache.drill.exec.store.TestOutputMutator)1 MapVector (org.apache.drill.exec.vector.complex.MapVector)1 JsonWriter (org.apache.drill.exec.vector.complex.fn.JsonWriter)1 ComplexWriterImpl (org.apache.drill.exec.vector.complex.impl.ComplexWriterImpl)1 VectorContainerWriter (org.apache.drill.exec.vector.complex.impl.VectorContainerWriter)1 FieldReader (org.apache.drill.exec.vector.complex.reader.FieldReader)1 ComplexWriter (org.apache.drill.exec.vector.complex.writer.BaseWriter.ComplexWriter)1 ListWriter (org.apache.drill.exec.vector.complex.writer.BaseWriter.ListWriter)1 BigIntWriter (org.apache.drill.exec.vector.complex.writer.BigIntWriter)1 Float8Writer (org.apache.drill.exec.vector.complex.writer.Float8Writer)1