http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryConfiguration.java new file mode 100644 index 0000000..9f1cb91 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryConfiguration.java @@ -0,0 +1,203 @@ +/* + * 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.cache.query; + +import java.io.*; +import java.util.*; + +/** + * Query configuration object. + */ +public class CacheQueryConfiguration implements Serializable { + /** */ + private static final long serialVersionUID = 0L; + + /** Collection of query type metadata. */ + private Collection<CacheQueryTypeMetadata> typeMeta; + + /** Query type resolver. */ + private CacheQueryTypeResolver typeRslvr; + + /** */ + private boolean idxPrimitiveKey; + + /** */ + private boolean idxPrimitiveVal; + + /** */ + private boolean idxFixedTyping; + + /** */ + private boolean escapeAll; + + /** + * Default constructor. + */ + public CacheQueryConfiguration() { + // No-op. + } + + /** + * @param cfg Configuration to copy. + */ + public CacheQueryConfiguration(CacheQueryConfiguration cfg) { + typeMeta = cfg.getTypeMetadata(); + typeRslvr = cfg.getTypeResolver(); + idxPrimitiveKey = cfg.isIndexPrimitiveKey(); + idxPrimitiveVal = cfg.isIndexPrimitiveValue(); + idxFixedTyping = cfg.isIndexFixedTyping(); + escapeAll = cfg.isEscapeAll(); + } + + /** + * Gets collection of query type metadata objects. + * + * @return Collection of query type metadata. + */ + public Collection<CacheQueryTypeMetadata> getTypeMetadata() { + return typeMeta; + } + + /** + * Sets collection of query type metadata objects. + * + * @param typeMeta Collection of query type metadata. + */ + public void setTypeMetadata(Collection<CacheQueryTypeMetadata> typeMeta) { + this.typeMeta = typeMeta; + } + + /** + * Gets query type resolver. + * + * @return Query type resolver. + */ + public CacheQueryTypeResolver getTypeResolver() { + return typeRslvr; + } + + /** + * Sets query type resolver. + * + * @param typeRslvr Query type resolver. + */ + public void setTypeResolver(CacheQueryTypeResolver typeRslvr) { + this.typeRslvr = typeRslvr; + } + + /** + * Gets flag indicating whether SQL engine should index by key in cases + * where key is primitive type + * + * @return {@code True} if primitive keys should be indexed. + */ + public boolean isIndexPrimitiveKey() { + return idxPrimitiveKey; + } + + /** + * Sets flag indicating whether SQL engine should index by key in cases + * where key is primitive type. + * + * @param idxPrimitiveKey {@code True} if primitive keys should be indexed. + */ + public void setIndexPrimitiveKey(boolean idxPrimitiveKey) { + this.idxPrimitiveKey = idxPrimitiveKey; + } + + /** + * Gets flag indicating whether SQL engine should index by value in cases + * where value is primitive type + * + * @return {@code True} if primitive values should be indexed. + */ + public boolean isIndexPrimitiveValue() { + return idxPrimitiveVal; + } + + /** + * Sets flag indexing whether SQL engine should index by value in cases + * where value is primitive type. + * + * @param idxPrimitiveVal {@code True} if primitive values should be indexed. + */ + public void setIndexPrimitiveValue(boolean idxPrimitiveVal) { + this.idxPrimitiveVal = idxPrimitiveVal; + } + + /** + * This flag essentially controls whether all values of the same type have + * identical key type. + * <p> + * If {@code false}, SQL engine will store all keys in BINARY form to make it possible to store + * the same value type with different key types. If {@code true}, key type will be converted + * to respective SQL type if it is possible, hence, improving performance of queries. + * <p> + * Setting this value to {@code false} also means that {@code '_key'} column cannot be indexed and + * cannot participate in query where clauses. The behavior of using '_key' column in where + * clauses with this flag set to {@code false} is undefined. + * + * @return {@code True} if SQL engine should try to convert values to their respective SQL + * types for better performance. + */ + public boolean isIndexFixedTyping() { + return idxFixedTyping; + } + + /** + * This flag essentially controls whether key type is going to be identical + * for all values of the same type. + * <p> + * If false, SQL engine will store all keys in BINARY form to make it possible to store + * the same value type with different key types. If true, key type will be converted + * to respective SQL type if it is possible, which may provide significant performance + * boost. + * + * @param idxFixedTyping {@code True} if SQL engine should try to convert values to their respective SQL + * types for better performance. + */ + public void setIndexFixedTyping(boolean idxFixedTyping) { + this.idxFixedTyping = idxFixedTyping; + } + + /** + * If {@code true}, then table name and all column names in 'create table' SQL + * generated for SQL engine are escaped with double quotes. This flag should be set if table name of + * column name is H2 reserved word or is not valid H2 identifier (e.g. contains space or hyphen). + * <p> + * Note if this flag is set then table and column name in SQL queries also must be escaped with double quotes. + + * @return Flag value. + */ + public boolean isEscapeAll() { + return escapeAll; + } + + /** + * If {@code true}, then table name and all column names in 'create table' SQL + * generated for SQL engine are escaped with double quotes. This flag should be set if table name of + * column name is H2 reserved word or is not valid H2 identifier (e.g. contains space or hyphen). + * <p> + * Note if this flag is set then table and column name in SQL queries also must be escaped with double quotes. + + * @param escapeAll Flag value. + */ + public void setEscapeAll(boolean escapeAll) { + this.escapeAll = escapeAll; + } +}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryFuture.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryFuture.java new file mode 100644 index 0000000..b0c930c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryFuture.java @@ -0,0 +1,66 @@ +/* + * 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.cache.query; + +import org.apache.ignite.*; +import org.apache.ignite.lang.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * Cache query future returned by query execution. + * Refer to {@link CacheQuery} documentation for more information. + */ +public interface CacheQueryFuture<T> extends IgniteFuture<Collection<T>> { + /** + * Returns number of elements that are already fetched and can + * be returned from {@link #next()} method without blocking. + * + * @return Number of fetched elements which are available immediately. + * @throws IgniteCheckedException In case of error. + */ + public int available() throws IgniteCheckedException; + + /** + * Returns next element from result set. + * <p> + * This is a blocking call which will wait if there are no + * elements available immediately. + * + * @return Next fetched element or {@code null} if all the elements have been fetched. + * @throws IgniteCheckedException If failed. + */ + @Nullable public T next() throws IgniteCheckedException; + + /** + * Checks if all data is fetched by the query. + * + * @return {@code True} if all data is fetched, {@code false} otherwise. + */ + @Override public boolean isDone(); + + /** + * Cancels this query future and stop receiving any further results for the query + * associated with this future. + * + * @return {@inheritDoc} + * @throws IgniteCheckedException {@inheritDoc} + */ + @Override public boolean cancel() throws IgniteCheckedException; +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryGroupIndex.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryGroupIndex.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryGroupIndex.java new file mode 100644 index 0000000..e6eaa3c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryGroupIndex.java @@ -0,0 +1,58 @@ +/* + * 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.cache.query; + +import java.lang.annotation.*; + +/** + * Describes group index. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface CacheQueryGroupIndex { + /** + * Group index name. + * + * @return Name. + */ + String name(); + + /** + * If this index is unique. + * + * @return True if this index is unique, false otherwise. + * @deprecated No longer supported, will be ignored. + */ + @Deprecated + boolean unique() default false; + + /** + * List of group indexes for type. + */ + @SuppressWarnings("PublicInnerClass") + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public static @interface List { + /** + * Gets array of group indexes. + * + * @return Array of group indexes. + */ + CacheQueryGroupIndex[] value(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryMetrics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryMetrics.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryMetrics.java new file mode 100644 index 0000000..6c99aef --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryMetrics.java @@ -0,0 +1,60 @@ +/* + * 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.cache.query; + +/** + * Cache query metrics used to obtain statistics on query. You can get metrics for + * particular query via {@link CacheQuery#metrics()} method or accumulated metrics + * for all queries via {@link CacheQueries#metrics()}. + */ +public interface CacheQueryMetrics { + /** + * Gets minimum execution time of query. + * + * @return Minimum execution time of query. + */ + public long minimumTime(); + + /** + * Gets maximum execution time of query. + * + * @return Maximum execution time of query. + */ + public long maximumTime(); + + /** + * Gets average execution time of query. + * + * @return Average execution time of query. + */ + public double averageTime(); + + /** + * Gets total number execution of query. + * + * @return Number of executions. + */ + public int executions(); + + /** + * Gets total number of times a query execution failed. + * + * @return Total number of times a query execution failed. + */ + public int fails(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlField.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlField.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlField.java new file mode 100644 index 0000000..c5560a5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlField.java @@ -0,0 +1,133 @@ +/* + * 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.cache.query; + +import java.lang.annotation.*; + +/** + * Annotates fields for SQL queries. All fields that will be involved in SQL clauses must have + * this annotation. For more information about cache queries see {@link CacheQuery} documentation. + * @see CacheQuery + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD}) +public @interface CacheQuerySqlField { + /** + * Specifies whether cache should maintain an index for this field or not. + * Just like with databases, field indexing may require additional overhead + * during updates, but makes select operations faster. + * <p> + * When indexing SPI and indexed field is + * of type {@code com.vividsolutions.jts.geom.Geometry} (or any subclass of this class) then GridGain will + * consider this index as spatial providing performance boost for spatial queries. + * + * @return {@code True} if index must be created for this field in database. + */ + boolean index() default false; + + /** + * Specifies whether index should be unique or not. This property only + * makes sense if {@link #index()} property is set to {@code true}. + * + * @return {@code True} if field index should be unique. + * @deprecated No longer supported, will be ignored. + */ + @Deprecated + boolean unique() default false; + + /** + * Specifies whether index should be in descending order or not. This property only + * makes sense if {@link #index()} property is set to {@code true}. + * + * @return {@code True} if field index should be in descending order. + */ + boolean descending() default false; + + /** + * Array of index groups this field belongs to. Groups are used for compound indexes, + * whenever index should be created on more than one field. All fields within the same + * group will belong to the same index. + * <p> + * Group indexes are needed because SQL engine can utilize only one index per table occurrence in a query. + * For example if we have two separate indexes on fields {@code a} and {@code b} of type {@code X} then + * query {@code select * from X where a = ? and b = ?} will use for filtering either index on field {@code a} + * or {@code b} but not both. For more effective query execution here it is preferable to have a single + * group index on both fields. + * <p> + * For more complex scenarios please refer to {@link CacheQuerySqlField.Group} documentation. + * + * @return Array of group names. + */ + String[] groups() default {}; + + /** + * Array of ordered index groups this field belongs to. For more information please refer to + * {@linkplain CacheQuerySqlField.Group} documentation. + * + * @return Array of ordered group indexes. + * @see #groups() + */ + Group[] orderedGroups() default {}; + + /** + * Property name. If not provided then field name will be used. + * + * @return Name of property. + */ + String name() default ""; + + /** + * Describes group of index and position of field in this group. + * <p> + * Opposite to {@link #groups()} this annotation gives control over order of fields in a group index. + * This can be needed in scenarios when we have a query like + * {@code select * from X where a = ? and b = ? order by b desc}. If we have index {@code (a asc, b asc)} + * sorting on {@code b} will be performed. Here it is preferable to have index {@code (b desc, a asc)} + * which will still allow query to search on index using both fields and avoid sorting because index + * is already sorted in needed way. + * + * @see #groups() + * @see #orderedGroups() + */ + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.METHOD, ElementType.FIELD}) + @SuppressWarnings("PublicInnerClass") + public static @interface Group { + /** + * Group index name where this field participate. + * + * @return Group index name + */ + String name(); + + /** + * Fields in this group index will be sorted on this attribute. + * + * @return Order number. + */ + int order(); + + /** + * Defines sorting order for this field in group. + * + * @return True if field will be in descending order. + */ + boolean descending() default false; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlFunction.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlFunction.java new file mode 100644 index 0000000..02b9e2b --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlFunction.java @@ -0,0 +1,69 @@ +/* + * 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.cache.query; + +import org.apache.ignite.configuration.*; + +import java.lang.annotation.*; + +/** + * Annotates public static methods in classes to be used in SQL queries as custom functions. + * Annotated class must be registered in H2 indexing SPI using following method + * {@link GridQueryConfiguration#setIndexCustomFunctionClasses(Class[])}. + * <p> + * Example usage: + * <pre name="code" class="java"> + * public class MyFunctions { + * @CacheQuerySqlFunction + * public static int sqr(int x) { + * return x * x; + * } + * } + * + * // Register. + * indexing.setIndexCustomFunctionClasses(MyFunctions.class); + * + * // And use in queries. + * cache.queries().createSqlFieldsQuery("select sqr(2) where sqr(1) = 1"); + * </pre> + * <p> + * For more information about H2 custom functions please refer to + * <a href="http://www.h2database.com/html/features.html#user_defined_functions">H2 documentation</a>. + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface CacheQuerySqlFunction { + /** + * Specifies alias for the function to be used form SQL queries. + * If no alias provided method name will be used. + * + * @return Alias for function. + */ + String alias() default ""; + + /** + * Specifies if the function is deterministic (result depends only on input parameters). + * <p> + * Deterministic function is a function which always returns the same result + * assuming that input parameters are the same. + * + * @return {@code true} If function is deterministic, {@code false} otherwise. + */ + boolean deterministic() default false; +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTextField.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTextField.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTextField.java new file mode 100644 index 0000000..d48cc23 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTextField.java @@ -0,0 +1,33 @@ +/* + * 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.cache.query; + +import java.lang.annotation.*; + +/** + * Annotation for fields or getters to be indexed for full text + * search using {@code H2 TEXT} indexing. For more information + * refer to {@link CacheQuery} documentation. + * @see CacheQuery + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) +public @interface CacheQueryTextField { + // No-op. +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryType.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryType.java new file mode 100644 index 0000000..a418cfd --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryType.java @@ -0,0 +1,47 @@ +/* + * 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.cache.query; + +/** + * Cache query type. + * <p> + * Used in {@link org.apache.ignite.events.IgniteCacheQueryExecutedEvent} and {@link org.apache.ignite.events.IgniteCacheQueryReadEvent} + * to identify the type of query for which an event was fired. + * + * @see org.apache.ignite.events.IgniteCacheQueryExecutedEvent#queryType() + * @see org.apache.ignite.events.IgniteCacheQueryReadEvent#queryType() + */ +public enum CacheQueryType { + /** SQL query. */ + SQL, + + /** SQL fields query. */ + SQL_FIELDS, + + /** Full text query. */ + FULL_TEXT, + + /** Scan query. */ + SCAN, + + /** Continuous query. */ + CONTINUOUS, + + /** SPI query. */ + SPI +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTypeMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTypeMetadata.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTypeMetadata.java new file mode 100644 index 0000000..7b0afff --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTypeMetadata.java @@ -0,0 +1,196 @@ +/* + * 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.cache.query; + +import org.apache.ignite.lang.*; +import org.apache.ignite.internal.util.tostring.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.util.*; + +/** + * Cache query type metadata. + */ +public class CacheQueryTypeMetadata { + /** Type name, e.g. class name. */ + @GridToStringInclude + private String type; + + /** Fields to be queried, in addition to indexed fields. */ + @GridToStringInclude + private Map<String, Class<?>> qryFlds = new HashMap<>(); + + /** Fields to index in ascending order. */ + @GridToStringInclude + private Map<String, Class<?>> ascFlds = new HashMap<>(); + + /** Fields to index in descending order. */ + @GridToStringInclude + private Map<String, Class<?>> descFlds = new HashMap<>(); + + /** Fields to index as text. */ + @GridToStringInclude + private Collection<String> txtFlds = new LinkedHashSet<>(); + + /** Fields to create group indexes for. */ + @GridToStringInclude + private Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps; + + /** + * Default constructor. + */ + public CacheQueryTypeMetadata() { + // No-op. + } + + /** + * + */ + public CacheQueryTypeMetadata(CacheQueryTypeMetadata src) { + type = src.getType(); + + qryFlds = new HashMap<>(src.getQueryFields()); + ascFlds = new HashMap<>(src.getAscendingFields()); + descFlds = new HashMap<>(src.getDescendingFields()); + txtFlds = new HashSet<>(src.getTextFields()); + + grps = new HashMap<>(src.getGroups()); + } + + /** + * Gets type (e.g. class name). + * + * @return Type name. + */ + public String getType() { + return type; + } + + /** + * Sets type. + * + * @param cls Type class. + */ + public void setType(Class<?> cls) { + setType(cls.getName()); + } + + /** + * Sets type. + * + * @param type Type name. + */ + public void setType(String type) { + this.type = type; + } + + /** + * Gets query-enabled fields. + * + * @return Collection of fields available for query. + */ + public Map<String, Class<?>> getQueryFields() { + return qryFlds; + } + + /** + * Sets query fields map. + * + * @param qryFlds Query fields. + */ + public void setQueryFields(Map<String, Class<?>> qryFlds) { + this.qryFlds = qryFlds; + } + + /** + * Gets ascending-indexed fields. + * + * @return Map of ascending-indexed fields. + */ + public Map<String, Class<?>> getAscendingFields() { + return ascFlds; + } + + /** + * Sets ascending-indexed fields. + * + * @param ascFlds Map of ascending-indexed fields. + */ + public void setAscendingFields(Map<String, Class<?>> ascFlds) { + this.ascFlds = ascFlds; + } + + /** + * Gets descending-indexed fields. + * + * @return Map of descending-indexed fields. + */ + public Map<String, Class<?>> getDescendingFields() { + return descFlds; + } + + /** + * Sets descending-indexed fields. + * + * @param descFlds Map of descending-indexed fields. + */ + public void setDescendingFields(Map<String, Class<?>> descFlds) { + this.descFlds = descFlds; + } + + /** + * Gets text-indexed fields. + * + * @return Collection of text indexed fields. + */ + public Collection<String> getTextFields() { + return txtFlds; + } + + /** + * Sets text-indexed fields. + * + * @param txtFlds Text-indexed fields. + */ + public void setTextFields(Collection<String> txtFlds) { + this.txtFlds = txtFlds; + } + + /** + * Gets group-indexed fields. + * + * @return Map of group-indexed fields. + */ + public Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> getGroups() { + return grps; + } + + /** + * Sets group-indexed fields. + * + * @param grps Map of group-indexed fields from index name to index fields. + */ + public void setGroups(Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps) { + this.grps = grps; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(CacheQueryTypeMetadata.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTypeResolver.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTypeResolver.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTypeResolver.java new file mode 100644 index 0000000..9fea55e --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTypeResolver.java @@ -0,0 +1,32 @@ +/* + * 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.cache.query; + +/** + * Interface allowing to override table name for portable objects stored in cache. + */ +public interface CacheQueryTypeResolver { + /** + * Allows to override type name for portable objects being stored in cache. + * + * @param key Key. + * @param val Value. + * @return Type name. + */ + public String resolveTypeName(Object key, Object val); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheContinuousQuery.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheContinuousQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheContinuousQuery.java deleted file mode 100644 index 254504b..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheContinuousQuery.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * 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.cache.query; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.lang.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * API for configuring and executing continuous cache queries. - * <p> - * Continuous queries are executed as follows: - * <ol> - * <li> - * Query is sent to requested grid nodes. Note that for {@link org.apache.ignite.cache.CacheMode#LOCAL LOCAL} - * and {@link org.apache.ignite.cache.CacheMode#REPLICATED REPLICATED} caches query will be always executed - * locally. - * </li> - * <li> - * Each node iterates through existing cache data and registers listeners that will - * notify about further updates. - * <li> - * Each key-value pair is passed through optional filter and if this filter returns - * true, key-value pair is sent to the master node (the one that executed query). - * If filter is not provided, all pairs are sent. - * </li> - * <li> - * When master node receives key-value pairs, it notifies the local callback. - * </li> - * </ol> - * <h2 class="header">NOTE</h2> - * Under some concurrent circumstances callback may get several notifications - * for one cache update. This should be taken into account when implementing callback. - * <h1 class="header">Query usage</h1> - * As an example, suppose we have cache with {@code 'Person'} objects and we need - * to query all persons with salary above 1000. - * <p> - * Here is the {@code Person} class: - * <pre name="code" class="java"> - * public class Person { - * // Name. - * private String name; - * - * // Salary. - * private double salary; - * - * ... - * } - * </pre> - * <p> - * You can create and execute continuous query like so: - * <pre name="code" class="java"> - * // Create new continuous query. - * qry = cache.createContinuousQuery(); - * - * // Callback that is called locally when update notifications are received. - * // It simply prints out information about all created persons. - * qry.callback(new GridPredicate2<UUID, Collection<Map.Entry<UUID, Person>>>() { - * @Override public boolean apply(UUID uuid, Collection<Map.Entry<UUID, Person>> entries) { - * for (Map.Entry<UUID, Person> e : entries) { - * Person p = e.getValue(); - * - * X.println(">>>"); - * X.println(">>> " + p.getFirstName() + " " + p.getLastName() + - * "'s salary is " + p.getSalary()); - * X.println(">>>"); - * } - * - * return true; - * } - * }); - * - * // This query will return persons with salary above 1000. - * qry.filter(new GridPredicate2<UUID, Person>() { - * @Override public boolean apply(UUID uuid, Person person) { - * return person.getSalary() > 1000; - * } - * }); - * - * // Execute query. - * qry.execute(); - * </pre> - * This will execute query on all nodes that have cache you are working with and notify callback - * with both data that already exists in cache and further updates. - * <p> - * To stop receiving updates call {@link #close()} method: - * <pre name="code" class="java"> - * qry.cancel(); - * </pre> - * Note that one query instance can be executed only once. After it's cancelled, it's non-operational. - * If you need to repeat execution, use {@link GridCacheQueries#createContinuousQuery()} method to create - * new query. - */ -public interface GridCacheContinuousQuery<K, V> extends AutoCloseable { - /** - * Default buffer size. Size of {@code 1} means that all entries - * will be sent to master node immediately (buffering is disabled). - */ - public static final int DFLT_BUF_SIZE = 1; - - /** Maximum default time interval after which buffer will be flushed (if buffering is enabled). */ - public static final long DFLT_TIME_INTERVAL = 0; - - /** - * Default value for automatic unsubscription flag. Remote filters - * will be unregistered by default if master node leaves topology. - */ - public static final boolean DFLT_AUTO_UNSUBSCRIBE = true; - - /** - * Sets local callback. This callback is called only - * in local node when new updates are received. - * <p> - * The callback predicate accepts ID of the node from where updates - * are received and collection of received entries. Note that - * for removed entries value will be {@code null}. - * <p> - * If the predicate returns {@code false}, query execution will - * be cancelled. - * <p> - * <b>WARNING:</b> all operations that involve any kind of JVM-local - * or distributed locking (e.g., synchronization or transactional - * cache operations), should be executed asynchronously without - * blocking the thread that called the callback. Otherwise, you - * can get deadlocks. - * - * @param cb Local callback. - * @deprecated Deprecated in favor of {@link #localCallback(IgniteBiPredicate)} method. - */ - @Deprecated - public void callback(@Nullable IgniteBiPredicate<UUID, Collection<Map.Entry<K, V>>> cb); - - /** - * Gets local callback. See {@link #callback(IgniteBiPredicate)} for more information. - * - * @return Local callback. - * @deprecated Deprecated in favor of {@link #localCallback()} method. - */ - @Deprecated - public IgniteBiPredicate<UUID, Collection<Map.Entry<K, V>>> callback(); - - /** - * Sets optional key-value filter. This filter is called before - * entry is sent to the master node. - * <p> - * <b>WARNING:</b> all operations that involve any kind of JVM-local - * or distributed locking (e.g., synchronization or transactional - * cache operations), should be executed asynchronously without - * blocking the thread that called the filter. Otherwise, you - * can get deadlocks. - * - * @param filter Key-value filter. - * @deprecated Deprecated in favor of {@link #remoteFilter(org.apache.ignite.lang.IgnitePredicate)} method. - */ - @Deprecated - public void filter(@Nullable IgniteBiPredicate<K, V> filter); - - /** - * Gets key-value filter. See {@link #filter(IgniteBiPredicate)} for more information. - * - * @return Key-value filter. - * @deprecated Deprecated in favor of {@link #remoteFilter()} method. - */ - @Deprecated - @Nullable public IgniteBiPredicate<K, V> filter(); - - /** - * Sets local callback. This callback is called only - * in local node when new updates are received. - * <p> - * The callback predicate accepts ID of the node from where updates - * are received and collection of received entries. Note that - * for removed entries value will be {@code null}. - * <p> - * If the predicate returns {@code false}, query execution will - * be cancelled. - * <p> - * <b>WARNING:</b> all operations that involve any kind of JVM-local - * or distributed locking (e.g., synchronization or transactional - * cache operations), should be executed asynchronously without - * blocking the thread that called the callback. Otherwise, you - * can get deadlocks. - * - * @param locCb Local callback. - */ - public void localCallback(IgniteBiPredicate<UUID, Collection<GridCacheContinuousQueryEntry<K, V>>> locCb); - - /** - * Gets local callback. See {@link #callback(IgniteBiPredicate)} for more information. - * - * @return Local callback. - */ - @Nullable public IgniteBiPredicate<UUID, Collection<GridCacheContinuousQueryEntry<K, V>>> localCallback(); - - /** - * Sets optional key-value filter. This filter is called before - * entry is sent to the master node. - * <p> - * <b>WARNING:</b> all operations that involve any kind of JVM-local - * or distributed locking (e.g., synchronization or transactional - * cache operations), should be executed asynchronously without - * blocking the thread that called the filter. Otherwise, you - * can get deadlocks. - * - * @param filter Key-value filter. - */ - public void remoteFilter(@Nullable IgnitePredicate<GridCacheContinuousQueryEntry<K, V>> filter); - - /** - * Gets key-value filter. See {@link #filter(IgniteBiPredicate)} for more information. - * - * @return Key-value filter. - */ - @Nullable public IgnitePredicate<GridCacheContinuousQueryEntry<K, V>> remoteFilter(); - - /** - * Sets buffer size. - * <p> - * When a cache update happens, entry is first put into a buffer. - * Entries from buffer will be sent to the master node only if - * the buffer is full or time provided via {@link #timeInterval(long)} - * method is exceeded. - * <p> - * Default buffer size is {@code 1} which means that entries will - * be sent immediately (buffering is disabled). - * - * @param bufSize Buffer size. - */ - public void bufferSize(int bufSize); - - /** - * Gets buffer size. See {@link #bufferSize(int)} for more information. - * - * @return Buffer size. - */ - public int bufferSize(); - - /** - * Sets time interval. - * <p> - * When a cache update happens, entry is first put into a buffer. - * Entries from buffer will be sent to the master node only if - * the buffer is full (its size can be provided via {@link #bufferSize(int)} - * method) or time provided via this method is exceeded. - * <p> - * Default time interval is {@code 0} which means that time check is - * disabled and entries will be sent only when buffer is full. - * - * @param timeInterval Time interval. - */ - public void timeInterval(long timeInterval); - - /** - * Gets time interval. See {@link #timeInterval(long)} for more information. - * - * @return Gets time interval. - */ - public long timeInterval(); - - /** - * Sets automatic unsubscribe flag. - * <p> - * This flag indicates that query filters on remote nodes should be automatically - * unregistered if master node (node that initiated the query) leaves topology. - * If this flag is {@code false}, filters will be unregistered only when - * the query is cancelled from master node, and won't ever be unregistered if - * master node leaves grid. - * <p> - * Default value for this flag is {@code true}. - * - * @param autoUnsubscribe Automatic unsubscription flag. - */ - public void autoUnsubscribe(boolean autoUnsubscribe); - - /** - * Gets automatic unsubscribe flag. See {@link #autoUnsubscribe(boolean)} - * for more information. - * - * @return Automatic unsubscribe flag. - */ - public boolean isAutoUnsubscribe(); - - /** - * Starts continuous query execution on the whole grid. - * <p> - * Note that if grid contains nodes without appropriate cache, - * these nodes will be filtered out. - * <p> - * Also note that for {@link org.apache.ignite.cache.CacheMode#LOCAL LOCAL} - * and {@link org.apache.ignite.cache.CacheMode#REPLICATED REPLICATED} caches - * query will be always executed locally. - * - * @throws IgniteCheckedException In case of error. - */ - public void execute() throws IgniteCheckedException; - - /** - * Starts continuous query execution on provided set of nodes. - * <p> - * Note that if provided projection contains nodes without - * appropriate cache, these nodes will be filtered out. - * <p> - * Also note that for {@link org.apache.ignite.cache.CacheMode#LOCAL LOCAL} - * and {@link org.apache.ignite.cache.CacheMode#REPLICATED REPLICATED} caches - * query will be always executed locally. - * - * @param prj Grid projection. - * @throws IgniteCheckedException In case of error. - */ - public void execute(@Nullable ClusterGroup prj) throws IgniteCheckedException; - - /** - * Stops continuous query execution. - * <p> - * Note that one query instance can be executed only once. - * After it's cancelled, it's non-operational. - * If you need to repeat execution, use {@link GridCacheQueries#createContinuousQuery()} - * method to create new query. - * - * @throws IgniteCheckedException In case of error. - */ - @Override public void close() throws IgniteCheckedException; -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheContinuousQueryEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheContinuousQueryEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheContinuousQueryEntry.java deleted file mode 100644 index 9601df8..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheContinuousQueryEntry.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.cache.query; - -import org.jetbrains.annotations.*; - -import java.io.*; -import java.util.*; - -/** - * Entry used for continuous query notifications. - */ -public interface GridCacheContinuousQueryEntry<K, V> extends Map.Entry<K, V>, Serializable { - /** - * Gets entry key. - * - * @return Entry key. - */ - @Override public K getKey(); - - /** - * Gets entry new value. New value may be null, if entry is being removed. - * - * @return Entry new value. - */ - @Override @Nullable public V getValue(); - - /** - * Gets entry old value. Old value may be null if entry is being inserted (not updated). - * - * @return Gets entry old value. - */ - @Nullable public V getOldValue(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueries.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueries.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueries.java deleted file mode 100644 index 28727dc..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueries.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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.cache.query; - -import org.apache.ignite.lang.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * Facade for creating distributed queries. It contains various {@code 'createXxxQuery(..)'} - * methods for {@code SQL}, {@code TEXT}, and {@code SCAN} query creation (see {@link GridCacheQuery} - * for more information). - * <p> - * Instance of {@code GridCacheQueries} is obtained from cache projection as follows: - * <pre name="code" class="java"> - * GridCacheQueries q = GridGain.grid().cache("myCache").queries(); - * </pre> - */ -public interface GridCacheQueries<K, V> { - /** - * Creates user's SQL query, queried class, and query clause which is generally - * a where clause. For more information refer to {@link GridCacheQuery} documentation. - * - * @param cls Query class. - * @param clause Query clause. - * @return Created query. - */ - public GridCacheQuery<Map.Entry<K, V>> createSqlQuery(Class<?> cls, String clause); - - /** - * Creates user's SQL query, queried class, and query clause which is generally - * a where clause. For more information refer to {@link GridCacheQuery} documentation. - * - * @param clsName Query class name. - * @param clause Query clause. - * @return Created query. - */ - public GridCacheQuery<Map.Entry<K, V>> createSqlQuery(String clsName, String clause); - - /** - * Creates user's SQL fields query for given clause. For more information refer to - * {@link GridCacheQuery} documentation. - * - * @param qry Query. - * @return Created query. - */ - public GridCacheQuery<List<?>> createSqlFieldsQuery(String qry); - - /** - * Creates user's full text query, queried class, and query clause. - * For more information refer to {@link GridCacheQuery} documentation. - * - * @param clsName Query class name. - * @param search Search clause. - * @return Created query. - */ - public GridCacheQuery<Map.Entry<K, V>> createFullTextQuery(String clsName, String search); - - /** - * Creates user's full text query, queried class, and query clause. - * For more information refer to {@link GridCacheQuery} documentation. - * - * @param cls Query class. - * @param search Search clause. - * @return Created query. - */ - public GridCacheQuery<Map.Entry<K, V>> createFullTextQuery(Class<?> cls, String search); - - /** - * Creates user's predicate based scan query. - * - * @param filter Scan filter. - * @return Created query. - */ - public GridCacheQuery<Map.Entry<K, V>> createScanQuery(@Nullable IgniteBiPredicate<K, V> filter); - - /** - * Creates new continuous query. - * <p> - * For more information refer to {@link GridCacheContinuousQuery} documentation. - * - * @return Created continuous query. - * @see GridCacheContinuousQuery - */ - public GridCacheContinuousQuery<K, V> createContinuousQuery(); - - /** - * Forces this cache to rebuild all search indexes of given value type. Sometimes indexes - * may hold references to objects that have already been removed from cache. Although - * not affecting query results, these objects may consume extra memory. Rebuilding - * indexes will remove any redundant references that may have temporarily got stuck - * inside in-memory index. - * - * @param cls Value type to rebuild indexes for. - * - * @return Future that will be completed when rebuilding of all indexes is finished. - */ - public IgniteFuture<?> rebuildIndexes(Class<?> cls); - - /** - * Forces this cache to rebuild all search indexes of given value type. Sometimes indexes - * may hold references to objects that have already been removed from cache. Although - * not affecting query results, these objects may consume extra memory. Rebuilding - * indexes will remove any redundant references that may have temporarily got stuck - * inside in-memory index. - * - * @param typeName Value type name to rebuild indexes for. - * - * @return Future that will be completed when rebuilding of all indexes is finished. - */ - public IgniteFuture<?> rebuildIndexes(String typeName); - - /** - * Forces this cache to rebuild search indexes of all types. Sometimes indexes - * may hold references to objects that have already been removed from cache. Although - * not affecting query results, these objects may consume extra memory. Rebuilding - * indexes will remove any redundant references that may have temporarily got stuck - * inside in-memory index. - * - * @return Future that will be completed when rebuilding of all indexes is finished. - */ - public IgniteFuture<?> rebuildAllIndexes(); - - /** - * Accumulated metrics for all queries executed for this cache. - * - * @return Cache query metrics. - */ - public GridCacheQueryMetrics metrics(); - - /** - * Resets accumulated metrics. - */ - public void resetMetrics(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQuery.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQuery.java deleted file mode 100644 index 7fddd46..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQuery.java +++ /dev/null @@ -1,295 +0,0 @@ -/* - * 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.cache.query; - -import org.apache.ignite.cluster.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.lang.*; -import org.jetbrains.annotations.*; - -/** - * Main API for configuring and executing cache queries. - * <p> - * Cache queries are created from {@link GridCacheQueries} API via any of the available - * {@code createXXXQuery(...)} methods. - * <h1 class="header">SQL Queries</h1> - * {@code SQL} query allows to execute distributed cache - * queries using standard SQL syntax. All values participating in where clauses - * or joins must be annotated with {@link GridCacheQuerySqlField} annotation. Query can be created - * with {@link GridCacheQueries#createSqlQuery(Class, String)} method. - * <h2 class="header">Field Queries</h2> - * By default {@code select} clause is ignored as query result contains full objects. - * If it is needed to select individual fields, use {@link GridCacheQueries#createSqlFieldsQuery(String)} method. - * This type of query replaces full objects with individual fields. Note that selected fields - * must be annotated with {@link GridCacheQuerySqlField} annotation. - * <h2 class="header">Cross-Cache Queries</h2> - * You are allowed to query data from several caches. Cache that this query was created on is - * treated as default schema in this case. Other caches can be referenced by their names. - * <p> - * Note that cache name is case sensitive and has to always be specified in double quotes. - * Here is an example of cross cache query (note that 'replicated' and 'partitioned' are - * cache names for replicated and partitioned caches accordingly): - * <pre name="code" class="java"> - * GridCacheQuery<Map.Entry<Integer, FactPurchase>> storePurchases = cache.queries().createSqlQuery( - * Purchase.class, - * "from \"replicated\".Store, \"partitioned\".Purchase where Store.id=Purchase.storeId and Store.id=?"); - * </pre> - * <h2 class="header">Custom functions in SQL queries.</h2> - * It is possible to write custom Java methods and call then form SQL queries. These methods must be public static - * and annotated with {@link GridCacheQuerySqlFunction}. Classes containing these methods must be registered in - * {@link GridQueryConfiguration#setIndexCustomFunctionClasses(Class[])}. - * <h1 class="header">Full Text Queries</h1> - * GridGain supports full text queries based on Apache Lucene engine. This queries are created by - * {@link GridCacheQueries#createFullTextQuery(Class, String)} method. Note that all fields that - * are expected to show up in text query results must be annotated with {@link GridCacheQueryTextField} - * annotation. - * <h1 class="header">Scan Queries</h1> - * Sometimes when it is known in advance that SQL query will cause a full data scan, or whenever data set - * is relatively small, the full scan query may be used. This query will iterate over all cache - * entries, skipping over entries that don't pass the optionally provided key-value filter - * (see {@link GridCacheQueries#createScanQuery(org.apache.ignite.lang.IgniteBiPredicate)} method). - * <h2 class="header">Limitations</h2> - * Data in GridGain cache is usually distributed across several nodes, - * so some queries may not work as expected. Keep in mind following limitations - * (not applied if data is queried from one node only): - * <ul> - * <li> - * {@code Group by} and {@code sort by} statements are applied separately - * on each node, so result set will likely be incorrectly grouped or sorted - * after results from multiple remote nodes are grouped together. - * </li> - * <li> - * Aggregation functions like {@code sum}, {@code max}, {@code avg}, etc. - * are also applied on each node. Therefore you will get several results - * containing aggregated values, one for each node. - * </li> - * <li> - * Joins will work correctly only if joined objects are stored in - * collocated mode or at least one side of the join is stored in - * {@link org.apache.ignite.cache.CacheMode#REPLICATED} cache. Refer to - * {@link org.apache.ignite.cache.affinity.GridCacheAffinityKey} javadoc for more information about colocation. - * </li> - * </ul> - * <h1 class="header">Query usage</h1> - * As an example, suppose we have data model consisting of {@code 'Employee'} and {@code 'Organization'} - * classes defined as follows: - * <pre name="code" class="java"> - * public class Organization { - * // Indexed field. - * @GridCacheQuerySqlField(index = true) - * private long id; - * - * // Indexed field. - * @GridCacheQuerySqlField(index = true) - * private String name; - * ... - * } - * - * public class Person { - * // Indexed field. - * @GridCacheQuerySqlField(index = true) - * private long id; - * - * // Indexed field (Organization ID, used as a foreign key). - * @GridCacheQuerySqlField(index = true) - * private long orgId; - * - * // Without SQL field annotation, this field cannot be used in queries. - * private String name; - * - * // Not indexed field. - * @GridCacheQuerySqlField - * private double salary; - * - * // Index for text search. - * @GridCacheQueryTextField - * private String resume; - * ... - * } - * </pre> - * Then you can create and execute queries that check various salary ranges like so: - * <pre name="code" class="java"> - * GridCache<Long, Person> cache = G.grid().cache(); - * ... - * // Create query which selects salaries based on range for all employees - * // that work for a certain company. - * GridCacheQuery<Map.Entry<Long, Person>> qry = cache.queries().createSqlQuery(Person.class, - * "from Person, Organization where Person.orgId = Organization.id " + - * "and Organization.name = ? and Person.salary > ? and Person.salary <= ?"); - * - * // Query all nodes to find all cached GridGain employees - * // with salaries less than 1000. - * qry.execute("GridGain", 0, 1000); - * - * // Query only remote nodes to find all remotely cached GridGain employees - * // with salaries greater than 1000 and less than 2000. - * qry.projection(grid.remoteProjection()).execute("GridGain", 1000, 2000); - * </pre> - * Here is a possible query that will use Lucene text search to scan all resumes to - * check if employees have {@code Master} degree: - * <pre name="code" class="java"> - * GridCacheQuery<Map.Entry<Long, Person>> mastersQry = - * cache.queries().createFullTextQuery(Person.class, "Master"); - * - * // Query all cache nodes. - * mastersQry.execute(); - * </pre> - * <h1 class="header">Geo-Spatial Indexes and Queries</h1> - * GridGain also support <b>Geo-Spatial Indexes</b>. Here is an example of geo-spatial index: - * <pre name="code" class="java"> - * private class MapPoint implements Serializable { - * // Geospatial index. - * @GridCacheQuerySqlField(index = true) - * private com.vividsolutions.jts.geom.Point location; - * - * // Not indexed field. - * @GridCacheQuerySqlField - * private String name; - * - * public MapPoint(com.vividsolutions.jts.geom.Point location, String name) { - * this.location = location; - * this.name = name; - * } - * } - * </pre> - * Example of spatial query on the geo-indexed field from above: - * <pre name="code" class="java"> - * com.vividsolutions.jts.geom.GeometryFactory factory = new com.vividsolutions.jts.geom.GeometryFactory(); - * - * com.vividsolutions.jts.geom.Polygon square = factory.createPolygon(new Coordinate[] { - * new com.vividsolutions.jts.geom.Coordinate(0, 0), - * new com.vividsolutions.jts.geom.Coordinate(0, 100), - * new com.vividsolutions.jts.geom.Coordinate(100, 100), - * new com.vividsolutions.jts.geom.Coordinate(100, 0), - * new com.vividsolutions.jts.geom.Coordinate(0, 0) - * }); - * - * Map.Entry<String, UserData> records = cache.queries().createSqlQuery(MapPoint.class, "select * from MapPoint where location && ?") - * .queryArguments(square) - * .execute() - * .get(); - * </pre> - */ -public interface GridCacheQuery<T> { - /** Default query page size. */ - public static final int DFLT_PAGE_SIZE = 1024; - - /** - * Sets result page size. If not provided, {@link #DFLT_PAGE_SIZE} will be used. - * Results are returned from queried nodes one page at a tme. - * - * @param pageSize Page size. - * @return {@code this} query instance for chaining. - */ - public GridCacheQuery<T> pageSize(int pageSize); - - /** - * Sets query timeout. {@code 0} means there is no timeout (this - * is a default value). - * - * @param timeout Query timeout. - * @return {@code this} query instance for chaining. - */ - public GridCacheQuery<T> timeout(long timeout); - - /** - * Sets whether or not to keep all query results local. If not - only the current page - * is kept locally. Default value is {@code true}. - * - * @param keepAll Keep results or not. - * @return {@code this} query instance for chaining. - */ - public GridCacheQuery<T> keepAll(boolean keepAll); - - /** - * Sets whether or not to include backup entries into query result. This flag - * is {@code false} by default. - * - * @param incBackups Query {@code includeBackups} flag. - * @return {@code this} query instance for chaining. - */ - public GridCacheQuery<T> includeBackups(boolean incBackups); - - /** - * Sets whether or not to deduplicate query result set. If this flag is {@code true} - * then query result will not contain some key more than once even if several nodes - * returned entries with the same keys. Default value is {@code false}. - * - * @param dedup Query {@code enableDedup} flag. - * @return {@code this} query instance for chaining. - */ - public GridCacheQuery<T> enableDedup(boolean dedup); - - /** - * Sets optional grid projection to execute this query on. - * - * @param prj Projection. - * @return {@code this} query instance for chaining. - */ - public GridCacheQuery<T> projection(ClusterGroup prj); - - /** - * Executes the query and returns the query future. Caller may decide to iterate - * over the returned future directly in which case the iterator may block until - * the next value will become available, or wait for the whole query to finish - * by calling any of the {@code 'get(..)'} methods on the returned future. If - * {@link #keepAll(boolean)} flag is set to {@code false}, then {@code 'get(..)'} - * methods will only return the last page received, otherwise all pages will be - * accumulated and returned to user as a collection. - * <p> - * Note that if the passed in grid projection is a local node, then query - * will be executed locally without distribution to other nodes. - * <p> - * Also note that query state cannot be changed (clause, timeout etc.), except - * arguments, if this method was called at least once. - * - * @param args Optional arguments. - * @return Future for the query result. - */ - public GridCacheQueryFuture<T> execute(@Nullable Object... args); - - /** - * Executes the query the same way as {@link #execute(Object...)} method but reduces result remotely. - * - * @param rmtReducer Remote reducer. - * @param args Optional arguments. - * @return Future for the query result. - */ - public <R> GridCacheQueryFuture<R> execute(IgniteReducer<T, R> rmtReducer, @Nullable Object... args); - - /** - * Executes the query the same way as {@link #execute(Object...)} method but transforms result remotely. - * - * @param rmtTransform Remote transformer. - * @param args Optional arguments. - * @return Future for the query result. - */ - public <R> GridCacheQueryFuture<R> execute(IgniteClosure<T, R> rmtTransform, @Nullable Object... args); - - /** - * Gets metrics for this query. - * - * @return Query metrics. - */ - public GridCacheQueryMetrics metrics(); - - /** - * Resets metrics for this query. - */ - public void resetMetrics(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryConfiguration.java deleted file mode 100644 index ad471c4..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryConfiguration.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * 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.cache.query; - -import java.io.*; -import java.util.*; - -/** - * Query configuration object. - */ -public class GridCacheQueryConfiguration implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** Collection of query type metadata. */ - private Collection<GridCacheQueryTypeMetadata> typeMeta; - - /** Query type resolver. */ - private GridCacheQueryTypeResolver typeRslvr; - - /** */ - private boolean idxPrimitiveKey; - - /** */ - private boolean idxPrimitiveVal; - - /** */ - private boolean idxFixedTyping; - - /** */ - private boolean escapeAll; - - /** - * Default constructor. - */ - public GridCacheQueryConfiguration() { - // No-op. - } - - /** - * @param cfg Configuration to copy. - */ - public GridCacheQueryConfiguration(GridCacheQueryConfiguration cfg) { - typeMeta = cfg.getTypeMetadata(); - typeRslvr = cfg.getTypeResolver(); - idxPrimitiveKey = cfg.isIndexPrimitiveKey(); - idxPrimitiveVal = cfg.isIndexPrimitiveValue(); - idxFixedTyping = cfg.isIndexFixedTyping(); - escapeAll = cfg.isEscapeAll(); - } - - /** - * Gets collection of query type metadata objects. - * - * @return Collection of query type metadata. - */ - public Collection<GridCacheQueryTypeMetadata> getTypeMetadata() { - return typeMeta; - } - - /** - * Sets collection of query type metadata objects. - * - * @param typeMeta Collection of query type metadata. - */ - public void setTypeMetadata(Collection<GridCacheQueryTypeMetadata> typeMeta) { - this.typeMeta = typeMeta; - } - - /** - * Gets query type resolver. - * - * @return Query type resolver. - */ - public GridCacheQueryTypeResolver getTypeResolver() { - return typeRslvr; - } - - /** - * Sets query type resolver. - * - * @param typeRslvr Query type resolver. - */ - public void setTypeResolver(GridCacheQueryTypeResolver typeRslvr) { - this.typeRslvr = typeRslvr; - } - - /** - * Gets flag indicating whether SQL engine should index by key in cases - * where key is primitive type - * - * @return {@code True} if primitive keys should be indexed. - */ - public boolean isIndexPrimitiveKey() { - return idxPrimitiveKey; - } - - /** - * Sets flag indicating whether SQL engine should index by key in cases - * where key is primitive type. - * - * @param idxPrimitiveKey {@code True} if primitive keys should be indexed. - */ - public void setIndexPrimitiveKey(boolean idxPrimitiveKey) { - this.idxPrimitiveKey = idxPrimitiveKey; - } - - /** - * Gets flag indicating whether SQL engine should index by value in cases - * where value is primitive type - * - * @return {@code True} if primitive values should be indexed. - */ - public boolean isIndexPrimitiveValue() { - return idxPrimitiveVal; - } - - /** - * Sets flag indexing whether SQL engine should index by value in cases - * where value is primitive type. - * - * @param idxPrimitiveVal {@code True} if primitive values should be indexed. - */ - public void setIndexPrimitiveValue(boolean idxPrimitiveVal) { - this.idxPrimitiveVal = idxPrimitiveVal; - } - - /** - * This flag essentially controls whether all values of the same type have - * identical key type. - * <p> - * If {@code false}, SQL engine will store all keys in BINARY form to make it possible to store - * the same value type with different key types. If {@code true}, key type will be converted - * to respective SQL type if it is possible, hence, improving performance of queries. - * <p> - * Setting this value to {@code false} also means that {@code '_key'} column cannot be indexed and - * cannot participate in query where clauses. The behavior of using '_key' column in where - * clauses with this flag set to {@code false} is undefined. - * - * @return {@code True} if SQL engine should try to convert values to their respective SQL - * types for better performance. - */ - public boolean isIndexFixedTyping() { - return idxFixedTyping; - } - - /** - * This flag essentially controls whether key type is going to be identical - * for all values of the same type. - * <p> - * If false, SQL engine will store all keys in BINARY form to make it possible to store - * the same value type with different key types. If true, key type will be converted - * to respective SQL type if it is possible, which may provide significant performance - * boost. - * - * @param idxFixedTyping {@code True} if SQL engine should try to convert values to their respective SQL - * types for better performance. - */ - public void setIndexFixedTyping(boolean idxFixedTyping) { - this.idxFixedTyping = idxFixedTyping; - } - - /** - * If {@code true}, then table name and all column names in 'create table' SQL - * generated for SQL engine are escaped with double quotes. This flag should be set if table name of - * column name is H2 reserved word or is not valid H2 identifier (e.g. contains space or hyphen). - * <p> - * Note if this flag is set then table and column name in SQL queries also must be escaped with double quotes. - - * @return Flag value. - */ - public boolean isEscapeAll() { - return escapeAll; - } - - /** - * If {@code true}, then table name and all column names in 'create table' SQL - * generated for SQL engine are escaped with double quotes. This flag should be set if table name of - * column name is H2 reserved word or is not valid H2 identifier (e.g. contains space or hyphen). - * <p> - * Note if this flag is set then table and column name in SQL queries also must be escaped with double quotes. - - * @param escapeAll Flag value. - */ - public void setEscapeAll(boolean escapeAll) { - this.escapeAll = escapeAll; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryFuture.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryFuture.java deleted file mode 100644 index 5824ffd..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryFuture.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.cache.query; - -import org.apache.ignite.*; -import org.apache.ignite.lang.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * Cache query future returned by query execution. - * Refer to {@link GridCacheQuery} documentation for more information. - */ -public interface GridCacheQueryFuture<T> extends IgniteFuture<Collection<T>> { - /** - * Returns number of elements that are already fetched and can - * be returned from {@link #next()} method without blocking. - * - * @return Number of fetched elements which are available immediately. - * @throws IgniteCheckedException In case of error. - */ - public int available() throws IgniteCheckedException; - - /** - * Returns next element from result set. - * <p> - * This is a blocking call which will wait if there are no - * elements available immediately. - * - * @return Next fetched element or {@code null} if all the elements have been fetched. - * @throws IgniteCheckedException If failed. - */ - @Nullable public T next() throws IgniteCheckedException; - - /** - * Checks if all data is fetched by the query. - * - * @return {@code True} if all data is fetched, {@code false} otherwise. - */ - @Override public boolean isDone(); - - /** - * Cancels this query future and stop receiving any further results for the query - * associated with this future. - * - * @return {@inheritDoc} - * @throws IgniteCheckedException {@inheritDoc} - */ - @Override public boolean cancel() throws IgniteCheckedException; -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryGroupIndex.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryGroupIndex.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryGroupIndex.java deleted file mode 100644 index 8d6121c..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryGroupIndex.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.cache.query; - -import java.lang.annotation.*; - -/** - * Describes group index. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface GridCacheQueryGroupIndex { - /** - * Group index name. - * - * @return Name. - */ - String name(); - - /** - * If this index is unique. - * - * @return True if this index is unique, false otherwise. - * @deprecated No longer supported, will be ignored. - */ - @Deprecated - boolean unique() default false; - - /** - * List of group indexes for type. - */ - @SuppressWarnings("PublicInnerClass") - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) - public static @interface List { - /** - * Gets array of group indexes. - * - * @return Array of group indexes. - */ - GridCacheQueryGroupIndex[] value(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cafee25f/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryMetrics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryMetrics.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryMetrics.java deleted file mode 100644 index a8ada11..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryMetrics.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.cache.query; - -/** - * Cache query metrics used to obtain statistics on query. You can get metrics for - * particular query via {@link GridCacheQuery#metrics()} method or accumulated metrics - * for all queries via {@link GridCacheQueries#metrics()}. - */ -public interface GridCacheQueryMetrics { - /** - * Gets minimum execution time of query. - * - * @return Minimum execution time of query. - */ - public long minimumTime(); - - /** - * Gets maximum execution time of query. - * - * @return Maximum execution time of query. - */ - public long maximumTime(); - - /** - * Gets average execution time of query. - * - * @return Average execution time of query. - */ - public double averageTime(); - - /** - * Gets total number execution of query. - * - * @return Number of executions. - */ - public int executions(); - - /** - * Gets total number of times a query execution failed. - * - * @return Total number of times a query execution failed. - */ - public int fails(); -}