Index provider.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/53af8a8f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/53af8a8f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/53af8a8f Branch: refs/heads/sql-store Commit: 53af8a8fbd258ea5e0528eb648c48d95f72d47a5 Parents: 0d7025c Author: Alexey Goncharuk <[email protected]> Authored: Thu Jan 21 11:37:18 2016 +0300 Committer: Alexey Goncharuk <[email protected]> Committed: Wed Feb 3 17:13:40 2016 +0300 ---------------------------------------------------------------------- .../processors/query/h2/IgniteH2Indexing.java | 25 +++++++++++-- .../query/h2/IgniteH2QueryIndexProvider.java | 38 ++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/53af8a8f/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 be72888..77156e0 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 @@ -242,6 +242,9 @@ public class IgniteH2Indexing implements GridQueryIndexing { /** */ private GridReduceQueryExecutor rdcQryExec; + /** Index provider. */ + private IgniteH2QueryIndexProvider idxProvider; + /** space name -> schema name */ private final Map<String, String> space2schema = new ConcurrentHashMap8<>(); @@ -1474,6 +1477,8 @@ public class IgniteH2Indexing implements GridQueryIndexing { rdcQryExec.start(ctx, this); } + idxProvider = ctx.plugins().createComponent(IgniteH2QueryIndexProvider.class); + // TODO https://issues.apache.org/jira/browse/IGNITE-2139 // registerMBean(gridName, this, GridH2IndexingSpiMBean.class); } @@ -1947,7 +1952,7 @@ public class IgniteH2Indexing implements GridQueryIndexing { ArrayList<Index> idxs = new ArrayList<>(); - idxs.add(new GridH2TreeIndex("_key_PK", tbl, true, KEY_COL, VAL_COL, tbl.indexColumn(0, ASCENDING))); + idxs.add(createSortedIndex("_key_PK", tbl, true, KEY_COL, VAL_COL, tbl.indexColumn(0, ASCENDING))); if (type().valueClass() == String.class) { try { @@ -1987,7 +1992,7 @@ public class IgniteH2Indexing implements GridQueryIndexing { } if (idx.type() == SORTED) - idxs.add(new GridH2TreeIndex(name, tbl, false, KEY_COL, VAL_COL, cols)); + idxs.add(createSortedIndex(name, tbl, false, KEY_COL, VAL_COL, cols)); else if (idx.type() == GEO_SPATIAL) idxs.add(createH2SpatialIndex(tbl, name, cols, KEY_COL, VAL_COL)); else @@ -1999,6 +2004,22 @@ public class IgniteH2Indexing implements GridQueryIndexing { } /** + * @param name Index name, + * @param tbl Table. + * @param pk Primary key flag. + * @param keyCol Key column. + * @param valCol Value column. + * @param cols Columns. + * @return Index. + */ + private Index createSortedIndex(String name, GridH2Table tbl, boolean pk, int keyCol, int valCol, IndexColumn... cols) { + if (idxProvider != null) + return idxProvider.createIndex(name, tbl, pk, keyCol, valCol, cols); + + return new GridH2TreeIndex(name, tbl, pk, keyCol, valCol, cols); + } + + /** * @param tbl Table. * @param idxName Index name. * @param cols Columns. http://git-wip-us.apache.org/repos/asf/ignite/blob/53af8a8f/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2QueryIndexProvider.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2QueryIndexProvider.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2QueryIndexProvider.java new file mode 100644 index 0000000..de8016d --- /dev/null +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2QueryIndexProvider.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.query.h2; + +import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table; +import org.h2.index.Index; +import org.h2.table.IndexColumn; + +/** + * + */ +public interface IgniteH2QueryIndexProvider { + /** + * @param name Index name. + * @param tbl Table to create index for. + * @param pk Primary key index flag. + * @param keyCol Key column index. + * @param valCol Value column index. + * @param cols Index columns. + * @return Created index. + */ + public Index createIndex(String name, GridH2Table tbl, boolean pk, int keyCol, int valCol, IndexColumn... cols); +}
