short numTuples = 0;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream valueStream = new DataOutputStream(stream);
while(iterator.hasNext()) {
BytesWritable writable = iterator.next();
byte[] valueBytes = writable.get();
int offsetTillNow = 0;
// Read node Id
if(this.nodeId == -1)
this.nodeId = ByteUtils.readInt(valueBytes, offsetTillNow);
offsetTillNow += ByteUtils.SIZE_OF_INT;
// Read partition id
if(this.partitionId == -1)
this.partitionId = ByteUtils.readInt(valueBytes, offsetTillNow);
offsetTillNow += ByteUtils.SIZE_OF_INT;
// Read chunk id
if(this.chunkId == -1)
this.chunkId = ReadOnlyUtils.chunk(key.get(), getNumChunks());
// Read replica type
if(getSaveKeys()) {
if(this.replicaType == -1)
this.replicaType = (int) ByteUtils.readBytes(valueBytes,
offsetTillNow,
ByteUtils.SIZE_OF_BYTE);
offsetTillNow += ByteUtils.SIZE_OF_BYTE;
}
int valueLength = writable.getSize() - offsetTillNow;
if(getSaveKeys()) {
// Write ( key_length, value_length, key,
// value )
valueStream.write(valueBytes, offsetTillNow, valueLength);
} else {