Search in sources :

Example 6 with BaseException

use of com.sap.hadoop.ds.BaseException 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 7 with BaseException

use of com.sap.hadoop.ds.BaseException 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();
    }
}
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 8 with BaseException

use of com.sap.hadoop.ds.BaseException in project SQLWindowing by hbutani.

the class PartitionedByteBasedSortedMap method persist.

private ByteBasedSortedMap persist(int i) throws BaseException {
    try {
        ByteBasedSortedMap mp = partitions.get(i);
        if (!(mp instanceof PersistentByteBasedSortedMap)) {
            File f = File.createTempFile("wdw", null, dir);
            mp = new PersistentByteBasedSortedMap(f, mp, comparator);
            partitions.set(i, mp);
        }
        return mp;
    } catch (IOException ie) {
        throw new BaseException(ie);
    }
}
Also used : BaseException(com.sap.hadoop.ds.BaseException) IOException(java.io.IOException) File(java.io.File)

Example 9 with BaseException

use of com.sap.hadoop.ds.BaseException in project SQLWindowing by hbutani.

the class PartitionedByteBasedSortedMap method getValue.

public int getValue(Writable key, Writable value) throws BaseException {
    LockUtils.lock(lock.readLock());
    try {
        DataOStream dos = Streams.dos.get();
        ByteArrayOS bos = dos.getUnderlyingStream();
        bos.reset();
        key.write(dos);
        int p = splitList.getPartition(bos.bytearray(), 0, bos.len());
        ByteBasedSortedMap mp = partitions.get(p);
        return mp.getValue(key, value);
    } 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 10 with BaseException

use of com.sap.hadoop.ds.BaseException in project SQLWindowing by hbutani.

the class PartitionedByteBasedSortedMap method put.

public void put(Writable key, Writable value) throws BaseException {
    LockUtils.lock(lock.writeLock());
    try {
        DataOStream dos = Streams.dos.get();
        ByteArrayOS bos = dos.getUnderlyingStream();
        bos.reset();
        key.write(dos);
        int p = splitList.getPartition(bos.bytearray(), 0, bos.len());
        ByteBasedSortedMap mp = bringInMemory(p);
        try {
            int prevSz = mp.size();
            mp.put(key, value);
            if (mp.size() > prevSz)
                currentSize++;
            fixStartPositions = true;
            persistRandom();
        } catch (MapFullException oe) {
            ByteBasedSortedMap[] parts = mp.split();
            //				System.out.println(parts[0]);
            //				System.out.println(parts[1]);
            partitions.set(p, parts[1]);
            partitions.add(p, parts[0]);
            byte[] b = parts[0].getLastKey();
            splitList.splitPartition(p, b, 0, b.length);
            put(key, value);
        }
    } catch (IOException ie) {
        throw new BaseException(ie);
    } finally {
        lock.writeLock().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)

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