ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [1/2] ignite git commit: IGNITE-1806 Refactored java code generation in case of one field in index.
Date Fri, 20 Nov 2015 06:36:53 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc1 1b5bfce1d -> f639220cf


IGNITE-1806 Refactored java code generation in case of one field in index.


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

Branch: refs/heads/ignite-843-rc1
Commit: c15f6dadcbeec2c46b5a5a02b6a70de932e5d259
Parents: 5ed01cf
Author: vsisko <vsisko@gridgain.com>
Authored: Fri Nov 20 13:36:56 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Nov 20 13:36:56 2015 +0700

----------------------------------------------------------------------
 .../main/js/helpers/generator/generator-java.js | 41 +++++++++++++-------
 1 file changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c15f6dad/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/helpers/generator/generator-java.js b/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
index 6428b01..19c181d 100644
--- a/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
+++ b/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
@@ -1108,30 +1108,41 @@ $generatorJava.metadataQueryIndexes = function (res, meta) {
         $generatorJava.declareVariable(res, 'indexes', 'java.util.List', 'java.util.ArrayList',
'org.apache.ignite.cache.QueryIndex');
 
         _.forEach(indexes, function (index) {
-            res.needEmptyLine = true;
+            var fields = index.fields;
 
-            $generatorJava.declareVariable(res, 'index', 'org.apache.ignite.cache.QueryIndex');
+            // One row generation for 1 field index.
+            if (fields && fields.length == 1) {
+                var field = index.fields[0];
 
-            $generatorJava.property(res, 'index', index, 'name');
-            $generatorJava.property(res, 'index', index, 'indexType', 'org.apache.ignite.cache.QueryIndexType');
+                res.line('indexes.add(new ' + res.importClass('org.apache.ignite.cache.QueryIndex')
+
+                    '("' + field.name + '", ' +
+                    res.importClass('org.apache.ignite.cache.QueryIndexType') + '.' + index.indexType
+ ', ' +
+                    field.direction + ', "' + index.name + '"));');
+            }
+            else {
+                res.needEmptyLine = true;
 
-            var fields = index.fields;
+                $generatorJava.declareVariable(res, 'index', 'org.apache.ignite.cache.QueryIndex');
 
-            if (fields && fields.length > 0) {
-                $generatorJava.declareVariable(res, 'indFlds', 'java.util.LinkedHashMap',
'java.util.LinkedHashMap', 'String', 'Boolean');
+                $generatorJava.property(res, 'index', index, 'name');
+                $generatorJava.property(res, 'index', index, 'indexType', 'org.apache.ignite.cache.QueryIndexType');
 
-                _.forEach(fields, function(field) {
-                    res.line('indFlds.put("' + field.name + '", ' + field.direction + ');');
-                });
+                if (fields && fields.length > 0) {
+                    $generatorJava.declareVariable(res, 'indFlds', 'java.util.LinkedHashMap',
'java.util.LinkedHashMap', 'String', 'Boolean');
 
-                res.needEmptyLine = true;
+                    _.forEach(fields, function(field) {
+                        res.line('indFlds.put("' + field.name + '", ' + field.direction +
');');
+                    });
 
-                res.line('index.setFields(indFlds);');
+                    res.needEmptyLine = true;
 
-                res.needEmptyLine = true;
-            }
+                    res.line('index.setFields(indFlds);');
 
-            res.line('indexes.add(index);');
+                    res.needEmptyLine = true;
+                }
+
+                res.line('indexes.add(index);');
+            }
         });
 
         res.needEmptyLine = true;


Mime
View raw message