Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
Support multiple slices over RocksDBPartitions
Browse files Browse the repository at this point in the history
  • Loading branch information
hashbrowncipher committed Mar 21, 2018
1 parent b5a1bb5 commit 9c8ada2
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions src/java/org/apache/cassandra/rocksdb/RocksDBPartition.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang.NotImplementedException;
Expand Down Expand Up @@ -147,8 +148,50 @@ public UnfilteredRowIterator unfilteredIterator()

public UnfilteredRowIterator unfilteredIterator(ColumnFilter columns, Slices slices, boolean reversed)
{
//TODO: support multiple slices
return sliceIterator(slices.get(0), columns, (reversed ? PartitionIterOrder.REVERSED : PartitionIterOrder.NORMAL));
if(slices.size() == 1) {
return sliceIterator(slices.get(0), columns, reversed
? PartitionIterOrder.REVERSED
: PartitionIterOrder.NORMAL);
}

return new SlicesIterator(slices, columns, reversed);
}

private class SlicesIterator extends AbstractUnfilteredRowIterator {
private final Iterator<Slice> slices;
private final PartitionIterOrder iterOrder;
private final ColumnFilter columnFilter;

private Iterator<Unfiltered> currentSlice;

private SlicesIterator(Slices slices, ColumnFilter columnFilter, boolean isReverseOrder) {
super(RocksDBPartition.this.metadata, RocksDBPartition.this.partitionKey, DeletionTime.LIVE,
RocksDBPartition.this.metadata.partitionColumns(), null, isReverseOrder, EncodingStats.NO_STATS);
this.slices = slices.iterator();
this.iterOrder = isReverseOrder ? PartitionIterOrder.REVERSED : PartitionIterOrder.NORMAL;
this.columnFilter = columnFilter;
}

protected Unfiltered computeNext()
{
while (true)
{
if (currentSlice == null)
{
if(slices.hasNext()) {
currentSlice = sliceIterator(slices.next(), columnFilter, iterOrder);
}
else {
return endOfData();
}
}

if (currentSlice.hasNext())
return currentSlice.next();

currentSlice = null;
}
}
}


Expand Down

0 comments on commit 9c8ada2

Please sign in to comment.