• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AvaticaStatement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.calcite.avatica.AvaticaStatement的典型用法代码示例。如果您正苦于以下问题:Java AvaticaStatement类的具体用法?Java AvaticaStatement怎么用?Java AvaticaStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AvaticaStatement类属于org.apache.calcite.avatica包,在下文中一共展示了AvaticaStatement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:26,代码来源:JdbcResultSet.java


示例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();
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:22,代码来源:RemoteMetaTest.java


示例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();
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:23,代码来源:RemoteMetaTest.java


示例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);
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:24,代码来源:CalciteMetaImpl.java


示例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);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:19,代码来源:CalciteConnectionImpl.java


示例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);
  }
}
 
开发者ID:qubole,项目名称:quark,代码行数:26,代码来源:QuarkMetaResultSet.java


示例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);
  }
}
 
开发者ID:qubole,项目名称:quark,代码行数:23,代码来源:QuarkMetaImpl.java


示例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);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:CalciteMetaImpl.java


示例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);
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:9,代码来源:RemoteMetaTest.java


示例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();
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:42,代码来源:RemoteMetaTest.java


示例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;
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:DremioConnectionImpl.java


示例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));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:DremioMetaImpl.java


示例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);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:14,代码来源:DremioResultSetImpl.java


示例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);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:DremioJdbc41Factory.java


示例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());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:DremioCursor.java


示例16: prepareAndExecuteInternal

import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
@Override
protected ExecuteResult prepareAndExecuteInternal(AvaticaStatement statement, String sql, long maxRowCount)
    throws SQLException {
  try {
    return super.prepareAndExecuteInternal(statement, sql, maxRowCount);
  } catch(RuntimeException e) {
    Throwables.propagateIfInstanceOf(e.getCause(), SQLException.class);
    throw e;
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:11,代码来源:DrillConnectionImpl.java


示例17: DrillCursor

import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
/**
 *
 * @param statement
 * @param signature
 */
DrillCursor(DrillConnectionImpl connection, AvaticaStatement statement, Signature signature) {
  this.connection = connection;
  this.statement = statement;
  this.signature = signature;

  DrillClient client = connection.getClient();
  final int batchQueueThrottlingThreshold =
      client.getConfig().getInt(
          ExecConstants.JDBC_BATCH_QUEUE_THROTTLING_THRESHOLD );
  resultsListener = new ResultsListener(batchQueueThrottlingThreshold);
  currentBatchHolder = new RecordBatchLoader(client.getAllocator());
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:18,代码来源:DrillCursor.java


示例18: newResultSet

import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
@Override
public DrillResultSetImpl newResultSet(AvaticaStatement statement,
                                       Meta.Signature signature,
                                       TimeZone timeZone,
                                       Meta.Frame firstFrame) {
  final ResultSetMetaData metaData =
      newResultSetMetaData(statement, signature);
  return new DrillResultSetImpl(statement, signature, metaData, timeZone, firstFrame);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:10,代码来源:DrillJdbc41Factory.java


示例19: AtsdResultSet

import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
public AtsdResultSet(AvaticaStatement statement, QueryState state, Signature signature,
					 ResultSetMetaData resultSetMetaData, TimeZone timeZone, Frame firstFrame) {
	super(statement, state, signature, resultSetMetaData, timeZone, firstFrame);
	final AtsdConnection connection = (AtsdConnection) statement.connection;
	this.meta = connection.getMeta();
	this.handle = statement.handle;
	this.context = meta.getContextFromMap(statement.handle);
	logger.trace("[ctor] {}", this.handle.id);
}
 
开发者ID:axibase,项目名称:atsd-jdbc,代码行数:10,代码来源:AtsdResultSet.java


示例20: newResultSet

import org.apache.calcite.avatica.AvaticaStatement; //导入依赖的package包/类
public CalciteResultSet newResultSet(AvaticaStatement statement, QueryState state,
                                     Meta.Signature signature, TimeZone timeZone, Meta.Frame firstFrame) {
    final ResultSetMetaData metaData =
            newResultSetMetaData(statement, signature);
    final CalcitePrepare.CalciteSignature calciteSignature =
            (CalcitePrepare.CalciteSignature) signature;
    return new CalciteResultSet(statement, calciteSignature, metaData, timeZone,
            firstFrame);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:10,代码来源:CalciteJdbc41Factory.java



注:本文中的org.apache.calcite.avatica.AvaticaStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ParameterParser类代码示例发布时间:2022-05-22
下一篇:
Java AbstractCard类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap