Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4342E107E2 for ; Fri, 5 Dec 2014 14:07:29 +0000 (UTC) Received: (qmail 4601 invoked by uid 500); 5 Dec 2014 14:07:29 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 4569 invoked by uid 500); 5 Dec 2014 14:07:29 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 4560 invoked by uid 99); 5 Dec 2014 14:07:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2014 14:07:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 05 Dec 2014 14:07:23 +0000 Received: (qmail 99933 invoked by uid 99); 5 Dec 2014 14:07:03 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2014 14:07:03 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BCEC28BDB9F; Fri, 5 Dec 2014 14:07:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Fri, 05 Dec 2014 14:07:50 -0000 Message-Id: <2e6fc5dc5b1a4d13bc669a7bc7ce2b28@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [49/52] [abbrv] incubator-ignite git commit: # Renaming X-Virus-Checked: Checked by ClamAV on apache.org http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridIndexingSpi.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridIndexingSpi.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridIndexingSpi.java deleted file mode 100644 index 7c6d4c8..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridIndexingSpi.java +++ /dev/null @@ -1,188 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.indexing; - -import org.apache.ignite.spi.*; -import org.gridgain.grid.cache.*; -import org.gridgain.grid.cache.query.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * Indexing SPI allows user to index cache content. Using indexing SPI user can index data in cache and run SQL, - * TEXT or individual field queries against these indexes. Usually indexing SPI is used by caches by name - * (see {@link GridCacheConfiguration#getIndexingSpiName()}). Logically storage is organized into separate spaces. - * Usually cache name will be used as space name, so multiple caches can write to single indexing SPI instance. - *

- * Functionality of this SPI is exposed to {@link GridCacheQueries} interface: - *

    - *
  • {@link GridCacheQueries#createSqlQuery(Class, String)}
  • - *
  • {@link GridCacheQueries#createSqlFieldsQuery(String)}
  • - *
  • {@link GridCacheQueries#createFullTextQuery(Class, String)}
  • - *
- *

- * The default indexing SPI implementation is - * {@gglink org.gridgain.grid.spi.indexing.h2.GridH2IndexingSpi} which uses H2 database engine - * for data indexing and querying. User can implement his own indexing SPI and use his own data structures - * and query language instead of SQL. SPI can be configured for grid using {@link org.apache.ignite.configuration.IgniteConfiguration#getIndexingSpi()}. - *

- * GridGain comes with following built-in indexing SPI implementations: - *

    - *
  • {@gglink org.gridgain.grid.spi.indexing.h2.GridH2IndexingSpi}
  • - *
- *

- * NOTE: this SPI (i.e. methods in this interface) should never be used directly. SPIs provide - * internal view on the subsystem and is used internally by GridGain kernal. In rare use cases when - * access to a specific implementation of this SPI is required - an instance of this SPI can be obtained - * via {@link org.apache.ignite.Ignite#configuration()} method to check its configuration properties or call other non-SPI - * methods. Note again that calling methods from this interface on the obtained instance can lead - * to undefined behavior and explicitly not supported. - */ -public interface GridIndexingSpi extends IgniteSpi { - /** - * Queries individual fields (generally used by JDBC drivers). - * - * @param spaceName Space name. - * @param qry Query. - * @param params Query parameters. - * @param filters Space name and key filters. - * @return Query result. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public GridIndexingFieldsResult queryFields(@Nullable String spaceName, String qry, - Collection params, GridIndexingQueryFilter filters) throws IgniteSpiException; - - /** - * Executes regular query. - * - * @param spaceName Space name. - * @param qry Query. - * @param params Query parameters. - * @param type Query return type. - * @param filters Space name and key filters. - * @return Queried rows. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public IgniteSpiCloseableIterator> query(@Nullable String spaceName, String qry, - Collection params, GridIndexingTypeDescriptor type, GridIndexingQueryFilter filters) - throws IgniteSpiException; - - /** - * Executes text query. - * - * @param spaceName Space name. - * @param qry Text query. - * @param type Query return type. - * @param filters Space name and key filter. - * @return Queried rows. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public IgniteSpiCloseableIterator> queryText(@Nullable String spaceName, String qry, - GridIndexingTypeDescriptor type, GridIndexingQueryFilter filters) throws IgniteSpiException; - - /** - * Gets size of index for given type or -1 if it is a unknown type. - * - * @param spaceName Space name. - * @param desc Type descriptor. - * @return Objects number. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public long size(@Nullable String spaceName, GridIndexingTypeDescriptor desc) throws IgniteSpiException; - - /** - * Registers type if it was not known before or updates it otherwise. - * - * @param spaceName Space name. - * @param desc Type descriptor. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - * @return {@code True} if type was registered, {@code false} if for some reason it was rejected. - */ - public boolean registerType(@Nullable String spaceName, GridIndexingTypeDescriptor desc) throws IgniteSpiException; - - /** - * Unregisters type and removes all corresponding data. - * - * @param spaceName Space name. - * @param type Type descriptor. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public void unregisterType(@Nullable String spaceName, GridIndexingTypeDescriptor type) throws IgniteSpiException; - - /** - * Updates index. Note that key is unique for space, so if space contains multiple indexes - * the key should be removed from indexes other than one being updated. - * - * @param spaceName Space name. - * @param type Value type. - * @param key Key. - * @param val Value. - * @param ver Version. - * @param expirationTime Expiration time or 0 if never expires. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public void store(@Nullable String spaceName, GridIndexingTypeDescriptor type, GridIndexingEntity key, - GridIndexingEntity val, byte[] ver, long expirationTime) throws IgniteSpiException; - - /** - * Removes index entry by key. - * - * @param spaceName Space name. - * @param key Key. - * @return {@code True} if removed by this operation, {@code false} otherwise. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public boolean remove(@Nullable String spaceName, GridIndexingEntity key) throws IgniteSpiException; - - /** - * Will be called when entry with given key is swapped. - * - * @param spaceName Space name. - * @param swapSpaceName Swap space name. - * @param key Key. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public void onSwap(@Nullable String spaceName, String swapSpaceName, K key) throws IgniteSpiException; - - /** - * Will be called when entry with given key is unswapped. - * - * @param spaceName Space name. - * @param key Key. - * @param val Value. - * @param valBytes Value bytes. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public void onUnswap(@Nullable String spaceName, K key, V val, byte[] valBytes) throws IgniteSpiException; - - /** - * Marshaller to be used by SPI. - * - * @param marshaller Marshaller. - */ - public void registerMarshaller(GridIndexingMarshaller marshaller); - - /** - * Registers space in this SPI. - * - * @param spaceName Space name. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public void registerSpace(String spaceName) throws IgniteSpiException; - - /** - * Rebuilds all indexes of given type. - * - * @param spaceName Space name. - * @param type Type descriptor. - */ - public void rebuildIndexes(@Nullable String spaceName, GridIndexingTypeDescriptor type); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridIndexingTypeDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridIndexingTypeDescriptor.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridIndexingTypeDescriptor.java deleted file mode 100644 index ea39e90..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridIndexingTypeDescriptor.java +++ /dev/null @@ -1,84 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.indexing; - - -import org.apache.ignite.spi.*; - -import java.util.*; - -/** - * Value descriptor which allows to extract fields from value object of given type. - * See also {@link GridIndexingSpi#registerType(String, GridIndexingTypeDescriptor)}. - */ -public interface GridIndexingTypeDescriptor { - /** - * Gets type name which uniquely identifies this type. - * - * @return Type name which uniquely identifies this type. - */ - public String name(); - - /** - * Gets mapping from values field name to its type. - * - * @return Fields that can be indexed, participate in queries and can be queried using - * {@link GridIndexingSpi#queryFields(String, String, Collection, GridIndexingQueryFilter[])} - * method. - */ - public Map> valueFields(); - - /** - * Gets mapping from keys field name to its type. - * - * @return Fields that can be indexed, participate in queries and can be queried using - * {@link GridIndexingSpi#queryFields(String, String, Collection, GridIndexingQueryFilter[])} - * method. - */ - public Map> keyFields(); - - /** - * Gets field value for given object. - * - * @param obj Object to get field value from. - * @param field Field name. - * @return Value for given field. - * @throws org.apache.ignite.spi.IgniteSpiException If failed. - */ - public T value(Object obj, String field) throws IgniteSpiException; - - /** - * Gets indexes for this type. - * - * @return Indexes for this type. - */ - public Map indexes(); - - /** - * Gets value class. - * - * @return Value class. - */ - public Class valueClass(); - - /** - * Gets key class. - * - * @return Key class. - */ - public Class keyClass(); - - /** - * Returns {@code true} if string representation of value should be indexed as text. - * - * @return If string representation of value should be full-text indexed. - */ - public boolean valueTextIndex(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridNoopIndexingSpi.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridNoopIndexingSpi.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridNoopIndexingSpi.java deleted file mode 100644 index 2cdd25d..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/GridNoopIndexingSpi.java +++ /dev/null @@ -1,119 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.spi.indexing; - -import org.apache.ignite.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.spi.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * No-op implementation of {@link GridIndexingSpi}, throws exception on query attempt. - */ -@IgniteSpiNoop -public class GridNoopIndexingSpi extends IgniteSpiAdapter implements GridIndexingSpi { - /** */ - @IgniteLoggerResource - private IgniteLogger log; - - /** {@inheritDoc} */ - @Override public GridIndexingFieldsResult queryFields(@Nullable String spaceName, String qry, - Collection params, GridIndexingQueryFilter filters) throws IgniteSpiException { - throw spiException(); - } - - /** {@inheritDoc} */ - @Override public IgniteSpiCloseableIterator> query(@Nullable String spaceName, - String qry, Collection params, GridIndexingTypeDescriptor type, - GridIndexingQueryFilter filters) throws IgniteSpiException { - throw spiException(); - } - - /** {@inheritDoc} */ - @Override public IgniteSpiCloseableIterator> queryText(@Nullable - String spaceName, String qry, GridIndexingTypeDescriptor type, GridIndexingQueryFilter filters) - throws IgniteSpiException { - throw spiException(); - } - - /** {@inheritDoc} */ - @Override public long size(@Nullable String spaceName, GridIndexingTypeDescriptor desc) throws IgniteSpiException { - throw spiException(); - } - - /** {@inheritDoc} */ - @Override public boolean registerType(@Nullable String spaceName, GridIndexingTypeDescriptor desc) - throws IgniteSpiException { - return false; - } - - /** {@inheritDoc} */ - @Override public void unregisterType(@Nullable String spaceName, GridIndexingTypeDescriptor type) - throws IgniteSpiException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void store(@Nullable String spaceName, GridIndexingTypeDescriptor type, - GridIndexingEntity key, GridIndexingEntity val, byte[] ver, long expirationTime) throws IgniteSpiException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public boolean remove(@Nullable String spaceName, GridIndexingEntity key) throws IgniteSpiException { - return false; - } - - /** {@inheritDoc} */ - @Override public void onSwap(@Nullable String spaceName, String swapSpaceName, K key) throws IgniteSpiException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void onUnswap(@Nullable String spaceName, K key, V val, byte[] valBytes) - throws IgniteSpiException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void registerMarshaller(GridIndexingMarshaller marshaller) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void registerSpace(String spaceName) throws IgniteSpiException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void rebuildIndexes(@Nullable String spaceName, GridIndexingTypeDescriptor type) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void spiStop() throws IgniteSpiException { - // No-op. - } - - /** - * @return No-op SPI usage exception. - */ - private IgniteSpiException spiException() { - return new IgniteSpiException("Current grid configuration does not support queries " + - "(please configure GridH2IndexingSpi)."); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexDescriptor.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexDescriptor.java new file mode 100644 index 0000000..7fecd56 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexDescriptor.java @@ -0,0 +1,42 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import java.util.*; + +/** + * Describes an index to be created for a certain type. It contains all necessary + * information about fields, order, uniqueness, and specified + * whether this is SQL or Text index. + * See also {@link IndexingTypeDescriptor#indexes()}. + */ +public interface IndexDescriptor { + /** + * Gets all fields to be indexed. + * + * @return Fields to be indexed. + */ + public Collection fields(); + + /** + * Specifies order of the index for each indexed field. + * + * @param field Field name. + * @return {@code True} if given field should be indexed in descending order. + */ + public boolean descending(String field); + + /** + * Gets index type. + * + * @return Type. + */ + public IndexType type(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexType.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexType.java new file mode 100644 index 0000000..f7f0ea2 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexType.java @@ -0,0 +1,24 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +/** + * Index types. + */ +public enum IndexType { + /** Sorted SQL index. */ + SORTED, + + /** Spatial SQL index. */ + GEO_SPATIAL, + + /** Fulltext index. */ + FULLTEXT +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingEntity.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingEntity.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingEntity.java new file mode 100644 index 0000000..556d4f0 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingEntity.java @@ -0,0 +1,50 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import org.apache.ignite.spi.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * Wrapper around indexed key or value which also may contain the value in + * unmarshalled form. It exists to avoid unnecessary unmarshalling whenever + * it is not needed. + * See also {@link IndexingSpi#queryFields(String, String, Collection, IndexingQueryFilter[])}. + */ +public interface IndexingEntity { + /** + * Gets indexed value. This method may return {@code null} only + * if actual value is {@code null}. Otherwise, it will unmarshal + * the {@link #bytes()} and return the actual value. + * + * @return Indexed value. + * @throws org.apache.ignite.spi.IgniteSpiException If value de-serialization failed. + */ + @Nullable public T value() throws IgniteSpiException; + + /** + * Optional bytes for marshaled indexed value. Certain SPI implementations + * may keep objects in unmarshalled form and therefore will not provide + * marshaled bytes for them. + * + * @return Optional marshaled value. + */ + @Nullable public byte[] bytes(); + + /** + * Flag indicating whether this entity contains unmarshalled value. + * + * @return {@code True} if entity contains unmarshalled value, {@code false} + * otherwise. + */ + public boolean hasValue(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingEntityAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingEntityAdapter.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingEntityAdapter.java new file mode 100644 index 0000000..1effa99 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingEntityAdapter.java @@ -0,0 +1,57 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import org.gridgain.grid.util.typedef.internal.*; +import org.gridgain.grid.util.tostring.*; +import org.jetbrains.annotations.*; + +/** + * Convenience adapter for {@link IndexingEntity}. + */ +public class IndexingEntityAdapter implements IndexingEntity { + /** */ + @GridToStringInclude + private final T val; + + /** */ + @GridToStringExclude + private final byte[] bytes; + + /** + * @param val Value. + * @param bytes Value marshalled by {@link org.apache.ignite.marshaller.IgniteMarshaller}. + */ + public IndexingEntityAdapter(T val, @Nullable byte[] bytes) { + this.val = val; + this.bytes = bytes; + } + + /** {@inheritDoc} */ + @Override public T value() { + return val; + } + + /** {@inheritDoc} */ + @Override public byte[] bytes() { + return bytes; + } + + /** {@inheritDoc} */ + @Override public boolean hasValue() { + return val != null || (val == null && bytes == null); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(IndexingEntityAdapter.class, this, + "bytesLength", (bytes == null ? 0 : bytes.length)); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldMetadata.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldMetadata.java new file mode 100644 index 0000000..f530b20 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldMetadata.java @@ -0,0 +1,46 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import java.io.*; + +/** + * Query field descriptor. This descriptor is used to provide metadata + * about fields returned in query result. + */ +public interface IndexingFieldMetadata extends Externalizable { + /** + * Gets schema name. + * + * @return Schema name. + */ + public String schemaName(); + + /** + * Gets name of type to which this field belongs. + * + * @return Gets type name. + */ + public String typeName(); + + /** + * Gets field name. + * + * @return Field name. + */ + public String fieldName(); + + /** + * Gets field type name. + * + * @return Field type name. + */ + public String fieldTypeName(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldsResult.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldsResult.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldsResult.java new file mode 100644 index 0000000..ede3278 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldsResult.java @@ -0,0 +1,35 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import org.apache.ignite.spi.*; + +import java.util.*; + +/** + * Field query result. It is composed of + * fields metadata and iterator over queried fields. + * See also {@link IndexingSpi#queryFields(String, String, Collection, IndexingQueryFilter)}. + */ +public interface IndexingFieldsResult { + /** + * Gets metadata for queried fields. + * + * @return Meta data for queried fields. + */ + List metaData(); + + /** + * Gets iterator over queried fields. + * + * @return Iterator over queried fields. + */ + IgniteSpiCloseableIterator>> iterator(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldsResultAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldsResultAdapter.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldsResultAdapter.java new file mode 100644 index 0000000..348f344 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingFieldsResultAdapter.java @@ -0,0 +1,49 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import org.apache.ignite.spi.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * Convenience adapter for {@link IndexingFieldsResult}. + */ +public class IndexingFieldsResultAdapter implements IndexingFieldsResult { + /** Meta data. */ + private final List metaData; + + /** Result iterator. */ + private final IgniteSpiCloseableIterator>> it; + + /** + * Creates query field result composed of field metadata and iterator + * over queried fields. + * + * @param metaData Meta data. + * @param it Result iterator. + */ + public IndexingFieldsResultAdapter(@Nullable List metaData, + IgniteSpiCloseableIterator>> it) { + this.metaData = metaData != null ? Collections.unmodifiableList(metaData) : null; + this.it = it; + } + + /** {@inheritDoc} */ + @Override public List metaData() { + return metaData; + } + + /** {@inheritDoc} */ + @Override public IgniteSpiCloseableIterator>> iterator() { + return it; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingKeyValueRow.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingKeyValueRow.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingKeyValueRow.java new file mode 100644 index 0000000..841130e --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingKeyValueRow.java @@ -0,0 +1,42 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import java.util.*; + +/** + * This class represents a single row returned by key-value query. For example, it is returned + * by query such as {@link IndexingSpi#query(String, String, Collection, IndexingTypeDescriptor, IndexingQueryFilter[])} + * method. Key-value queries are different from fields query in a way that they + * return the whole cached value, not its individual fields. + * See also {@link IndexingSpi#query(String, String, Collection, IndexingTypeDescriptor, IndexingQueryFilter[])}. + */ +public interface IndexingKeyValueRow { + /** + * Gets cache key. + * + * @return Cache key. + */ + public IndexingEntity key(); + + /** + * Gets cache value. + * + * @return Cache value. + */ + public IndexingEntity value(); + + /** + * Gets version of cache value. + * + * @return Version of cache value. + */ + public byte[] version(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingKeyValueRowAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingKeyValueRowAdapter.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingKeyValueRowAdapter.java new file mode 100644 index 0000000..8b95aa3 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingKeyValueRowAdapter.java @@ -0,0 +1,82 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ +* __ ____/___________(_)______ /__ ____/______ ____(_)_______ +* _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ +* / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / +* \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ +*/ + +package org.gridgain.grid.spi.indexing; + +import org.gridgain.grid.kernal.processors.cache.query.*; +import org.gridgain.grid.util.typedef.internal.*; +import org.gridgain.grid.util.tostring.*; +import org.jetbrains.annotations.*; + +/** + * Convenience adapter for {@link IndexingKeyValueRow}. + */ +public class IndexingKeyValueRowAdapter implements IndexingKeyValueRow { + /** Key. */ + @GridToStringInclude + private IndexingEntity key; + + /** Value. */ + @GridToStringInclude + private IndexingEntity val; + + /** Version. */ + @GridToStringInclude + private byte[] ver; + + /** + * Constructor. + * + * @param key Key. + * @param val Value. + */ + public IndexingKeyValueRowAdapter(K key, V val) { + assert key != null; + assert val != null; + + this.key = new IndexingEntityAdapter<>(key, null); + this.val = new IndexingEntityAdapter<>(val, null); + } + + /** + * Constructs query index row. + * + * @param key Key. + * @param val Value. + * @param ver Version. It is {@code null} in case of {@link GridCacheQueryType#SCAN} query. + */ + public IndexingKeyValueRowAdapter(IndexingEntity key, @Nullable IndexingEntity val, + @Nullable byte[] ver) { + assert key != null; + + this.key = key; + this.val = val; + this.ver = ver; + } + + /** {@inheritDoc} */ + @Override public IndexingEntity key() { + return key; + } + + /** {@inheritDoc} */ + @Override public IndexingEntity value() { + return val; + } + + /** {@inheritDoc} */ + @Override public byte[] version() { + return ver; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(IndexingKeyValueRowAdapter.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingMarshaller.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingMarshaller.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingMarshaller.java new file mode 100644 index 0000000..403b871 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingMarshaller.java @@ -0,0 +1,38 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import org.apache.ignite.spi.*; + +/** + * Marshaller to be used in indexing SPI. This marshaller automatically + * takes care of class loading of unmarshalled classes. + * See also {@link IndexingSpi#registerMarshaller(IndexingMarshaller)}. + */ +public interface IndexingMarshaller { + /** + * Unmarshalls bytes to object. + * + * @param bytes Bytes. + * @param Value type. + * @return Value. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public IndexingEntity unmarshal(byte[] bytes) throws IgniteSpiException; + + /** + * Marshals object to bytes. + * + * @param entity Entity. + * @return Bytes. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public byte[] marshal(IndexingEntity entity) throws IgniteSpiException; +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingQueryFilter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingQueryFilter.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingQueryFilter.java new file mode 100644 index 0000000..4424734 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingQueryFilter.java @@ -0,0 +1,27 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import org.apache.ignite.lang.*; +import org.gridgain.grid.*; +import org.jetbrains.annotations.*; + +/** + * Space name and key filter. + */ +public interface IndexingQueryFilter { + /** + * Creates optional predicate for space. + * + * @param spaceName Space name. + * @return Predicate or {@code null} if no filtering is needed. + */ + @Nullable public IgniteBiPredicate forSpace(String spaceName) throws GridException; +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingSpi.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingSpi.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingSpi.java new file mode 100644 index 0000000..d95905a --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingSpi.java @@ -0,0 +1,188 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import org.apache.ignite.spi.*; +import org.gridgain.grid.cache.*; +import org.gridgain.grid.cache.query.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * Indexing SPI allows user to index cache content. Using indexing SPI user can index data in cache and run SQL, + * TEXT or individual field queries against these indexes. Usually indexing SPI is used by caches by name + * (see {@link GridCacheConfiguration#getIndexingSpiName()}). Logically storage is organized into separate spaces. + * Usually cache name will be used as space name, so multiple caches can write to single indexing SPI instance. + *

+ * Functionality of this SPI is exposed to {@link GridCacheQueries} interface: + *

    + *
  • {@link GridCacheQueries#createSqlQuery(Class, String)}
  • + *
  • {@link GridCacheQueries#createSqlFieldsQuery(String)}
  • + *
  • {@link GridCacheQueries#createFullTextQuery(Class, String)}
  • + *
+ *

+ * The default indexing SPI implementation is + * {@gglink org.gridgain.grid.spi.indexing.h2.GridH2IndexingSpi} which uses H2 database engine + * for data indexing and querying. User can implement his own indexing SPI and use his own data structures + * and query language instead of SQL. SPI can be configured for grid using {@link org.apache.ignite.configuration.IgniteConfiguration#getIndexingSpi()}. + *

+ * GridGain comes with following built-in indexing SPI implementations: + *

    + *
  • {@gglink org.gridgain.grid.spi.indexing.h2.GridH2IndexingSpi}
  • + *
+ *

+ * NOTE: this SPI (i.e. methods in this interface) should never be used directly. SPIs provide + * internal view on the subsystem and is used internally by GridGain kernal. In rare use cases when + * access to a specific implementation of this SPI is required - an instance of this SPI can be obtained + * via {@link org.apache.ignite.Ignite#configuration()} method to check its configuration properties or call other non-SPI + * methods. Note again that calling methods from this interface on the obtained instance can lead + * to undefined behavior and explicitly not supported. + */ +public interface IndexingSpi extends IgniteSpi { + /** + * Queries individual fields (generally used by JDBC drivers). + * + * @param spaceName Space name. + * @param qry Query. + * @param params Query parameters. + * @param filters Space name and key filters. + * @return Query result. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public IndexingFieldsResult queryFields(@Nullable String spaceName, String qry, + Collection params, IndexingQueryFilter filters) throws IgniteSpiException; + + /** + * Executes regular query. + * + * @param spaceName Space name. + * @param qry Query. + * @param params Query parameters. + * @param type Query return type. + * @param filters Space name and key filters. + * @return Queried rows. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public IgniteSpiCloseableIterator> query(@Nullable String spaceName, String qry, + Collection params, IndexingTypeDescriptor type, IndexingQueryFilter filters) + throws IgniteSpiException; + + /** + * Executes text query. + * + * @param spaceName Space name. + * @param qry Text query. + * @param type Query return type. + * @param filters Space name and key filter. + * @return Queried rows. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public IgniteSpiCloseableIterator> queryText(@Nullable String spaceName, String qry, + IndexingTypeDescriptor type, IndexingQueryFilter filters) throws IgniteSpiException; + + /** + * Gets size of index for given type or -1 if it is a unknown type. + * + * @param spaceName Space name. + * @param desc Type descriptor. + * @return Objects number. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public long size(@Nullable String spaceName, IndexingTypeDescriptor desc) throws IgniteSpiException; + + /** + * Registers type if it was not known before or updates it otherwise. + * + * @param spaceName Space name. + * @param desc Type descriptor. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + * @return {@code True} if type was registered, {@code false} if for some reason it was rejected. + */ + public boolean registerType(@Nullable String spaceName, IndexingTypeDescriptor desc) throws IgniteSpiException; + + /** + * Unregisters type and removes all corresponding data. + * + * @param spaceName Space name. + * @param type Type descriptor. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public void unregisterType(@Nullable String spaceName, IndexingTypeDescriptor type) throws IgniteSpiException; + + /** + * Updates index. Note that key is unique for space, so if space contains multiple indexes + * the key should be removed from indexes other than one being updated. + * + * @param spaceName Space name. + * @param type Value type. + * @param key Key. + * @param val Value. + * @param ver Version. + * @param expirationTime Expiration time or 0 if never expires. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public void store(@Nullable String spaceName, IndexingTypeDescriptor type, IndexingEntity key, + IndexingEntity val, byte[] ver, long expirationTime) throws IgniteSpiException; + + /** + * Removes index entry by key. + * + * @param spaceName Space name. + * @param key Key. + * @return {@code True} if removed by this operation, {@code false} otherwise. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public boolean remove(@Nullable String spaceName, IndexingEntity key) throws IgniteSpiException; + + /** + * Will be called when entry with given key is swapped. + * + * @param spaceName Space name. + * @param swapSpaceName Swap space name. + * @param key Key. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public void onSwap(@Nullable String spaceName, String swapSpaceName, K key) throws IgniteSpiException; + + /** + * Will be called when entry with given key is unswapped. + * + * @param spaceName Space name. + * @param key Key. + * @param val Value. + * @param valBytes Value bytes. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public void onUnswap(@Nullable String spaceName, K key, V val, byte[] valBytes) throws IgniteSpiException; + + /** + * Marshaller to be used by SPI. + * + * @param marshaller Marshaller. + */ + public void registerMarshaller(IndexingMarshaller marshaller); + + /** + * Registers space in this SPI. + * + * @param spaceName Space name. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public void registerSpace(String spaceName) throws IgniteSpiException; + + /** + * Rebuilds all indexes of given type. + * + * @param spaceName Space name. + * @param type Type descriptor. + */ + public void rebuildIndexes(@Nullable String spaceName, IndexingTypeDescriptor type); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingTypeDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingTypeDescriptor.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingTypeDescriptor.java new file mode 100644 index 0000000..dfcb7d4 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/IndexingTypeDescriptor.java @@ -0,0 +1,84 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + + +import org.apache.ignite.spi.*; + +import java.util.*; + +/** + * Value descriptor which allows to extract fields from value object of given type. + * See also {@link IndexingSpi#registerType(String, IndexingTypeDescriptor)}. + */ +public interface IndexingTypeDescriptor { + /** + * Gets type name which uniquely identifies this type. + * + * @return Type name which uniquely identifies this type. + */ + public String name(); + + /** + * Gets mapping from values field name to its type. + * + * @return Fields that can be indexed, participate in queries and can be queried using + * {@link IndexingSpi#queryFields(String, String, Collection, IndexingQueryFilter[])} + * method. + */ + public Map> valueFields(); + + /** + * Gets mapping from keys field name to its type. + * + * @return Fields that can be indexed, participate in queries and can be queried using + * {@link IndexingSpi#queryFields(String, String, Collection, IndexingQueryFilter[])} + * method. + */ + public Map> keyFields(); + + /** + * Gets field value for given object. + * + * @param obj Object to get field value from. + * @param field Field name. + * @return Value for given field. + * @throws org.apache.ignite.spi.IgniteSpiException If failed. + */ + public T value(Object obj, String field) throws IgniteSpiException; + + /** + * Gets indexes for this type. + * + * @return Indexes for this type. + */ + public Map indexes(); + + /** + * Gets value class. + * + * @return Value class. + */ + public Class valueClass(); + + /** + * Gets key class. + * + * @return Key class. + */ + public Class keyClass(); + + /** + * Returns {@code true} if string representation of value should be indexed as text. + * + * @return If string representation of value should be full-text indexed. + */ + public boolean valueTextIndex(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/main/java/org/gridgain/grid/spi/indexing/NoopIndexingSpi.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/spi/indexing/NoopIndexingSpi.java b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/NoopIndexingSpi.java new file mode 100644 index 0000000..d82954c --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/spi/indexing/NoopIndexingSpi.java @@ -0,0 +1,119 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.spi.indexing; + +import org.apache.ignite.*; +import org.apache.ignite.resources.*; +import org.apache.ignite.spi.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * No-op implementation of {@link IndexingSpi}, throws exception on query attempt. + */ +@IgniteSpiNoop +public class NoopIndexingSpi extends IgniteSpiAdapter implements IndexingSpi { + /** */ + @IgniteLoggerResource + private IgniteLogger log; + + /** {@inheritDoc} */ + @Override public IndexingFieldsResult queryFields(@Nullable String spaceName, String qry, + Collection params, IndexingQueryFilter filters) throws IgniteSpiException { + throw spiException(); + } + + /** {@inheritDoc} */ + @Override public IgniteSpiCloseableIterator> query(@Nullable String spaceName, + String qry, Collection params, IndexingTypeDescriptor type, + IndexingQueryFilter filters) throws IgniteSpiException { + throw spiException(); + } + + /** {@inheritDoc} */ + @Override public IgniteSpiCloseableIterator> queryText(@Nullable + String spaceName, String qry, IndexingTypeDescriptor type, IndexingQueryFilter filters) + throws IgniteSpiException { + throw spiException(); + } + + /** {@inheritDoc} */ + @Override public long size(@Nullable String spaceName, IndexingTypeDescriptor desc) throws IgniteSpiException { + throw spiException(); + } + + /** {@inheritDoc} */ + @Override public boolean registerType(@Nullable String spaceName, IndexingTypeDescriptor desc) + throws IgniteSpiException { + return false; + } + + /** {@inheritDoc} */ + @Override public void unregisterType(@Nullable String spaceName, IndexingTypeDescriptor type) + throws IgniteSpiException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void store(@Nullable String spaceName, IndexingTypeDescriptor type, + IndexingEntity key, IndexingEntity val, byte[] ver, long expirationTime) throws IgniteSpiException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public boolean remove(@Nullable String spaceName, IndexingEntity key) throws IgniteSpiException { + return false; + } + + /** {@inheritDoc} */ + @Override public void onSwap(@Nullable String spaceName, String swapSpaceName, K key) throws IgniteSpiException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void onUnswap(@Nullable String spaceName, K key, V val, byte[] valBytes) + throws IgniteSpiException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void registerMarshaller(IndexingMarshaller marshaller) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void registerSpace(String spaceName) throws IgniteSpiException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void rebuildIndexes(@Nullable String spaceName, IndexingTypeDescriptor type) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void spiStart(@Nullable String gridName) throws IgniteSpiException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void spiStop() throws IgniteSpiException { + // No-op. + } + + /** + * @return No-op SPI usage exception. + */ + private IgniteSpiException spiException() { + return new IgniteSpiException("Current grid configuration does not support queries " + + "(please configure GridH2IndexingSpi)."); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxExceptionAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxExceptionAbstractSelfTest.java index 27560ac..f319eb3 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxExceptionAbstractSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxExceptionAbstractSelfTest.java @@ -571,7 +571,7 @@ public abstract class GridCacheTxExceptionAbstractSelfTest extends GridCacheAbst /** * Indexing SPI that can fail on demand. */ - private static class TestIndexingSpi extends IgniteSpiAdapter implements GridIndexingSpi { + private static class TestIndexingSpi extends IgniteSpiAdapter implements IndexingSpi { /** Fail flag. */ private volatile boolean fail; @@ -583,37 +583,37 @@ public abstract class GridCacheTxExceptionAbstractSelfTest extends GridCacheAbst } /** {@inheritDoc} */ - @Override public GridIndexingFieldsResult queryFields(@Nullable String spaceName, String qry, - Collection params, GridIndexingQueryFilter filters) { + @Override public IndexingFieldsResult queryFields(@Nullable String spaceName, String qry, + Collection params, IndexingQueryFilter filters) { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override public IgniteSpiCloseableIterator> query( - @Nullable String spaceName, String qry, Collection params, GridIndexingTypeDescriptor type, - GridIndexingQueryFilter filters) { + @Override public IgniteSpiCloseableIterator> query( + @Nullable String spaceName, String qry, Collection params, IndexingTypeDescriptor type, + IndexingQueryFilter filters) { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override public IgniteSpiCloseableIterator> queryText( - @Nullable String spaceName, String qry, GridIndexingTypeDescriptor type, - GridIndexingQueryFilter filters) { + @Override public IgniteSpiCloseableIterator> queryText( + @Nullable String spaceName, String qry, IndexingTypeDescriptor type, + IndexingQueryFilter filters) { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override public long size(@Nullable String spaceName, GridIndexingTypeDescriptor desc) { + @Override public long size(@Nullable String spaceName, IndexingTypeDescriptor desc) { return 0; } /** {@inheritDoc} */ - @Override public boolean registerType(@Nullable String spaceName, GridIndexingTypeDescriptor desc) { + @Override public boolean registerType(@Nullable String spaceName, IndexingTypeDescriptor desc) { return true; } /** {@inheritDoc} */ - @Override public void unregisterType(@Nullable String spaceName, GridIndexingTypeDescriptor type) { + @Override public void unregisterType(@Nullable String spaceName, IndexingTypeDescriptor type) { // No-op. } @@ -628,18 +628,18 @@ public abstract class GridCacheTxExceptionAbstractSelfTest extends GridCacheAbst } /** {@inheritDoc} */ - @Override public void registerMarshaller(GridIndexingMarshaller marshaller) { + @Override public void registerMarshaller(IndexingMarshaller marshaller) { // No-op. } /** {@inheritDoc} */ - @Override public void rebuildIndexes(@Nullable String spaceName, GridIndexingTypeDescriptor type) { + @Override public void rebuildIndexes(@Nullable String spaceName, IndexingTypeDescriptor type) { // No-op. } /** {@inheritDoc} */ - @Override public void store(@Nullable String spaceName, GridIndexingTypeDescriptor type, - GridIndexingEntity key, GridIndexingEntity val, byte[] ver, long expirationTime) + @Override public void store(@Nullable String spaceName, IndexingTypeDescriptor type, + IndexingEntity key, IndexingEntity val, byte[] ver, long expirationTime) throws IgniteSpiException { if (fail) { fail = false; @@ -649,7 +649,7 @@ public abstract class GridCacheTxExceptionAbstractSelfTest extends GridCacheAbst } /** {@inheritDoc} */ - @Override public boolean remove(@Nullable String spaceName, GridIndexingEntity k) + @Override public boolean remove(@Nullable String spaceName, IndexingEntity k) throws IgniteSpiException { if (fail) { fail = false; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpi.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpi.java b/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpi.java index f6aff01..4a0f8bb 100644 --- a/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpi.java +++ b/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/GridH2IndexingSpi.java @@ -45,7 +45,7 @@ import java.util.*; import java.util.concurrent.*; import static org.apache.ignite.IgniteSystemProperties.*; -import static org.gridgain.grid.spi.indexing.GridIndexType.*; +import static org.gridgain.grid.spi.indexing.IndexType.*; import static org.gridgain.grid.spi.indexing.h2.opt.GridH2AbstractKeyValueRow.*; import static org.h2.result.SortOrder.*; @@ -56,10 +56,10 @@ import static org.h2.result.SortOrder.*; * with name {@code PUBLIC} will be used. To avoid name conflicts user should not explicitly name * a schema {@code PUBLIC}. *

- * For each registered {@link GridIndexingTypeDescriptor} this SPI will create respective SQL table with + * For each registered {@link org.gridgain.grid.spi.indexing.IndexingTypeDescriptor} this SPI will create respective SQL table with * {@code '_key'} and {@code '_val'} fields for key and value, and fields from - * {@link GridIndexingTypeDescriptor#keyFields()} and {@link GridIndexingTypeDescriptor#valueFields()}. - * For each table it will create indexes declared in {@link GridIndexingTypeDescriptor#indexes()}. + * {@link org.gridgain.grid.spi.indexing.IndexingTypeDescriptor#keyFields()} and {@link org.gridgain.grid.spi.indexing.IndexingTypeDescriptor#valueFields()}. + * For each table it will create indexes declared in {@link org.gridgain.grid.spi.indexing.IndexingTypeDescriptor#indexes()}. *

* Note that you can monitor longer queries by setting {@link #setLongQueryExplain(boolean)} to {@code true}. * In this case a warning and execution plan are printed out if query exceeds certain time threshold. The @@ -131,11 +131,11 @@ import static org.h2.result.SortOrder.*; * *
* For information about Spring framework visit www.springframework.org - * @see GridIndexingSpi + * @see org.gridgain.grid.spi.indexing.IndexingSpi */ @IgniteSpiMultipleInstancesSupport(true) @SuppressWarnings({"UnnecessaryFullyQualifiedName", "NonFinalStaticVariableUsedInClassInitialization"}) -public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingSpi, GridH2IndexingSpiMBean { +public class GridH2IndexingSpi extends IgniteSpiAdapter implements IndexingSpi, GridH2IndexingSpiMBean { /** Default query execution time interpreted as long query (3 seconds). */ public static final long DFLT_LONG_QRY_EXEC_TIMEOUT = 3000; @@ -244,7 +244,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS private final CountDownLatch ctxInitLatch = new CountDownLatch(1); /** Marshaller. */ - private GridIndexingMarshaller marshaller; + private IndexingMarshaller marshaller; /** */ private GridUnsafeMemory offheap; @@ -406,7 +406,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS * @param tblToUpdate Table to update. * @throws org.apache.ignite.spi.IgniteSpiException In case of error. */ - private void removeKey(@Nullable String spaceName, GridIndexingEntity k, TableDescriptor tblToUpdate) + private void removeKey(@Nullable String spaceName, IndexingEntity k, TableDescriptor tblToUpdate) throws IgniteSpiException { K key = k.value(); @@ -471,8 +471,8 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } /** {@inheritDoc} */ - @Override public void store(@Nullable String spaceName, GridIndexingTypeDescriptor type, - GridIndexingEntity k, GridIndexingEntity v, byte[] ver, long expirationTime) + @Override public void store(@Nullable String spaceName, IndexingTypeDescriptor type, + IndexingEntity k, IndexingEntity v, byte[] ver, long expirationTime) throws IgniteSpiException { TableDescriptor tbl = tableDescriptor(spaceName, type); @@ -498,7 +498,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } /** {@inheritDoc} */ - @Override public boolean remove(@Nullable String spaceName, GridIndexingEntity k) throws IgniteSpiException { + @Override public boolean remove(@Nullable String spaceName, IndexingEntity k) throws IgniteSpiException { assert k != null; K key = k.value(); @@ -652,9 +652,9 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public IgniteSpiCloseableIterator> queryText( - @Nullable String spaceName, String qry, GridIndexingTypeDescriptor type, - GridIndexingQueryFilter filters) throws IgniteSpiException { + @Override public IgniteSpiCloseableIterator> queryText( + @Nullable String spaceName, String qry, IndexingTypeDescriptor type, + IndexingQueryFilter filters) throws IgniteSpiException { TableDescriptor tbl = tableDescriptor(spaceName, type); if (tbl != null && tbl.luceneIdx != null) @@ -664,7 +664,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } /** {@inheritDoc} */ - @Override public void unregisterType(@Nullable String spaceName, GridIndexingTypeDescriptor type) + @Override public void unregisterType(@Nullable String spaceName, IndexingTypeDescriptor type) throws IgniteSpiException { TableDescriptor tbl = tableDescriptor(spaceName, type); @@ -674,8 +674,8 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public GridIndexingFieldsResult queryFields(@Nullable final String spaceName, final String qry, - @Nullable final Collection params, final GridIndexingQueryFilter filters) + @Override public IndexingFieldsResult queryFields(@Nullable final String spaceName, final String qry, + @Nullable final Collection params, final IndexingQueryFilter filters) throws IgniteSpiException { localSpi.set(this); @@ -686,7 +686,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS ResultSet rs = executeSqlQueryWithTimer(conn, qry, params); - List meta = null; + List meta = null; if (rs != null) { try { @@ -708,7 +708,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } } - return new GridIndexingFieldsResultAdapter(meta, new FieldsIterator(rs)); + return new IndexingFieldsResultAdapter(meta, new FieldsIterator(rs)); } finally { setFilters(null); @@ -869,9 +869,9 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS * @throws org.apache.ignite.spi.IgniteSpiException If failed. */ @SuppressWarnings("unchecked") - @Override public IgniteSpiCloseableIterator> query(@Nullable String spaceName, - final String qry, @Nullable final Collection params, GridIndexingTypeDescriptor type, - final GridIndexingQueryFilter filters) throws IgniteSpiException { + @Override public IgniteSpiCloseableIterator> query(@Nullable String spaceName, + final String qry, @Nullable final Collection params, IndexingTypeDescriptor type, + final IndexingQueryFilter filters) throws IgniteSpiException { final TableDescriptor tbl = tableDescriptor(spaceName, type); if (tbl == null) @@ -900,7 +900,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS * * @param filters Filters. */ - private void setFilters(@Nullable GridIndexingQueryFilter filters) { + private void setFilters(@Nullable IndexingQueryFilter filters) { GridH2IndexBase.setFiltersForThread(filters); } @@ -962,7 +962,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS * @param type Type description. * @throws org.apache.ignite.spi.IgniteSpiException In case of error. */ - @Override public boolean registerType(@Nullable String spaceName, GridIndexingTypeDescriptor type) + @Override public boolean registerType(@Nullable String spaceName, IndexingTypeDescriptor type) throws IgniteSpiException { if (!validateTypeDescriptor(spaceName, type)) return false; @@ -1023,7 +1023,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS * @return True if type is valid. * @throws org.apache.ignite.spi.IgniteSpiException If validation failed. */ - private boolean validateTypeDescriptor(@Nullable String spaceName, GridIndexingTypeDescriptor type) + private boolean validateTypeDescriptor(@Nullable String spaceName, IndexingTypeDescriptor type) throws IgniteSpiException { assert type != null; @@ -1152,7 +1152,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS * @param type Value type descriptor. * @return Table descriptor or {@code null} if not found. */ - @Nullable private TableDescriptor tableDescriptor(@Nullable String spaceName, GridIndexingTypeDescriptor type) { + @Nullable private TableDescriptor tableDescriptor(@Nullable String spaceName, IndexingTypeDescriptor type) { return tableDescriptor(type.name(), spaceName); } @@ -1201,7 +1201,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } /** {@inheritDoc} */ - @Override public void rebuildIndexes(@Nullable String spaceName, GridIndexingTypeDescriptor type) { + @Override public void rebuildIndexes(@Nullable String spaceName, IndexingTypeDescriptor type) { if (offheap != null) throw new UnsupportedOperationException("Index rebuilding is not supported when off-heap memory is used"); @@ -1214,19 +1214,19 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } /** {@inheritDoc} */ - @Override public long size(@Nullable String spaceName, GridIndexingTypeDescriptor type) throws IgniteSpiException { + @Override public long size(@Nullable String spaceName, IndexingTypeDescriptor type) throws IgniteSpiException { TableDescriptor tbl = tableDescriptor(spaceName, type); if (tbl == null) return -1; - IgniteSpiCloseableIterator>> iter = queryFields(spaceName, + IgniteSpiCloseableIterator>> iter = queryFields(spaceName, "SELECT COUNT(*) FROM " + tbl.fullTableName(), null, null).iterator(); if (!iter.hasNext()) throw new IllegalStateException(); - return ((GridIndexingEntityAdapter)iter.next().get(0)).value().longValue(); + return ((IndexingEntityAdapter)iter.next().get(0)).value().longValue(); } /** {@inheritDoc} */ @@ -1724,7 +1724,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } /** {@inheritDoc} */ - @Override public void registerMarshaller(GridIndexingMarshaller marshaller) { + @Override public void registerMarshaller(IndexingMarshaller marshaller) { this.marshaller = marshaller; } @@ -1943,7 +1943,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS private final String fullTblName; /** */ - private final GridIndexingTypeDescriptor type; + private final IndexingTypeDescriptor type; /** */ private final String spaceName; @@ -1961,7 +1961,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS * @param spaceName Space name. * @param type Type descriptor. */ - TableDescriptor(@Nullable String spaceName, GridIndexingTypeDescriptor type) { + TableDescriptor(@Nullable String spaceName, IndexingTypeDescriptor type) { this.spaceName = spaceName; this.type = type; @@ -1994,7 +1994,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS /** * @return Type. */ - GridIndexingTypeDescriptor type() { + IndexingTypeDescriptor type() { return type; } @@ -2020,9 +2020,9 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } } - for (Map.Entry e : type.indexes().entrySet()) { + for (Map.Entry e : type.indexes().entrySet()) { String name = e.getKey(); - GridIndexDescriptor idx = e.getValue(); + IndexDescriptor idx = e.getValue(); if (idx.type() == FULLTEXT) { try { @@ -2064,7 +2064,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS /** * Special field set iterator based on database result set. */ - private static class FieldsIterator extends GridH2ResultSetIterator>> { + private static class FieldsIterator extends GridH2ResultSetIterator>> { /** */ private static final long serialVersionUID = 0L; @@ -2077,12 +2077,12 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } /** {@inheritDoc} */ - @Override protected List> createRow() { - List> res = new ArrayList<>(row.length); + @Override protected List> createRow() { + List> res = new ArrayList<>(row.length); for (Object val : row) { - res.add(val instanceof GridIndexingEntity ? (GridIndexingEntity)val : - new GridIndexingEntityAdapter<>(val, null)); + res.add(val instanceof IndexingEntity ? (IndexingEntity)val : + new IndexingEntityAdapter<>(val, null)); } return res; @@ -2092,7 +2092,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS /** * Special key/value iterator based on database result set. */ - private static class KeyValIterator extends GridH2ResultSetIterator> { + private static class KeyValIterator extends GridH2ResultSetIterator> { /** */ private static final long serialVersionUID = 0L; @@ -2105,19 +2105,19 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS } /** {@inheritDoc} */ - @Override protected GridIndexingKeyValueRow createRow() { + @Override protected IndexingKeyValueRow createRow() { K key = (K)row[0]; V val = (V)row[1]; - return new GridIndexingKeyValueRowAdapter<>(new GridIndexingEntityAdapter<>(key, null), - new GridIndexingEntityAdapter<>(val, null), null); + return new IndexingKeyValueRowAdapter<>(new IndexingEntityAdapter<>(key, null), + new IndexingEntityAdapter<>(val, null), null); } } /** * Field descriptor. */ - private static class SqlFieldMetadata implements GridIndexingFieldMetadata { + private static class SqlFieldMetadata implements IndexingFieldMetadata { /** */ private static final long serialVersionUID = 0L; @@ -2221,7 +2221,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS */ private class RowDescriptor implements GridH2RowDescriptor { /** */ - private final GridIndexingTypeDescriptor type; + private final IndexingTypeDescriptor type; /** */ private final String[] fields; @@ -2252,7 +2252,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS * @param schema Schema. * @param keyAsObj Store key as java object. */ - RowDescriptor(GridIndexingTypeDescriptor type, Schema schema, boolean keyAsObj) { + RowDescriptor(IndexingTypeDescriptor type, Schema schema, boolean keyAsObj) { assert type != null; assert schema != null; @@ -2387,7 +2387,7 @@ public class GridH2IndexingSpi extends IgniteSpiAdapter implements GridIndexingS private static class H2Serializer implements JavaObjectSerializer { /** {@inheritDoc} */ @Override public byte[] serialize(Object o) throws Exception { - return localSpi.get().marshaller.marshal(new GridIndexingEntityAdapter<>(o, null)); + return localSpi.get().marshaller.marshal(new IndexingEntityAdapter<>(o, null)); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2AbstractKeyValueRow.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2AbstractKeyValueRow.java b/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2AbstractKeyValueRow.java index 56d6461..99b778f 100644 --- a/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2AbstractKeyValueRow.java +++ b/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2AbstractKeyValueRow.java @@ -11,7 +11,6 @@ package org.gridgain.grid.spi.indexing.h2.opt; import org.apache.ignite.spi.*; import org.gridgain.grid.*; -import org.gridgain.grid.spi.indexing.*; import org.gridgain.grid.util.typedef.internal.*; import org.h2.message.*; import org.h2.result.*; @@ -25,7 +24,7 @@ import java.sql.*; import java.util.*; /** - * Table row implementation based on {@link GridIndexingTypeDescriptor}. + * Table row implementation based on {@link org.gridgain.grid.spi.indexing.IndexingTypeDescriptor}. */ public abstract class GridH2AbstractKeyValueRow extends GridH2Row { /** */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2IndexBase.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2IndexBase.java b/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2IndexBase.java index d279e1e..d605d1a 100644 --- a/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2IndexBase.java +++ b/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2IndexBase.java @@ -27,7 +27,7 @@ import java.util.*; */ public abstract class GridH2IndexBase extends BaseIndex { /** */ - protected static final ThreadLocal filters = new ThreadLocal<>(); + protected static final ThreadLocal filters = new ThreadLocal<>(); /** */ protected final int keyCol; @@ -49,7 +49,7 @@ public abstract class GridH2IndexBase extends BaseIndex { * * @param fs Filters. */ - public static void setFiltersForThread(GridIndexingQueryFilter fs) { + public static void setFiltersForThread(IndexingQueryFilter fs) { filters.set(fs); } @@ -105,7 +105,7 @@ public abstract class GridH2IndexBase extends BaseIndex { protected Iterator filter(Iterator iter) { IgniteBiPredicate p = null; - GridIndexingQueryFilter f = filters.get(); + IndexingQueryFilter f = filters.get(); if (f != null) { String spaceName = ((GridH2Table)getTable()).spaceName(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dec83ed4/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2TreeIndex.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2TreeIndex.java b/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2TreeIndex.java index ff01b25..ecc89fe 100644 --- a/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2TreeIndex.java +++ b/modules/indexing/src/main/java/org/gridgain/grid/spi/indexing/h2/opt/GridH2TreeIndex.java @@ -162,7 +162,7 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator key, GridIndexingEntity val, byte[] ver, long expires) + public void store(IndexingEntity key, IndexingEntity val, byte[] ver, long expires) throws IgniteSpiException { Document doc = new Document(); @@ -197,7 +197,7 @@ public class GridLuceneIndex implements Closeable { * @param key Key. * @throws org.apache.ignite.spi.IgniteSpiException If failed. */ - public void remove(GridIndexingEntity key) throws IgniteSpiException { + public void remove(IndexingEntity key) throws IgniteSpiException { try { writer.deleteDocuments(new Term(KEY_FIELD_NAME, Base64.encodeBase64String(marshaller.marshal(key)))); } @@ -217,8 +217,8 @@ public class GridLuceneIndex implements Closeable { * @return Query result. * @throws org.apache.ignite.spi.IgniteSpiException If failed. */ - public GridCloseableIterator> query(String qry, - GridIndexingQueryFilter filters) throws IgniteSpiException { + public GridCloseableIterator> query(String qry, + IndexingQueryFilter filters) throws IgniteSpiException { IndexReader reader; try { @@ -277,7 +277,7 @@ public class GridLuceneIndex implements Closeable { /** * Key-value iterator over fulltext search result. */ - private class It extends GridCloseableIteratorAdapter> { + private class It extends GridCloseableIteratorAdapter> { /** */ private static final long serialVersionUID = 0L; @@ -297,7 +297,7 @@ public class GridLuceneIndex implements Closeable { private int idx; /** */ - private GridIndexingKeyValueRow curr; + private IndexingKeyValueRow curr; /** * Constructor. @@ -349,28 +349,28 @@ public class GridLuceneIndex implements Closeable { String keyStr = doc.get(KEY_FIELD_NAME); - GridIndexingEntity k = marshaller.unmarshal(Base64.decodeBase64(keyStr)); + IndexingEntity k = marshaller.unmarshal(Base64.decodeBase64(keyStr)); byte[] valBytes = doc.getBinaryValue(VAL_FIELD_NAME); - GridIndexingEntity v = valBytes != null ? marshaller.unmarshal(valBytes) : + IndexingEntity v = valBytes != null ? marshaller.unmarshal(valBytes) : type.valueClass() == String.class ? - new GridIndexingEntityAdapter<>((V)doc.get(VAL_STR_FIELD_NAME), null): null; + new IndexingEntityAdapter<>((V)doc.get(VAL_STR_FIELD_NAME), null): null; if (!filter(k.value(), v == null ? null : v.value())) continue; byte[] ver = doc.getBinaryValue(VER_FIELD_NAME); - curr = new GridIndexingKeyValueRowAdapter<>(k, v, ver); + curr = new IndexingKeyValueRowAdapter<>(k, v, ver); break; } } /** {@inheritDoc} */ - @Override protected GridIndexingKeyValueRow onNext() throws GridException { - GridIndexingKeyValueRow res = curr; + @Override protected IndexingKeyValueRow onNext() throws GridException { + IndexingKeyValueRow res = curr; findNext();