summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/amazon/carbonado/cursor/AbstractCursor.java10
-rw-r--r--src/main/java/com/amazon/carbonado/cursor/SingletonCursor.java3
2 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/com/amazon/carbonado/cursor/AbstractCursor.java b/src/main/java/com/amazon/carbonado/cursor/AbstractCursor.java
index 5fb0fa8..9a31412 100644
--- a/src/main/java/com/amazon/carbonado/cursor/AbstractCursor.java
+++ b/src/main/java/com/amazon/carbonado/cursor/AbstractCursor.java
@@ -38,11 +38,12 @@ public abstract class AbstractCursor<S> implements Cursor<S> {
public int copyInto(Collection<? super S> c) throws FetchException {
try {
- int originalSize = c.size();
+ int count = 0;
while (hasNext()) {
c.add(next());
+ count++;
}
- return c.size() - originalSize;
+ return count;
} catch (FetchException e) {
try {
close();
@@ -55,11 +56,12 @@ public abstract class AbstractCursor<S> implements Cursor<S> {
public int copyInto(Collection<? super S> c, int limit) throws FetchException {
try {
- int originalSize = c.size();
+ int count = 0;
while (--limit >= 0 && hasNext()) {
c.add(next());
+ count++;
}
- return c.size() - originalSize;
+ return count;
} catch (FetchException e) {
try {
close();
diff --git a/src/main/java/com/amazon/carbonado/cursor/SingletonCursor.java b/src/main/java/com/amazon/carbonado/cursor/SingletonCursor.java
index 55b6cb6..f6cd142 100644
--- a/src/main/java/com/amazon/carbonado/cursor/SingletonCursor.java
+++ b/src/main/java/com/amazon/carbonado/cursor/SingletonCursor.java
@@ -80,9 +80,8 @@ public class SingletonCursor<S> implements Cursor<S> {
if (object == null) {
return 0;
}
- int originalSize = c.size();
c.add(object);
- return originalSize + 1;
+ return 1;
}
public int copyInto(Collection<? super S> c, int limit) {