Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Duplicate
-
None
-
None
-
None
-
Java 1.6.0_21
-
Normal
Description
I was testing cassandra and trying to get iterate over a bunch of rows using the get_range_slices method.
In a loop I create small amount of data with this code:
for(int i=0;i<14;i++){
long timestamp = System.currentTimeMillis();
ColumnPath colPathName = new ColumnPath(CF_NAME);
colPathName.setColumn(propName.getBytes(UTF8));
client.insert(CASSANDRA_KEYSPACE, "my key "+i, colPathName, value, timestamp, ConsistencyLevel.ONE);
}
Next I try to iterate over the rows using this code:
Map<String, Map<String, byte[]>> rows = cs.getRows("", fetchSize);
//System.out.println(rows.size()+"-ROWS="+rows);
while(!rows.isEmpty()){
Iterator<String> it = rows.keySet().iterator();
while(it.hasNext()){
String key = it.next();
System.out.println(key+"-printing row:"+rows.get(key));
if(!it.hasNext())
}
}
the getrows method basically calls the get slice, for the key and count passed [I have set the predicate as per the example posted on the cassandra wiki]:
ColumnParent parent = new ColumnParent(CF_NAME);
List<ColumnOrSuperColumn> results = client.get_slice(CASSANDRA_KEYSPACE, key, parent, predicate, ConsistencyLevel.ONE);
This goes in an endless loop. The keys are returned randomly and I am never able to successfully finish the iteration.
Here's the output. It seems to move forward a little and them goes in a wild loop:
total slices:2
my key 0-printing row:
my key 1-printing row:
{description=[B@18088c0}reached end of current page. getting next page:my key 1
total slices:2
obtained new row:{my key 1=
my key 1-printing row:{description=[B@1922221}
my key 10-printing row:
{description=[B@fec107}reached end of current page. getting next page:my key 10
total slices:2
obtained new row:{my key 10=
my key 10-printing row:{description=[B@132e13d}
my key 11-printing row:
{description=[B@1617189}reached end of current page. getting next page:my key 11
total slices:2
obtained new row:{my key 12=
my key 12-printing row:{description=[B@64f6cd}
my key 11-printing row:
{description=[B@872380}reached end of current page. getting next page:my key 11
total slices:2
obtained new row:{my key 12=
my key 12-printing row:{description=[B@2bb514}
my key 11-printing row:
{description=[B@17d5d2a}reached end of current page. getting next page:my key 11
total slices:2
obtained new row:{my key 12=
my key 12-printing row:{description=[B@16fa474}
my key 11-printing row:
{description=[B@95c083}reached end of current page. getting next page:my key 11
total slices:2
obtained new row:{my key 12=
my key 12-printing row:{description=[B@191d8c1}
my key 11-printing row:
{description=[B@2d9c06}reached end of current page. getting next page:my key 11
total slices:2
obtained new row:{my key 12=
my key 12-printing row:{description=[B@5e5a50}
my key 11-printing row:
{description=[B@7b6889}reached end of current page. getting next page:my key 11
total slices:2
.
.
.
Shouldn't iteration work normally like other common iteration patterns or do I need to do things differently with casssandra to get iteration working?
Attachments
Issue Links
- relates to
-
CASSANDRA-1442 Get Range Slices is broken
- Resolved