Skip to content

Commit

Permalink
ignite-sql-tests - renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
S.Vladykin committed Feb 8, 2015
1 parent 2a799c9 commit c4ed31f
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 91 deletions.
16 changes: 8 additions & 8 deletions modules/core/src/main/java/org/apache/ignite/IgniteCache.java
Expand Up @@ -199,10 +199,10 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* *
* @param qry Query. * @param qry Query.
* @return Cursor. * @return Cursor.
* @see QueryScan * @see ScanQuery
* @see QuerySql * @see SqlQuery
* @see QueryText * @see TextQuery
* @see QuerySpi * @see SpiQuery
*/ */
public QueryCursor<Entry<K, V>> query(Query qry); public QueryCursor<Entry<K, V>> query(Query qry);


Expand All @@ -219,10 +219,10 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* *
* @param qry Query. * @param qry Query.
* @return Cursor. * @return Cursor.
* @see QueryScan * @see ScanQuery
* @see QuerySql * @see SqlQuery
* @see QueryText * @see TextQuery
* @see QuerySpi * @see SpiQuery
*/ */
public QueryCursor<Entry<K, V>> localQuery(Query qry); public QueryCursor<Entry<K, V>> localQuery(Query qry);


Expand Down
Expand Up @@ -27,8 +27,12 @@


/** /**
* Base class for all Ignite cache queries. * Base class for all Ignite cache queries.
* Use {@link QuerySql} and {@link QueryText} for SQL and * Use {@link SqlQuery} and {@link TextQuery} for SQL and
* text queries accordingly. * text queries accordingly.
* <p>
* Also contains convenience shortcuts for query object construction:
* {@link #sql(Class, String)}, {@link #sql(String)}, {@link #text(Class, String)},
* {@link #scan(IgniteBiPredicate)} and {@link #spi()}.
* *
* @see IgniteCache#query(Query) * @see IgniteCache#query(Query)
* @see IgniteCache#localQuery(Query) * @see IgniteCache#localQuery(Query)
Expand Down Expand Up @@ -63,8 +67,8 @@ public static SqlFieldsQuery sql(String sql) {
* @param sql SQL Query string. * @param sql SQL Query string.
* @return SQL Query instance. * @return SQL Query instance.
*/ */
public static QuerySql sql(Class<?> type, String sql) { public static SqlQuery sql(Class<?> type, String sql) {
return new QuerySql(type, sql); return new SqlQuery(type, sql);
} }


/** /**
Expand All @@ -74,8 +78,8 @@ public static QuerySql sql(Class<?> type, String sql) {
* @param txt Search string. * @param txt Search string.
* @return Fulltext query. * @return Fulltext query.
*/ */
public static QueryText text(Class<?> type, String txt) { public static TextQuery text(Class<?> type, String txt) {
return new QueryText(txt).setType(type); return new TextQuery(txt).setType(type);
} }


/** /**
Expand All @@ -84,8 +88,8 @@ public static QueryText text(Class<?> type, String txt) {
* @param filter Filter. * @param filter Filter.
* @return SPI Query. * @return SPI Query.
*/ */
public static <K, V> QueryScan<K, V> scan(final IgniteBiPredicate<K, V> filter) { public static <K, V> ScanQuery<K, V> scan(final IgniteBiPredicate<K, V> filter) {
return new QueryScan<>(filter); return new ScanQuery<>(filter);
} }


/** /**
Expand All @@ -94,8 +98,8 @@ public static <K, V> QueryScan<K, V> scan(final IgniteBiPredicate<K, V> filter)
* @return SPI Query. * @return SPI Query.
* @see IndexingSpi * @see IndexingSpi
*/ */
public static QuerySpi spi() { public static SpiQuery spi() {
return new QuerySpi(); return new SpiQuery();
} }


/** /**
Expand Down
Expand Up @@ -28,14 +28,14 @@
* @see IgniteCache#query(Query) * @see IgniteCache#query(Query)
* @see IgniteCache#localQuery(Query) * @see IgniteCache#localQuery(Query)
*/ */
public class QueryScan<K, V> extends Query<QueryScan<K, V>> { public class ScanQuery<K, V> extends Query<ScanQuery<K, V>> {
/** */ /** */
private IgniteBiPredicate<K,V> filter; private IgniteBiPredicate<K,V> filter;


/** /**
* Create scan query returning all entries. * Create scan query returning all entries.
*/ */
public QueryScan() { public ScanQuery() {
this(null); this(null);
} }


Expand All @@ -44,7 +44,7 @@ public QueryScan() {
* *
* @param filter Filter. If {@code null} then all entries will be returned. * @param filter Filter. If {@code null} then all entries will be returned.
*/ */
public QueryScan(@Nullable IgniteBiPredicate<K,V> filter) { public ScanQuery(@Nullable IgniteBiPredicate<K,V> filter) {
setFilter(filter); setFilter(filter);
} }


Expand All @@ -68,6 +68,6 @@ public void setFilter(@Nullable IgniteBiPredicate<K,V> filter) {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public String toString() { @Override public String toString() {
return S.toString(QueryScan.class, this); return S.toString(ScanQuery.class, this);
} }
} }
Expand Up @@ -28,7 +28,7 @@
* @see IgniteCache#query(Query) * @see IgniteCache#query(Query)
* @see IgniteCache#localQuery(Query) * @see IgniteCache#localQuery(Query)
*/ */
public final class QuerySpi extends Query<QuerySpi> { public final class SpiQuery extends Query<SpiQuery> {
/** Arguments. */ /** Arguments. */
@GridToStringInclude @GridToStringInclude
private Object[] args; private Object[] args;
Expand All @@ -48,14 +48,14 @@ public Object[] getArgs() {
* @param args SQL arguments. * @param args SQL arguments.
* @return {@code this} For chaining. * @return {@code this} For chaining.
*/ */
public QuerySpi setArgs(Object... args) { public SpiQuery setArgs(Object... args) {
this.args = args; this.args = args;


return this; return this;
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public String toString() { @Override public String toString() {
return S.toString(QuerySpi.class, this); return S.toString(SpiQuery.class, this);
} }
} }
Expand Up @@ -28,7 +28,7 @@
* @see IgniteCache#query(Query) * @see IgniteCache#query(Query)
* @see IgniteCache#localQuery(Query) * @see IgniteCache#localQuery(Query)
*/ */
public final class QuerySql extends Query<QuerySql> { public final class SqlQuery extends Query<SqlQuery> {
/** */ /** */
private String type; private String type;


Expand All @@ -44,7 +44,7 @@ public final class QuerySql extends Query<QuerySql> {
* *
* @param sql SQL Query. * @param sql SQL Query.
*/ */
public QuerySql(String sql) { public SqlQuery(String sql) {
setSql(sql); setSql(sql);
} }


Expand All @@ -54,7 +54,7 @@ public QuerySql(String sql) {
* @param type Type. * @param type Type.
* @param sql SQL Query. * @param sql SQL Query.
*/ */
public QuerySql(Class<?> type, String sql) { public SqlQuery(Class<?> type, String sql) {
this(sql); this(sql);


setType(type); setType(type);
Expand All @@ -75,7 +75,7 @@ public String getSql() {
* @param sql SQL clause. * @param sql SQL clause.
* @return {@code this} For chaining. * @return {@code this} For chaining.
*/ */
public QuerySql setSql(String sql) { public SqlQuery setSql(String sql) {
A.notNull(sql, "sql"); A.notNull(sql, "sql");


this.sql = sql; this.sql = sql;
Expand All @@ -98,7 +98,7 @@ public Object[] getArgs() {
* @param args SQL arguments. * @param args SQL arguments.
* @return {@code this} For chaining. * @return {@code this} For chaining.
*/ */
public QuerySql setArgs(Object... args) { public SqlQuery setArgs(Object... args) {
this.args = args; this.args = args;


return this; return this;
Expand All @@ -119,7 +119,7 @@ public String getType() {
* @param type Type. * @param type Type.
* @return {@code this} For chaining. * @return {@code this} For chaining.
*/ */
public QuerySql setType(String type) { public SqlQuery setType(String type) {
this.type = type; this.type = type;


return this; return this;
Expand All @@ -128,12 +128,12 @@ public QuerySql setType(String type) {
/** /**
* @param type Type. * @param type Type.
*/ */
public QuerySql setType(Class<?> type) { public SqlQuery setType(Class<?> type) {
return setType(GridQueryProcessor.typeName(type)); return setType(GridQueryProcessor.typeName(type));
} }


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public String toString() { @Override public String toString() {
return S.toString(QuerySql.class, this); return S.toString(SqlQuery.class, this);
} }
} }
Expand Up @@ -27,7 +27,7 @@
* @see IgniteCache#query(Query) * @see IgniteCache#query(Query)
* @see IgniteCache#localQuery(Query) * @see IgniteCache#localQuery(Query)
*/ */
public final class QueryText extends Query<QueryText> { public final class TextQuery extends Query<TextQuery> {
/** */ /** */
private String type; private String type;


Expand All @@ -39,7 +39,7 @@ public final class QueryText extends Query<QueryText> {
* *
* @param txt Search string. * @param txt Search string.
*/ */
public QueryText(String txt) { public TextQuery(String txt) {
setText(txt); setText(txt);
} }


Expand All @@ -49,7 +49,7 @@ public QueryText(String txt) {
* @param type Type. * @param type Type.
* @param txt Search string. * @param txt Search string.
*/ */
public QueryText(Class<?> type, String txt) { public TextQuery(Class<?> type, String txt) {
this(txt); this(txt);


setType(type); setType(type);
Expand All @@ -70,7 +70,7 @@ public String getType() {
* @param type Type. * @param type Type.
* @return {@code this} For chaining. * @return {@code this} For chaining.
*/ */
public QueryText setType(Class<?> type) { public TextQuery setType(Class<?> type) {
return setType(GridQueryProcessor.typeName(type)); return setType(GridQueryProcessor.typeName(type));
} }


Expand All @@ -80,7 +80,7 @@ public QueryText setType(Class<?> type) {
* @param type Type. * @param type Type.
* @return {@code this} For chaining. * @return {@code this} For chaining.
*/ */
public QueryText setType(String type) { public TextQuery setType(String type) {
this.type = type; this.type = type;


return this; return this;
Expand All @@ -101,7 +101,7 @@ public String getText() {
* @param txt Text search string. * @param txt Text search string.
* @return {@code this} For chaining. * @return {@code this} For chaining.
*/ */
public QueryText setText(String txt) { public TextQuery setText(String txt) {
A.notNull(txt, "txt"); A.notNull(txt, "txt");


this.txt = txt; this.txt = txt;
Expand All @@ -111,6 +111,6 @@ public QueryText setText(String txt) {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public String toString() { @Override public String toString() {
return S.toString(QueryText.class, this); return S.toString(TextQuery.class, this);
} }
} }
Expand Up @@ -260,8 +260,8 @@ private QueryCursor<Entry<K,V>> query(Query filter, @Nullable ClusterGroup grp)
final CacheQuery<Map.Entry<K,V>> qry; final CacheQuery<Map.Entry<K,V>> qry;
final CacheQueryFuture<Map.Entry<K,V>> fut; final CacheQueryFuture<Map.Entry<K,V>> fut;


if (filter instanceof QueryScan) { if (filter instanceof ScanQuery) {
IgniteBiPredicate<K,V> p = ((QueryScan)filter).getFilter(); IgniteBiPredicate<K,V> p = ((ScanQuery)filter).getFilter();


qry = delegate.queries().createScanQuery(p != null ? p : ACCEPT_ALL); qry = delegate.queries().createScanQuery(p != null ? p : ACCEPT_ALL);


Expand All @@ -270,8 +270,8 @@ private QueryCursor<Entry<K,V>> query(Query filter, @Nullable ClusterGroup grp)


fut = qry.execute(); fut = qry.execute();
} }
else if (filter instanceof QueryText) { else if (filter instanceof TextQuery) {
QueryText p = (QueryText)filter; TextQuery p = (TextQuery)filter;


qry = delegate.queries().createFullTextQuery(p.getType(), p.getText()); qry = delegate.queries().createFullTextQuery(p.getType(), p.getText());


Expand All @@ -280,13 +280,13 @@ else if (filter instanceof QueryText) {


fut = qry.execute(); fut = qry.execute();
} }
else if (filter instanceof QuerySpi) { else if (filter instanceof SpiQuery) {
qry = ((GridCacheQueriesEx)delegate.queries()).createSpiQuery(); qry = ((GridCacheQueriesEx)delegate.queries()).createSpiQuery();


if (grp != null) if (grp != null)
qry.projection(grp); qry.projection(grp);


fut = qry.execute(((QuerySpi)filter).getArgs()); fut = qry.execute(((SpiQuery)filter).getArgs());
} }
else else
throw new IgniteException("Unsupported query predicate: " + filter); throw new IgniteException("Unsupported query predicate: " + filter);
Expand Down Expand Up @@ -323,8 +323,8 @@ else if (filter instanceof QuerySpi) {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
if (filter instanceof QuerySql) { if (filter instanceof SqlQuery) {
QuerySql p = (QuerySql)filter; SqlQuery p = (SqlQuery)filter;


return ctx.kernalContext().query().queryTwoStep(ctx.name(), p.getType(), p.getSql(), p.getArgs()); return ctx.kernalContext().query().queryTwoStep(ctx.name(), p.getType(), p.getSql(), p.getArgs());
} }
Expand Down Expand Up @@ -369,8 +369,8 @@ else if (filter instanceof QuerySpi) {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
if (filter instanceof QuerySql) { if (filter instanceof SqlQuery) {
QuerySql p = (QuerySql)filter; SqlQuery p = (SqlQuery)filter;


return new QueryCursorImpl<>(ctx.kernalContext().query().<K,V>queryLocal( return new QueryCursorImpl<>(ctx.kernalContext().query().<K,V>queryLocal(
ctx.name(), p.getType(), p.getSql(), p.getArgs())); ctx.name(), p.getType(), p.getSql(), p.getArgs()));
Expand Down
Expand Up @@ -73,7 +73,7 @@ public class IgniteCacheFieldsQueryNoDataSelfTest extends GridCommonAbstractTest
*/ */
public void testQuery() throws Exception { public void testQuery() throws Exception {
Collection<Cache.Entry<Object, Object>> res = grid().jcache(null) Collection<Cache.Entry<Object, Object>> res = grid().jcache(null)
.query(new QuerySql("select _VAL from Integer")).getAll(); .query(new SqlQuery("select _VAL from Integer")).getAll();


assert res != null; assert res != null;
assert res.isEmpty(); assert res.isEmpty();
Expand Down
Expand Up @@ -98,7 +98,7 @@ private void checkCache(IgniteCache<Integer, CacheValue> cache) throws Exception
*/ */
private void checkQuery(IgniteCache<Integer, CacheValue> cache) throws Exception { private void checkQuery(IgniteCache<Integer, CacheValue> cache) throws Exception {
QueryCursor<Cache.Entry<Integer, CacheValue>> qry = QueryCursor<Cache.Entry<Integer, CacheValue>> qry =
cache.query(new QuerySql("val >= 5")); cache.query(new SqlQuery("val >= 5"));


Collection<Cache.Entry<Integer, CacheValue>> queried = qry.getAll(); Collection<Cache.Entry<Integer, CacheValue>> queried = qry.getAll();


Expand Down

0 comments on commit c4ed31f

Please sign in to comment.