Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added getPendingMutationSize to Mutator #448

Merged
merged 1 commit into from Apr 5, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -265,6 +265,11 @@ public String toString() {
return "Mutator(" + keyspace.toString() + ")";
}

@Override
public int getPendingMutationCount() {
return getPendingMutations().getSize();
}

private BatchMutation<K> getPendingMutations() {
if (pendingMutations == null) {
pendingMutations = new BatchMutation<K>(keySerializer, sizeHint);
Expand Down
Expand Up @@ -155,4 +155,12 @@ public BatchMutation<K> makeCopy() {
public boolean isEmpty() {
return mutationMap.isEmpty() ;
}

/**
* Return the current size of the underlying map
* @return
*/
public int getSize() {
return mutationMap.size();
}
}
Expand Up @@ -218,4 +218,9 @@ <SN, N> MutationResult subDeleteCounter(final K key, final String cf, final SN s
*/
<SN,N> Mutator<K> addCounterSubDeletion(K key, String cf, HCounterSuperColumn<SN,N> sc);

/**
* Get the size of the pending mutations map
*/
int getPendingMutationCount();

}
Expand Up @@ -150,6 +150,7 @@ public void testBatchMutationManagement() {
for (int i = 0; i < 5; i++) {
m.addInsertion("k" + i, cf, createColumn("name", "value" + i, se, se));
}
assertEquals(5, m.getPendingMutationCount());
MutationResult r = m.execute();
assertTrue("Execute time should be > 0", r.getExecutionTimeMicro() > 0);
assertTrue("Should have operated on a host", r.getHostUsed() != null);
Expand Down