/** * Create a FilteredPartition holding all the rows of the provided iterator. * * Warning: Note that this method does not close the provided iterator and it is * up to the caller to do so. */ public static FilteredPartition create(RowIterator iterator) { return new FilteredPartition(iterator); }
public PartitionColumns columns() { return FilteredPartition.this.columns(); }
public RowIterator rowIterator() final Iterator<Row> iter = iterator(); return new RowIterator()
static RowIterator casInternal(CQL3CasRequest request, QueryState state) { UUID ballot = UUIDGen.getTimeUUIDFromMicros(state.getTimestamp()); SinglePartitionReadCommand readCommand = request.readCommand(FBUtilities.nowInSeconds()); FilteredPartition current; try (ReadExecutionController executionController = readCommand.executionController(); PartitionIterator iter = readCommand.executeInternal(executionController)) { current = FilteredPartition.create(PartitionIterators.getOnlyElement(iter, readCommand)); } if (!request.appliesTo(current)) return current.rowIterator(); PartitionUpdate updates = request.makeUpdates(current); updates = TriggerExecutor.instance.execute(updates); Commit proposal = Commit.newProposal(ballot, updates); proposal.makeMutation().apply(); return null; }
public boolean appliesTo(FilteredPartition current) return current.isEmpty(); else if (current.isEmpty()) return false; FilteredPartition.create( UnfilteredRowIterators.filter( ThriftResultsMerger.maybeWrap(expectedToUnfilteredRowIterator(), nowInSec), nowInSec)); Row c = current.getRow(e.clustering()); if (c == null) return false;
public SinglePartitionReadCommand readCommand(int nowInSec) { if (expected.isEmpty()) { // We want to know if the partition exists, so just fetch a single cell. ClusteringIndexSliceFilter filter = new ClusteringIndexSliceFilter(Slices.ALL, false); DataLimits limits = DataLimits.thriftLimits(1, 1); return SinglePartitionReadCommand.create(true, metadata, nowInSec, ColumnFilter.all(metadata), RowFilter.NONE, limits, key, filter); } // Gather the clustering for the expected values and query those. BTreeSet.Builder<Clustering> clusterings = BTreeSet.builder(metadata.comparator); FilteredPartition expectedPartition = FilteredPartition.create(LegacyLayout.toRowIterator(metadata, key, expected.iterator(), nowInSec)); for (Row row : expectedPartition) clusterings.add(row.clustering()); PartitionColumns columns = expectedPartition.staticRow().isEmpty() ? metadata.partitionColumns().withoutStatics() : metadata.partitionColumns(); ClusteringIndexNamesFilter filter = new ClusteringIndexNamesFilter(clusterings.build(), false); return SinglePartitionReadCommand.create(true, metadata, nowInSec, ColumnFilter.selection(columns), RowFilter.NONE, DataLimits.NONE, key, filter); }
public boolean appliesTo(FilteredPartition current) { return current.getRow(clustering) != null; } }
public boolean isEmpty() { return staticRow().isEmpty() && !hasRows(); } };
public DecoratedKey partitionKey() { return FilteredPartition.this.partitionKey(); }
public FilteredPartition(RowIterator rows) { super(rows.metadata(), rows.partitionKey(), build(rows, DeletionInfo.LIVE, false, 16)); }
public Row staticRow() { return FilteredPartition.this.staticRow(); }
private Map<DecoratedKey, Partition> asMaterializedMap(PartitionIterator iterator) { Map<DecoratedKey, Partition> map = new HashMap<>(); while (iterator.hasNext()) { try (RowIterator partition = iterator.next()) { map.put(partition.partitionKey(), FilteredPartition.create(partition)); } } return map; }
try (RowIterator rowIter = readOne(readCommand, readConsistency, queryStartNanoTime)) current = FilteredPartition.create(rowIter); return current.rowIterator();
public boolean appliesTo(FilteredPartition current) return current.isEmpty(); else if (current.isEmpty()) return false; FilteredPartition.create( UnfilteredRowIterators.filter( ThriftResultsMerger.maybeWrap(expectedToUnfilteredRowIterator(), nowInSec), nowInSec)); Row c = current.getRow(e.clustering()); if (c == null) return false;
public SinglePartitionReadCommand readCommand(int nowInSec) { if (expected.isEmpty()) { // We want to know if the partition exists, so just fetch a single cell. ClusteringIndexSliceFilter filter = new ClusteringIndexSliceFilter(Slices.ALL, false); DataLimits limits = DataLimits.thriftLimits(1, 1); return SinglePartitionReadCommand.create(true, metadata, nowInSec, ColumnFilter.all(metadata), RowFilter.NONE, limits, key, filter); } // Gather the clustering for the expected values and query those. BTreeSet.Builder<Clustering> clusterings = BTreeSet.builder(metadata.comparator); FilteredPartition expectedPartition = FilteredPartition.create(LegacyLayout.toRowIterator(metadata, key, expected.iterator(), nowInSec)); for (Row row : expectedPartition) clusterings.add(row.clustering()); PartitionColumns columns = expectedPartition.staticRow().isEmpty() ? metadata.partitionColumns().withoutStatics() : metadata.partitionColumns(); ClusteringIndexNamesFilter filter = new ClusteringIndexNamesFilter(clusterings.build(), false); return SinglePartitionReadCommand.create(true, metadata, nowInSec, ColumnFilter.selection(columns), RowFilter.NONE, DataLimits.NONE, key, filter); }
public boolean appliesTo(FilteredPartition current) { return current.getRow(clustering) == null; } }
public boolean isEmpty() { return staticRow().isEmpty() && !hasRows(); } };
public DecoratedKey partitionKey() { return FilteredPartition.this.partitionKey(); }
public FilteredPartition(RowIterator rows) { super(rows.metadata(), rows.partitionKey(), build(rows, DeletionInfo.LIVE, false, 16)); }
public Row staticRow() { return FilteredPartition.this.staticRow(); }