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());
}
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());
}
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));
}
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);
}
Aggregations