use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class RecordViewImpl method unmarshal.
/**
* Unmarshal value object from given binary row.
*
* @param binaryRow Binary row.
* @return Value object.
*/
private R unmarshal(BinaryRow binaryRow) {
if (binaryRow == null || !binaryRow.hasValue()) {
return null;
}
Row row = schemaReg.resolve(binaryRow);
RecordMarshaller<R> marshaller = marshaller(row.schemaVersion());
try {
return marshaller.unmarshal(row);
} catch (MarshallerException e) {
throw new IgniteException(e);
}
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class TupleMarshallerFixlenOnlyBenchmark method measureTupleBuildAndMarshallerCost.
/**
* Measure tuple build then marshall.
*
* @param bh Black hole.
*/
@Benchmark
public void measureTupleBuildAndMarshallerCost(Blackhole bh) throws TupleMarshallerException {
final Columns cols = schema.valueColumns();
final Tuple valBld = Tuple.create(cols.length());
for (int i = 0; i < cols.length(); i++) {
valBld.set(cols.column(i).name(), vals[i]);
}
Tuple keyTuple = Tuple.create(1).set("key", rnd.nextLong());
final Row row = marshaller.marshal(keyTuple, valBld);
bh.consume(row);
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class TupleMarshallerVarlenOnlyBenchmark method measureTupleBuildAndMarshallerCost.
/**
* Measure tuple build then marshall.
*
* @param bh Black hole.
*/
@Benchmark
public void measureTupleBuildAndMarshallerCost(Blackhole bh) throws TupleMarshallerException {
final Columns cols = schema.valueColumns();
final Tuple valBld = Tuple.create(cols.length());
for (int i = 0; i < cols.length(); i++) {
valBld.set(cols.column(i).name(), val);
}
Tuple keyTuple = Tuple.create(1).set("key", rnd.nextLong());
final Row row = marshaller.marshal(keyTuple, valBld);
bh.consume(row);
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class MutableRowTupleAdapterTest method getTuple.
private Tuple getTuple() {
try {
Tuple original = Tuple.create().set("id", 3L).set("name", "Shirt");
TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(schema));
return TableRow.tuple(new Row(schema, new ByteBufferRow(marshaller.marshal(original).bytes())));
} catch (TupleMarshallerException e) {
return fail();
}
}
use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.
the class MutableRowTupleAdapterTest method testKeyValueSerialization.
@Test
public void testKeyValueSerialization() throws Exception {
Random rnd = new Random();
Tuple key1 = Tuple.create().set("keyUuidCol", UUID.randomUUID());
Tuple val1 = 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("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));
TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(fullSchema));
Row row = new Row(fullSchema, new ByteBufferRow(marshaller.marshal(key1, val1).bytes()));
Tuple key2 = deserializeTuple(serializeTuple(TableRow.keyTuple(row)));
Tuple val2 = deserializeTuple(serializeTuple(TableRow.valueTuple(row)));
assertEquals(key1, key2);
assertEquals(val1, val2);
}
Aggregations