Search in sources :

Example 1 with DataIStream

use of com.sap.hadoop.ds.streams.Streams.DataIStream 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 2 with DataIStream

use of com.sap.hadoop.ds.streams.Streams.DataIStream 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 3 with DataIStream

use of com.sap.hadoop.ds.streams.Streams.DataIStream in project SQLWindowing by hbutani.

the class ByteBasedSortedMap method getKey.

public void getKey(int i, Writable wObj) 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]);
        wObj.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 4 with DataIStream

use of com.sap.hadoop.ds.streams.Streams.DataIStream in project SQLWindowing by hbutani.

the class ByteBasedList method get.

public void get(int i, Writable wObj) throws BaseException {
    LockUtils.lock(lock.readLock());
    try {
        i = index(i);
        DataIStream dis = Streams.dis.get();
        ByteArrayIS bis = dis.getUnderlyingStream();
        bis.setBuffer(bytes, offsetsArray[i], offsetsArray[i + 1]);
        wObj.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)

Aggregations

BaseException (com.sap.hadoop.ds.BaseException)4 ByteArrayIS (com.sap.hadoop.ds.streams.Streams.ByteArrayIS)4 DataIStream (com.sap.hadoop.ds.streams.Streams.DataIStream)4 IOException (java.io.IOException)4