Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-1505

Bug with get_range_slices

    XMLWordPrintableJSON

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())

      { System.out.println("reached end of current page. getting next page:"+key); rows = cs.getRows(key, fetchSize); System.out.println("obtained new row:"+rows); }

      }
      }

      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:

      {description=[B@1a786c3}

      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=

      {description=[B@1922221}, my key 10={description=[B@fec107}}
      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=

      {description=[B@132e13d}, my key 11={description=[B@1617189}}
      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=

      {description=[B@64f6cd}, my key 11={description=[B@872380}}
      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=

      {description=[B@2bb514}, my key 11={description=[B@17d5d2a}}
      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=

      {description=[B@16fa474}, my key 11={description=[B@95c083}}
      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=

      {description=[B@191d8c1}, my key 11={description=[B@2d9c06}}
      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=

      {description=[B@5e5a50}, my key 11={description=[B@7b6889}}
      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

          Activity

            People

              Unassigned Unassigned
              aimran Imran Ahmed
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: