mirror of https://github.com/apache/cassandra
make CFS.getRangeSlice return List<Row>. patch by jbellis
git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@949421 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3dd229c167
commit
342f628a0a
|
|
@ -934,7 +934,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public RangeSliceReply getRangeSlice(byte[] super_column, final AbstractBounds range, int keyMax, SliceRange sliceRange, List<byte[]> columnNames)
|
||||
public List<Row> getRangeSlice(byte[] super_column, final AbstractBounds range, int keyMax, SliceRange sliceRange, List<byte[]> columnNames)
|
||||
throws ExecutionException, InterruptedException
|
||||
{
|
||||
List<Row> rows = new ArrayList<Row>();
|
||||
|
|
@ -956,7 +956,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
}
|
||||
}
|
||||
|
||||
return new RangeSliceReply(rows);
|
||||
return rows;
|
||||
}
|
||||
|
||||
public AbstractType getComparator()
|
||||
|
|
@ -1030,7 +1030,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
long i = 0;
|
||||
while (i < ssTables_.getRowCache().getCapacity())
|
||||
{
|
||||
RangeSliceReply result;
|
||||
List<Row> result;
|
||||
try
|
||||
{
|
||||
SliceRange range = new SliceRange(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, false, ROWS);
|
||||
|
|
@ -1041,13 +1041,13 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
for (Row row : result.rows)
|
||||
for (Row row : result)
|
||||
ssTables_.getRowCache().put(row.key, row.cf);
|
||||
i += result.rows.size();
|
||||
if (result.rows.size() < ROWS)
|
||||
i += result.size();
|
||||
if (result.size() < ROWS)
|
||||
break;
|
||||
|
||||
start = DatabaseDescriptor.getPartitioner().getToken(result.rows.get(ROWS - 1).key.key);
|
||||
start = DatabaseDescriptor.getPartitioner().getToken(result.get(ROWS - 1).key.key);
|
||||
}
|
||||
logger_.info(String.format("Loaded %s rows into the %s cache", i, columnFamily_));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ public class RangeSliceVerbHandler implements IVerbHandler
|
|||
{
|
||||
RangeSliceCommand command = RangeSliceCommand.read(message);
|
||||
ColumnFamilyStore cfs = Table.open(command.keyspace).getColumnFamilyStore(command.column_family);
|
||||
RangeSliceReply reply = cfs.getRangeSlice(command.super_column,
|
||||
command.range,
|
||||
command.max_keys,
|
||||
command.predicate.slice_range,
|
||||
command.predicate.column_names);
|
||||
RangeSliceReply reply = new RangeSliceReply(cfs.getRangeSlice(command.super_column,
|
||||
command.range,
|
||||
command.max_keys,
|
||||
command.predicate.slice_range,
|
||||
command.predicate.column_names));
|
||||
Message response = reply.getReply(message);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Sending " + reply+ " to " + message.getMessageId() + "@" + message.getFrom());
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class Util
|
|||
return bytes;
|
||||
}
|
||||
|
||||
public static RangeSliceReply getRangeSlice(ColumnFamilyStore cfs) throws IOException, ExecutionException, InterruptedException
|
||||
public static List<Row> getRangeSlice(ColumnFamilyStore cfs) throws IOException, ExecutionException, InterruptedException
|
||||
{
|
||||
Token min = StorageService.getPartitioner().getMinimumToken();
|
||||
return cfs.getRangeSlice(null,
|
||||
|
|
|
|||
|
|
@ -138,12 +138,12 @@ public class ColumnFamilyStoreTest extends CleanupHelper
|
|||
ColumnFamilyStore cfs = insertKey1Key2();
|
||||
|
||||
IPartitioner p = StorageService.getPartitioner();
|
||||
RangeSliceReply result = cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
|
||||
Util.range(p, "key15", "key1"),
|
||||
10,
|
||||
null,
|
||||
Arrays.asList("asdf".getBytes()));
|
||||
assertEquals(2, result.rows.size());
|
||||
List<Row> result = cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
|
||||
Util.range(p, "key15", "key1"),
|
||||
10,
|
||||
null,
|
||||
Arrays.asList("asdf".getBytes()));
|
||||
assertEquals(2, result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -152,13 +152,13 @@ public class ColumnFamilyStoreTest extends CleanupHelper
|
|||
ColumnFamilyStore cfs = insertKey1Key2();
|
||||
|
||||
IPartitioner p = StorageService.getPartitioner();
|
||||
RangeSliceReply result = cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
|
||||
Util.range(p, "key1", "key2"),
|
||||
10,
|
||||
null,
|
||||
Arrays.asList("asdf".getBytes()));
|
||||
assertEquals(1, result.rows.size());
|
||||
assert Arrays.equals(result.rows.get(0).key.key, "key2".getBytes());
|
||||
List<Row> result = cfs.getRangeSlice(ArrayUtils.EMPTY_BYTE_ARRAY,
|
||||
Util.range(p, "key1", "key2"),
|
||||
10,
|
||||
null,
|
||||
Arrays.asList("asdf".getBytes()));
|
||||
assertEquals(1, result.size());
|
||||
assert Arrays.equals(result.get(0).key.key, "key2".getBytes());
|
||||
}
|
||||
|
||||
private ColumnFamilyStore insertKey1Key2() throws IOException, ExecutionException, InterruptedException
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class CompactionsTest extends CleanupHelper
|
|||
inserted.add(key);
|
||||
}
|
||||
store.forceBlockingFlush();
|
||||
assertEquals(inserted.toString(), inserted.size(), Util.getRangeSlice(store).rows.size());
|
||||
assertEquals(inserted.toString(), inserted.size(), Util.getRangeSlice(store).size());
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
|
|
@ -74,7 +74,7 @@ public class CompactionsTest extends CleanupHelper
|
|||
{
|
||||
CompactionManager.instance.submitMajor(store).get();
|
||||
}
|
||||
assertEquals(inserted.size(), Util.getRangeSlice(store).rows.size());
|
||||
assertEquals(inserted.size(), Util.getRangeSlice(store).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class OneCompactionTest extends CleanupHelper
|
|||
rm.apply();
|
||||
inserted.add(key);
|
||||
store.forceBlockingFlush();
|
||||
assertEquals(inserted.size(), Util.getRangeSlice(store).rows.size());
|
||||
assertEquals(inserted.size(), Util.getRangeSlice(store).size());
|
||||
}
|
||||
CompactionManager.instance.submitMajor(store).get();
|
||||
assertEquals(1, store.getSSTables().size());
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class RecoveryManager2Test extends CleanupHelper
|
|||
cfs.clearUnsafe();
|
||||
CommitLog.recover(); // this is a no-op. is testing this useful?
|
||||
|
||||
assert Util.getRangeSlice(cfs).rows.isEmpty();
|
||||
assert Util.getRangeSlice(cfs).isEmpty();
|
||||
}
|
||||
|
||||
private void insertRow(String key) throws IOException
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ public class StreamingTest extends CleanupHelper
|
|||
|
||||
// confirm that the SSTable was transferred and registered
|
||||
ColumnFamilyStore cfstore = Table.open(tablename).getColumnFamilyStore(cfname);
|
||||
RangeSliceReply rr = Util.getRangeSlice(cfstore);
|
||||
assert rr.rows.size() == 1;
|
||||
assert Arrays.equals(rr.rows.get(0).key.key, "key".getBytes());
|
||||
List<Row> rows = Util.getRangeSlice(cfstore);
|
||||
assert rows.size() == 1;
|
||||
assert Arrays.equals(rows.get(0).key.key, "key".getBytes());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue