use of org.apache.ignite.internal.schema.row.RowAssembler in project ignite-3 by apache.
the class ItTablePersistenceTest method createKeyValueRow.
/**
* Creates a {@link Row} with the supplied key and value.
*
* @param id Key.
* @param value Value.
* @return Row.
*/
private static Row createKeyValueRow(long id, long value) {
RowAssembler rowBuilder = new RowAssembler(SCHEMA, 0, 0);
rowBuilder.appendLong(id);
rowBuilder.appendLong(value);
return new Row(SCHEMA, new ByteBufferRow(rowBuilder.toBytes()));
}
use of org.apache.ignite.internal.schema.row.RowAssembler 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);
}
use of org.apache.ignite.internal.schema.row.RowAssembler in project ignite-3 by apache.
the class BinaryIndexRowFactory method createIndexRow.
@Override
public IndexRow createIndexRow(Object[] columnValues, SearchRow primaryKey) {
if (columnValues.length != descriptor.indexRowColumns().size()) {
throw new IllegalArgumentException(String.format("Incorrect number of column values passed. Expected %d, got %d", descriptor.indexRowColumns().size(), columnValues.length));
}
RowAssembler rowAssembler = createRowAssembler(columnValues);
for (Column column : descriptor.asSchemaDescriptor().keyColumns().columns()) {
Object columnValue = columnValues[column.columnOrder()];
RowAssembler.writeValue(rowAssembler, column, columnValue);
}
return new BinaryIndexRow(rowAssembler.build(), primaryKey);
}
use of org.apache.ignite.internal.schema.row.RowAssembler in project ignite-3 by apache.
the class TupleMarshallerImpl method buildRow.
/**
* Marshal tuple to a row.
*
* @param schema Schema.
* @param keyTuple0 Internal key tuple.
* @param valTuple0 Internal value tuple.
* @return Row.
* @throws SchemaMismatchException If failed to write tuple column.
*/
@NotNull
private Row buildRow(SchemaDescriptor schema, InternalTuple keyTuple0, InternalTuple valTuple0) throws SchemaMismatchException {
RowAssembler rowBuilder = createAssembler(schema, keyTuple0, valTuple0);
Columns columns = schema.keyColumns();
for (int i = 0, len = columns.length(); i < len; i++) {
final Column col = columns.column(i);
writeColumn(rowBuilder, col, keyTuple0);
}
if (valTuple0.tuple != null) {
columns = schema.valueColumns();
for (int i = 0, len = columns.length(); i < len; i++) {
final Column col = columns.column(i);
writeColumn(rowBuilder, col, valTuple0);
}
}
return new Row(schema, rowBuilder.build());
}
use of org.apache.ignite.internal.schema.row.RowAssembler in project ignite-3 by apache.
the class TupleMarshallerImpl method marshalKey.
/**
* {@inheritDoc}
*/
@Override
public Row marshalKey(@NotNull Tuple keyTuple) throws TupleMarshallerException {
try {
final SchemaDescriptor schema = schemaReg.schema();
InternalTuple keyTuple0 = toInternalTuple(schema, keyTuple, true);
if (keyTuple0.knownColumns() < keyTuple.columnCount()) {
throw new SchemaMismatchException("Key tuple contains extra columns: " + extraColumnNames(keyTuple, true, schema));
}
final RowAssembler rowBuilder = createAssembler(schema, keyTuple0, InternalTuple.NO_VALUE);
Columns cols = schema.keyColumns();
for (int i = 0, len = cols.length(); i < len; i++) {
final Column col = cols.column(i);
writeColumn(rowBuilder, col, keyTuple0);
}
return new Row(schema, rowBuilder.build());
} catch (Exception ex) {
throw new TupleMarshallerException("Failed to marshal tuple.", ex);
}
}
Aggregations