Skip to content

Commit

Permalink
ignite-1.9 - SQL related fixes and improvements:
Browse files Browse the repository at this point in the history
 - Sorted MERGE index
 - EXPLAIN fixes
 - Replicated subqueries fixes

Squashed commit of the following:

commit 423c215
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Thu Mar 9 23:21:38 2017 +0300

    ignite-1.9.1 - test fix

commit ff3c1f2
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Thu Mar 9 11:08:34 2017 +0300

    ignite-1.9.0 - replicated subqueries fix

commit bc0801a
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Wed Mar 8 16:03:40 2017 +0300

    ignite-1.9.0 - fix for distributed join test

commit f1f1d96
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Wed Mar 8 15:28:44 2017 +0300

    ignite-1.9.0 - fix for distributed join test

commit a8751d5
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Tue Feb 28 18:46:07 2017 +0300

    ignite-1.9 - splitter fixes

commit 0601ce6
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Sun Feb 26 23:24:14 2017 +0300

    ignite-1.9 - merge index test

commit 4ad048e
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Sun Feb 26 23:19:49 2017 +0300

    ignite-1.9 - merge index

commit 4ea63d7
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Sun Feb 26 22:44:51 2017 +0300

    ignite-1.9 - unsorted index fixed

commit a639bff
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Sun Feb 26 20:08:26 2017 +0300

    ignite-1.9 - sorted index fixes2

commit ee9d524
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Fri Feb 24 16:00:26 2017 +0300

    ignite-1.9 - sorted index fixes

commit fc42406
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Date:   Thu Feb 23 16:46:39 2017 +0300

    ignite-1.9 - sorted index
  • Loading branch information
svladykin committed Mar 9, 2017
1 parent 8362fe7 commit 8817190
Show file tree
Hide file tree
Showing 22 changed files with 1,138 additions and 559 deletions.
Expand Up @@ -19,6 +19,8 @@


import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.GridDirectTransient; import org.apache.ignite.internal.GridDirectTransient;
Expand Down Expand Up @@ -74,6 +76,19 @@ public class GridCacheSqlQuery implements Message, GridCacheQueryMarshallable {
/** Field kept for backward compatibility. */ /** Field kept for backward compatibility. */
private String alias; private String alias;


/** Sort columns. */
@GridToStringInclude
@GridDirectTransient
private transient List<?> sort;

/** If we have partitioned tables in this query. */
@GridToStringInclude
@GridDirectTransient
private transient boolean partitioned;

/** Single node to execute the query on. */
private UUID node;

/** /**
* For {@link Message}. * For {@link Message}.
*/ */
Expand Down Expand Up @@ -218,12 +233,18 @@ public GridCacheSqlQuery parameters(Object[] params, int[] paramIdxs) {
writer.incrementState(); writer.incrementState();


case 1: case 1:
if (!writer.writeByteArray("paramsBytes", paramsBytes)) if (!writer.writeUuid("node", node))
return false; return false;


writer.incrementState(); writer.incrementState();


case 2: case 2:
if (!writer.writeByteArray("paramsBytes", paramsBytes))
return false;

writer.incrementState();

case 3:
if (!writer.writeString("qry", qry)) if (!writer.writeString("qry", qry))
return false; return false;


Expand Down Expand Up @@ -251,14 +272,22 @@ public GridCacheSqlQuery parameters(Object[] params, int[] paramIdxs) {
reader.incrementState(); reader.incrementState();


case 1: case 1:
paramsBytes = reader.readByteArray("paramsBytes"); node = reader.readUuid("node");


if (!reader.isLastRead()) if (!reader.isLastRead())
return false; return false;


reader.incrementState(); reader.incrementState();


case 2: case 2:
paramsBytes = reader.readByteArray("paramsBytes");

if (!reader.isLastRead())
return false;

reader.incrementState();

case 3:
qry = reader.readString("qry"); qry = reader.readString("qry");


if (!reader.isLastRead()) if (!reader.isLastRead())
Expand All @@ -278,7 +307,7 @@ public GridCacheSqlQuery parameters(Object[] params, int[] paramIdxs) {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public byte fieldsCount() { @Override public byte fieldsCount() {
return 3; return 4;
} }


/** /**
Expand All @@ -292,6 +321,8 @@ public GridCacheSqlQuery copy(Object[] args) {
cp.cols = cols; cp.cols = cols;
cp.paramIdxs = paramIdxs; cp.paramIdxs = paramIdxs;
cp.paramsSize = paramsSize; cp.paramsSize = paramsSize;
cp.sort = sort;
cp.partitioned = partitioned;


if (F.isEmpty(args)) if (F.isEmpty(args))
cp.params = EMPTY_PARAMS; cp.params = EMPTY_PARAMS;
Expand All @@ -304,4 +335,49 @@ public GridCacheSqlQuery copy(Object[] args) {


return cp; return cp;
} }

/**
* @param sort Sort columns.
*/
public void sortColumns(List<?> sort) {
this.sort = sort;
}

/**
* @return Sort columns.
*/
public List<?> sortColumns() {
return sort;
}

/**
* @param partitioned If the query contains partitioned tables.
*/
public void partitioned(boolean partitioned) {
this.partitioned = partitioned;
}

/**
* @return {@code true} If the query contains partitioned tables.
*/
public boolean isPartitioned() {
return partitioned;
}

/**
* @return Single node to execute the query on or {@code null} if need to execute on all the nodes.
*/
public UUID node() {
return node;
}

/**
* @param node Single node to execute the query on or {@code null} if need to execute on all the nodes.
* @return {@code this}.
*/
public GridCacheSqlQuery node(UUID node) {
this.node = node;

return this;
}
} }
Expand Up @@ -85,7 +85,6 @@
import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery; import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
import org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator; import org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator;
import org.apache.ignite.internal.processors.query.GridRunningQueryInfo;
import org.apache.ignite.internal.processors.query.GridQueryCancel; import org.apache.ignite.internal.processors.query.GridQueryCancel;
import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata; import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
import org.apache.ignite.internal.processors.query.GridQueryFieldsResult; import org.apache.ignite.internal.processors.query.GridQueryFieldsResult;
Expand Down Expand Up @@ -155,7 +154,6 @@
import org.h2.server.web.WebServer; import org.h2.server.web.WebServer;
import org.h2.table.Column; import org.h2.table.Column;
import org.h2.table.IndexColumn; import org.h2.table.IndexColumn;
import org.h2.table.Table;
import org.h2.tools.Server; import org.h2.tools.Server;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.value.DataType; import org.h2.value.DataType;
Expand Down Expand Up @@ -1453,7 +1451,7 @@ public static Session session(Connection c) {
} }




Prepared prepared = GridSqlQueryParser.prepared((JdbcPreparedStatement) stmt); Prepared prepared = GridSqlQueryParser.prepared(stmt);


if (qry instanceof JdbcSqlFieldsQuery && ((JdbcSqlFieldsQuery) qry).isQuery() != prepared.isQuery()) if (qry instanceof JdbcSqlFieldsQuery && ((JdbcSqlFieldsQuery) qry).isQuery() != prepared.isQuery())
throw new IgniteSQLException("Given statement type does not match that declared by JDBC driver", throw new IgniteSQLException("Given statement type does not match that declared by JDBC driver",
Expand Down
Expand Up @@ -300,10 +300,10 @@ private void calculate() {
assert childFilters == null; assert childFilters == null;


// We are at table instance. // We are at table instance.
GridH2Table tbl = (GridH2Table)filter().getTable(); Table tbl = filter().getTable();


// Only partitioned tables will do distributed joins. // Only partitioned tables will do distributed joins.
if (!tbl.isPartitioned()) { if (!(tbl instanceof GridH2Table) || !((GridH2Table)tbl).isPartitioned()) {
type = Type.REPLICATED; type = Type.REPLICATED;
multiplier = MULTIPLIER_COLLOCATED; multiplier = MULTIPLIER_COLLOCATED;


Expand Down Expand Up @@ -593,7 +593,7 @@ else if (!left.isPartitioned() && !right.isPartitioned())
private GridH2CollocationModel child(int i, boolean create) { private GridH2CollocationModel child(int i, boolean create) {
GridH2CollocationModel child = children[i]; GridH2CollocationModel child = children[i];


if (child == null && create && isChildTableOrView(i, null)) { if (child == null && create) {
TableFilter f = childFilters[i]; TableFilter f = childFilters[i];


if (f.getTable().isView()) { if (f.getTable().isView()) {
Expand Down

0 comments on commit 8817190

Please sign in to comment.