ignite-sql-old - annotations
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/55045794 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/55045794 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/55045794 Branch: refs/heads/ignite-sql-old Commit: 550457941c749712b0d26f3f965188f4cc687a2a Parents: 8be3faa Author: S.Vladykin <svlady...@gridgain.com> Authored: Sat Feb 14 01:07:26 2015 +0300 Committer: S.Vladykin <svlady...@gridgain.com> Committed: Sat Feb 14 01:07:26 2015 +0300 ---------------------------------------------------------------------- .../apache/ignite/cache/query/CacheQuery.java | 16 +-- .../cache/query/CacheQueryGroupIndex.java | 49 -------- .../ignite/cache/query/CacheQuerySqlField.java | 123 ------------------- .../cache/query/CacheQuerySqlFunction.java | 67 ---------- .../ignite/cache/query/CacheQueryTextField.java | 33 ----- .../query/annotations/QuerySqlFunction.java | 2 +- .../processors/query/GridQueryProcessor.java | 2 +- .../scala/org/apache/ignite/scalar/scalar.scala | 4 +- 8 files changed, 12 insertions(+), 284 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55045794/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuery.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuery.java index efb15a8..1d4a3a7 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuery.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuery.java @@ -91,33 +91,33 @@ import org.jetbrains.annotations.*; * <pre name="code" class="java"> * public class Organization { * // Indexed field. - * @CacheQuerySqlField(index = true) + * @QuerySqlField(index = true) * private long id; * * // Indexed field. - * @CacheQuerySqlField(index = true) + * @QuerySqlField(index = true) * private String name; * ... * } * * public class Person { * // Indexed field. - * @CacheQuerySqlField(index = true) + * @QuerySqlField(index = true) * private long id; * * // Indexed field (Organization ID, used as a foreign key). - * @CacheQuerySqlField(index = true) + * @QuerySqlField(index = true) * private long orgId; * * // Without SQL field annotation, this field cannot be used in queries. * private String name; * * // Not indexed field. - * @CacheQuerySqlField + * @QuerySqlField * private double salary; * * // Index for text search. - * @CacheQueryTextField + * @QueryTextField * private String resume; * ... * } @@ -154,11 +154,11 @@ import org.jetbrains.annotations.*; * <pre name="code" class="java"> * private class MapPoint implements Serializable { * // Geospatial index. - * @CacheQuerySqlField(index = true) + * @QuerySqlField(index = true) * private com.vividsolutions.jts.geom.Point location; * * // Not indexed field. - * @CacheQuerySqlField + * @QuerySqlField * private String name; * * public MapPoint(com.vividsolutions.jts.geom.Point location, String name) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55045794/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 deleted file mode 100644 index 5c15baf..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryGroupIndex.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 java.lang.annotation.*; - -/** - * Describes group index. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface CacheQueryGroupIndex { - /** - * Group index name. - * - * @return Name. - */ - String name(); - - /** - * 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/55045794/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 deleted file mode 100644 index e095cc5..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlField.java +++ /dev/null @@ -1,123 +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.*; - -/** - * 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 Ignite 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 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/55045794/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 deleted file mode 100644 index 23e1683..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQuerySqlFunction.java +++ /dev/null @@ -1,67 +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.*; - -/** - * 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 org.apache.ignite.configuration.QueryConfiguration#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/55045794/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 deleted file mode 100644 index d48cc23..0000000 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryTextField.java +++ /dev/null @@ -1,33 +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.*; - -/** - * 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/55045794/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlFunction.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlFunction.java index 86882d3..f938bac 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlFunction.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlFunction.java @@ -27,7 +27,7 @@ import java.lang.annotation.*; * Example usage: * <pre name="code" class="java"> * public class MyFunctions { - * @CacheQuerySqlFunction + * @QuerySqlFunction * public static int sqr(int x) { * return x * x; * } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55045794/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java index 60bf730..759bcfb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java @@ -781,7 +781,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { if (sqlAnn != null || txtAnn != null) { if (mtd.getParameterTypes().length != 0) - throw new IgniteCheckedException("Getter with CacheQuerySqlField " + + throw new IgniteCheckedException("Getter with QuerySqlField " + "annotation cannot have parameters: " + mtd); ClassProperty prop = new ClassProperty(mtd); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55045794/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala ---------------------------------------------------------------------- diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala index 1a26615..4d51837 100644 --- a/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala +++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala @@ -128,10 +128,10 @@ import scala.annotation.meta.field * </pre> */ object scalar extends ScalarConversions { - /** Type alias for `CacheQuerySqlField`. */ + /** Type alias for `QuerySqlField`. */ type ScalarCacheQuerySqlField = QuerySqlField @field - /** Type alias for `CacheQueryTextField`. */ + /** Type alias for `QueryTextField`. */ type ScalarCacheQueryTextField = QueryTextField @field /**