ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: Moved full-text index into separate property.
Date Thu, 09 Mar 2017 11:31:24 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-4565-ddl f6fa2659d -> f4a56fe67


Moved full-text index into separate property.


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

Branch: refs/heads/ignite-4565-ddl
Commit: f4a56fe67739ca6b8666cec6c0b2f7bce288d191
Parents: f6fa265
Author: devozerov <vozerov@gridgain.com>
Authored: Thu Mar 9 14:31:17 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Thu Mar 9 14:31:17 2017 +0300

----------------------------------------------------------------------
 .../cache/query/GridCacheQueryManager.java      |  9 ++--
 .../processors/query/GridQueryProcessor.java    | 10 ++--
 .../query/GridQueryTypeDescriptor.java          |  7 +++
 .../processors/query/h2/IgniteH2Indexing.java   | 55 ++++++++++----------
 .../query/h2/opt/GridLuceneIndex.java           | 11 +---
 .../h2/GridIndexingSpiAbstractSelfTest.java     |  8 ++-
 6 files changed, 53 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f4a56fe6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 28a5886..66ac16d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -2489,13 +2489,14 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
                         fields.put(type.name(), fieldsMap);
 
-                        Collection<GridCacheSqlIndexMetadata> indexesCol =
-                            new ArrayList<>(type.indexes().size());
+                        Map<String, GridQueryIndexDescriptor> idxs = type.indexes();
 
-                        for (Map.Entry<String, GridQueryIndexDescriptor> e : type.indexes().entrySet())
{
+                        Collection<GridCacheSqlIndexMetadata> indexesCol = new ArrayList<>(idxs.size());
+
+                        for (Map.Entry<String, GridQueryIndexDescriptor> e : idxs.entrySet())
{
                             GridQueryIndexDescriptor desc = e.getValue();
 
-                            // Add only SQL indexes.
+                            // Add only SQL SORTED indexes.
                             if (desc.type() == GridQueryIndexType.SORTED) {
                                 Collection<String> idxFields = new LinkedList<>();
                                 Collection<String> descendings = new LinkedList<>();

http://git-wip-us.apache.org/repos/asf/ignite/blob/f4a56fe6/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index ad900ea..01c7122 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -2455,6 +2455,11 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             return Collections.<String, GridQueryIndexDescriptor>unmodifiableMap(indexes);
         }
 
+        /** {@inheritDoc} */
+        @Override public GridQueryIndexDescriptor textIndex() {
+            return fullTextIdx;
+        }
+
         /**
          * Adds index.
          *
@@ -2497,12 +2502,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
          * @param field Field name.
          */
         public void addFieldToTextIndex(String field) {
-            if (fullTextIdx == null) {
+            if (fullTextIdx == null)
                 fullTextIdx = new IndexDescriptor(FULLTEXT);
 
-                indexes.put(null, fullTextIdx);
-            }
-
             fullTextIdx.addField(field, 0, false);
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f4a56fe6/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
index 855726f..2857af5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
@@ -81,6 +81,13 @@ public interface GridQueryTypeDescriptor {
     public Map<String, GridQueryIndexDescriptor> indexes();
 
     /**
+     * Get text index for this type (if any).
+     *
+     * @return Text index or {@code null}.
+     */
+    public GridQueryIndexDescriptor textIndex();
+
+    /**
      * Gets value class.
      *
      * @return Value class.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f4a56fe6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index f0f6bba..c7077a8 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -2629,45 +2629,46 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             boolean affIdxFound = false;
 
+            GridQueryIndexDescriptor textIdx = type.textIndex();
+
+            if (textIdx != null) {
+                try {
+                    luceneIdx = new GridLuceneIndex(ctx, schema.offheap, schema.spaceName,
type);
+                }
+                catch (IgniteCheckedException e1) {
+                    throw new IgniteException(e1);
+                }
+            }
+
             for (Map.Entry<String, GridQueryIndexDescriptor> e : type.indexes().entrySet())
{
                 String name = e.getKey();
                 GridQueryIndexDescriptor idx = e.getValue();
 
-                if (idx.type() == FULLTEXT) {
-                    try {
-                        luceneIdx = new GridLuceneIndex(ctx, schema.offheap, schema.spaceName,
type);
-                    }
-                    catch (IgniteCheckedException e1) {
-                        throw new IgniteException(e1);
-                    }
-                }
-                else {
-                    List<IndexColumn> cols = new ArrayList<>(idx.fields().size()
+ 2);
+                List<IndexColumn> cols = new ArrayList<>(idx.fields().size()
+ 2);
 
-                    boolean escapeAll = schema.escapeAll();
+                boolean escapeAll = schema.escapeAll();
 
-                    for (String field : idx.fields()) {
-                        String fieldName = escapeAll ? field : escapeName(field, false).toUpperCase();
+                for (String field : idx.fields()) {
+                    String fieldName = escapeAll ? field : escapeName(field, false).toUpperCase();
 
-                        Column col = tbl.getColumn(fieldName);
+                    Column col = tbl.getColumn(fieldName);
 
-                        cols.add(tbl.indexColumn(col.getColumnId(),
-                            idx.descending(field) ? SortOrder.DESCENDING : SortOrder.ASCENDING));
-                    }
+                    cols.add(tbl.indexColumn(col.getColumnId(),
+                        idx.descending(field) ? SortOrder.DESCENDING : SortOrder.ASCENDING));
+                }
 
-                    if (idx.type() == SORTED) {
-                        // We don't care about number of fields in affinity index, just affinity
key must be the first.
-                        affIdxFound |= affCol != null && equal(cols.get(0), affCol);
+                if (idx.type() == SORTED) {
+                    // We don't care about number of fields in affinity index, just affinity
key must be the first.
+                    affIdxFound |= affCol != null && equal(cols.get(0), affCol);
 
-                        cols = treeIndexColumns(cols, keyCol, affCol);
+                    cols = treeIndexColumns(cols, keyCol, affCol);
 
-                        idxs.add(new GridH2TreeIndex(name, tbl, false, cols));
-                    }
-                    else if (idx.type() == GEO_SPATIAL)
-                        idxs.add(createH2SpatialIndex(tbl, name, cols.toArray(new IndexColumn[cols.size()])));
-                    else
-                        throw new IllegalStateException("Index type: " + idx.type());
+                    idxs.add(new GridH2TreeIndex(name, tbl, false, cols));
                 }
+                else if (idx.type() == GEO_SPATIAL)
+                    idxs.add(createH2SpatialIndex(tbl, name, cols.toArray(new IndexColumn[cols.size()])));
+                else
+                    throw new IllegalStateException("Index type: " + idx.type());
             }
 
             // Add explicit affinity key index if nothing alike was found.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f4a56fe6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
index 716c9cb..0e003a4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
 import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
-import org.apache.ignite.internal.processors.query.GridQueryIndexType;
 import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
 import org.apache.ignite.internal.util.GridAtomicLong;
 import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
@@ -115,15 +114,7 @@ public class GridLuceneIndex implements AutoCloseable {
             throw new IgniteCheckedException(e);
         }
 
-        GridQueryIndexDescriptor idx = null;
-
-        for (GridQueryIndexDescriptor descriptor : type.indexes().values()) {
-            if (descriptor.type() == GridQueryIndexType.FULLTEXT) {
-                idx = descriptor;
-
-                break;
-            }
-        }
+        GridQueryIndexDescriptor idx = type.textIndex();
 
         if (idx != null) {
             Collection<String> fields = idx.fields();

http://git-wip-us.apache.org/repos/asf/ignite/blob/f4a56fe6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index 54c6019..e670666 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -627,8 +627,12 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
 
         /** */
         @Override public Map<String, GridQueryIndexDescriptor> indexes() {
-            return textIdx == null ? Collections.<String, GridQueryIndexDescriptor>emptyMap()
:
-                Collections.singletonMap("index", textIdx);
+            return Collections.emptyMap();
+        }
+
+        /** */
+        @Override public GridQueryIndexDescriptor textIndex() {
+            return textIdx;
         }
 
         /** */


Mime
View raw message