use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class RecordBinaryViewImpl method deleteExactAsync.
/**
* {@inheritDoc}
*/
@Override
@NotNull
public CompletableFuture<Boolean> deleteExactAsync(@Nullable Transaction tx, @NotNull Tuple rec) {
Objects.requireNonNull(rec);
final Row row = marshal(rec, false);
return tbl.deleteExact(row, (InternalTransaction) tx);
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class RecordBinaryViewImpl method getAndUpsertAsync.
/**
* {@inheritDoc}
*/
@Override
@NotNull
public CompletableFuture<Tuple> getAndUpsertAsync(@Nullable Transaction tx, @NotNull Tuple rec) {
Objects.requireNonNull(rec);
final Row row = marshal(rec, false);
return tbl.getAndUpsert(row, (InternalTransaction) tx).thenApply(this::wrap);
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class TxAbstractTest method testScan.
@Test
public void testScan() throws InterruptedException {
accounts.recordView().upsertAll(null, List.of(makeValue(1, 100.), makeValue(2, 200.)));
Flow.Publisher<BinaryRow> pub = ((TableImpl) accounts).internalTable().scan(0, null);
List<Tuple> rows = new ArrayList<>();
CountDownLatch l = new CountDownLatch(1);
pub.subscribe(new Flow.Subscriber<BinaryRow>() {
@Override
public void onSubscribe(Flow.Subscription subscription) {
subscription.request(3);
}
@Override
public void onNext(BinaryRow item) {
Row row = ((TableImpl) accounts).schemaView().resolve(item);
rows.add(TableRow.tuple(row));
}
@Override
public void onError(Throwable throwable) {
// No-op.
}
@Override
public void onComplete() {
l.countDown();
}
});
assertTrue(l.await(5_000, TimeUnit.MILLISECONDS));
Map<Long, Tuple> map = new HashMap<>();
for (Tuple row : rows) {
map.put(row.longValue("accountNumber"), row);
}
assertEquals(100., map.get(1L).doubleValue("balance"));
assertEquals(200., map.get(2L).doubleValue("balance"));
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class PartitionCommandListenerTest method getTestKey.
/**
* Prepares a test row which contains only key field.
*
* @return Row.
*/
@NotNull
private Row getTestKey(int key) {
RowAssembler rowBuilder = new RowAssembler(SCHEMA, 0, 0);
rowBuilder.appendInt(key);
return new Row(SCHEMA, rowBuilder.build());
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class NumericTypesSerializerTest method testDecimalMaxScale.
@Test
public void testDecimalMaxScale() throws TupleMarshallerException {
schema = new SchemaDescriptor(42, new Column[] { new Column("key", NativeTypes.INT64, false) }, new Column[] { new Column("decimalCol", NativeTypes.decimalOf(Integer.MAX_VALUE, Integer.MAX_VALUE), false) });
final Tuple tup = createTuple().set("key", rnd.nextLong()).set("decimalCol", BigDecimal.valueOf(123, Integer.MAX_VALUE));
TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(schema));
final Row row = marshaller.marshal(tup);
assertEquals(row.decimalValue(1), BigDecimal.valueOf(123, Integer.MAX_VALUE));
}
Aggregations