You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/12/28 13:14:55 UTC

[GitHub] [ignite-3] korlov42 commented on a change in pull request #510: IGNITE-16115: Implement getOrDefault and getNullable key-value operations.

korlov42 commented on a change in pull request #510:
URL: https://github.com/apache/ignite-3/pull/510#discussion_r775784892



##########
File path: modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
##########
@@ -66,62 +66,52 @@
     /**
      * Gets a nullable value associated with the given key.
      *
-     * @param tx  The transaction or {@code null} to auto commit.
+     * @param tx The transaction or {@code null} to auto commit.
      * @param key A key which associated the value is to be returned. The key cannot be {@code null}.
      * @return Wrapped nullable value or {@code null}, if it does not exist.
      */
-    default NullableValue<V> getNullable(@Nullable Transaction tx, K key) {
-        //TODO: to be implemented https://issues.apache.org/jira/browse/IGNITE-16115
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
+    NullableValue<V> getNullable(@Nullable Transaction tx, @NotNull K key);
 
     /**
      * Gets a nullable value associated with the given key.
      *
-     * @param tx  The transaction or {@code null} to auto commit.
+     * @param tx The transaction or {@code null} to auto commit.
      * @param key A key which associated the value is to be returned. The key cannot be {@code null}.
      * @return Future representing pending completion of the operation.
      * @see #getNullable(Transaction, Object)
      */
-    default @NotNull CompletableFuture<NullableValue<V>> getNullableAsync(@Nullable Transaction tx, K key) {
-        //TODO: to be implemented https://issues.apache.org/jira/browse/IGNITE-16115
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
+    @NotNull CompletableFuture<NullableValue<V>> getNullableAsync(@Nullable Transaction tx, @NotNull K key);
 
     /**
      * Gets a value associated with the given key if exists, returns {@code defaultValue} otherwise.
      *
-     * <p>Note: method has same semantic as {@link #get(Transaction, Object)} with regard to {@code null} values.
+     * <p>Note: result may be {@code null} if null-values are allowed, and the {@code null} is associated with the key.
      *
-     * @param tx  The transaction or {@code null} to auto commit.
+     * @param tx The transaction or {@code null} to auto commit.
      * @param key A key which associated the value is to be returned. The key cannot be {@code null}.
+     * @param defaultValue Default value that. The value cannot be {@code null}.
      * @return Value or {@code defaultValue}, if does not exist.
      * @throws IllegalStateException If value for the key exists, and it is {@code null}.
      */
-    default V getOrDefault(@Nullable Transaction tx, K key, V defaultValue) {
-        //TODO: to be implemented https://issues.apache.org/jira/browse/IGNITE-16115
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
+    V getOrDefault(@Nullable Transaction tx, @NotNull K key, @NotNull V defaultValue);
 
     /**
-     * Gets a nullable value associated with the given key.
+     * Gets a value associated with the given key if exists, returns {@code defaultValue} otherwise.

Review comment:
       ```suggestion
        * Returns a value associated with the given key if exists, returns {@code defaultValue} otherwise.
   ```

##########
File path: modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
##########
@@ -223,7 +213,7 @@ default V getOrDefault(@Nullable Transaction tx, K key, V defaultValue) {
     /**
      * Asynchronously puts value associated with given key into the table if not exists.
      *
-     * @param tx  The transaction or {@code null} to auto commit.

Review comment:
       AFAIK all descriptions should be aligned within a group (all `param`s descriptions, all `throw`s descriptions). Could you please fix this everywhere in this PR?

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/registry/SchemaRegistryImpl.java
##########
@@ -145,40 +146,48 @@ public Row resolve(BinaryRow row) {
 
     /** {@inheritDoc} */
     @Override
-    public Collection<Row> resolve(Collection<BinaryRow> rows) {
+    public Collection<Row> resolve(Collection<BinaryRow> binaryRows) {
         final SchemaDescriptor curSchema = waitLatestSchema();
 
-        return rows.stream().map(row -> resolveInternal(row, curSchema)).collect(toList());
+        List<Row> rows = new ArrayList<>(binaryRows.size());
+
+        for (BinaryRow r : binaryRows) {
+            if (r != null) {
+                rows.add(resolveInternal(r, curSchema));
+            }
+        }
+
+        return rows;
     }
 
     /**
-     * Resolves a schema for row.
-     * The method is optimal when the latest schema is already gotten.
+     * Resolves a schema for row. The method is optimal when the latest schema is already got.
      *
-     * @param row       Binary row.
+     * @param row Binary row.
      * @param curSchema The latest available local schema.
-     * @return Schema-aware rows.
+     * @return Schema-aware row or {@code null} of the given row is null.

Review comment:
       ```suggestion
        * @return Schema-aware row or {@code null} if the given row is null.
   ```

##########
File path: modules/api/src/main/java/org/apache/ignite/table/KeyValueView.java
##########
@@ -66,62 +66,52 @@
     /**
      * Gets a nullable value associated with the given key.
      *
-     * @param tx  The transaction or {@code null} to auto commit.
+     * @param tx The transaction or {@code null} to auto commit.
      * @param key A key which associated the value is to be returned. The key cannot be {@code null}.
      * @return Wrapped nullable value or {@code null}, if it does not exist.
      */
-    default NullableValue<V> getNullable(@Nullable Transaction tx, K key) {
-        //TODO: to be implemented https://issues.apache.org/jira/browse/IGNITE-16115
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
+    NullableValue<V> getNullable(@Nullable Transaction tx, @NotNull K key);
 
     /**
      * Gets a nullable value associated with the given key.
      *
-     * @param tx  The transaction or {@code null} to auto commit.
+     * @param tx The transaction or {@code null} to auto commit.
      * @param key A key which associated the value is to be returned. The key cannot be {@code null}.
      * @return Future representing pending completion of the operation.
      * @see #getNullable(Transaction, Object)
      */
-    default @NotNull CompletableFuture<NullableValue<V>> getNullableAsync(@Nullable Transaction tx, K key) {
-        //TODO: to be implemented https://issues.apache.org/jira/browse/IGNITE-16115
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
+    @NotNull CompletableFuture<NullableValue<V>> getNullableAsync(@Nullable Transaction tx, @NotNull K key);
 
     /**
      * Gets a value associated with the given key if exists, returns {@code defaultValue} otherwise.
      *
-     * <p>Note: method has same semantic as {@link #get(Transaction, Object)} with regard to {@code null} values.
+     * <p>Note: result may be {@code null} if null-values are allowed, and the {@code null} is associated with the key.
      *
-     * @param tx  The transaction or {@code null} to auto commit.
+     * @param tx The transaction or {@code null} to auto commit.
      * @param key A key which associated the value is to be returned. The key cannot be {@code null}.
+     * @param defaultValue Default value that. The value cannot be {@code null}.
      * @return Value or {@code defaultValue}, if does not exist.
      * @throws IllegalStateException If value for the key exists, and it is {@code null}.
      */
-    default V getOrDefault(@Nullable Transaction tx, K key, V defaultValue) {
-        //TODO: to be implemented https://issues.apache.org/jira/browse/IGNITE-16115
-        throw new UnsupportedOperationException("Not implemented yet.");
-    }
+    V getOrDefault(@Nullable Transaction tx, @NotNull K key, @NotNull V defaultValue);
 
     /**
-     * Gets a nullable value associated with the given key.
+     * Gets a value associated with the given key if exists, returns {@code defaultValue} otherwise.
      *
-     * <p>Note: method has same semantic as {@link #get(Transaction, Object)} with regard to {@code null} values.
+     * <p>Note: result may be {@code null} if null-values are allowed, and the {@code null} is associated with the key.
      *
-     * @param tx  The transaction or {@code null} to auto commit.
+     * @param tx The transaction or {@code null} to auto commit.
      * @param key A key which associated the value is to be returned. The key cannot be {@code null}.
+     * @param defaultValue Default value that. The value cannot be {@code null}.

Review comment:
       looks like something missing in this description




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org