Search in sources :

Example 1 with BaseException

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);
    }
}
Also used : BaseException(com.sap.hadoop.ds.BaseException) IOException(java.io.IOException) File(java.io.File)

Example 2 with BaseException

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();
    }
}
Also used : BaseException(com.sap.hadoop.ds.BaseException) DataIStream(com.sap.hadoop.ds.streams.Streams.DataIStream) IOException(java.io.IOException) ByteArrayIS(com.sap.hadoop.ds.streams.Streams.ByteArrayIS)

Example 3 with BaseException

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();
    }
}
Also used : BaseException(com.sap.hadoop.ds.BaseException) DataIStream(com.sap.hadoop.ds.streams.Streams.DataIStream) IOException(java.io.IOException) ByteArrayIS(com.sap.hadoop.ds.streams.Streams.ByteArrayIS)

Example 4 with BaseException

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();
    }
}
Also used : BaseException(com.sap.hadoop.ds.BaseException) ByteArrayOS(com.sap.hadoop.ds.streams.Streams.ByteArrayOS) DataOStream(com.sap.hadoop.ds.streams.Streams.DataOStream) IOException(java.io.IOException)

Example 5 with BaseException

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();
    }
}
Also used : BaseException(com.sap.hadoop.ds.BaseException) IOException(java.io.IOException)

Aggregations

BaseException (com.sap.hadoop.ds.BaseException)12 IOException (java.io.IOException)11 ByteArrayIS (com.sap.hadoop.ds.streams.Streams.ByteArrayIS)4 ByteArrayOS (com.sap.hadoop.ds.streams.Streams.ByteArrayOS)4 DataIStream (com.sap.hadoop.ds.streams.Streams.DataIStream)4 DataOStream (com.sap.hadoop.ds.streams.Streams.DataOStream)4 File (java.io.File)2 Properties (java.util.Properties)1 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)1 LazySimpleSerDe (org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe)1