This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new b54f5bbc0c IGNITE-20524 Fix nullable annotations and javadoc in
KeyValueView (#2818)
b54f5bbc0c is described below
commit b54f5bbc0c5867e72c51ad24985cdc9b3897dfb0
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Thu Nov 9 07:42:00 2023 +0200
IGNITE-20524 Fix nullable annotations and javadoc in KeyValueView (#2818)
`KeyValueView` allows null value in all methods when `OneColumnMapper` is
used. Reflect this in Javadoc and add `@Nullable` annotations accordingly.
---
.../java/org/apache/ignite/table/KeyValueView.java | 89 +++++++++++-----------
.../internal/client/table/ClientKeyValueView.java | 12 ++-
.../ignite/internal/marshaller/FieldAccessor.java | 6 +-
.../ignite/internal/marshaller/Marshaller.java | 6 +-
.../internal/schema/marshaller/KvMarshaller.java | 2 +-
.../marshaller/reflection/KvMarshallerImpl.java | 4 +-
.../marshaller/reflection/ObjectStatistics.java | 6 +-
.../ignite/internal/table/KeyValueViewImpl.java | 38 ++++-----
8 files changed, 86 insertions(+), 77 deletions(-)
diff --git
a/modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
b/modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
index 1bc9f99c2b..2ce7d764e8 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
@@ -49,7 +49,7 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
* @throws UnexpectedNullValueException If value for the key exists, and
it is {@code null}.
* @see #getNullable(Transaction, Object)
*/
- V get(@Nullable Transaction tx, K key);
+ @Nullable V get(@Nullable Transaction tx, K key);
/**
* Asynchronously gets a value associated with a given key.
@@ -96,7 +96,7 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
* @return Value or {@code defaultValue} if does not exist.
* @throws MarshallerException if the key doesn't match the schema.
*/
- V getOrDefault(@Nullable Transaction tx, K key, V defaultValue);
+ @Nullable V getOrDefault(@Nullable Transaction tx, K key, @Nullable V
defaultValue);
/**
* Gets a value associated with a given key, if it exists and is not null,
otherwise returns {@code defaultValue}.
@@ -108,7 +108,7 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
* @throws MarshallerException if the key doesn't match the schema.
* @see #getOrDefault(Transaction, Object, Object)
*/
- CompletableFuture<V> getOrDefaultAsync(@Nullable Transaction tx, K key, V
defaultValue);
+ CompletableFuture<V> getOrDefaultAsync(@Nullable Transaction tx, K key,
@Nullable V defaultValue);
/**
* Get values associated with given keys.
@@ -155,21 +155,21 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key with which the specified value is to be associated. The
key cannot be {@code null}.
- * @param val Value to be associated with the specified key.
+ * @param val Value to be associated with the specified key. Can be null
when mapped to a single column with a simple type.
* @throws MarshallerException if the key and/or the value doesn't match
the schema.
*/
- void put(@Nullable Transaction tx, K key, V val);
+ void put(@Nullable Transaction tx, K key, @Nullable V val);
/**
* Asynchronously puts into a table a value associated with the given key.
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key with which the specified value is to be associated. The
key cannot be {@code null}.
- * @param val Value to be associated with the specified key.
+ * @param val Value to be associated with the specified key. Can be null
when mapped to a single column with a simple type.
* @return Future that represents the pending completion of the operation.
* @throws MarshallerException if the key and/or the value doesn't match
the schema.
*/
- CompletableFuture<Void> putAsync(@Nullable Transaction tx, K key, V val);
+ CompletableFuture<Void> putAsync(@Nullable Transaction tx, K key,
@Nullable V val);
/**
* Puts associated key-value pairs.
@@ -193,73 +193,74 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
/**
* Puts into a table a new, or replaces an existing, value associated with
the given key.
*
- * <p>NB: The method doesn't support {@code null} value, use {@link
#getNullableAndPut(Transaction, Object, Object)} instead.
+ * <p>NB: The method doesn't support {@code null} column value, use {@link
#getNullableAndPut(Transaction, Object, Object)} instead.
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key with which the specified value is to be associated. The
key cannot be {@code null}.
- * @param val Value to be associated with the specified key. The value
cannot be {@code null}.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Replaced value or {@code null} if it did not exist.
* @throws MarshallerException if one of the keys or values doesn't match
the schema.
* @throws UnexpectedNullValueException If value for the key exists, and
it is {@code null}.
*/
- V getAndPut(@Nullable Transaction tx, K key, V val);
+ @Nullable V getAndPut(@Nullable Transaction tx, K key, @Nullable V val);
/**
* Asynchronously puts into a table a new, or replaces an existing, value
associated with given key.
*
- * <p>NB: The method doesn't support {@code null} value, use {@link
#getNullableAndPutAsync(Transaction, Object, Object)} instead.
+ * <p>NB: The method doesn't support {@code null} column value, use {@link
#getNullableAndPutAsync(Transaction, Object, Object)}
+ * instead.
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key with which the specified value is to be associated. The
key cannot be {@code null}.
- * @param val Value to be associated with the specified key. The value
cannot be {@code null}.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Future that represents the pending completion of the operation.
* @throws MarshallerException if the key and/or the value doesn't match
the schema.
*/
- CompletableFuture<V> getAndPutAsync(@Nullable Transaction tx, K key, V
val);
+ CompletableFuture<V> getAndPutAsync(@Nullable Transaction tx, K key,
@Nullable V val);
/**
* Puts into a table a new, or replaces an existing, value associated with
given key.
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key with which the specified value is to be associated. The
key cannot be {@code null}.
- * @param val Value to be associated with the specified key.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Wrapped nullable value that was replaced or {@code null} if it
did no exist.
* @throws MarshallerException if the key and/or the value doesn't match
the schema.
*/
- NullableValue<V> getNullableAndPut(@Nullable Transaction tx, K key, V val);
+ NullableValue<V> getNullableAndPut(@Nullable Transaction tx, K key,
@Nullable V val);
/**
* Asynchronously puts into a table a new, or replaces an existing, value
associated with given key.
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key with which the specified value is to be associated. The
key cannot be {@code null}.
- * @param val Value to be associated with the specified key.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Future that represents the pending completion of the operation.
* @throws MarshallerException if the key and/or the value doesn't match
the schema.
*/
- CompletableFuture<NullableValue<V>> getNullableAndPutAsync(@Nullable
Transaction tx, K key, V val);
+ CompletableFuture<NullableValue<V>> getNullableAndPutAsync(@Nullable
Transaction tx, K key, @Nullable V val);
/**
* Puts into a table a value associated with the given key if this value
does not exists.
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key with which the specified value is to be associated. The
key cannot be {@code null}.
- * @param val Value to be associated with the specified key.
+ * @param val 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 successful, {@code false} otherwise.
* @throws MarshallerException if the key and/or the value doesn't match
the schema.
*/
- boolean putIfAbsent(@Nullable Transaction tx, K key, V val);
+ boolean putIfAbsent(@Nullable Transaction tx, K key, @Nullable V val);
/**
* Asynchronously puts into a table a value associated with the given key
if this value does not exist.
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key with which the specified value is to be associated. The
key cannot be {@code null}.
- * @param val Value to be associated with the specified key.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Future that represents the pending completion of the operation.
* @throws MarshallerException if the key and/or the value doesn't match
the schema.
*/
- CompletableFuture<Boolean> putIfAbsentAsync(@Nullable Transaction tx, K
key, V val);
+ CompletableFuture<Boolean> putIfAbsentAsync(@Nullable Transaction tx, K
key, @Nullable V val);
/**
* Removes from a table a value associated with the given key.
@@ -326,7 +327,7 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
/**
* Gets and removes from a table a value associated with the given key.
*
- * <p>NB: Method doesn't support {@code null} value, use {@link
#getNullableAndRemove(Transaction, Object)} instead.
+ * <p>NB: Method doesn't support {@code null} column value, use {@link
#getNullableAndRemove(Transaction, Object)} instead.
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key whose value is to be removed from the table. The key
cannot be {@code null}.
@@ -334,12 +335,12 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
* @throws UnexpectedNullValueException If the key value is {@code null}.
* @throws MarshallerException if the key doesn't match the schema.
*/
- V getAndRemove(@Nullable Transaction tx, K key);
+ @Nullable V getAndRemove(@Nullable Transaction tx, K key);
/**
* Asynchronously gets and removes from a table a value associated with
the given key.
*
- * <p>NB: Method doesn't support {@code null} value, use {@link
#getNullableAndRemoveAsync(Transaction, Object)} instead.
+ * <p>NB: Method doesn't support {@code null} column value, use {@link
#getNullableAndRemoveAsync(Transaction, Object)} instead.
*
* @param tx Transaction or {@code null} to auto-commit.
* @param key Key whose value is to be removed from the table. The key
cannot be {@code null}.
@@ -381,11 +382,11 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
*
* @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 val Value to be associated with the specified key.
+ * @param val 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 and/or the value doesn't match
the schema.
*/
- boolean replace(@Nullable Transaction tx, K key, V val);
+ boolean replace(@Nullable Transaction tx, K key, @Nullable V val);
/**
* Replaces an expected value for a key. This is equivalent to
@@ -401,34 +402,35 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
* @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 newValue Value to be associated with the specified key.
+ * @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, V newValue);
+ boolean replace(@Nullable Transaction tx, K key, V oldValue, @Nullable V
newValue);
/**
* Asynchronously replaces a value for a key if it exists. See {@link
#replace(Transaction, Object, Object)}.
*
* @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 val Value to be associated with the specified key.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Future that represents the pending completion of the operation.
* @throws MarshallerException if the key or the oldValue doesn't match
the schema.
*/
- CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, K key, V
val);
+ CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, K key,
@Nullable V val);
/**
* Asynchronously replaces an expected value for a key. See {@link
#replace(Transaction, Object, Object, Object)}
*
* @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 oldVal Expected value associated with the specified key.
- * @param newVal Value to be associated with the specified key.
+ * @param oldVal Expected value associated with the specified key. Can be
{@code null} when mapped to a single column
+ * with a simple type.
+ * @param newVal Value to be associated with the specified key. Can be
{@code null} when mapped to a single column with a simple type.
* @return Future that represents the pending completion of the operation.
* @throws MarshallerException if the key, the oldValue, or the newValue
doesn't match the schema.
*/
- CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, K key, V
oldVal, V newVal);
+ CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, K key,
@Nullable V oldVal, @Nullable V newVal);
/**
* Replaces a value for a given key if it exists. This is equivalent to
@@ -443,52 +445,53 @@ public interface KeyValueView<K, V> extends
DataStreamerTarget<Entry<K, V>> {
* </code></pre>
* except the action is performed atomically.
*
- * <p>NB: Method doesn't support {@code null} value, use {@link
#getNullableAndReplace(Transaction, Object, Object)} instead.
+ * <p>NB: Method doesn't support {@code null} column value, use {@link
#getNullableAndReplace(Transaction, Object, Object)} instead.
*
* @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 val Value to be associated with the specified key. The value
cannot be {@code null}.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Replaced value, or {@code null} if it did not exist.
* @throws UnexpectedNullValueException If the value for the key is {@code
null}.
* @throws MarshallerException if the key, or the value doesn't match the
schema.
*/
- V getAndReplace(@Nullable Transaction tx, K key, V val);
+ @Nullable V getAndReplace(@Nullable Transaction tx, @Nullable K key,
@Nullable V val);
/**
* Asynchronously replaces a value for a given key if it exists.
*
- * <p>NB: Method doesn't support {@code null} value, use {@link
#getNullableAndReplaceAsync(Transaction, Object, Object)} instead.
+ * <p>NB: Method doesn't support {@code null} column value, use {@link
#getNullableAndReplaceAsync(Transaction, Object, Object)}
+ * instead.
*
* @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 val Value to be associated with the specified key.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Future that represents the pending completion of the operation.
* @throws MarshallerException if the key or the value doesn't match the
schema.
* @see #getAndReplace(Transaction, Object, Object)
*/
- CompletableFuture<V> getAndReplaceAsync(@Nullable Transaction tx, K key, V
val);
+ CompletableFuture<V> getAndReplaceAsync(@Nullable Transaction tx, K key,
@Nullable V val);
/**
* Replaces a value for a given key if it exists.
*
* @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 val Value to be associated with the specified key.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Wrapped nullable value that was replaced or {@code null} if it
did not exist.
* @throws MarshallerException if the key or the value doesn't match the
schema.
* @see #getAndReplace(Transaction, Object, Object)
*/
- NullableValue<V> getNullableAndReplace(@Nullable Transaction tx, K key, V
val);
+ NullableValue<V> getNullableAndReplace(@Nullable Transaction tx, K key,
@Nullable V val);
/**
* Asynchronously replaces a value for a given key if it exists.
*
* @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 val Value to be associated with the specified key.
+ * @param val Value to be associated with the specified key. Can be {@code
null} when mapped to a single column with a simple type.
* @return Future that represents the pending completion of the operation.
* @throws MarshallerException if the key or the value doesn't match the
schema.
* @see #getAndReplace(Transaction, Object, Object)
*/
- CompletableFuture<NullableValue<V>> getNullableAndReplaceAsync(@Nullable
Transaction tx, K key, V val);
+ CompletableFuture<NullableValue<V>> getNullableAndReplaceAsync(@Nullable
Transaction tx, K key, @Nullable V val);
}
diff --git
a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueView.java
b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueView.java
index c8f55c4dd7..2bccc85173 100644
---
a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueView.java
+++
b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientKeyValueView.java
@@ -110,6 +110,7 @@ public class ClientKeyValueView<K, V> implements
KeyValueView<K, V> {
/** {@inheritDoc} */
@Override
public CompletableFuture<NullableValue<V>> getNullableAsync(@Nullable
Transaction tx, K key) {
+ // TODO IGNITE-20807
throw new UnsupportedOperationException("Not implemented yet.");
}
@@ -122,6 +123,7 @@ public class ClientKeyValueView<K, V> implements
KeyValueView<K, V> {
/** {@inheritDoc} */
@Override
public CompletableFuture<V> getOrDefaultAsync(@Nullable Transaction tx, K
key, V defaultValue) {
+ // TODO IGNITE-20807
throw new UnsupportedOperationException("Not implemented yet.");
}
@@ -221,9 +223,8 @@ public class ClientKeyValueView<K, V> implements
KeyValueView<K, V> {
/** {@inheritDoc} */
@Override
- public CompletableFuture<V> getAndPutAsync(@Nullable Transaction tx, K
key, V val) {
+ public CompletableFuture<V> getAndPutAsync(@Nullable Transaction tx, K
key, @Nullable V val) {
Objects.requireNonNull(key);
- Objects.requireNonNull(val);
return tbl.doSchemaOutInOpAsync(
ClientOp.TUPLE_GET_AND_UPSERT,
@@ -242,6 +243,7 @@ public class ClientKeyValueView<K, V> implements
KeyValueView<K, V> {
/** {@inheritDoc} */
@Override
public CompletableFuture<NullableValue<V>>
getNullableAndPutAsync(@Nullable Transaction tx, K key, V val) {
+ // TODO IGNITE-20807
throw new UnsupportedOperationException("Not implemented yet.");
}
@@ -350,6 +352,7 @@ public class ClientKeyValueView<K, V> implements
KeyValueView<K, V> {
/** {@inheritDoc} */
@Override
public CompletableFuture<NullableValue<V>>
getNullableAndRemoveAsync(@Nullable Transaction tx, K key) {
+ // TODO IGNITE-20807
throw new UnsupportedOperationException("Not implemented yet.");
}
@@ -424,15 +427,16 @@ public class ClientKeyValueView<K, V> implements
KeyValueView<K, V> {
/** {@inheritDoc} */
@Override
public CompletableFuture<NullableValue<V>>
getNullableAndReplaceAsync(@Nullable Transaction tx, K key, V val) {
+ // TODO IGNITE-20807
throw new UnsupportedOperationException("Not implemented yet.");
}
- private void writeKeyValue(ClientSchema s, PayloadOutputChannel w,
@Nullable Transaction tx, K key, V val) {
+ private void writeKeyValue(ClientSchema s, PayloadOutputChannel w,
@Nullable Transaction tx, K key, @Nullable V val) {
writeSchemaAndTx(s, w, tx);
writeKeyValueRaw(s, w, key, val);
}
- private void writeKeyValueRaw(ClientSchema s, PayloadOutputChannel w, K
key, V val) {
+ private void writeKeyValueRaw(ClientSchema s, PayloadOutputChannel w, K
key, @Nullable V val) {
var builder = new BinaryTupleBuilder(s.columns().length);
var noValueSet = new BitSet();
ClientMarshallerWriter writer = new ClientMarshallerWriter(builder,
noValueSet);
diff --git
a/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/FieldAccessor.java
b/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/FieldAccessor.java
index 56d9af2a3d..d6712b5b1e 100644
---
a/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/FieldAccessor.java
+++
b/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/FieldAccessor.java
@@ -394,7 +394,7 @@ abstract class FieldAccessor {
* @param obj Source object.
* @throws MarshallerException If failed.
*/
- final void write(MarshallerWriter writer, Object obj) throws
MarshallerException {
+ final void write(MarshallerWriter writer, @Nullable Object obj) throws
MarshallerException {
try {
write0(writer, obj);
} catch (Exception ex) {
@@ -409,7 +409,7 @@ abstract class FieldAccessor {
* @param obj Source object.
* @throws Exception If write failed.
*/
- abstract void write0(MarshallerWriter writer, Object obj) throws Exception;
+ abstract void write0(MarshallerWriter writer, @Nullable Object obj) throws
Exception;
/**
* Reads value fom row to object field.
@@ -786,7 +786,7 @@ abstract class FieldAccessor {
}
@Override
- void write0(MarshallerWriter writer, Object obj) {
+ void write0(MarshallerWriter writer, @Nullable Object obj) {
assert writer != null;
if (obj == null) {
diff --git
a/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/Marshaller.java
b/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/Marshaller.java
index fd06c87685..7adbd581d3 100644
---
a/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/Marshaller.java
+++
b/modules/marshaller-common/src/main/java/org/apache/ignite/internal/marshaller/Marshaller.java
@@ -188,7 +188,7 @@ public abstract class Marshaller {
* @param writer Row writer.
* @throws MarshallerException If failed.
*/
- public abstract void writeObject(Object obj, MarshallerWriter writer)
throws MarshallerException;
+ public abstract void writeObject(@Nullable Object obj, MarshallerWriter
writer) throws MarshallerException;
/**
* Marshaller for objects of natively supported types.
@@ -223,7 +223,7 @@ public abstract class Marshaller {
/** {@inheritDoc} */
@Override
- public void writeObject(Object obj, MarshallerWriter writer) throws
MarshallerException {
+ public void writeObject(@Nullable Object obj, MarshallerWriter writer)
throws MarshallerException {
fieldAccessor.write(writer, obj);
}
}
@@ -269,7 +269,7 @@ public abstract class Marshaller {
/** {@inheritDoc} */
@Override
- public void writeObject(Object obj, MarshallerWriter writer) throws
MarshallerException {
+ public void writeObject(@Nullable Object obj, MarshallerWriter writer)
throws MarshallerException {
for (int fldIdx = 0; fldIdx < fieldAccessors.length; fldIdx++) {
fieldAccessors[fldIdx].write(writer, obj);
}
diff --git
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/KvMarshaller.java
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/KvMarshaller.java
index 640aa659e6..bb9224ff2a 100644
---
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/KvMarshaller.java
+++
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/KvMarshaller.java
@@ -51,7 +51,7 @@ public interface KvMarshaller<K, V> {
* @return Table row with columns from given key-value pair.
* @throws MarshallerException If failed to marshal key and/or value.
*/
- Row marshal(K key, V val) throws MarshallerException;
+ Row marshal(K key, @Nullable V val) throws MarshallerException;
/**
* Unmarshal given row to a key object.
diff --git
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/KvMarshallerImpl.java
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/KvMarshallerImpl.java
index 88bedaba59..45d3ebd888 100644
---
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/KvMarshallerImpl.java
+++
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/KvMarshallerImpl.java
@@ -87,7 +87,7 @@ public class KvMarshallerImpl<K, V> implements
KvMarshaller<K, V> {
/** {@inheritDoc} */
@Override
- public Row marshal(K key, V val) throws MarshallerException {
+ public Row marshal(K key, @Nullable V val) throws MarshallerException {
assert keyClass.isInstance(key);
assert val == null || valClass.isInstance(val);
@@ -153,7 +153,7 @@ public class KvMarshallerImpl<K, V> implements
KvMarshaller<K, V> {
* @return Row assembler.
* @throws MarshallerException If failed to read key or value object
content.
*/
- private RowAssembler createAssembler(Object key, Object val) throws
MarshallerException {
+ private RowAssembler createAssembler(Object key, @Nullable Object val)
throws MarshallerException {
try {
return ObjectStatistics.createAssembler(schema, keyMarsh,
valMarsh, key, val);
} catch (Throwable e) {
diff --git
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/ObjectStatistics.java
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/ObjectStatistics.java
index 05ad88bcd1..36040a9009 100644
---
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/ObjectStatistics.java
+++
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/ObjectStatistics.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.schema.Columns;
import org.apache.ignite.internal.schema.SchemaDescriptor;
import org.apache.ignite.internal.schema.row.RowAssembler;
import org.apache.ignite.internal.type.NativeType;
+import org.jetbrains.annotations.Nullable;
/**
* Object statistic.
@@ -48,7 +49,7 @@ class ObjectStatistics {
/**
* Reads object fields and gather statistic.
*/
- private static ObjectStatistics collectObjectStats(Columns cols,
Marshaller marsh, Object obj) {
+ private static ObjectStatistics collectObjectStats(Columns cols,
Marshaller marsh, @Nullable Object obj) {
if (obj == null) {
return ZERO_STATISTICS;
}
@@ -84,7 +85,8 @@ class ObjectStatistics {
return new RowAssembler(schema.keyColumns(), null, schema.version(),
totalValueSize);
}
- static RowAssembler createAssembler(SchemaDescriptor schema, Marshaller
keyMarsh, Marshaller valMarsh, Object key, Object val) {
+ static RowAssembler createAssembler(
+ SchemaDescriptor schema, Marshaller keyMarsh, Marshaller valMarsh,
Object key, @Nullable Object val) {
ObjectStatistics keyStat = collectObjectStats(schema.keyColumns(),
keyMarsh, key);
ObjectStatistics valStat = collectObjectStats(schema.valueColumns(),
valMarsh, val);
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java
index 2d92efd9bd..8f1179e251 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueViewImpl.java
@@ -181,13 +181,13 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public void put(@Nullable Transaction tx, K key, V val) {
+ public void put(@Nullable Transaction tx, K key, @Nullable V val) {
sync(putAsync(tx, key, val));
}
/** {@inheritDoc} */
@Override
- public CompletableFuture<Void> putAsync(@Nullable Transaction tx, K key, V
val) {
+ public CompletableFuture<Void> putAsync(@Nullable Transaction tx, K key,
@Nullable V val) {
Objects.requireNonNull(key);
return withSchemaSync(tx, (schemaVersion) -> {
@@ -220,13 +220,13 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public V getAndPut(@Nullable Transaction tx, K key, V val) {
+ public V getAndPut(@Nullable Transaction tx, K key, @Nullable V val) {
return sync(getAndPutAsync(tx, key, val));
}
/** {@inheritDoc} */
@Override
- public CompletableFuture<V> getAndPutAsync(@Nullable Transaction tx, K
key, V val) {
+ public CompletableFuture<V> getAndPutAsync(@Nullable Transaction tx, K
key, @Nullable V val) {
Objects.requireNonNull(key);
Objects.requireNonNull(val);
@@ -238,13 +238,13 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public NullableValue<V> getNullableAndPut(@Nullable Transaction tx, K key,
V val) {
+ public NullableValue<V> getNullableAndPut(@Nullable Transaction tx, K key,
@Nullable V val) {
return sync(getNullableAndPutAsync(tx, key, val));
}
/** {@inheritDoc} */
@Override
- public CompletableFuture<NullableValue<V>>
getNullableAndPutAsync(@Nullable Transaction tx, K key, V val) {
+ public CompletableFuture<NullableValue<V>>
getNullableAndPutAsync(@Nullable Transaction tx, K key, @Nullable V val) {
Objects.requireNonNull(key);
return withSchemaSync(tx, (schemaVersion) -> {
@@ -257,13 +257,13 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public boolean putIfAbsent(@Nullable Transaction tx, K key, V val) {
+ public boolean putIfAbsent(@Nullable Transaction tx, K key, @Nullable V
val) {
return sync(putIfAbsentAsync(tx, key, val));
}
/** {@inheritDoc} */
@Override
- public CompletableFuture<Boolean> putIfAbsentAsync(@Nullable Transaction
tx, K key, V val) {
+ public CompletableFuture<Boolean> putIfAbsentAsync(@Nullable Transaction
tx, K key, @Nullable V val) {
Objects.requireNonNull(key);
return withSchemaSync(tx, (schemaVersion) -> {
@@ -281,7 +281,7 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public boolean remove(@Nullable Transaction tx, K key, V val) {
+ public boolean remove(@Nullable Transaction tx, K key, @Nullable V val) {
return sync(removeAsync(tx, key, val));
}
@@ -299,7 +299,7 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public CompletableFuture<Boolean> removeAsync(@Nullable Transaction tx, K
key, V val) {
+ public CompletableFuture<Boolean> removeAsync(@Nullable Transaction tx, K
key, @Nullable V val) {
Objects.requireNonNull(key);
return withSchemaSync(tx, (schemaVersion) -> {
@@ -367,19 +367,19 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public boolean replace(@Nullable Transaction tx, K key, V val) {
+ public boolean replace(@Nullable Transaction tx, K key, @Nullable V val) {
return sync(replaceAsync(tx, key, val));
}
/** {@inheritDoc} */
@Override
- public boolean replace(@Nullable Transaction tx, K key, V oldVal, V
newVal) {
+ public boolean replace(@Nullable Transaction tx, K key, @Nullable V
oldVal, @Nullable V newVal) {
return sync(replaceAsync(tx, key, oldVal, newVal));
}
/** {@inheritDoc} */
@Override
- public CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, K
key, V val) {
+ public CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, K
key, @Nullable V val) {
Objects.requireNonNull(key);
return withSchemaSync(tx, (schemaVersion) -> {
@@ -391,7 +391,7 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, K
key, V oldVal, V newVal) {
+ public CompletableFuture<Boolean> replaceAsync(@Nullable Transaction tx, K
key, @Nullable V oldVal, @Nullable V newVal) {
Objects.requireNonNull(key);
return withSchemaSync(tx, (schemaVersion) -> {
@@ -404,13 +404,13 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public V getAndReplace(@Nullable Transaction tx, K key, V val) {
+ public V getAndReplace(@Nullable Transaction tx, K key, @Nullable V val) {
return sync(getAndReplaceAsync(tx, key, val));
}
/** {@inheritDoc} */
@Override
- public CompletableFuture<V> getAndReplaceAsync(@Nullable Transaction tx, K
key, V val) {
+ public CompletableFuture<V> getAndReplaceAsync(@Nullable Transaction tx, K
key, @Nullable V val) {
Objects.requireNonNull(key);
Objects.requireNonNull(val);
@@ -422,13 +422,13 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
/** {@inheritDoc} */
@Override
- public NullableValue<V> getNullableAndReplace(@Nullable Transaction tx, K
key, V val) {
+ public NullableValue<V> getNullableAndReplace(@Nullable Transaction tx, K
key, @Nullable V val) {
return sync(getNullableAndReplaceAsync(tx, key, val));
}
/** {@inheritDoc} */
@Override
- public CompletableFuture<NullableValue<V>>
getNullableAndReplaceAsync(@Nullable Transaction tx, K key, V val) {
+ public CompletableFuture<NullableValue<V>>
getNullableAndReplaceAsync(@Nullable Transaction tx, K key, @Nullable V val) {
Objects.requireNonNull(key);
return withSchemaSync(tx, (schemaVersion) -> {
@@ -486,7 +486,7 @@ public class KeyValueViewImpl<K, V> extends
AbstractTableView implements KeyValu
* @param schemaVersion Schema version to use when marshalling.
* @return Binary row.
*/
- private BinaryRowEx marshal(K key, V val, int schemaVersion) {
+ private BinaryRowEx marshal(K key, @Nullable V val, int schemaVersion) {
KvMarshaller<K, V> marsh = marshaller(schemaVersion);
try {