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 2021/09/03 13:49:53 UTC
[ignite-3] 02/02: Fix styles.
This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch ignite-15438
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 36100f39e7215840f3ff1b31d26799ca23d3f580
Author: Andrew Mashenkov <an...@gmail.com>
AuthorDate: Fri Sep 3 16:49:41 2021 +0300
Fix styles.
---
.../internal/schema/row/TemporalTypesHelper.java | 2 +-
.../distributed/storage/InternalTableImpl.java | 74 ++++++++++------------
2 files changed, 34 insertions(+), 42 deletions(-)
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/TemporalTypesHelper.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/TemporalTypesHelper.java
index fce400d..cb188bd 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/TemporalTypesHelper.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/TemporalTypesHelper.java
@@ -243,7 +243,7 @@ public class TemporalTypesHelper {
break;
}
case 9: {
- nanos = nanos; // 1ns precision
+ // 1ns precision
break;
}
default: // Should never get here.
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java
index e6c10c3..4f0b1b9 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java
@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@@ -114,20 +115,14 @@ public class InternalTableImpl implements InternalTable {
}
/** {@inheritDoc} */
- @Override public CompletableFuture<Collection<BinaryRow>> getAll(Collection<BinaryRow> keyRows,
- Transaction tx) {
- HashMap<Integer, HashSet<BinaryRow>> keyRowsByPartition = new HashMap<>();
-
- for (BinaryRow keyRow : keyRows) {
- keyRowsByPartition.computeIfAbsent(partId(keyRow), HashSet::new)
- .add(keyRow);
- }
+ @Override public CompletableFuture<Collection<BinaryRow>> getAll(Collection<BinaryRow> keyRows, Transaction tx) {
+ Map<Integer, Set<BinaryRow>> keyRowsByPartition = mapRowsToPartitions(keyRows);
CompletableFuture<MultiRowsResponse>[] futures = new CompletableFuture[keyRowsByPartition.size()];
int batchNum = 0;
- for (Map.Entry<Integer, HashSet<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
+ for (Map.Entry<Integer, Set<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
futures[batchNum] = partitionMap.get(partToRows.getKey()).run(new GetAllCommand(partToRows.getValue()));
batchNum++;
@@ -148,18 +143,13 @@ public class InternalTableImpl implements InternalTable {
/** {@inheritDoc} */
@Override public CompletableFuture<Void> upsertAll(Collection<BinaryRow> rows, Transaction tx) {
- HashMap<Integer, HashSet<BinaryRow>> keyRowsByPartition = new HashMap<>();
-
- for (BinaryRow keyRow : rows) {
- keyRowsByPartition.computeIfAbsent(partId(keyRow), HashSet::new)
- .add(keyRow);
- }
+ Map<Integer, Set<BinaryRow>> keyRowsByPartition = mapRowsToPartitions(rows);
CompletableFuture<Void>[] futures = new CompletableFuture[keyRowsByPartition.size()];
int batchNum = 0;
- for (Map.Entry<Integer, HashSet<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
+ for (Map.Entry<Integer, Set<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
futures[batchNum] = partitionMap.get(partToRows.getKey()).run(new UpsertAllCommand(partToRows.getValue()));
batchNum++;
@@ -181,18 +171,13 @@ public class InternalTableImpl implements InternalTable {
/** {@inheritDoc} */
@Override public CompletableFuture<Collection<BinaryRow>> insertAll(Collection<BinaryRow> rows, Transaction tx) {
- HashMap<Integer, HashSet<BinaryRow>> keyRowsByPartition = new HashMap<>();
-
- for (BinaryRow keyRow : rows) {
- keyRowsByPartition.computeIfAbsent(partId(keyRow), HashSet::new)
- .add(keyRow);
- }
+ Map<Integer, Set<BinaryRow>> keyRowsByPartition = mapRowsToPartitions(rows);
CompletableFuture<MultiRowsResponse>[] futures = new CompletableFuture[keyRowsByPartition.size()];
int batchNum = 0;
- for (Map.Entry<Integer, HashSet<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
+ for (Map.Entry<Integer, Set<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
futures[batchNum] = partitionMap.get(partToRows.getKey()).run(new InsertAllCommand(partToRows.getValue()));
batchNum++;
@@ -240,20 +225,14 @@ public class InternalTableImpl implements InternalTable {
}
/** {@inheritDoc} */
- @Override public CompletableFuture<Collection<BinaryRow>> deleteAll(Collection<BinaryRow> rows,
- Transaction tx) {
- HashMap<Integer, HashSet<BinaryRow>> keyRowsByPartition = new HashMap<>();
-
- for (BinaryRow keyRow : rows) {
- keyRowsByPartition.computeIfAbsent(partId(keyRow), HashSet::new)
- .add(keyRow);
- }
+ @Override public CompletableFuture<Collection<BinaryRow>> deleteAll(Collection<BinaryRow> rows, Transaction tx) {
+ Map<Integer, Set<BinaryRow>> keyRowsByPartition = mapRowsToPartitions(rows);
CompletableFuture<MultiRowsResponse>[] futures = new CompletableFuture[keyRowsByPartition.size()];
int batchNum = 0;
- for (Map.Entry<Integer, HashSet<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
+ for (Map.Entry<Integer, Set<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
futures[batchNum] = partitionMap.get(partToRows.getKey()).run(new DeleteAllCommand(partToRows.getValue()));
batchNum++;
@@ -268,20 +247,17 @@ public class InternalTableImpl implements InternalTable {
}
/** {@inheritDoc} */
- @Override public CompletableFuture<Collection<BinaryRow>> deleteAllExact(Collection<BinaryRow> rows,
- Transaction tx) {
- HashMap<Integer, HashSet<BinaryRow>> keyRowsByPartition = new HashMap<>();
-
- for (BinaryRow keyRow : rows) {
- keyRowsByPartition.computeIfAbsent(partId(keyRow), HashSet::new)
- .add(keyRow);
- }
+ @Override public CompletableFuture<Collection<BinaryRow>> deleteAllExact(
+ Collection<BinaryRow> rows,
+ Transaction tx
+ ) {
+ Map<Integer, Set<BinaryRow>> keyRowsByPartition = mapRowsToPartitions(rows);
CompletableFuture<MultiRowsResponse>[] futures = new CompletableFuture[keyRowsByPartition.size()];
int batchNum = 0;
- for (Map.Entry<Integer, HashSet<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
+ for (Map.Entry<Integer, Set<BinaryRow>> partToRows : keyRowsByPartition.entrySet()) {
futures[batchNum] = partitionMap.get(partToRows.getKey()).run(new DeleteExactAllCommand(partToRows.getValue()));
batchNum++;
@@ -296,6 +272,22 @@ public class InternalTableImpl implements InternalTable {
}
/**
+ * Map rows to partitions.
+ *
+ * @param rows Rows.
+ * @return Partition -%gt; rows mapping.
+ */
+ private Map<Integer, Set<BinaryRow>> mapRowsToPartitions(Collection<BinaryRow> rows) {
+ //TODO: IGNITE-15400 Use IntMap structure instead of HashMap.
+ HashMap<Integer, Set<BinaryRow>> keyRowsByPartition = new HashMap<>();
+
+ for (BinaryRow keyRow : rows)
+ keyRowsByPartition.computeIfAbsent(partId(keyRow), k -> new HashSet<>()).add(keyRow);
+
+ return keyRowsByPartition;
+ }
+
+ /**
* Get partition id by key row.
*
* @param row Key row.