use of org.apache.ignite.internal.schema.ByteBufferRow in project ignite-3 by apache.
the class UpgradingRowAdapterTest method validateRow.
private void validateRow(List<Object> values, SchemaRegistryImpl schemaRegistry, ByteBufferRow binaryRow) {
Row row = schemaRegistry.resolve(binaryRow);
SchemaDescriptor schema = row.schema();
for (int i = 0; i < values.size(); i++) {
Column col = schema.column(i);
NativeTypeSpec type = col.type().spec();
if (type == NativeTypeSpec.BYTES) {
assertArrayEquals((byte[]) values.get(i), (byte[]) NativeTypeSpec.BYTES.objectValue(row, col.schemaIndex()), "Failed for column: " + col);
} else {
assertEquals(values.get(i), type.objectValue(row, col.schemaIndex()), "Failed for column: " + col);
}
}
}
use of org.apache.ignite.internal.schema.ByteBufferRow in project ignite-3 by apache.
the class ItInternalTableScanTest method setUp.
/**
* Prepare test environment.
* <ol>
* <li>Start network node.</li>
* <li>Start raft server.</li>
* <li>Prepare partitioned raft group.</li>
* <li>Prepare partitioned raft group service.</li>
* <li>Prepare internal table as a test object.</li>
* </ol>
*
* @throws Exception If any.
*/
@BeforeEach
public void setUp(TestInfo testInfo) throws Exception {
NetworkAddress nodeNetworkAddress = new NetworkAddress("localhost", 20_000);
network = ClusterServiceTestUtils.clusterService(testInfo, 20_000, new StaticNodeFinder(List.of(nodeNetworkAddress)), NETWORK_FACTORY);
network.start();
raftSrv = new RaftServerImpl(network, FACTORY);
raftSrv.start();
String grpName = "test_part_grp";
List<Peer> conf = List.of(new Peer(nodeNetworkAddress));
mockStorage = mock(PartitionStorage.class);
txManager = new TxManagerImpl(network, new HeapLockManager());
txManager.start();
UUID tblId = UUID.randomUUID();
raftSrv.startRaftGroup(grpName, new PartitionListener(tblId, new VersionedRowStore(mockStorage, txManager) {
@Override
protected Pair<BinaryRow, BinaryRow> versionedRow(@Nullable DataRow row, Timestamp timestamp) {
// Return as is.
return new Pair<>(new ByteBufferRow(row.valueBytes()), null);
}
}), conf);
executor = new ScheduledThreadPoolExecutor(20, new NamedThreadFactory(Loza.CLIENT_POOL_NAME));
RaftGroupService raftGrpSvc = RaftGroupServiceImpl.start(RAFT_GRP_ID, network, FACTORY, 10_000, conf, true, 200, executor).get(3, TimeUnit.SECONDS);
internalTbl = new InternalTableImpl(TEST_TABLE_NAME, tblId, Int2ObjectMaps.singleton(0, raftGrpSvc), 1, NetworkAddress::toString, txManager, mock(TableStorage.class));
}
use of org.apache.ignite.internal.schema.ByteBufferRow in project ignite-3 by apache.
the class ItTablePersistenceTest method createKeyRow.
/**
* Creates a {@link Row} with the supplied key.
*
* @param id Key.
* @return Row.
*/
private static Row createKeyRow(long id) {
RowAssembler rowBuilder = new RowAssembler(SCHEMA, 0, 0);
rowBuilder.appendLong(id);
return new Row(SCHEMA, new ByteBufferRow(rowBuilder.toBytes()));
}
use of org.apache.ignite.internal.schema.ByteBufferRow in project ignite-3 by apache.
the class KvMarshallerImpl method marshal.
/**
* {@inheritDoc}
*/
@Override
public BinaryRow marshal(@NotNull K key) throws MarshallerException {
assert keyClass.isInstance(key);
final RowAssembler asm = createAssembler(key, null);
keyMarsh.writeObject(key, asm);
return new ByteBufferRow(asm.toBytes());
}
use of org.apache.ignite.internal.schema.ByteBufferRow in project ignite-3 by apache.
the class RecordMarshallerImpl method marshalKey.
/**
* {@inheritDoc}
*/
@Override
public BinaryRow marshalKey(@NotNull R rec) throws MarshallerException {
assert recClass.isInstance(rec);
final RowAssembler asm = createAssembler(Objects.requireNonNull(rec), null);
keyMarsh.writeObject(rec, asm);
return new ByteBufferRow(asm.toBytes());
}
Aggregations