incubator-cassandra-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Ellis <>
Subject What to do with data that isn't there
Date Mon, 20 Apr 2009 21:29:43 GMT
Currently if you ask for a slice and there is no data for the slice
you defined you will get a CassandraException thrown.

I think this is the wrong thing to do for three reasons.

First, If you ask for a slice of cardinality 1 you get a list of size
1.  Slice of cardinality 2, list of size 2.  And so on.  So it would
be consistent if a slice of cardinality zero gave a list of
cardinality zero.

Second, in any other database I've used, a query that results in no
data found gives an empty resultset, not an error.  So the principle
of least surprise is relevant here.  (And I have certainly never
wished the db would raise an error in this case instead!)

Third, it's analogous to returning "null" in java -- over the years I
have found that having to check for "list == null || list.size() == 0"
usually leads to errors and always leads to ugly code.  Better to use
empty lists consistently and avoid requiring vigilance to prevent



(Note that I am only talking about API calls that can return a list of
values -- for scalar API calls, we'll have to return a
NotFoundException -- which should still be distinct from the exception
for bad requests or internal errors -- since Thrift has no way to
represent the absence of a value.)

View raw message