use of com.sap.hadoop.ds.BaseException in project SQLWindowing by hbutani.
the class PartitionedByteBasedList method addPartition.
private void addPartition() throws BaseException {
try {
if (partitions.size() > 0) {
int idx = partitions.size() - 1;
ByteBasedList bl = partitions.get(idx);
File f = File.createTempFile("wdw", null, dir);
PersistentByteBasedList.store(bl, f);
partitions.set(idx, new PersistentByteBasedList(f, bl));
}
ByteBasedList bl = new ByteBasedList(currentSize, batchSize);
partitions.add(bl);
partitionOffsets.add(currentSize);
} catch (IOException ie) {
throw new BaseException(ie);
}
}
use of com.sap.hadoop.ds.BaseException in project SQLWindowing by hbutani.
the class ByteBasedSortedMap method getEntry.
public void getEntry(int i, WritableEntry entry) throws BaseException {
LockUtils.lock(lock.readLock());
try {
i = index(i);
DataIStream dis = Streams.dis.get();
ByteArrayIS bis = dis.getUnderlyingStream();
bis.setBuffer(bytes, keyOffsetsArray[i], keyOffsetsArray[i + 1]);
entry.key.readFields(dis);
bis.setBuffer(bytes, valueOffsetsArray[i], valueOffsetsArray[i + 1]);
entry.value.readFields(dis);
} catch (IOException ie) {
throw new BaseException(ie);
} finally {
lock.readLock().unlock();
}
}
use of com.sap.hadoop.ds.BaseException in project SQLWindowing by hbutani.
the class ByteBasedSortedMap method getValue.
public int getValue(Writable key, Writable value) throws BaseException {
LockUtils.lock(lock.readLock());
try {
int pos = getIndex(key) - startOffset;
if (pos != -1) {
int i = pos * 2;
DataIStream dis = Streams.dis.get();
ByteArrayIS bis = dis.getUnderlyingStream();
bis.setBuffer(bytes, valueOffsetsArray[i], valueOffsetsArray[i + 1]);
value.readFields(dis);
}
return pos;
} catch (IOException ie) {
throw new BaseException(ie);
} finally {
lock.readLock().unlock();
}
}
use of com.sap.hadoop.ds.BaseException 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.BaseException in project SQLWindowing by hbutani.
the class ByteBasedSortedMap method put.
public void put(Writable key, Writable value) throws BaseException {
LockUtils.lock(lock.writeLock());
try {
int pos = writeKey(key);
writeValue(value, pos);
} catch (IOException ie) {
throw new BaseException(ie);
} finally {
lock.writeLock().unlock();
}
}
Aggregations