read a single row #1

monisa opened this Issue May 5, 2011 · 2 comments


None yet

2 participants

monisa commented May 5, 2011

Hi am new to cassandra 0.7. could u able to clear my doubt???

This is my code for read a single row

public class Read1Column
private static StringSerializer stringSerializer = StringSerializer.get();
private static DoubleSerializer doubtSerializer = DoubleSerializer.get();
public static void main(String[] args) throws Exception {

          String keyspaceName = "User";
          String columnFamilyName ="User_Details";
          String serverAddress = "localhost:9160";
          //String username="stu1";
          String Uid="0001";
          // String FirstName="ss";
         // String LastName="kk";
         // String EMail="sksk";
         String password="ssss";      
    // Create a cluster
          Cluster cluster = HFactory.getOrCreateCluster("TestCluster", serverAddress);            
          Keyspace keyspaceOperator = HFactory.createKeyspace(keyspaceName, cluster);


                Iterator<SuperRow<String, String, String, Double>> rowIter =
                            stringSerializer, stringSerializer, stringSerializer,
                                        .setRange(Uid, password, false, 40)

                    while (rowIter.hasNext()) {

                                    SuperRow<String, String, String, Double> row =

                                    List<HSuperColumn<String, String, Double>> scList =

                                    for (int i=0; i<scList.size(); i++) {
                                             HSuperColumn<String, String, Double> sc =
                                            // Double val = sc.get(2).getValue(); 
                            // gets the value of column 2 within the supercolumn


            } catch (HectorException e) {
          //  client.getConnectionManager().shutdown();


its show the error:

log4j:WARN No appenders could be found for logger (me.prettyprint.cassandra.connection.CassandraHostRetryService).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NullPointerException: Null not allowed, number 1
at me.prettyprint.cassandra.utils.Assert.noneNull(
at me.prettyprint.cassandra.model.HSuperColumnImpl.(
at me.prettyprint.cassandra.model.SuperSliceImpl.(
at me.prettyprint.cassandra.model.SuperRowImpl.(
at me.prettyprint.cassandra.model.SuperRowsImpl.(
at me.prettyprint.cassandra.model.OrderedSuperRowsImpl.(
at me.prettyprint.cassandra.model.thrift.ThriftRangeSuperSlicesQuery$1.doInKeyspace(
at me.prettyprint.cassandra.model.thrift.ThriftRangeSuperSlicesQuery$1.doInKeyspace(
at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(
at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(
at me.prettyprint.cassandra.model.thrift.ThriftRangeSuperSlicesQuery.execute(
at Read1Column.main(

zznate commented May 5, 2011

Strange - looks like you got a null SC back in the result list. Can you show me output from cassandra-cli of what you expect to be there?

monisa commented May 6, 2011

If i give the key(Uid) means its display the entire column from the cassandra-cli. This is my expecting output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment