本文整理汇总了Java中org.apache.calcite.avatica.AvaticaStatement类的典型用法代码示例。如果您正苦于以下问题:Java AvaticaStatement类的具体用法?Java AvaticaStatement怎么用?Java AvaticaStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AvaticaStatement类属于org.apache.calcite.avatica包,在下文中一共展示了AvaticaStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
public static JdbcResultSet create(String connectionId, int statementId,
ResultSet resultSet, int maxRowCount, Meta.Signature signature) {
try {
final Calendar calendar = DateTimeUtils.calendar();
final int fetchRowCount;
if (maxRowCount == JdbcMeta.UNLIMITED_COUNT) {
fetchRowCount = -1;
} else if (maxRowCount < 0L) {
fetchRowCount = AvaticaStatement.DEFAULT_FETCH_SIZE;
} else if (maxRowCount > AvaticaStatement.DEFAULT_FETCH_SIZE) {
fetchRowCount = AvaticaStatement.DEFAULT_FETCH_SIZE;
} else {
fetchRowCount = maxRowCount;
}
final Meta.Frame firstFrame = frame(null, resultSet, 0, fetchRowCount, calendar,
Optional.of(signature));
if (firstFrame.done) {
resultSet.close();
}
return new JdbcResultSet(connectionId, statementId, true, signature,
firstFrame);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
示例2: testRemoteExecuteMaxRowCount
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
@Test public void testRemoteExecuteMaxRowCount() throws Exception {
ConnectionSpec.getDatabaseLock().lock();
try (AvaticaConnection conn = (AvaticaConnection) DriverManager.getConnection(url)) {
final AvaticaStatement statement = conn.createStatement();
prepareAndExecuteInternal(conn, statement,
"select * from (values ('a', 1), ('b', 2))", 0);
ResultSet rs = statement.getResultSet();
int count = 0;
while (rs.next()) {
count++;
}
assertEquals("Check maxRowCount=0 and ResultSets is 0 row", count, 0);
assertEquals("Check result set meta is still there",
rs.getMetaData().getColumnCount(), 2);
rs.close();
statement.close();
conn.close();
} finally {
ConnectionSpec.getDatabaseLock().unlock();
}
}
示例3: checkLargeQuery
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
private void checkLargeQuery(int n) throws Exception {
try (AvaticaConnection conn = (AvaticaConnection) DriverManager.getConnection(url)) {
final AvaticaStatement statement = conn.createStatement();
final String frenchDisko = "It said human existence is pointless\n"
+ "As acts of rebellious solidarity\n"
+ "Can bring sense in this world\n"
+ "La resistance!\n";
final String sql = "select '"
+ longString(frenchDisko, n)
+ "' as s from (values 'x')";
prepareAndExecuteInternal(conn, statement, sql, -1);
ResultSet rs = statement.getResultSet();
int count = 0;
while (rs.next()) {
count++;
}
assertThat(count, is(1));
rs.close();
statement.close();
conn.close();
}
}
示例4: createResultSet
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
protected MetaResultSet createResultSet(
Map<String, Object> internalParameters, List<ColumnMetaData> columns,
CursorFactory cursorFactory, final Frame firstFrame) {
try {
final CalciteConnectionImpl connection = getConnection();
final AvaticaStatement statement = connection.createStatement();
final CalcitePrepare.CalciteSignature<Object> signature =
new CalcitePrepare.CalciteSignature<Object>("",
ImmutableList.<AvaticaParameter>of(), internalParameters, null,
columns, cursorFactory, ImmutableList.<RelCollation>of(), -1,
null, Meta.StatementType.SELECT) {
@Override
public Enumerable<Object> enumerable(
DataContext dataContext) {
return Linq4j.asEnumerable(firstFrame.rows);
}
};
return MetaResultSet.create(connection.id, statement.getId(), true,
signature, firstFrame);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
示例5: enumerable
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
public <T> Enumerable<T> enumerable(Meta.StatementHandle handle,
CalcitePrepare.CalciteSignature<T> signature) throws SQLException {
Map<String, Object> map = Maps.newLinkedHashMap();
AvaticaStatement statement = lookupStatement(handle);
final List<TypedValue> parameterValues =
TROJAN.getParameterValues(statement);
if (MetaImpl.checkParameterValueHasNull(parameterValues)) {
throw new SQLException("exception while executing query: unbound parameter");
}
for (Ord<TypedValue> o : Ord.zip(parameterValues)) {
map.put("?" + o.i, o.e.toLocal());
}
map.putAll(signature.internalParameters);
final DataContext dataContext = createDataContext(map);
return signature.enumerable(dataContext);
}
示例6: create
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
public static QuarkMetaResultSet create(String connectionId, int statementId,
ResultSet resultSet,
long maxRowCount, Meta.Signature signature) {
try {
final Calendar calendar = Calendar.getInstance(DateTimeUtils.GMT_ZONE);
final int fetchRowCount;
if (maxRowCount == QuarkMetaImpl.UNLIMITED_COUNT) {
fetchRowCount = -1;
} else if (maxRowCount < 0L) {
fetchRowCount = AvaticaStatement.DEFAULT_FETCH_SIZE;
} else if (maxRowCount > AvaticaStatement.DEFAULT_FETCH_SIZE) {
fetchRowCount = AvaticaStatement.DEFAULT_FETCH_SIZE;
} else {
fetchRowCount = (int) maxRowCount;
}
final Meta.Frame firstFrame = frame(resultSet, 0, fetchRowCount, calendar);
if (firstFrame.done) {
resultSet.close();
}
return new QuarkMetaResultSet(connectionId, statementId, true, signature,
firstFrame);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
示例7: createResultSet
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
protected MetaResultSet createResultSet(
Map<String, Object> internalParameters, List<ColumnMetaData> columns,
CursorFactory cursorFactory, final Frame firstFrame) {
try {
final QuarkConnectionImpl connection = getConnection();
final AvaticaStatement statement = connection.createStatement();
final CalcitePrepare.CalciteSignature<Object> signature =
new CalcitePrepare.CalciteSignature<Object>("",
ImmutableList.<AvaticaParameter>of(), internalParameters, null,
columns, cursorFactory, null, ImmutableList.<RelCollation>of(), -1,
null, Meta.StatementType.SELECT) {
@Override public Enumerable<Object> enumerable(
DataContext dataContext) {
return Linq4j.asEnumerable(firstFrame.rows);
}
};
return MetaResultSet.create(connection.id, statement.getId(), true,
signature, firstFrame);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
示例8: createResultSet
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
protected MetaResultSet createResultSet(
Map<String, Object> internalParameters, List<ColumnMetaData> columns,
CursorFactory cursorFactory, final Frame firstFrame) {
try {
final CalciteConnectionImpl connection = getConnection();
final AvaticaStatement statement = connection.createStatement();
final CalcitePrepare.CalciteSignature<Object> signature =
new CalcitePrepare.CalciteSignature<Object>("",
ImmutableList.<AvaticaParameter>of(), internalParameters, null,
columns, cursorFactory, null, ImmutableList.<RelCollation>of(), -1,
null, Meta.StatementType.SELECT) {
@Override public Enumerable<Object> enumerable(
DataContext dataContext) {
return Linq4j.asEnumerable(firstFrame.rows);
}
};
return MetaResultSet.create(connection.id, statement.getId(), true,
signature, firstFrame);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
示例9: prepareAndExecuteInternal
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
private static Meta.ExecuteResult prepareAndExecuteInternal(AvaticaConnection conn,
final AvaticaStatement statement, String sql, int maxRowCount) throws Exception {
Method m =
AvaticaConnection.class.getDeclaredMethod("prepareAndExecuteInternal",
AvaticaStatement.class, String.class, long.class);
m.setAccessible(true);
return (Meta.ExecuteResult) m.invoke(conn, statement, sql, maxRowCount);
}
示例10: testCancel
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1301">[CALCITE-1301]
* Add cancel flag to AvaticaStatement</a>. */
@Test public void testCancel() throws Exception {
ConnectionSpec.getDatabaseLock().lock();
try (AvaticaConnection conn = (AvaticaConnection) DriverManager.getConnection(url)) {
final AvaticaStatement statement = conn.createStatement();
final String sql = "select * from (values ('a', 1), ('b', 2))";
final ResultSet rs = statement.executeQuery(sql);
int count = 0;
loop:
for (;;) {
switch (count++) {
case 0:
assertThat(rs.next(), is(true));
break;
case 1:
rs.getStatement().cancel();
try {
boolean x = rs.next();
fail("expected exception, got " + x);
} catch (SQLException e) {
assertThat(e.getMessage(), is("Statement canceled"));
}
break loop;
default:
fail("count: " + count);
}
}
assertThat(count, is(2));
assertThat(statement.isClosed(), is(false));
rs.close();
assertThat(statement.isClosed(), is(false));
statement.close();
assertThat(statement.isClosed(), is(true));
statement.close();
assertThat(statement.isClosed(), is(true));
} finally {
ConnectionSpec.getDatabaseLock().unlock();
}
}
示例11: prepareAndExecuteInternal
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
@Override
protected ExecuteResult prepareAndExecuteInternal(AvaticaStatement statement, String sql, long maxRowCount)
throws SQLException, NoSuchStatementException {
try {
return super.prepareAndExecuteInternal(statement, sql, maxRowCount);
} catch(RuntimeException e) {
Throwables.propagateIfInstanceOf(e.getCause(), SQLException.class);
throw e;
}
}
示例12: execute
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
@Override
public ExecuteResult execute(StatementHandle h, List<TypedValue> parameterValues, int maxRowsInFirstFrame)
throws NoSuchStatementException {
// Signature might have been zeroed by AvaticaConnection#executeQueryInternal()
// Get it from the original handle
final AvaticaStatement stmt;
try {
stmt = connection.lookupStatement(h);
} catch(SQLException e) {
throw new NoSuchStatementException(h);
}
MetaResultSet metaResultSet =
MetaResultSet.create(h.connectionId, h.id, false, stmt.handle.signature, null);
return new ExecuteResult(ImmutableList.of(metaResultSet));
}
示例13: DremioResultSetImpl
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
DremioResultSetImpl(AvaticaStatement statement, QueryState state,
Meta.Signature signature, ResultSetMetaData resultSetMetaData,
TimeZone timeZone, Meta.Frame firstFrame) {
super(statement, state, signature, resultSetMetaData, timeZone, firstFrame);
connection = (DremioConnectionImpl) statement.getConnection();
client = connection.getClient();
final int batchQueueThrottlingThreshold =
client.getConfig().getInt(
ExecConstants.JDBC_BATCH_QUEUE_THROTTLING_THRESHOLD );
resultsListener = new ResultsListener(batchQueueThrottlingThreshold);
batchLoader = new RecordBatchLoader(client.getAllocator());
cursor = new DremioCursor(connection, statement, signature);
}
示例14: newResultSet
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
@Override
public DremioResultSetImpl newResultSet(AvaticaStatement statement,
QueryState state,
Meta.Signature signature,
TimeZone timeZone,
Meta.Frame firstFrame) {
final ResultSetMetaData metaData =
newResultSetMetaData(statement, signature);
return new DremioResultSetImpl(statement, state, signature, metaData, timeZone, firstFrame);
}
示例15: DremioCursor
import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
/**
*
* @param statement
* @param signature
*/
DremioCursor(DremioConnectionImpl connection, AvaticaStatement statement, Signature signature) {
this.connection = connection;
this.statement = statement;
this.signature = signature;
DremioClient client = connection.getClient();
final int batchQueueThrottlingThreshold =
client.getConfig().getInt(
ExecConstants.JDBC_BATCH_QUEUE_THROTTLING_THRESHOLD );
resultsListener = new ResultsListener(batchQueueThrottlingThreshold);
currentBatchHolder = new RecordBatchLoader(client.getAllocator());
}