Pass jdbc fetch size to the scroller

Original commit: elastic/x-pack-elasticsearch@2309a43980
This commit is contained in:
Costin Leau 2017-07-21 00:11:01 +03:00
parent 76b429bfe2
commit 04c9427596
3 changed files with 11 additions and 7 deletions

View File

@ -388,6 +388,9 @@ class JdbcResultSet implements ResultSet, JdbcWrapper {
if (rows < 0) {
throw new SQLException("Rows is negative");
}
if (rows != getFetchSize()) {
throw new SQLException("Fetch size cannot be changed");
}
// ignore fetch size since scrolls cannot be changed in flight
}

View File

@ -35,6 +35,7 @@ import org.elasticsearch.xpack.sql.querydsl.container.SearchHitFieldRef;
import org.elasticsearch.xpack.sql.querydsl.container.TotalCountRef;
import org.elasticsearch.xpack.sql.session.RowSetCursor;
import org.elasticsearch.xpack.sql.session.Rows;
import org.elasticsearch.xpack.sql.session.SqlSettings;
import org.elasticsearch.xpack.sql.type.Schema;
import org.elasticsearch.xpack.sql.util.ObjectUtils;
@ -51,9 +52,9 @@ public class Scroller {
private final int size;
private final Client client;
public Scroller(Client client) {
// TODO: use better defaults?
this(client, TimeValue.timeValueSeconds(90), TimeValue.timeValueSeconds(45), 100);
public Scroller(Client client, SqlSettings settings) {
// TODO: use better defaults (maybe use the sql settings)?
this(client, TimeValue.timeValueSeconds(90), TimeValue.timeValueSeconds(45), settings.pageSize());
}
public Scroller(Client client, TimeValue keepAlive, TimeValue timeout, int size) {

View File

@ -5,9 +5,6 @@
*/
package org.elasticsearch.xpack.sql.plan.physical;
import java.util.List;
import java.util.Objects;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.xpack.sql.execution.search.Scroller;
import org.elasticsearch.xpack.sql.expression.Attribute;
@ -17,6 +14,9 @@ import org.elasticsearch.xpack.sql.session.Rows;
import org.elasticsearch.xpack.sql.session.SqlSession;
import org.elasticsearch.xpack.sql.tree.Location;
import java.util.List;
import java.util.Objects;
public class EsQueryExec extends LeafExec {
private final String index, type;
@ -55,7 +55,7 @@ public class EsQueryExec extends LeafExec {
@Override
public void execute(SqlSession session, ActionListener<RowSetCursor> listener) {
Scroller scroller = new Scroller(session.client());
Scroller scroller = new Scroller(session.client(), session.settings());
scroller.scroll(Rows.schema(output), queryContainer, index, type, listener);
}