Search in sources :

Example 1 with Status

use of io.sbk.api.Status in project SBK by kmgowda.

the class IgniteTransactionReader method recordRead.

@Override
public void recordRead(DataType<byte[]> dType, int size, Time time, Status status, PerlChannel perlChannel) throws EOFException, IOException {
    final int recs = params.getRecordsPerSync();
    status.startTime = time.getCurrentTime();
    Transaction tx = ignite.transactions().txStart();
    long startKey = key;
    Status stat = new Status();
    for (int i = 0; i < recs; i++) {
        byte[] result = cache.get(startKey++);
        if (result != null) {
            stat.bytes += result.length;
            stat.records += 1;
        }
    }
    tx.commit();
    if (stat.records == 0) {
        throw new EOFException();
    }
    status.records = stat.records;
    status.bytes = stat.bytes;
    status.endTime = time.getCurrentTime();
    key += recs;
    cnt += recs;
    perlChannel.send(status.startTime, status.endTime, status.bytes, status.records);
}
Also used : Status(io.sbk.api.Status) Transaction(org.apache.ignite.transactions.Transaction) EOFException(java.io.EOFException)

Example 2 with Status

use of io.sbk.api.Status in project SBK by kmgowda.

the class IgniteTransactionReader method recordReadTime.

@Override
public void recordReadTime(DataType<byte[]> dType, int size, Time time, Status status, PerlChannel perlChannel) throws EOFException, IOException {
    final int recs = params.getRecordsPerSync();
    Transaction tx = ignite.transactions().txStart();
    long startKey = key;
    Status stat = new Status();
    for (int i = 0; i < recs; i++) {
        byte[] result = cache.get(startKey++);
        if (result != null) {
            stat.bytes += result.length;
            stat.records += 1;
            if (stat.startTime == 0) {
                stat.startTime = dType.getTime(result);
            }
        } else {
            break;
        }
    }
    tx.commit();
    status.records = stat.records;
    status.bytes = stat.bytes;
    status.startTime = stat.startTime;
    status.endTime = time.getCurrentTime();
    key += status.records;
    cnt += status.records;
    perlChannel.send(status.startTime, status.endTime, status.bytes, status.records);
}
Also used : Status(io.sbk.api.Status) Transaction(org.apache.ignite.transactions.Transaction)

Example 3 with Status

use of io.sbk.api.Status in project SBK by kmgowda.

the class FoundationDBMultiKeyReader method recordReadTime.

@Override
public void recordReadTime(DataType<byte[]> dType, int size, Time time, Status status, PerlChannel perlChannel) throws EOFException, IOException {
    final int recs = params.getRecordsPerSync();
    final Status ret = db.read(tr -> {
        long startKey = key;
        Status stat = new Status();
        for (int i = 0; i < recs; i++) {
            byte[] result = tr.get(Tuple.from(startKey++).pack()).join();
            if (result != null) {
                stat.bytes += result.length;
                stat.records += 1;
                if (stat.startTime == 0) {
                    stat.startTime = dType.getTime(result);
                }
            } else {
                break;
            }
        }
        return stat;
    });
    status.records = ret.records;
    status.bytes = ret.bytes;
    status.startTime = ret.startTime;
    status.endTime = time.getCurrentTime();
    key += status.records;
    cnt += status.records;
    perlChannel.send(status.startTime, status.endTime, status.bytes, status.records);
}
Also used : Status(io.sbk.api.Status)

Example 4 with Status

use of io.sbk.api.Status in project SBK by kmgowda.

the class FdbRecordMultiReader method recordRead.

@Override
public void recordRead(DataType<ByteString> dType, int size, Time time, Status status, PerlChannel perlChannel) throws EOFException, IOException {
    final int recs = params.getRecordsPerSync();
    status.startTime = time.getCurrentTime();
    final Status ret = db.run(context -> {
        long startKey = key;
        Status stat = new Status();
        FDBRecordStore recordStore = recordStoreProvider.apply(context);
        FDBStoredRecord<Message> storedRecord;
        for (int i = 0; i < recs; i++) {
            storedRecord = recordStore.loadRecord(Tuple.from(startKey++));
            if (storedRecord != null) {
                FdbRecordLayerProto.Record record = FdbRecordLayerProto.Record.newBuilder().mergeFrom(storedRecord.getRecord()).build();
                stat.bytes += record.getData().size();
                stat.records += 1;
            }
        }
        return stat;
    });
    if (ret.records == 0) {
        throw new EOFException();
    }
    status.records = ret.records;
    status.bytes = ret.bytes;
    status.endTime = time.getCurrentTime();
    key += recs;
    cnt += recs;
    perlChannel.send(status.startTime, status.endTime, status.bytes, status.records);
}
Also used : Status(io.sbk.api.Status) Message(com.google.protobuf.Message) EOFException(java.io.EOFException) FDBRecordStore(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStore)

Example 5 with Status

use of io.sbk.api.Status in project SBK by kmgowda.

the class FdbRecordMultiReader method recordReadTime.

@Override
public void recordReadTime(DataType<ByteString> dType, int size, Time time, Status status, PerlChannel perlChannel) throws EOFException, IOException {
    final int recs = params.getRecordsPerSync();
    final Status ret = db.run(context -> {
        long startKey = key;
        Status stat = new Status();
        FDBRecordStore recordStore = recordStoreProvider.apply(context);
        FDBStoredRecord<Message> storedRecord;
        ByteString data;
        for (int i = 0; i < recs; i++) {
            storedRecord = recordStore.loadRecord(Tuple.from(startKey++));
            if (storedRecord != null) {
                FdbRecordLayerProto.Record record = FdbRecordLayerProto.Record.newBuilder().mergeFrom(storedRecord.getRecord()).build();
                data = record.getData();
                stat.bytes += data.size();
                stat.records += 1;
                if (stat.startTime == 0) {
                    stat.startTime = dType.getTime(data);
                }
            } else {
                break;
            }
        }
        return stat;
    });
    status.startTime = ret.startTime;
    status.records = ret.records;
    status.bytes = ret.bytes;
    status.endTime = time.getCurrentTime();
    key += status.records;
    cnt += status.records;
    perlChannel.send(status.startTime, status.endTime, status.bytes, status.records);
}
Also used : Status(io.sbk.api.Status) Message(com.google.protobuf.Message) ByteString(com.google.protobuf.ByteString) FDBRecordStore(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStore)

Aggregations

Status (io.sbk.api.Status)9 EOFException (java.io.EOFException)4 FDBRecordStore (com.apple.foundationdb.record.provider.foundationdb.FDBRecordStore)2 Message (com.google.protobuf.Message)2 ClientTransaction (org.apache.ignite.client.ClientTransaction)2 Transaction (org.apache.ignite.transactions.Transaction)2 ByteString (com.google.protobuf.ByteString)1 AckHandler (io.nats.streaming.AckHandler)1 NatsStreaming (io.nats.streaming.NatsStreaming)1 Builder (io.nats.streaming.Options.Builder)1 StreamingConnection (io.nats.streaming.StreamingConnection)1 PerlChannel (io.perl.api.PerlChannel)1 ParameterOptions (io.sbk.api.ParameterOptions)1 Writer (io.sbk.api.Writer)1 DataType (io.sbk.data.DataType)1 Printer (io.sbk.system.Printer)1 Time (io.time.Time)1 IOException (java.io.IOException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 TimeoutException (java.util.concurrent.TimeoutException)1