use of org.apache.ignite.internal.schema.SchemaDescriptor in project ignite-3 by apache.
the class NumericTypesSerializerTest method testNumber.
/**
* Test.
*/
@ParameterizedTest
@MethodSource("numbers")
public void testNumber(Pair<BigInteger, BigInteger> pair) throws TupleMarshallerException {
schema = new SchemaDescriptor(42, new Column[] { new Column("key", NativeTypes.INT64, false) }, new Column[] { new Column("number1", NativeTypes.numberOf(19), false), new Column("number2", NativeTypes.numberOf(10), false) });
TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(schema));
final Tuple tup = createTuple().set("key", rnd.nextLong()).set("number1", pair.getFirst()).set("number2", pair.getSecond());
final Row row = marshaller.marshal(tup);
assertEquals(row.numberValue(1), row.numberValue(2));
}
use of org.apache.ignite.internal.schema.SchemaDescriptor in project ignite-3 by apache.
the class ClientTableCommon method writeTuplesNullable.
/**
* Writes multiple tuples with null flags.
*
* @param packer Packer.
* @param tuples Tuples.
* @param part Which part of tuple to write.
* @param schemaRegistry The registry.
* @param skipHeader Whether to skip the tuple header.
* @throws IgniteException on failed serialization.
*/
public static void writeTuplesNullable(ClientMessagePacker packer, Collection<Tuple> tuples, TuplePart part, SchemaRegistry schemaRegistry, boolean skipHeader) {
if (tuples == null || tuples.isEmpty()) {
packer.packNil();
return;
}
SchemaDescriptor schema = schemaRegistry.schema();
packer.packInt(schema.version());
packer.packInt(tuples.size());
for (Tuple tuple : tuples) {
if (tuple == null) {
packer.packBoolean(false);
continue;
}
assert schema.version() == ((SchemaAware) tuple).schema().version();
packer.packBoolean(true);
writeTuple(packer, tuple, schema, skipHeader, part);
}
}
use of org.apache.ignite.internal.schema.SchemaDescriptor in project ignite-3 by apache.
the class ClientTableCommon method writeTuples.
/**
* Writes multiple tuples.
*
* @param packer Packer.
* @param tuples Tuples.
* @param part Which part of tuple to write.
* @param schemaRegistry The registry.
* @param skipHeader Whether to skip the tuple header.
* @throws IgniteException on failed serialization.
*/
public static void writeTuples(ClientMessagePacker packer, Collection<Tuple> tuples, TuplePart part, SchemaRegistry schemaRegistry, boolean skipHeader) {
if (tuples == null || tuples.isEmpty()) {
packer.packNil();
return;
}
SchemaDescriptor schema = schemaRegistry.schema();
packer.packInt(schema.version());
packer.packInt(tuples.size());
for (Tuple tuple : tuples) {
assert tuple != null;
assert schema.version() == ((SchemaAware) tuple).schema().version();
writeTuple(packer, tuple, schema, skipHeader, part);
}
}
use of org.apache.ignite.internal.schema.SchemaDescriptor in project ignite-3 by apache.
the class ClientTableCommon method readTuples.
/**
* Reads multiple tuples.
*
* @param unpacker Unpacker.
* @param table Table.
* @param keyOnly Whether only key fields are expected.
* @return Tuples.
*/
public static ArrayList<Tuple> readTuples(ClientMessageUnpacker unpacker, TableImpl table, boolean keyOnly) {
SchemaDescriptor schema = readSchema(unpacker, table);
var rowCnt = unpacker.unpackInt();
var res = new ArrayList<Tuple>(rowCnt);
for (int i = 0; i < rowCnt; i++) {
res.add(readTuple(unpacker, keyOnly, schema));
}
return res;
}
use of org.apache.ignite.internal.schema.SchemaDescriptor in project ignite-3 by apache.
the class BinaryIndexRowFactory method createRowAssembler.
/**
* Creates a {@link RowAssembler} that can later be used to serialized the given column mapping.
*/
private RowAssembler createRowAssembler(Object[] rowColumns) {
SchemaDescriptor schemaDescriptor = descriptor.asSchemaDescriptor();
int nonNullVarlenKeyCols = 0;
for (Column column : schemaDescriptor.keyColumns().columns()) {
Object columnValue = rowColumns[column.columnOrder()];
if (!column.type().spec().fixedLength() && columnValue != null) {
nonNullVarlenKeyCols += 1;
}
}
return new RowAssembler(schemaDescriptor, nonNullVarlenKeyCols, 0);
}
Aggregations