Search in sources :

Example 11 with DataOutputBlobWriter

use of com.ociweb.pronghorn.pipe.DataOutputBlobWriter in project PronghornPipes by oci-pronghorn.

the class TrieParserTest method testwriteCapturedShort.

@Test
public void testwriteCapturedShort() {
    TrieParserReader reader = new TrieParserReader(3);
    TrieParser map = new TrieParser(16);
    map.setUTF8Value("12%iabcd", 33);
    CharSequence test = "128abcd";
    // query holds most recent thing
    reader.query(map, test);
    Pipe<RawDataSchema> pipe = RawDataSchema.instance.newPipe(2, 64);
    pipe.initBuffers();
    int size = Pipe.addMsgIdx(pipe, RawDataSchema.MSG_CHUNKEDSTREAM_1);
    DataOutputBlobWriter x = Pipe.outputStream(pipe);
    DataOutputBlobWriter.openField(x);
    TrieParserReader.writeCapturedShort(reader, 0, x);
    x.closeLowLevelField();
    Pipe.confirmLowLevelWrite(pipe, size);
    Pipe.publishWrites(pipe);
    // /////////
    int msg = Pipe.takeMsgIdx(pipe);
    assertEquals(RawDataSchema.MSG_CHUNKEDSTREAM_1, msg);
    DataInputBlobReader y = Pipe.inputStream(pipe);
    y.openLowLevelAPIField();
    // 2nd value has length of captured field.
    byte[] vals = new byte[2];
    y.read(vals);
    assertEquals(vals[1], 8);
}
Also used : RawDataSchema(com.ociweb.pronghorn.pipe.RawDataSchema) DataInputBlobReader(com.ociweb.pronghorn.pipe.DataInputBlobReader) DataOutputBlobWriter(com.ociweb.pronghorn.pipe.DataOutputBlobWriter) Test(org.junit.Test)

Aggregations

DataOutputBlobWriter (com.ociweb.pronghorn.pipe.DataOutputBlobWriter)11 Test (org.junit.Test)9 DataInputBlobReader (com.ociweb.pronghorn.pipe.DataInputBlobReader)6 RawDataSchema (com.ociweb.pronghorn.pipe.RawDataSchema)6 ChannelReader (com.ociweb.pronghorn.pipe.ChannelReader)3 Pipe (com.ociweb.pronghorn.pipe.Pipe)2 FieldType (com.ociweb.gl.api.FieldType)1 ClientConnection (com.ociweb.pronghorn.network.ClientConnection)1 ClientHTTPRequestSchema (com.ociweb.pronghorn.network.schema.ClientHTTPRequestSchema)1 NetPayloadSchema (com.ociweb.pronghorn.network.schema.NetPayloadSchema)1 PipeConfig (com.ociweb.pronghorn.pipe.PipeConfig)1 DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1