Search in sources :

Example 11 with RawDataSchema

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

the class JSONParseTest method simpleNullBTest.

@Test
public void simpleNullBTest() {
    try {
        Pipe<RawDataSchema> targetData = parseJSON(nullBExample, 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(null, valueB);
        long valueA = dataStream.readPackedLong();
        assertEquals(123, valueA);
    } catch (Throwable t) {
        t.printStackTrace();
        throw new AssertionError("rethrow", t);
    }
}
Also used : RawDataSchema(com.ociweb.pronghorn.pipe.RawDataSchema) ChannelReader(com.ociweb.pronghorn.pipe.ChannelReader) Test(org.junit.Test)

Example 12 with RawDataSchema

use of com.ociweb.pronghorn.pipe.RawDataSchema 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 13 with RawDataSchema

use of com.ociweb.pronghorn.pipe.RawDataSchema 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 14 with RawDataSchema

use of com.ociweb.pronghorn.pipe.RawDataSchema 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 15 with RawDataSchema

use of com.ociweb.pronghorn.pipe.RawDataSchema 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

RawDataSchema (com.ociweb.pronghorn.pipe.RawDataSchema)19 Test (org.junit.Test)17 ChannelReader (com.ociweb.pronghorn.pipe.ChannelReader)10 DataInputBlobReader (com.ociweb.pronghorn.pipe.DataInputBlobReader)6 DataOutputBlobWriter (com.ociweb.pronghorn.pipe.DataOutputBlobWriter)6 Pipe (com.ociweb.pronghorn.pipe.Pipe)2 TrieParserReader (com.ociweb.pronghorn.util.TrieParserReader)2 ValveSchema (com.ociweb.iot.valveManifold.schema.ValveSchema)1 GraphManager (com.ociweb.pronghorn.stage.scheduling.GraphManager)1 NonThreadScheduler (com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1