Package com.datastax.driver.core

Examples of com.datastax.driver.core.ResultSetFuture


      final Executor executor) {

    return execute(new SessionCallback<Cancellable>() {
      @Override
      public Cancellable doInSession(Session s) throws DataAccessException {
        final ResultSetFuture rsf = s.executeAsync(select);
        Runnable wrapper = new Runnable() {
          @Override
          public void run() {
            listener.onQueryComplete(rsf);
          }
        };
        rsf.addListener(wrapper, executor);
        return new ResultSetFutureCancellable(rsf);
      }
    });
  }
View Full Code Here


  @Override
  public Cancellable queryAsynchronously(final Select select, final Runnable listener, final Executor executor) {
    return execute(new SessionCallback<Cancellable>() {
      @Override
      public Cancellable doInSession(Session s) throws DataAccessException {
        ResultSetFuture rsf = s.executeAsync(select);
        rsf.addListener(listener, executor);
        return new ResultSetFutureCancellable(rsf);
      }
    });
  }
View Full Code Here

    final String isbn = "999999999";

    final Book b1 = getBook(isbn);

    ResultSetFuture rsf = cqlTemplate.queryAsynchronously("select * from book where isbn='" + isbn + "'", options);

    ResultSet rs = rsf.getUninterruptibly();

    assertNotNull(rs);

    cqlTemplate.process(rs, new RowCallbackHandler() {

View Full Code Here

  public void processTestResultSetRowMapper() {

    // Insert our 3 test books.
    ingestionTestObjectArray();

    ResultSetFuture rsf = cqlTemplate.queryAsynchronously("select * from book where isbn in ('1234','2345','3456')");

    ResultSet rs = rsf.getUninterruptibly();

    assertNotNull(rs);

    List<Book> books = cqlTemplate.process(rs, new RowMapper<Book>() {

View Full Code Here

  public void processOneTestResultSetRowMapper() {

    // Insert our 3 test books.
    ingestionTestObjectArray();

    ResultSetFuture rsf = cqlTemplate.queryAsynchronously("select * from book where isbn in ('" + ISBN_NINES + "')");

    ResultSet rs = rsf.getUninterruptibly();

    assertNotNull(rs);

    Book book = cqlTemplate.processOne(rs, new RowMapper<Book>() {
      @Override
View Full Code Here

  }

  @Test
  public void processOneTestResultSetType() {

    ResultSetFuture rsf = cqlTemplate
        .queryAsynchronously("select title from book where isbn in ('" + ISBN_NINES + "')");

    ResultSet rs = rsf.getUninterruptibly();

    assertNotNull(rs);

    String title = cqlTemplate.processOne(rs, String.class);
View Full Code Here

  }

  @Test
  public void processMapTestResultSet() {

    ResultSetFuture rsf = cqlTemplate.queryAsynchronously("select * from book where isbn in ('" + ISBN_NINES + "')");

    ResultSet rs = rsf.getUninterruptibly();

    assertNotNull(rs);

    Map<String, Object> rsMap = cqlTemplate.processMap(rs);

View Full Code Here

  public void processListTestResultSetType() {

    // Insert our 3 test books.
    ingestionTestObjectArray();

    ResultSetFuture rsf = cqlTemplate.queryAsynchronously("select * from book where isbn in ('1234','2345','3456')");

    ResultSet rs = rsf.getUninterruptibly();

    assertNotNull(rs);

    List<String> titles = cqlTemplate.processList(rs, String.class);

View Full Code Here

  public void processListOfMapTestResultSet() {

    // Insert our 3 test books.
    ingestionTestObjectArray();

    ResultSetFuture rsf = cqlTemplate.queryAsynchronously("select * from book where isbn in ('1234','2345','3456')");

    ResultSet rs = rsf.getUninterruptibly();

    assertNotNull(rs);

    List<Map<String, Object>> results = cqlTemplate.processListOfMap(rs);

View Full Code Here

    {
        CassandraTableHandle tableHandle = table.getTableHandle();
        List<CassandraColumnHandle> partitionKeyColumns = table.getPartitionKeyColumns();

        boolean fullPartitionKey = filterPrefix.size() == partitionKeyColumns.size();
        ResultSetFuture countFuture;
        if (!fullPartitionKey) {
            Select countAll = CassandraCqlUtils.selectCountAllFrom(tableHandle).limit(limitForPartitionKeySelect);
            countFuture = session.executeAsync(countAll);
        }
        else {
            // no need to count if partition key is completely known
            countFuture = null;
        }

        int limit = fullPartitionKey ? 1 : limitForPartitionKeySelect;
        Select partitionKeys = CassandraCqlUtils.selectDistinctFrom(tableHandle, partitionKeyColumns);
        partitionKeys.limit(limit);
        partitionKeys.setFetchSize(fetchSizeForPartitionKeySelect);
        addWhereClause(partitionKeys.where(), partitionKeyColumns, filterPrefix);
        ResultSetFuture partitionKeyFuture = session.executeAsync(partitionKeys);

        if (!fullPartitionKey) {
            long count = countFuture.getUninterruptibly().one().getLong(0);
            if (count == limitForPartitionKeySelect) {
                partitionKeyFuture.cancel(true);
                return null; // too much effort to query all partition keys
            }
        }
        return partitionKeyFuture.getUninterruptibly();
    }
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.ResultSetFuture

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.