Java Code Examples for org.apache.cassandra.service.StorageProxy#read()
The following examples show how to use
org.apache.cassandra.service.StorageProxy#read() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectStatement.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private ResultMessage.Rows execute(Pageable command, QueryOptions options, int limit, long now, QueryState state) throws RequestValidationException, RequestExecutionException { List<Row> rows; if (command == null) { rows = Collections.<Row>emptyList(); } else { rows = command instanceof Pageable.ReadCommands ? StorageProxy.read(((Pageable.ReadCommands)command).commands, options.getConsistency(), state.getClientState()) : StorageProxy.getRangeSlice((RangeSliceCommand)command, options.getConsistency()); } return processResults(rows, options, limit, now); }
Example 2
Source File: SliceQueryPager.java From stratio-cassandra with Apache License 2.0 | 6 votes |
protected List<Row> queryNextPage(int pageSize, ConsistencyLevel consistencyLevel, boolean localQuery) throws RequestValidationException, RequestExecutionException { // For some queries, such as a DISTINCT query on static columns, the limit for slice queries will be lower // than the page size (in the static example, it will be 1). We use the min here to ensure we don't fetch // more rows than we're supposed to. See CASSANDRA-8108 for more details. SliceQueryFilter filter = command.filter.withUpdatedCount(Math.min(command.filter.count, pageSize)); if (lastReturned != null) filter = filter.withUpdatedStart(lastReturned, cfm.comparator); logger.debug("Querying next page of slice query; new filter: {}", filter); ReadCommand pageCmd = command.withUpdatedFilter(filter); return localQuery ? Collections.singletonList(pageCmd.getRow(Keyspace.open(command.ksName))) : StorageProxy.read(Collections.singletonList(pageCmd), consistencyLevel, cstate); }
Example 3
Source File: CassandraEmbeddedStoreManager.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
private void retryDummyRead(String ks, String cf) throws PermanentBackendException { final long limit = System.currentTimeMillis() + (60L * 1000L); while (System.currentTimeMillis() < limit) { try { SortedSet<CellName> names = new TreeSet<>(new Comparator<CellName>() { // This is a singleton set. We need to define a comparator because SimpleDenseCellName is not // comparable, but it doesn't have to be a useful comparator @Override public int compare(CellName o1, CellName o2) { return 0; } }); names.add(CellNames.simpleDense(ByteBufferUtil.zeroByteBuffer(1))); NamesQueryFilter nqf = new NamesQueryFilter(names); SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf); StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM); log.info("Read on CF {} in KS {} succeeded", cf, ks); return; } catch (Throwable t) { log.warn("Failed to read CF {} in KS {} following creation", cf, ks, t); } try { Thread.sleep(1000L); } catch (InterruptedException e) { throw new PermanentBackendException(e); } } throw new PermanentBackendException("Timed out while attempting to read CF " + cf + " in KS " + ks + " following creation"); }
Example 4
Source File: CassandraServer.java From stratio-cassandra with Apache License 2.0 | 5 votes |
protected Map<DecoratedKey, ColumnFamily> readColumnFamily(List<ReadCommand> commands, org.apache.cassandra.db.ConsistencyLevel consistency_level, ClientState cState) throws org.apache.cassandra.exceptions.InvalidRequestException, UnavailableException, TimedOutException { // TODO - Support multiple column families per row, right now row only contains 1 column family Map<DecoratedKey, ColumnFamily> columnFamilyKeyMap = new HashMap<DecoratedKey, ColumnFamily>(); List<Row> rows = null; try { schedule(DatabaseDescriptor.getReadRpcTimeout()); try { rows = StorageProxy.read(commands, consistency_level, cState); } finally { release(); } } catch (RequestExecutionException e) { ThriftConversion.rethrow(e); } for (Row row: rows) { columnFamilyKeyMap.put(row.key, row.cf); } return columnFamilyKeyMap; }