NamesQueryFilter nqf = new NamesQueryFilter(names); SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf); StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
RangeNamesQueryPager(RangeSliceCommand command, ConsistencyLevel consistencyLevel, boolean localQuery) { super(consistencyLevel, command.maxResults, localQuery, command.keyspace, command.columnFamily, command.predicate, command.timestamp); this.command = command; assert columnFilter instanceof NamesQueryFilter && ((NamesQueryFilter)columnFilter).countCQL3Rows(); }
public static IDiskAtomFilter fromSCNamesFilter(CellNameType type, ByteBuffer scName, NamesQueryFilter filter) { if (scName == null) { ColumnSlice[] slices = new ColumnSlice[filter.columns.size()]; int i = 0; for (CellName name : filter.columns) { // Note that, because the filter in argument is the one from thrift, 'name' are SimpleDenseCellName. // So calling name.slice() would be incorrect, as simple cell names don't handle the EOC properly. // This is why we call toByteBuffer() and rebuild a Composite of the right type before call slice(). slices[i++] = type.make(name.toByteBuffer()).slice(); } return new SliceQueryFilter(slices, false, slices.length, 1); } else { SortedSet<CellName> newColumns = new TreeSet<>(type); for (CellName c : filter.columns) newColumns.add(type.makeCellName(scName, c.toByteBuffer())); return filter.withUpdatedColumns(newColumns); } }
public ColumnCounter columnCounter() { // We know NamesQueryFilter.columnCounter don't care about his argument return command.filter.columnCounter(null, command.timestamp); }
public boolean countCQL3Rows() { return countCQL3Rows(null); }
columns.add(cfs.getComparator().cellFromByteBuffer(expr.column)); columns.addAll(((NamesQueryFilter) filter).columns); return ((NamesQueryFilter) filter).withUpdatedColumns(columns);
public NamesQueryFilter withUpdatedColumns(SortedSet<CellName> newColumns) { return new NamesQueryFilter(newColumns, countCQL3Rows); }
public int maxRemaining() { if (queried) return 0; return command.filter.countCQL3Rows() ? 1 : command.filter.columns.size(); }
QueryFilter reducedFilter = new QueryFilter(filter.key, filter.cfName, namesFilter.withUpdatedColumns(filterColumns), filter.timestamp);
/** * @return a QueryFilter object that will return columns matching the given names * @param key the row to slice * @param cfName column family to query * @param columns the column names to restrict the results to, sorted in comparator order */ public static QueryFilter getNamesFilter(DecoratedKey key, String cfName, SortedSet<CellName> columns, long timestamp) { return new QueryFilter(key, cfName, new NamesQueryFilter(columns), timestamp); }
private static int maxQueried(ReadCommand command) { if (command instanceof SliceByNamesReadCommand) { NamesQueryFilter filter = ((SliceByNamesReadCommand)command).filter; return filter.countCQL3Rows() ? 1 : filter.columns.size(); } else { SliceQueryFilter filter = ((SliceFromReadCommand)command).filter; return filter.count; } }
public NamesQueryFilter deserialize(DataInput in, int version) throws IOException { int size = in.readInt(); SortedSet<CellName> columns = new TreeSet<CellName>(type); ISerializer<CellName> serializer = type.cellSerializer(); for (int i = 0; i < size; ++i) columns.add(serializer.deserialize(in)); boolean countCQL3Rows = in.readBoolean(); return new NamesQueryFilter(columns, countCQL3Rows); }
public List<Row> fetchPage(int pageSize) throws RequestValidationException, RequestExecutionException { assert command.filter.countCQL3Rows() || command.filter.columns.size() <= pageSize; if (isExhausted()) return Collections.<Row>emptyList(); queried = true; return localQuery ? Collections.singletonList(command.getRow(Keyspace.open(command.ksName))) : StorageProxy.read(Collections.<ReadCommand>singletonList(command), consistencyLevel, state); }
private void retryDummyRead(String ks, String cf) throws PermanentBackendException { final long limit = System.currentTimeMillis() + (60L * 1000L); while (System.currentTimeMillis() < limit) { try { SortedSet<ByteBuffer> ss = new TreeSet<ByteBuffer>(); ss.add(ByteBufferUtil.zeroByteBuffer(1)); NamesQueryFilter nqf = new NamesQueryFilter(ss); 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"); } }
NamesQueryFilter nqf = new NamesQueryFilter(names); SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf); StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
private IDiskAtomFilter toInternalFilter(CFMetaData metadata, ColumnParent parent, SlicePredicate predicate) { IDiskAtomFilter filter; if (predicate.column_names != null) { if (metadata.isSuper()) { CellNameType columnType = new SimpleDenseCellNameType(metadata.comparator.subtype(parent.isSetSuper_column() ? 1 : 0)); SortedSet<CellName> s = new TreeSet<>(columnType); for (ByteBuffer bb : predicate.column_names) s.add(columnType.cellFromByteBuffer(bb)); filter = SuperColumns.fromSCNamesFilter(metadata.comparator, parent.bufferForSuper_column(), new NamesQueryFilter(s)); } else { SortedSet<CellName> s = new TreeSet<CellName>(metadata.comparator); for (ByteBuffer bb : predicate.column_names) s.add(metadata.comparator.cellFromByteBuffer(bb)); filter = new NamesQueryFilter(s); } } else { filter = toInternalFilter(metadata, parent, predicate.slice_range); } return filter; }
private void getCurrentValuesFromCFS(List<CounterUpdateCell> counterUpdateCells, ColumnFamilyStore cfs, ClockAndCount[] currentValues) { SortedSet<CellName> names = new TreeSet<>(cfs.metadata.comparator); for (int i = 0; i < currentValues.length; i++) if (currentValues[i] == null) names.add(counterUpdateCells.get(i).name()); ReadCommand cmd = new SliceByNamesReadCommand(getKeyspaceName(), key(), cfs.metadata.cfName, Long.MIN_VALUE, new NamesQueryFilter(names)); Row row = cmd.getRow(cfs.keyspace); ColumnFamily cf = row == null ? null : row.cf; for (int i = 0; i < currentValues.length; i++) { if (currentValues[i] != null) continue; Cell cell = cf == null ? null : cf.getColumn(counterUpdateCells.get(i).name()); if (cell == null || !cell.isLive()) // absent or a tombstone. currentValues[i] = ClockAndCount.BLANK; else currentValues[i] = CounterContext.instance().getLocalClockAndCount(cell.value()); } }
public IDiskAtomFilter readFilter() { return expected == null || expected.isEmpty() ? new SliceQueryFilter(ColumnSlice.ALL_COLUMNS_ARRAY, false, 1) : new NamesQueryFilter(ImmutableSortedSet.copyOf(expected.getComparator(), expected.getColumnNames())); }
public IDiskAtomFilter getExtraFilter(DecoratedKey rowKey, ColumnFamily data) { /* * This method assumes the IndexExpression names are valid column names, which is not the * case with composites. This is ok for now however since: * 1) CompositeSearcher doesn't use it. * 2) We don't yet allow non-indexed range slice with filters in CQL3 (i.e. this will never be * called by CFS.filter() for composites). */ assert !(cfs.getComparator().isCompound()) : "Sequential scan with filters is not supported (if you just created an index, you " + "need to wait for the creation to be propagated to all nodes before querying it)"; if (!needsExtraQuery(rowKey.getKey(), data)) return null; // Note: for counters we must be careful to not add a column that was already there (to avoid overcount). That is // why we do the dance of avoiding to query any column we already have (it's also more efficient anyway) SortedSet<CellName> columns = new TreeSet<CellName>(cfs.getComparator()); for (IndexExpression expr : clause) { CellName name = data.getComparator().cellFromByteBuffer(expr.column); if (data.getColumn(name) == null) columns.add(name); } assert !columns.isEmpty(); return new NamesQueryFilter(columns); }
return null; QueryProcessor.validateCellNames(cellNames, cfm.comparator); return new NamesQueryFilter(cellNames, true);