Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ColumnFamilyResultIterator class to implement 'normal' iterable onto ColumnFamilyResult. #587

Merged
merged 1 commit into from

2 participants

ctcttest Nate McCall
ctcttest

No description provided.

Nate McCall zznate merged commit 7cf189b into from
Nate McCall
Collaborator

Awesome. Thanks!

ctcttest

You're welcome. I hope its helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
70 core/src/main/java/me/prettyprint/cassandra/service/template/ColumnFamilyResultIterator.java
View
@@ -0,0 +1,70 @@
+/**
+ * This class will instill 'normal' iterator behavior to a ColumnFamilyResult.
+ * Simply instantiate this class while passing your ColumnFamilyResult as a
+ * constructor argument.
+ *
+ * Ex.
+ *
+ * ColumnFamilyResultIterator myResultsInterator =
+ * new ColumnFamilyResultIterator(someColumnFamilyResult);
+ *
+ * You can then use myResultsInterator with for loops or iterate with a while loop
+ * just as with any standard java iterator.
+ *
+ */
+package me.prettyprint.cassandra.service.template;
+
+import java.util.Iterator;
+
+import me.prettyprint.cassandra.service.template.ColumnFamilyResult;
+
+public class ColumnFamilyResultIterator implements Iterator<ColumnFamilyResult<?,?>> {
+ private ColumnFamilyResult<?, ?> res;
+ private boolean isStart = true;
+
+ public ColumnFamilyResultIterator(ColumnFamilyResult<?, ?> res) {
+ this.res = res;
+ }
+
+ public boolean hasNext()
+ {
+ boolean retval = false;
+ if (isStart)
+ {
+ retval = res.hasResults();
+ }
+ else
+ {
+ retval = res.hasNext();
+ }
+ return retval;
+ }
+
+ public ColumnFamilyResult<?, ?> getRes()
+ {
+ return res;
+ }
+
+ public void setRes(ColumnFamilyResult<?, ?> res)
+ {
+ this.res = res;
+ }
+
+ public ColumnFamilyResult<?, ?> next()
+ {
+ if (isStart)
+ {
+ isStart = false;
+ return res;
+ }
+ else
+ {
+ return (ColumnFamilyResult<?, ?>) res.next();
+ }
+ }
+
+ public void remove()
+ {
+ res.remove();
+ }
+}
Something went wrong with that request. Please try again.