Search in sources :

Example 21 with Row

use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.

the class KeyValueBinaryViewImpl method removeAsync.

/**
 * {@inheritDoc}
 */
@Override
@NotNull
public CompletableFuture<Boolean> removeAsync(@Nullable Transaction tx, @NotNull Tuple key, @NotNull Tuple val) {
    Objects.requireNonNull(key);
    Objects.requireNonNull(val);
    // Convert to portable format to pass TX/storage layer.
    Row row = marshal(key, val);
    return tbl.deleteExact(row, (InternalTransaction) tx);
}
Also used : BinaryRow(org.apache.ignite.internal.schema.BinaryRow) Row(org.apache.ignite.internal.schema.row.Row) NotNull(org.jetbrains.annotations.NotNull)

Example 22 with Row

use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.

the class KeyValueBinaryViewImpl method removeAllAsync.

/**
 * {@inheritDoc}
 */
@Override
@NotNull
public CompletableFuture<Collection<Tuple>> removeAllAsync(@Nullable Transaction tx, @NotNull Collection<Tuple> keys) {
    Objects.requireNonNull(keys);
    List<BinaryRow> keyRows = new ArrayList<>(keys.size());
    for (Tuple keyRec : keys) {
        final Row keyRow = marshal(keyRec, null);
        keyRows.add(keyRow);
    }
    return tbl.deleteAll(keyRows, (InternalTransaction) tx).thenApply(t -> t.stream().filter(Objects::nonNull).map(this::wrap).map(TableRow::valueTuple).collect(Collectors.toList()));
}
Also used : ArrayList(java.util.ArrayList) Objects(java.util.Objects) BinaryRow(org.apache.ignite.internal.schema.BinaryRow) BinaryRow(org.apache.ignite.internal.schema.BinaryRow) Row(org.apache.ignite.internal.schema.row.Row) InternalTransaction(org.apache.ignite.internal.tx.InternalTransaction) Tuple(org.apache.ignite.table.Tuple) NotNull(org.jetbrains.annotations.NotNull)

Example 23 with Row

use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.

the class KeyValueViewImpl method unmarshalPairs.

/**
 * Marshal key-value pairs.
 *
 * @param rows Binary rows.
 * @return Key-value pairs.
 */
@NotNull
public Map<K, V> unmarshalPairs(Collection<BinaryRow> rows) {
    if (rows.isEmpty()) {
        return Collections.emptyMap();
    }
    final KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
    Map<K, V> pairs = new HashMap<>(rows.size());
    try {
        for (Row row : schemaReg.resolve(rows)) {
            if (row != null) {
                pairs.put(marsh.unmarshalKey(row), marsh.unmarshalValue(row));
            }
        }
        return pairs;
    } catch (MarshallerException e) {
        throw new IgniteException(e);
    }
}
Also used : MarshallerException(org.apache.ignite.internal.schema.marshaller.MarshallerException) HashMap(java.util.HashMap) IgniteException(org.apache.ignite.lang.IgniteException) BinaryRow(org.apache.ignite.internal.schema.BinaryRow) Row(org.apache.ignite.internal.schema.row.Row) NotNull(org.jetbrains.annotations.NotNull)

Example 24 with Row

use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.

the class RecordBinaryViewImpl method deleteAsync.

/**
 * {@inheritDoc}
 */
@Override
@NotNull
public CompletableFuture<Boolean> deleteAsync(@Nullable Transaction tx, @NotNull Tuple keyRec) {
    Objects.requireNonNull(keyRec);
    final Row keyRow = marshal(keyRec, true);
    return tbl.delete(keyRow, (InternalTransaction) tx);
}
Also used : BinaryRow(org.apache.ignite.internal.schema.BinaryRow) Row(org.apache.ignite.internal.schema.row.Row) NotNull(org.jetbrains.annotations.NotNull)

Example 25 with Row

use of org.apache.ignite.internal.schema.row.Row in project ignite-3 by apache.

the class RecordBinaryViewImpl method upsertAsync.

/**
 * {@inheritDoc}
 */
@Override
@NotNull
public CompletableFuture<Void> upsertAsync(@Nullable Transaction tx, @NotNull Tuple rec) {
    Objects.requireNonNull(rec);
    final Row row = marshal(rec, false);
    return tbl.upsert(row, (InternalTransaction) tx);
}
Also used : BinaryRow(org.apache.ignite.internal.schema.BinaryRow) Row(org.apache.ignite.internal.schema.row.Row) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Row (org.apache.ignite.internal.schema.row.Row)83 BinaryRow (org.apache.ignite.internal.schema.BinaryRow)55 Column (org.apache.ignite.internal.schema.Column)34 SchemaDescriptor (org.apache.ignite.internal.schema.SchemaDescriptor)30 NotNull (org.jetbrains.annotations.NotNull)25 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 MethodSource (org.junit.jupiter.params.provider.MethodSource)22 Tuple (org.apache.ignite.table.Tuple)21 Test (org.junit.jupiter.api.Test)18 ByteBufferRow (org.apache.ignite.internal.schema.ByteBufferRow)17 TupleMarshaller (org.apache.ignite.internal.schema.marshaller.TupleMarshaller)15 TupleMarshallerImpl (org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl)15 DummySchemaManagerImpl (org.apache.ignite.internal.table.impl.DummySchemaManagerImpl)15 RowAssembler (org.apache.ignite.internal.schema.row.RowAssembler)14 ArrayList (java.util.ArrayList)8 InternalTransaction (org.apache.ignite.internal.tx.InternalTransaction)6 Random (java.util.Random)5 MarshallerException (org.apache.ignite.internal.schema.marshaller.MarshallerException)5 TestObjectWithAllTypes (org.apache.ignite.internal.schema.testobjects.TestObjectWithAllTypes)5 IgniteException (org.apache.ignite.lang.IgniteException)5