本文整理汇总了Java中com.ociweb.pronghorn.pipe.PipeReader.isNewMessage方法的典型用法代码示例。如果您正苦于以下问题:Java PipeReader.isNewMessage方法的具体用法?Java PipeReader.isNewMessage怎么用?Java PipeReader.isNewMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ociweb.pronghorn.pipe.PipeReader
的用法示例。
在下文中一共展示了PipeReader.isNewMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dataToRead
import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
private boolean dataToRead(long[] counts) {
int msgIdx = 0;
boolean data = false;
while (PipeReader.tryReadFragment(input)) {
if (PipeReader.isNewMessage(input)) {
msgIdx = PipeReader.getMsgIdx(input);
if (msgIdx<0) {
PipeReader.releaseReadLock(input);
requestShutdown();
break;
} else {
counts[msgIdx]++;
data = true;
}
}
totalBytes += (PipeReader.sizeOfFragment(input)*4) + PipeReader.bytesConsumedByFragment(input);
//logger.info("reading new input total bytes :"+totalBytes);
PipeReader.releaseReadLock(input);
}
return data;
}
示例2: simpleBytesWriteRead
import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Test
public void simpleBytesWriteRead() {
byte primaryRingSizeInBits = 7; //this ring is 2^7 eg 128
byte byteRingSizeInBits = 16;
Pipe ring = new Pipe(new PipeConfig(RawDataSchema.instance, 1<<primaryRingSizeInBits, 1<<byteRingSizeInBits));
ring.initBuffers();
int messageSize = FROM.fragDataSize[FRAG_LOC];
int varDataMax = (ring.blobMask/(ring.slabMask>>1))/messageSize;
int testSize = (1<<primaryRingSizeInBits)/messageSize;
populateRingBufferWithBytes(ring, varDataMax, testSize);
//now read the data back
int BYTE_LOC = FieldReferenceOffsetManager.lookupFieldLocator("ByteArray", FRAG_LOC, FROM);
byte[] target = new byte[varDataMax];
int k = testSize;
while (PipeReader.tryReadFragment(ring)) {
if (PipeReader.isNewMessage(ring)) {
assertEquals(0, PipeReader.getMsgIdx(ring));
int expectedLength = (varDataMax*(--k))/testSize;
int actualLength = PipeReader.readBytes(ring, BYTE_LOC, target, 0); //read bytes as normal code would do
assertEquals(expectedLength,actualLength);
}
}
}