ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: # IGNITE-32 WIP: Store implementation.
Date Tue, 13 Jan 2015 04:44:15 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-32 2a89ce079 -> b3a0f5894


# IGNITE-32 WIP: Store implementation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b3a0f589
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b3a0f589
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b3a0f589

Branch: refs/heads/ignite-32
Commit: b3a0f5894fe9e73b347215ba6d6c01d53bcd7f11
Parents: 2a89ce0
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Tue Jan 13 11:44:29 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Tue Jan 13 11:44:29 2015 +0700

----------------------------------------------------------------------
 .../grid/cache/store/auto/AutoCacheStore.java   | 23 +++++++++++++++-----
 .../grid/cache/store/auto/H2PojoCacheStore.java | 11 ++++++----
 .../grid/cache/store/auto/PojoJdbcMapper.java   | 15 +++++++------
 3 files changed, 32 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3a0f589/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/AutoCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/AutoCacheStore.java
b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/AutoCacheStore.java
index 6dfcc3d..ff7974b 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/AutoCacheStore.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/AutoCacheStore.java
@@ -114,7 +114,7 @@ public abstract class AutoCacheStore<K, V> implements GridCacheStore<K,
V> {
          * @param keyCnt Key count.
          */
         protected String loadQueryLast(int keyCnt) {
-            assert keyCnt > loadBatchSize;
+            assert keyCnt >= loadBatchSize;
 
             if (keyCnt == loadBatchSize)
                 return loadQry;
@@ -242,7 +242,7 @@ public abstract class AutoCacheStore<K, V> implements GridCacheStore<K,
V> {
      * @param conn Allocated connection.
      * @param st Created statement,
      */
-    protected void end(@Nullable IgniteTx tx, Connection conn, Statement st) {
+    protected void end(@Nullable IgniteTx tx, @Nullable Connection conn, @Nullable Statement
st) {
         U.closeQuiet(st);
 
         if (tx == null)
@@ -271,7 +271,7 @@ public abstract class AutoCacheStore<K, V> implements GridCacheStore<K,
V> {
      *
      * @param conn Connection to close.
      */
-    protected void closeConnection(Connection conn) {
+    protected void closeConnection(@Nullable Connection conn) {
         U.closeQuiet(conn);
     }
 
@@ -859,7 +859,7 @@ public abstract class AutoCacheStore<K, V> implements GridCacheStore<K,
V> {
     }
 
     /** {@inheritDoc} */
-    @Override public final void putAll(@Nullable IgniteTx tx, Map<? extends K, ? extends
V> map)
+    @Override public final void putAll(@Nullable final IgniteTx tx, Map<? extends K, ?
extends V> map)
         throws IgniteCheckedException {
         Map<Object, Collection<Map.Entry<? extends K, ? extends V>>> keyByType
= U.newHashMap(typesCache.size());
 
@@ -874,8 +874,19 @@ public abstract class AutoCacheStore<K, V> implements GridCacheStore<K,
V> {
             batch.add(entry);
         }
 
-        for (Map.Entry<Object, Collection<Map.Entry<? extends K, ? extends V>>>
m : keyByType.entrySet())
-            putAll(tx, m.getKey(), m.getValue());
+        final Collection<Future<?>> futs = new ArrayList<>();
+
+        for (final Map.Entry<Object, Collection<Map.Entry<? extends K, ? extends
V>>> entry : keyByType.entrySet())
+            futs.add(exec.submit(new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    putAll(tx, entry.getKey(), entry.getValue());
+
+                    return null;
+                }
+            }));
+
+        for (Future<?> fut : futs)
+            U.get(fut);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3a0f589/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
index e35467b..e439fa7 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/H2PojoCacheStore.java
@@ -31,11 +31,14 @@ public class H2PojoCacheStore extends AutoCacheStore<Object, Object>
{
         typesCache = U.newHashMap(typeMetadata.size());
 
         for (GridCacheQueryTypeMetadata type : typeMetadata) {
-            Set<String> paramNames = new LinkedHashSet<>(databaseColumns(type.getValueDescriptors()));
-            paramNames.removeAll(databaseColumns(type.getKeyDescriptors()));
+            Collection<String> excludeValCols = new LinkedHashSet<>(databaseColumns(type.getValueDescriptors()));
 
-            PojoJdbcMapper keyMapper = new PojoJdbcMapper(type.getKeyType(), type.getKeyDescriptors(),
null);
-            PojoJdbcMapper valMapper = new PojoJdbcMapper(type.getType(), type.getValueDescriptors(),
paramNames);
+            excludeValCols.retainAll(databaseColumns(type.getKeyDescriptors()));
+
+            PojoJdbcMapper keyMapper = new PojoJdbcMapper(type.getKeyType(), type.getKeyDescriptors(),
+                Collections.<String>emptyList());
+
+            PojoJdbcMapper valMapper = new PojoJdbcMapper(type.getType(), type.getValueDescriptors(),
excludeValCols);
 
             typesCache.put(keyMapper.cls, new TypeCache(type, keyMapper, valMapper));
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b3a0f589/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/PojoJdbcMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/PojoJdbcMapper.java
b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/PojoJdbcMapper.java
index 6606c707..f1544a9 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/PojoJdbcMapper.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/store/auto/PojoJdbcMapper.java
@@ -30,20 +30,21 @@ public class PojoJdbcMapper implements JdbcMapper<Object> {
     /** Database column names. */
     private final String[] colNames;
 
-    /** Cached getters for POJO object. */
-    private final Method[] getters;
-
     /** Cached setters for POJO object. */
     private final Method[] setters;
 
+    /** Cached getters for POJO object. */
+    private final Method[] getters;
+
     /**
      * @param clsName POJO class name.
      * @param descs Fields descriptors.
-     * @param paramNames Parameter for set from this object.
+     * @param excludeCols Columns for exclude from set parameters.
      */
     protected PojoJdbcMapper(String clsName, Collection<GridCacheQueryTypeDescriptor>
descs,
-        @Nullable Collection<String> paramNames) throws IgniteCheckedException {
+        Collection<String> excludeCols) throws IgniteCheckedException {
         assert descs != null && !descs.isEmpty();
+        assert excludeCols != null;
 
         try {
             cls = Class.forName(clsName);
@@ -62,7 +63,7 @@ public class PojoJdbcMapper implements JdbcMapper<Object> {
 
         colNames = new String[descs.size()];
 
-        List<Method> getters = new ArrayList<>(descs.size());
+        List<Method> getters = new ArrayList<>(descs.size() - excludeCols.size());
 
         setters = new Method[descs.size()];
 
@@ -81,7 +82,7 @@ public class PojoJdbcMapper implements JdbcMapper<Object> {
                     " of class: " + clsName, e);
             }
 
-            if (paramNames == null || paramNames.contains(colNames[i])) {
+            if (!excludeCols.contains(colNames[i])) {
                 try {
                     getters.add(cls.getMethod("get" + prop));
                 }


Mime
View raw message