Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-21836: KeyValueView. GetNullable produces confusing error for a PoJo when field / column nullability do not match #3714

Merged
merged 11 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,13 @@ public interface KeyValueView<K, V> extends DataStreamerTarget<Entry<K, V>>, Cri
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key the specified value is associated with. The key cannot be {@code null}.
* @param oldValue Expected value associated with the specified key.
* @param oldValue Expected value associated with the specified key. Can be {@code null} when mapped to a single column
* with a simple type.
* @param newValue Value to be associated with the specified key. Can be {@code null} when mapped to a single column with a simple type.
* @return {@code True} if an old value was replaced, {@code false} otherwise.
* @throws MarshallerException if the key, the oldValue, or the newValue doesn't match the schema.
*/
boolean replace(@Nullable Transaction tx, K key, V oldValue, @Nullable V newValue);
boolean replace(@Nullable Transaction tx, K key, @Nullable V oldValue, @Nullable V newValue);

/**
* Asynchronously replaces a value for a key if it exists. See {@link #replace(Transaction, Object, Object)}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Tuple get(@Nullable Transaction tx, Tuple key) {
/** {@inheritDoc} */
@Override
public CompletableFuture<Tuple> getAsync(@Nullable Transaction tx, Tuple key) {
Objects.requireNonNull(key);
Objects.requireNonNull(key, "key");

return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET,
Expand All @@ -98,7 +98,7 @@ public Map<Tuple, Tuple> getAll(@Nullable Transaction tx, Collection<Tuple> keys
/** {@inheritDoc} */
@Override
public CompletableFuture<Map<Tuple, Tuple>> getAllAsync(@Nullable Transaction tx, Collection<Tuple> keys) {
Objects.requireNonNull(keys);
Objects.requireNonNull(keys, "keys");

if (keys.isEmpty()) {
return emptyMapCompletedFuture();
Expand Down Expand Up @@ -142,7 +142,7 @@ public Tuple getOrDefault(@Nullable Transaction tx, Tuple key, Tuple defaultValu
/** {@inheritDoc} */
@Override
public CompletableFuture<Tuple> getOrDefaultAsync(@Nullable Transaction tx, Tuple key, Tuple defaultValue) {
Objects.requireNonNull(key);
Objects.requireNonNull(key, "key");

return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET,
Expand All @@ -162,7 +162,7 @@ public boolean contains(@Nullable Transaction tx, Tuple key) {
/** {@inheritDoc} */
@Override
public CompletableFuture<Boolean> containsAsync(@Nullable Transaction tx, Tuple key) {
Objects.requireNonNull(key);
Objects.requireNonNull(key, "key");

return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_CONTAINS_KEY,
Expand All @@ -174,14 +174,14 @@ public CompletableFuture<Boolean> containsAsync(@Nullable Transaction tx, Tuple

/** {@inheritDoc} */
@Override
public void put(@Nullable Transaction tx, Tuple key, Tuple val) {
public void put(@Nullable Transaction tx, Tuple key, @Nullable Tuple val) {
sync(putAsync(tx, key, val));
}

/** {@inheritDoc} */
@Override
public CompletableFuture<Void> putAsync(@Nullable Transaction tx, Tuple key, Tuple val) {
Objects.requireNonNull(key);
public CompletableFuture<Void> putAsync(@Nullable Transaction tx, Tuple key, @Nullable Tuple val) {
Objects.requireNonNull(key, "key");

return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_UPSERT,
Expand All @@ -200,7 +200,7 @@ public void putAll(@Nullable Transaction tx, Map<Tuple, Tuple> pairs) {
/** {@inheritDoc} */
@Override
public CompletableFuture<Void> putAllAsync(@Nullable Transaction tx, Map<Tuple, Tuple> pairs) {
Objects.requireNonNull(pairs);
Objects.requireNonNull(pairs, "pairs");

if (pairs.isEmpty()) {
return nullCompletedFuture();
Expand All @@ -223,8 +223,8 @@ public Tuple getAndPut(@Nullable Transaction tx, Tuple key, Tuple val) {
/** {@inheritDoc} */
@Override
public CompletableFuture<Tuple> getAndPutAsync(@Nullable Transaction tx, Tuple key, Tuple val) {
Objects.requireNonNull(key);
Objects.requireNonNull(val);
Objects.requireNonNull(key, "key");
Objects.requireNonNull(val, "val");

return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_UPSERT,
Expand Down Expand Up @@ -264,8 +264,8 @@ public boolean putIfAbsent(@Nullable Transaction tx, Tuple key, Tuple val) {

/** {@inheritDoc} */
@Override
public CompletableFuture<Boolean> putIfAbsentAsync(@Nullable Transaction tx, Tuple key, Tuple val) {
Objects.requireNonNull(key);
public CompletableFuture<Boolean> putIfAbsentAsync(@Nullable Transaction tx, Tuple key, @Nullable Tuple val) {
Objects.requireNonNull(key, "key");

return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_INSERT,
Expand All @@ -290,7 +290,7 @@ public boolean remove(@Nullable Transaction tx, Tuple key, Tuple val) {
/** {@inheritDoc} */
@Override
public CompletableFuture<Boolean> removeAsync(@Nullable Transaction tx, Tuple key) {
Objects.requireNonNull(key);
Objects.requireNonNull(key, "key");

return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE,
Expand All @@ -303,8 +303,8 @@ public CompletableFuture<Boolean> removeAsync(@Nullable Transaction tx, Tuple ke
/** {@inheritDoc} */
@Override
public CompletableFuture<Boolean> removeAsync(@Nullable Transaction tx, Tuple key, Tuple val) {
Objects.requireNonNull(key);
Objects.requireNonNull(val);
Objects.requireNonNull(key, "key");
Objects.requireNonNull(val, "val");

return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_DELETE_EXACT,
Expand All @@ -323,7 +323,7 @@ public Collection<Tuple> removeAll(@Nullable Transaction tx, Collection<Tuple> k
/** {@inheritDoc} */
@Override
public CompletableFuture<Collection<Tuple>> removeAllAsync(@Nullable Transaction tx, Collection<Tuple> keys) {
Objects.requireNonNull(keys);
Objects.requireNonNull(keys, "keys");

if (keys.isEmpty()) {
return emptyCollectionCompletedFuture();
Expand All @@ -347,7 +347,7 @@ public Tuple getAndRemove(@Nullable Transaction tx, Tuple key) {
/** {@inheritDoc} */
@Override
public CompletableFuture<Tuple> getAndRemoveAsync(@Nullable Transaction tx, Tuple key) {
Objects.requireNonNull(key);
Objects.requireNonNull(key, "key");

return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_DELETE,
Expand Down Expand Up @@ -393,7 +393,7 @@ public boolean replace(@Nullable Transaction tx, Tuple key, Tuple oldVal, Tuple
/** {@inheritDoc} */
@Override
public CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, Tuple key, Tuple val) {
Objects.requireNonNull(key);
Objects.requireNonNull(key, "key");

return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_REPLACE,
Expand All @@ -406,7 +406,7 @@ public CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, Tuple k
/** {@inheritDoc} */
@Override
public CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, Tuple key, Tuple oldVal, Tuple newVal) {
Objects.requireNonNull(key);
Objects.requireNonNull(key, "key");

return tbl.doSchemaOutOpAsync(
ClientOp.TUPLE_REPLACE_EXACT,
Expand All @@ -428,8 +428,8 @@ public Tuple getAndReplace(@Nullable Transaction tx, Tuple key, Tuple val) {
/** {@inheritDoc} */
@Override
public CompletableFuture<Tuple> getAndReplaceAsync(@Nullable Transaction tx, Tuple key, Tuple val) {
Objects.requireNonNull(key);
Objects.requireNonNull(val);
Objects.requireNonNull(key, "key");
Objects.requireNonNull(val, "val");

return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_REPLACE,
Expand Down Expand Up @@ -466,7 +466,7 @@ public CompletableFuture<NullableValue<Tuple>> getNullableAndReplaceAsync(@Nulla
public CompletableFuture<Void> streamData(
Publisher<DataStreamerItem<Entry<Tuple, Tuple>>> publisher,
@Nullable DataStreamerOptions options) {
Objects.requireNonNull(publisher);
Objects.requireNonNull(publisher, "publisher");

var provider = new KeyValueTupleStreamerPartitionAwarenessProvider(tbl);
var opts = options == null ? DataStreamerOptions.DEFAULT : options;
Expand Down
Loading