You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2022/07/29 14:45:23 UTC

[ignite-3] branch ignite-14487 created (now c8fe4a2f8)

This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a change to branch ignite-14487
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


      at c8fe4a2f8 Minor.

This branch includes the following new commits:

     new c8fe4a2f8 Minor.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[ignite-3] 01/01: Minor.

Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch ignite-14487
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit c8fe4a2f898484dac240284361fde686fb027dde
Author: Andrew V. Mashenkov <an...@gmail.com>
AuthorDate: Fri Jul 29 17:44:56 2022 +0300

    Minor.
---
 .../internal/table/KeyValueBinaryViewImpl.java     | 19 ++++++----
 .../ignite/internal/table/KeyValueViewImpl.java    | 42 +++++++++++-----------
 .../internal/table/RecordBinaryViewImpl.java       | 25 +++++++------
 .../ignite/internal/table/RecordViewImpl.java      | 23 ++++++------
 4 files changed, 59 insertions(+), 50 deletions(-)

diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java
index de010b3d1..a5b47e485 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.table;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -475,8 +476,8 @@ public class KeyValueBinaryViewImpl extends AbstractTableView implements KeyValu
      * @param rows Binary rows.
      * @return Key-value pairs of tuples.
      */
-    public Map<Tuple, Tuple> unmarshalValue(Collection<BinaryRow> rows) {
-        Map<Tuple, Tuple> pairs = new HashMap<>();
+    private Map<Tuple, Tuple> unmarshalValue(Collection<BinaryRow> rows) {
+        Map<Tuple, Tuple> pairs = new HashMap<>(rows.size());
 
         for (Row row : schemaReg.resolve(rows)) {
             if (row.hasValue()) {
@@ -493,13 +494,15 @@ public class KeyValueBinaryViewImpl extends AbstractTableView implements KeyValu
      * @param keys Key tuples.
      * @return Rows.
      */
-    public List<BinaryRowEx> marshalKeys(@NotNull Collection<Tuple> keys) {
+    private List<BinaryRowEx> marshalKeys(Collection<Tuple> keys) {
+        if (keys.isEmpty()) {
+            return Collections.emptyList();
+        }
+
         List<BinaryRowEx> keyRows = new ArrayList<>(keys.size());
 
         for (Tuple keyRec : keys) {
-            final Row keyRow = marshal(Objects.requireNonNull(keyRec), null);
-
-            keyRows.add(keyRow);
+            keyRows.add(marshal(Objects.requireNonNull(keyRec), null));
         }
         return keyRows;
     }
@@ -511,6 +514,10 @@ public class KeyValueBinaryViewImpl extends AbstractTableView implements KeyValu
      * @return Value tuple.
      */
     private Collection<Tuple> unmarshalKeys(Collection<BinaryRow> rows) {
+        if (rows.isEmpty()) {
+            return Collections.emptyList();
+        }
+
         List<Tuple> tuples = new ArrayList<>(rows.size());
 
         for (Row row : schemaReg.resolve(rows)) {
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 82db8bdd8..b636c4e38 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
@@ -450,17 +450,18 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
      * @param keys Key objects.
      * @return Binary rows.
      */
-    @NotNull
-    public Collection<BinaryRowEx> marshal(@NotNull Collection<K> keys) {
-        final KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
+    private Collection<BinaryRowEx> marshal(Collection<K> keys) {
+        if (keys.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
 
         List<BinaryRowEx> keyRows = new ArrayList<>(keys.size());
 
         try {
             for (K key : keys) {
-                final BinaryRowEx keyRow = marsh.marshal(Objects.requireNonNull(key));
-
-                keyRows.add(keyRow);
+                keyRows.add(marsh.marshal(Objects.requireNonNull(key)));
             }
         } catch (MarshallerException e) {
             throw new org.apache.ignite.lang.MarshallerException(e);
@@ -475,17 +476,18 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
      * @param pairs Key-value map.
      * @return Binary rows.
      */
-    @NotNull
-    public List<BinaryRowEx> marshal(@NotNull Map<K, V> pairs) {
-        final KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
+    private List<BinaryRowEx> marshal(Map<K, V> pairs) {
+        if (pairs.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
 
         List<BinaryRowEx> rows = new ArrayList<>(pairs.size());
 
         try {
             for (Map.Entry<K, V> pair : pairs.entrySet()) {
-                final BinaryRowEx row = marsh.marshal(Objects.requireNonNull(pair.getKey()), pair.getValue());
-
-                rows.add(row);
+                rows.add(marsh.marshal(Objects.requireNonNull(pair.getKey()), pair.getValue()));
             }
         } catch (MarshallerException e) {
             throw new org.apache.ignite.lang.MarshallerException(e);
@@ -500,13 +502,12 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
      * @param rows Binary rows.
      * @return Keys.
      */
-    @NotNull
-    public Collection<K> unmarshalKeys(Collection<BinaryRow> rows) {
+    private Collection<K> unmarshalKeys(Collection<BinaryRow> rows) {
         if (rows.isEmpty()) {
             return Collections.emptyList();
         }
 
-        final KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
+        KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
 
         List<K> keys = new ArrayList<>(rows.size());
 
@@ -529,8 +530,8 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
      * @param binaryRow Binary row.
      * @return Value object or {@code null} if not exists.
      */
-    private V unmarshalNullableValue(BinaryRow binaryRow) {
-        if (binaryRow == null || !binaryRow.hasValue()) {
+    private @Nullable V unmarshalNullableValue(BinaryRow binaryRow) {
+        if (!binaryRow.hasValue()) {
             return null;
         }
 
@@ -551,13 +552,12 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
      * @param rows Binary rows.
      * @return Key-value pairs.
      */
-    @NotNull
-    public Map<K, V> unmarshalPairs(Collection<BinaryRow> rows) {
+    private Map<K, V> unmarshalPairs(Collection<BinaryRow> rows) {
         if (rows.isEmpty()) {
             return Collections.emptyMap();
         }
 
-        final KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
+        KvMarshaller<K, V> marsh = marshaller(schemaReg.lastSchemaVersion());
 
         Map<K, V> pairs = new HashMap<>(rows.size());
 
@@ -580,7 +580,7 @@ public class KeyValueViewImpl<K, V> extends AbstractTableView implements KeyValu
      * @return Value object or {@code null} if not exists.
      * @throws UnexpectedNullValueException if value object is null.
      */
-    private V unmarshallValue(BinaryRow binaryRow) {
+    private @Nullable V unmarshallValue(@Nullable BinaryRow binaryRow) {
         if (binaryRow == null) {
             return null;
         }
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java
index a9b5a3598..f06cbb902 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java
@@ -17,11 +17,10 @@
 
 package org.apache.ignite.internal.table;
 
-import static java.util.stream.Collectors.toList;
-
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
@@ -356,14 +355,8 @@ public class RecordBinaryViewImpl extends AbstractTableView implements RecordVie
      *
      * @param row Binary row.
      */
-    private Tuple wrap(BinaryRow row) {
-        if (row == null) {
-            return null;
-        }
-
-        final Row wrapped = schemaReg.resolve(row);
-
-        return TableRow.tuple(wrapped);
+    private @Nullable Tuple wrap(@Nullable BinaryRow row) {
+        return row == null ? null : TableRow.tuple(schemaReg.resolve(row));
     }
 
     /**
@@ -372,7 +365,17 @@ public class RecordBinaryViewImpl extends AbstractTableView implements RecordVie
      * @param rows Binary rows.
      */
     private Collection<Tuple> wrap(Collection<BinaryRow> rows) {
-        return rows.stream().filter(Objects::nonNull).map(schemaReg::resolve).map(TableRow::tuple).collect(toList());
+        if (rows.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        Collection<Tuple> wrapped = new ArrayList<>(rows.size());
+
+        for (Row row : schemaReg.resolve(rows)) {
+            wrapped.add(row == null ? null : TableRow.tuple(row));
+        }
+
+        return wrapped;
     }
 
     /**
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
index 4ccce3540..408eed526 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
@@ -337,8 +337,8 @@ public class RecordViewImpl<R> extends AbstractTableView implements RecordView<R
      * @param rec Record object.
      * @return Binary row.
      */
-    private BinaryRowEx marshal(@NotNull R rec) {
-        final RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
+    private BinaryRowEx marshal(R rec) {
+        RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
 
         try {
             return marsh.marshal(rec);
@@ -353,14 +353,14 @@ public class RecordViewImpl<R> extends AbstractTableView implements RecordView<R
      * @param recs Records collection.
      * @return Binary rows collection.
      */
-    private Collection<BinaryRowEx> marshal(@NotNull Collection<R> recs) {
-        final RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
+    private Collection<BinaryRowEx> marshal(Collection<R> recs) {
+        RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
 
         List<BinaryRowEx> rows = new ArrayList<>(recs.size());
 
         try {
             for (R rec : recs) {
-                final Row row = marsh.marshal(Objects.requireNonNull(rec));
+                Row row = marsh.marshal(Objects.requireNonNull(rec));
 
                 rows.add(row);
             }
@@ -378,7 +378,7 @@ public class RecordViewImpl<R> extends AbstractTableView implements RecordView<R
      * @return Binary row.
      */
     private BinaryRowEx marshalKey(@NotNull R rec) {
-        final RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
+        RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
 
         try {
             return marsh.marshalKey(rec);
@@ -393,14 +393,14 @@ public class RecordViewImpl<R> extends AbstractTableView implements RecordView<R
      * @param recs Records collection.
      * @return Binary rows collection.
      */
-    private Collection<BinaryRowEx> marshalKeys(@NotNull Collection<R> recs) {
-        final RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
+    private Collection<BinaryRowEx> marshalKeys(Collection<R> recs) {
+        RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
 
         List<BinaryRowEx> rows = new ArrayList<>(recs.size());
 
         try {
             for (R rec : recs) {
-                final Row row = marsh.marshalKey(Objects.requireNonNull(rec));
+                Row row = marsh.marshalKey(Objects.requireNonNull(rec));
 
                 rows.add(row);
             }
@@ -439,13 +439,12 @@ public class RecordViewImpl<R> extends AbstractTableView implements RecordView<R
      * @param rows Row collection.
      * @return Records collection.
      */
-    @NotNull
-    public Collection<R> unmarshal(Collection<BinaryRow> rows) {
+    private Collection<R> unmarshal(Collection<BinaryRow> rows) {
         if (rows.isEmpty()) {
             return Collections.emptyList();
         }
 
-        final RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
+        RecordMarshaller<R> marsh = marshaller(schemaReg.lastSchemaVersion());
 
         List<R> recs = new ArrayList<>(rows.size());