Package com.datastax.driver.core

Examples of com.datastax.driver.core.ResultSetFuture


        CassandraTableHandle tableHandle = table.getTableHandle();
        String schemaName = tableHandle.getSchemaName();
        List<CassandraColumnHandle> partitionKeyColumns = table.getPartitionKeyColumns();

        boolean fullPartitionKey = filterPrefix.size() == partitionKeyColumns.size();
        ResultSetFuture countFuture;
        if (!fullPartitionKey) {
            final Select countAll = CassandraCqlUtils.selectCountAllFrom(tableHandle).limit(limitForPartitionKeySelect);
            countFuture = executeWithSession(schemaName, new SessionCallable<ResultSetFuture>() {
                @Override
                public ResultSetFuture executeWithSession(Session session)
                {
                    return session.executeAsync(countAll);
                }
            });
        }
        else {
            // no need to count if partition key is completely known
            countFuture = null;
        }

        int limit = fullPartitionKey ? 1 : limitForPartitionKeySelect;
        final Select partitionKeys = CassandraCqlUtils.selectDistinctFrom(tableHandle, partitionKeyColumns);
        partitionKeys.limit(limit);
        partitionKeys.setFetchSize(fetchSizeForPartitionKeySelect);

        if (!fullPartitionKey) {
            addWhereClause(partitionKeys.where(), partitionKeyColumns, new ArrayList<Comparable<?>>());
            ResultSetFuture partitionKeyFuture =  executeWithSession(schemaName, new SessionCallable<ResultSetFuture>() {
                @Override
                public ResultSetFuture executeWithSession(Session session)
                {
                    return session.executeAsync(partitionKeys);
                }
            });

            long count = countFuture.getUninterruptibly().one().getLong(0);
            if (count == limitForPartitionKeySelect) {
                partitionKeyFuture.cancel(true);
                return null; // too much effort to query all partition keys
            }
            else {
                return partitionKeyFuture.getUninterruptibly();
            }
        }
        else {
            addWhereClause(partitionKeys.where(), partitionKeyColumns, filterPrefix);
            ResultSetFuture partitionKeyFuture = executeWithSession(schemaName, new SessionCallable<ResultSetFuture>() {
                @Override
                public ResultSetFuture executeWithSession(Session session)
                {
                    return session.executeAsync(partitionKeys);
                }
            });
            return partitionKeyFuture.getUninterruptibly();
        }
    }
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

   *             execution.
   */
  @Override
  public Iterator<EventBean> iterator() {
    final String selectAllQuery = String.format("SELECT * FROM %s", _table);
    ResultSetFuture results;
    synchronized (_session) {
      results = _session.executeAsync(selectAllQuery);
    }
    try {
      final ResultSet cassandraResultList = results.get();
      return new EsperResultSetIterator(cassandraResultList,
          _context.getEventFactory());
    } catch (InterruptedException e) {
      _log.warn(
          "Query execution was interrupted, returning empty iterator.",
View Full Code Here

        CassandraTableHandle tableHandle = table.getTableHandle();
        String schemaName = tableHandle.getSchemaName();
        List<CassandraColumnHandle> partitionKeyColumns = table.getPartitionKeyColumns();

        boolean fullPartitionKey = filterPrefix.size() == partitionKeyColumns.size();
        ResultSetFuture countFuture;
        if (!fullPartitionKey) {
            final Select countAll = CassandraCqlUtils.selectCountAllFrom(tableHandle).limit(limitForPartitionKeySelect);
            countFuture = executeWithSession(schemaName, new SessionCallable<ResultSetFuture>() {
                @Override
                public ResultSetFuture executeWithSession(Session session)
                {
                    return session.executeAsync(countAll);
                }
            });
        }
        else {
            // no need to count if partition key is completely known
            countFuture = null;
        }

        int limit = fullPartitionKey ? 1 : limitForPartitionKeySelect;
        final Select partitionKeys = CassandraCqlUtils.selectDistinctFrom(tableHandle, partitionKeyColumns);
        partitionKeys.limit(limit);
        partitionKeys.setFetchSize(fetchSizeForPartitionKeySelect);

        if (!fullPartitionKey) {
            addWhereClause(partitionKeys.where(), partitionKeyColumns, new ArrayList<Comparable<?>>());
            ResultSetFuture partitionKeyFuture =  executeWithSession(schemaName, new SessionCallable<ResultSetFuture>() {
                @Override
                public ResultSetFuture executeWithSession(Session session)
                {
                    return session.executeAsync(partitionKeys);
                }
            });

            long count = countFuture.getUninterruptibly().one().getLong(0);
            if (count == limitForPartitionKeySelect) {
                partitionKeyFuture.cancel(true);
                return null; // too much effort to query all partition keys
            }
            else {
                return partitionKeyFuture.getUninterruptibly();
            }
        }
        else {
            addWhereClause(partitionKeys.where(), partitionKeyColumns, filterPrefix);
            ResultSetFuture partitionKeyFuture = executeWithSession(schemaName, new SessionCallable<ResultSetFuture>() {
                @Override
                public ResultSetFuture executeWithSession(Session session)
                {
                    return session.executeAsync(partitionKeys);
                }
            });
            return partitionKeyFuture.getUninterruptibly();
        }
    }
View Full Code Here

    }

    public void countAsync(Class<?> bean, Session session,
            ConsistencyLevel consistency, ResultAsyncCallBack<Long> resultCallBack) {
        Select select = prepareCount(bean, consistency);
        ResultSetFuture resultSet = session.executeAsync(select);
        AsyncResult.INSTANCE.runCount(resultCallBack, resultSet);

    }
View Full Code Here

        return (List<T>) RecoveryObject.INTANCE.recoverObjet(classBean.getClassInstance(),
                resultSet);
    }
    @Override
    public void executeAsync(ResultAsyncCallBack<List<T>> callBack) {
        ResultSetFuture resultSet = session.executeAsync(select);
        AsyncResult.INSTANCE.runSelect(callBack, resultSet, classBean.getClassInstance());
    }
View Full Code Here

    public <T> void listAllAsync(Class<T> bean, Session session,
            ResultAsyncCallBack<List<T>> resultCallBack,
            ConsistencyLevel consistency) {

        QueryBean byKeyBean = createQueryBean(bean, consistency);
        ResultSetFuture resultSet = session.executeAsync(byKeyBean.getSelect());
        AsyncResult.INSTANCE.runSelect(resultCallBack, resultSet, bean);
    }
View Full Code Here

            ConsistencyLevel consistency, ResultAsyncCallBack<List<T>> resultCallBack) {

        QueryBean byKeyBean = createQueryBean(bean, consistency);
        List<ResultSetFuture> results = new LinkedList<>();
        for (K key : keys) {
            ResultSetFuture resultSet = executeQueryAsync(key, bean, session,
                    byKeyBean);
            results.add(resultSet);
        }
        AsyncResult.INSTANCE.runKeys(resultCallBack, results, bean);
    }
View Full Code Here

    }


    private <T> void executeConditions(Object key, Class<T> bean, Session session,
            QueryBean byKeyBean, ResultAsyncCallBack<T> resultCallBack) {
        ResultSetFuture resultSet = executeQueryAsync(key, bean, session,
                byKeyBean);
        AsyncResult.INSTANCE.runKey(resultCallBack, resultSet, bean);
    }
View Full Code Here

        CassandraTableName.getMetaLayoutTableName(uri);

    final String deleteMetaKeyValue = CQLUtils.getDropTableStatement(metaKeyValueTableName);
    final String deleteMetaLayout = CQLUtils.getDropTableStatement(metaLayoutTableName);

    final ResultSetFuture keyValueFuture = admin.executeAsync(deleteMetaKeyValue);
    final ResultSetFuture layoutFuture = admin.executeAsync(deleteMetaLayout);

    keyValueFuture.getUninterruptibly();
    layoutFuture.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.