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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations