cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Ellis (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CASSANDRA-5563) The CQL3 binary protocol does not allow a user to bind an empty buffer to signify the start of the token range
Date Mon, 13 May 2013 19:31:15 GMT

     [ https://issues.apache.org/jira/browse/CASSANDRA-5563?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jonathan Ellis updated CASSANDRA-5563:
--------------------------------------

          Description: 
Using CQL2 or CQL3 over thrift, one can issue a query which starts at the beginning of the
table by binding an empty buffer.  The same is true for CQL2 using calls like get_range_slice.
  This is not allowed with the binary protocol.  Here is working sample code for CQL3 over
thrift:

{code}
    // Bind empty buffer to get query to start at the beginning of 
    // the table
    ByteBuffer b = ByteBuffer.wrap(new byte[0]);
    bindVars.add(b);

    int cnt = 0;
    CqlResult result;

    do {
      result =  _client.execute_prepared_cql3_query(stmt.itemId, bindVars, ConsistencyLevel.ONE);
      // Set up the next chunk, by setting the bind var to the last received key
      bindVars.set(0, ByteBuffer.wrap(result.getRows()
              .get(result.getRows().size() - 1).getColumns().get(0).getValue()));

      // Count rows
      cnt += result.getRows().size();

      if (cnt > 100)
        Assert.fail("Running past the end of the table: cnt = " + cnt + ", size() =  " + result.getRows().size());

    } while (result.getRows().size() >= CHUNK_SIZE);

    Assert.assertEquals("Wrong count", 100, cnt);

  } 
{code}

  was:
Using CQL2 or CQL3 over thrift, one can issue a query which starts at the beginning of the
table by binding an empty buffer.  The same is true for CQL2 using calls like get_range_slice.
  This is not allowed with the binary protocol.  Here is working sample code for CQL3 over
thrift:

    // Bind empty buffer to get query to start at the beginning of 
    // the table
    ByteBuffer b = ByteBuffer.wrap(new byte[0]);
    bindVars.add(b);

    int cnt = 0;
    CqlResult result;

    do {
      result =  _client.execute_prepared_cql3_query(stmt.itemId, bindVars, ConsistencyLevel.ONE);
      // Set up the next chunk, by setting the bind var to the last received key
      bindVars.set(0, ByteBuffer.wrap(result.getRows()
              .get(result.getRows().size() - 1).getColumns().get(0).getValue()));

      // Count rows
      cnt += result.getRows().size();

      if (cnt > 100)
        Assert.fail("Running past the end of the table: cnt = " + cnt + ", size() =  " + result.getRows().size());

    } while (result.getRows().size() >= CHUNK_SIZE);

    Assert.assertEquals("Wrong count", 100, cnt);

  } 

             Priority: Minor  (was: Major)
    Affects Version/s:     (was: 1.2.3)
                       1.2.0
        Fix Version/s: 1.2.5

You didn't include your statement.  Is it using {{token()}}?
                
> The CQL3 binary protocol does not allow a user to bind an empty buffer to signify the
start of the token range
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-5563
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-5563
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: API
>    Affects Versions: 1.2.0
>            Reporter: Steven Lowenthal
>            Priority: Minor
>             Fix For: 1.2.5
>
>
> Using CQL2 or CQL3 over thrift, one can issue a query which starts at the beginning of
the table by binding an empty buffer.  The same is true for CQL2 using calls like get_range_slice.
  This is not allowed with the binary protocol.  Here is working sample code for CQL3 over
thrift:
> {code}
>     // Bind empty buffer to get query to start at the beginning of 
>     // the table
>     ByteBuffer b = ByteBuffer.wrap(new byte[0]);
>     bindVars.add(b);
>     int cnt = 0;
>     CqlResult result;
>     do {
>       result =  _client.execute_prepared_cql3_query(stmt.itemId, bindVars, ConsistencyLevel.ONE);
>       // Set up the next chunk, by setting the bind var to the last received key
>       bindVars.set(0, ByteBuffer.wrap(result.getRows()
>               .get(result.getRows().size() - 1).getColumns().get(0).getValue()));
>       // Count rows
>       cnt += result.getRows().size();
>       if (cnt > 100)
>         Assert.fail("Running past the end of the table: cnt = " + cnt + ", size() = 
" + result.getRows().size());
>     } while (result.getRows().size() >= CHUNK_SIZE);
>     Assert.assertEquals("Wrong count", 100, cnt);
>   } 
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message