You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/02/02 11:28:43 UTC
[07/50] [abbrv] incubator-ignite git commit: minor fix for data
loader (add of single key optimizations) and example
minor fix for data loader (add of single key optimizations) and example
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ddbd18e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ddbd18e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ddbd18e4
Branch: refs/heads/ignite-16
Commit: ddbd18e4a3872cd31c036693650990e506334c99
Parents: 38164d0
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Wed Jan 28 19:12:59 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Wed Jan 28 19:12:59 2015 +0300
----------------------------------------------------------------------
.../datagrid/CacheDataLoaderExample.java | 15 ++++++----
.../dataload/IgniteDataLoaderImpl.java | 29 ++++++++++++++------
2 files changed, 31 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ddbd18e4/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java
index a7da7a6..853a72d 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java
@@ -58,11 +58,16 @@ public class CacheDataLoaderExample {
// Clean up caches on all nodes before run.
g.cache(CACHE_NAME).globalClearAll(0);
+ System.out.println();
+ System.out.println(">>> Cache clear finished.");
+
+ long start = System.currentTimeMillis();
+
try (IgniteDataLoader<Integer, String> ldr = g.dataLoader(CACHE_NAME)) {
// Configure loader.
ldr.perNodeBufferSize(1024);
-
- long start = System.currentTimeMillis();
+ ldr.perNodeParallelLoadOperations(8);
+ ldr.isolated(true);
for (int i = 0; i < ENTRY_COUNT; i++) {
ldr.addData(i, Integer.toString(i));
@@ -71,11 +76,11 @@ public class CacheDataLoaderExample {
if (i > 0 && i % 10000 == 0)
System.out.println("Loaded " + i + " keys.");
}
+ }
- long end = System.currentTimeMillis();
+ long end = System.currentTimeMillis();
- System.out.println(">>> Loaded " + ENTRY_COUNT + " keys in " + (end - start) + "ms.");
- }
+ System.out.println(">>> Loaded " + ENTRY_COUNT + " keys in " + (end - start) + "ms.");
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ddbd18e4/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
index 4b1f50c..fd9ab76 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
@@ -371,14 +371,18 @@ public class IgniteDataLoaderImpl<K, V> implements IgniteDataLoader<K, V>, Delay
try {
GridFutureAdapter<Object> resFut = new GridFutureAdapter<>(ctx);
+ resFut.listenAsync(rmvActiveFut);
+
activeFuts.add(resFut);
- resFut.listenAsync(rmvActiveFut);
+ Collection<K> keys = null;
- Collection<K> keys = new GridConcurrentHashSet<>(entries.size(), 1.0f, 16);
+ if (entries.size() > 1) {
+ keys = new GridConcurrentHashSet<>(entries.size(), U.capacity(entries.size()), 1);
- for (Map.Entry<K, V> entry : entries)
- keys.add(entry.getKey());
+ for (Map.Entry<K, V> entry : entries)
+ keys.add(entry.getKey());
+ }
load0(entries, resFut, keys, 0);
@@ -420,7 +424,7 @@ public class IgniteDataLoaderImpl<K, V> implements IgniteDataLoader<K, V>, Delay
private void load0(
Collection<? extends Map.Entry<K, V>> entries,
final GridFutureAdapter<Object> resFut,
- final Collection<K> activeKeys,
+ @Nullable final Collection<K> activeKeys,
final int remaps
) {
assert entries != null;
@@ -492,11 +496,20 @@ public class IgniteDataLoaderImpl<K, V> implements IgniteDataLoader<K, V>, Delay
try {
t.get();
- for (Map.Entry<K, V> e : entriesForNode)
- activeKeys.remove(e.getKey());
+ if (activeKeys != null) {
+ for (Map.Entry<K, V> e : entriesForNode)
+ activeKeys.remove(e.getKey());
- if (activeKeys.isEmpty())
+ if (activeKeys.isEmpty())
+ resFut.onDone();
+ }
+ else {
+ assert entriesForNode.size() == 1;
+
+ // That has been a single key,
+ // so complete result future right away.
resFut.onDone();
+ }
}
catch (IgniteCheckedException e1) {
if (log.isDebugEnabled())