use of com.sap.hadoop.ds.streams.Streams.DataOStream in project SQLWindowing by hbutani.
the class ByteBasedList method write.
private void write(Writable w) throws BaseException, IOException {
DataOStream dos = Streams.dos.get();
ByteArrayOS bos = dos.getUnderlyingStream();
bos.reset();
w.write(dos);
ensureCapacity(bos.len());
int i = currentSize * 2;
System.arraycopy(bos.bytearray(), 0, bytes, bytesUsed, bos.len());
offsetsArray[i] = bytesUsed;
offsetsArray[i + 1] = bos.len();
currentSize += 1;
bytesUsed += bos.len();
lastModified = System.nanoTime();
}
use of com.sap.hadoop.ds.streams.Streams.DataOStream in project SQLWindowing by hbutani.
the class ByteBasedSortedMap method writeKey.
private int writeKey(Writable w) throws BaseException, IOException {
DataOStream dos = Streams.dos.get();
ByteArrayOS bos = dos.getUnderlyingStream();
bos.reset();
w.write(dos);
ensureCapacity(bos.len(), true);
int i = currentSize * 2;
System.arraycopy(bos.bytearray(), 0, bytes, bytesUsed, bos.len());
keyOffsetsArray[i] = bytesUsed;
keyOffsetsArray[i + 1] = bos.len();
int[] posRet = position(new EntryPosition(currentSize));
int pos = posRet[1];
if (posRet[0] == 0) {
rearrange(keyOffsetsArray, pos);
rearrange(valueOffsetsArray, pos);
currentSize += 1;
bytesUsed += bos.len();
lastModified = System.nanoTime();
}
return pos;
}
use of com.sap.hadoop.ds.streams.Streams.DataOStream in project SQLWindowing by hbutani.
the class ByteBasedSortedMap method writeValue.
private void writeValue(Writable w, int pos) throws BaseException, IOException {
int i = pos * 2;
if (w == null) {
valueOffsetsArray[i] = 0;
valueOffsetsArray[i + 1] = 0;
return;
}
DataOStream dos = Streams.dos.get();
ByteArrayOS bos = dos.getUnderlyingStream();
bos.reset();
w.write(dos);
ensureCapacity(bos.len(), false);
System.arraycopy(bos.bytearray(), 0, bytes, bytesUsed, bos.len());
valueOffsetsArray[i] = bytesUsed;
valueOffsetsArray[i + 1] = bos.len();
bytesUsed += bos.len();
}
use of com.sap.hadoop.ds.streams.Streams.DataOStream in project SQLWindowing by hbutani.
the class ByteBasedSortedMap method getIndex.
public int getIndex(Writable w) throws BaseException {
LockUtils.lock(lock.readLock());
try {
DataOStream dos = Streams.dos.get();
ByteArrayOS bos = dos.getUnderlyingStream();
bos.reset();
w.write(dos);
TempEntryPosition te = new TempEntryPosition(bos.bytearray(), bos.len());
int[] posRet = position(te);
int pos = posRet[1];
return (posRet[0] == 1) ? startOffset + pos : -1;
} catch (IOException ie) {
throw new BaseException(ie);
} finally {
lock.readLock().unlock();
}
}
use of com.sap.hadoop.ds.streams.Streams.DataOStream in project SQLWindowing by hbutani.
the class PartitionedByteBasedSortedMap method getIndex.
public int getIndex(Writable w) throws BaseException {
fixStartPositions();
LockUtils.lock(lock.readLock());
try {
DataOStream dos = Streams.dos.get();
ByteArrayOS bos = dos.getUnderlyingStream();
bos.reset();
w.write(dos);
int p = splitList.getPartition(bos.bytearray(), 0, bos.len());
ByteBasedSortedMap mp = partitions.get(p);
return mp.getIndex(w);
} catch (IOException ie) {
throw new BaseException(ie);
} finally {
lock.readLock().unlock();
}
}
Aggregations