Search code examples
cassandrapycassa

To to know which key not found in Cassandra?


I am using pycassa. I am requesting some columns from a row:

cf.get(rowKey, column_start=column_start, column_finish=column_finish)

If specified row key or any of start and finish column keys do not exist, NotFoundException is raised. Is there a way to determine which key wasn't found - row key or column key (name)?


Solution

  • In the near future a NotFoundException will not be returned when a key exists but an empty slice is returned; that should disambiguate the result.

    I've opened https://github.com/pycassa/pycassa/issues/50 to address this.

    In the meantime as a workaround, upon getting a NotFoundException, you can try:

    cf.get(rowKey, column_count=1)
    

    And if a NotFoundException is not raised, you know that the key exists and the row is not empty.