Search in sources :

Example 11 with ChannelReader

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

the class JSONParseTest method simpleArrayMissingParseTest.

@Test
public void simpleArrayMissingParseTest() {
    Pipe<RawDataSchema> targetData = parseJSON(simpleArrayMissingExample, simpleArrayExtractor);
    // confirm data on the pipe is good...
    Pipe.takeMsgIdx(targetData);
    ChannelReader dataStream = (ChannelReader) Pipe.openInputStream(targetData);
    long header = dataStream.readPackedLong();
    assertEquals(0, header);
    assertEquals(5, dataStream.readPackedInt());
    assertEquals("one", dataStream.readUTFOfLength(dataStream.readPackedInt()));
    assertEquals("two", dataStream.readUTFOfLength(dataStream.readPackedInt()));
    assertEquals(null, dataStream.readUTFOfLength(dataStream.readPackedInt()));
    assertEquals("four", dataStream.readUTFOfLength(dataStream.readPackedInt()));
    assertEquals("five", dataStream.readUTFOfLength(dataStream.readPackedInt()));
    assertEquals(5, dataStream.readPackedInt());
    assertEquals(1, dataStream.readPackedLong());
    assertEquals(0, dataStream.readPackedLong());
    assertTrue(dataStream.wasPackedNull());
    assertEquals(3, dataStream.readPackedLong());
    assertEquals(4, dataStream.readPackedLong());
    assertEquals(5, dataStream.readPackedLong());
    assertEquals(0, dataStream.available());
}
Also used : RawDataSchema(com.ociweb.pronghorn.pipe.RawDataSchema) ChannelReader(com.ociweb.pronghorn.pipe.ChannelReader) Test(org.junit.Test)

Example 12 with ChannelReader

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

the class JSONParseTest method simpleNullATest.

@Test
public void simpleNullATest() {
    Pipe<RawDataSchema> targetData = parseJSON(nullAExample, simpleExtractor);
    // confirm data on the pipe is good...
    Pipe.takeMsgIdx(targetData);
    ChannelReader dataStream = (ChannelReader) Pipe.openInputStream(targetData);
    long header = dataStream.readPackedLong();
    assertEquals(0, header);
    String valueB = dataStream.readUTFOfLength(dataStream.readPackedInt());
    assertEquals("hello", valueB);
    long valueA = dataStream.readPackedLong();
    assertEquals(0, valueA);
    assertTrue(dataStream.wasPackedNull());
}
Also used : RawDataSchema(com.ociweb.pronghorn.pipe.RawDataSchema) ChannelReader(com.ociweb.pronghorn.pipe.ChannelReader) Test(org.junit.Test)

Example 13 with ChannelReader

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

the class JSONParseTest method simpleMultipleParseTest.

@Test
public void simpleMultipleParseTest() {
    Pipe<RawDataSchema> targetData = parseJSON(simpleMultipleRootExample, simpleArrayExtractor);
    while (Pipe.contentRemaining(targetData) > 0) {
        // confirm data on the pipe is good...
        int msgIdx = Pipe.takeMsgIdx(targetData);
        ChannelReader dataStream = (ChannelReader) Pipe.openInputStream(targetData);
        long header = dataStream.readPackedLong();
        assertEquals(0, header);
        assertEquals(5, dataStream.readPackedInt());
        assertEquals("one", dataStream.readUTFOfLength(dataStream.readPackedInt()));
        assertEquals("two", dataStream.readUTFOfLength(dataStream.readPackedInt()));
        assertEquals(null, dataStream.readUTFOfLength(dataStream.readPackedInt()));
        assertEquals("four", dataStream.readUTFOfLength(dataStream.readPackedInt()));
        assertEquals("five", dataStream.readUTFOfLength(dataStream.readPackedInt()));
        assertEquals(5, dataStream.readPackedInt());
        assertEquals(1, dataStream.readPackedLong());
        assertEquals(0, dataStream.readPackedLong());
        assertTrue(dataStream.wasPackedNull());
        assertEquals(3, dataStream.readPackedLong());
        assertEquals(4, dataStream.readPackedLong());
        assertEquals(5, dataStream.readPackedLong());
        assertEquals(0, dataStream.available());
        Pipe.confirmLowLevelRead(targetData, Pipe.sizeOf(targetData, msgIdx));
        Pipe.releaseReadLock(targetData);
    }
    assertEquals(0, Pipe.contentRemaining(targetData));
}
Also used : RawDataSchema(com.ociweb.pronghorn.pipe.RawDataSchema) ChannelReader(com.ociweb.pronghorn.pipe.ChannelReader) Test(org.junit.Test)

Example 14 with ChannelReader

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

the class JSONParseTest method simpleMissingBTest.

@Test
public void simpleMissingBTest() {
    Pipe<RawDataSchema> targetData = parseJSON(missingBExample, simpleExtractor);
    // confirm data on the pipe is good...
    Pipe.takeMsgIdx(targetData);
    ChannelReader dataStream = (ChannelReader) Pipe.openInputStream(targetData);
    long header = dataStream.readPackedLong();
    assertEquals(1, header);
    // donot read number it is supposed to be missing.
    long valueA = dataStream.readPackedLong();
    assertEquals(123, valueA);
}
Also used : RawDataSchema(com.ociweb.pronghorn.pipe.RawDataSchema) ChannelReader(com.ociweb.pronghorn.pipe.ChannelReader) Test(org.junit.Test)

Aggregations

ChannelReader (com.ociweb.pronghorn.pipe.ChannelReader)14 Test (org.junit.Test)13 RawDataSchema (com.ociweb.pronghorn.pipe.RawDataSchema)10 DataOutputBlobWriter (com.ociweb.pronghorn.pipe.DataOutputBlobWriter)3 FieldType (com.ociweb.gl.api.FieldType)1 ChannelWriter (com.ociweb.pronghorn.pipe.ChannelWriter)1 DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1 Date (java.util.Date)1