use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class RecordBinaryViewImpl method replaceAsync.
/**
* {@inheritDoc}
*/
@Override
@NotNull
public CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, @NotNull Tuple rec) {
Objects.requireNonNull(rec);
final Row row = marshal(rec, false);
return tbl.replace(row, (InternalTransaction) tx);
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class KeyValueBinaryViewImpl method putIfAbsentAsync.
/**
* {@inheritDoc}
*/
@Override
@NotNull
public CompletableFuture<Boolean> putIfAbsentAsync(@Nullable Transaction tx, @NotNull Tuple key, Tuple val) {
Objects.requireNonNull(key);
// Convert to portable format to pass TX/storage layer.
Row row = marshal(key, val);
return tbl.insert(row, (InternalTransaction) tx);
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class SerializerBenchmarkTest method measureSerializeDeserializeCost.
/**
* Measure serialization-deserialization operation cost.
*
* @param bh Black hole.
* @throws Exception If failed.
*/
@Benchmark
public void measureSerializeDeserializeCost(Blackhole bh) throws Exception {
Long key = rnd.nextLong();
Object val = objectFactory.create();
BinaryRow row = marshaller.marshal(key, val);
Object restoredKey = marshaller.unmarshalKey(new Row(schema, row));
Object restoredVal = marshaller.unmarshalValue(new Row(schema, row));
bh.consume(restoredVal);
bh.consume(restoredKey);
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class RecordViewImpl method unmarshal.
/**
* Unmarshal records.
*
* @param rows Row collection.
* @return Records collection.
*/
@NotNull
public Collection<R> unmarshal(Collection<BinaryRow> rows) {
if (rows.isEmpty()) {
return Collections.emptyList();
}
final RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
List<R> recs = new ArrayList<>(rows.size());
try {
for (Row row : schemaReg.resolve(rows)) {
if (row != null) {
recs.add(marsh.unmarshal(row));
}
}
return recs;
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class MutableRowTupleAdapterTest method testVariousColumnTypes.
@Test
public void testVariousColumnTypes() throws TupleMarshallerException {
Random rnd = new Random();
TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(fullSchema));
Tuple tuple = Tuple.create().set("valByteCol", (byte) 1).set("valShortCol", (short) 2).set("valIntCol", 3).set("valLongCol", 4L).set("valFloatCol", 0.055f).set("valDoubleCol", 0.066d).set("keyUuidCol", UUID.randomUUID()).set("valDateCol", LocalDate.now()).set("valDateTimeCol", truncatedLocalDateTimeNow()).set("valTimeCol", truncatedLocalTimeNow()).set("valTimeStampCol", truncatedInstantNow()).set("valBitmask1Col", randomBitSet(rnd, 12)).set("valBytesCol", IgniteTestUtils.randomBytes(rnd, 13)).set("valStringCol", IgniteTestUtils.randomString(rnd, 14)).set("valNumberCol", BigInteger.valueOf(rnd.nextLong())).set("valDecimalCol", BigDecimal.valueOf(rnd.nextLong(), 5));
Tuple rowTuple = TableRow.tuple(new Row(fullSchema, new ByteBufferRow(marshaller.marshal(tuple).bytes())));
assertEquals(tuple, rowTuple);
// Force row to tuple conversion.
rowTuple.set("foo", "bar");
// Force row to tuple conversion.
tuple.set("foo", "bar");
assertEquals(tuple, rowTuple);
}
Aggregations