Super columns: supercolumn parameter is not optional for super CF Documents #26

Closed
blakesmith opened this Issue Apr 23, 2012 · 2 comments

Projects

None yet

2 participants

@blakesmith
Contributor

Hello there!

I seem to be having some trouble creating a mutation on a super column family.

First, I create the column family:

letterleaf.tasks.bootstrap> (ddl/add-column-family cass/cluster cass/keyspace-name {:name "Documents" :type :super :comparator :ascii})
 "2611c110-8ce6-11e1-0000-5416249b7faf"

Which yields a schema like so:

create column family Documents
  with column_type = 'Super'
  and comparator = 'AsciiType'
  and subcomparator = 'BytesType'
  and default_validation_class = 'BytesType'
  and key_validation_class = 'BytesType'
  and rows_cached = 0.0
  and row_cache_save_period = 0
  and row_cache_keys_to_save = 0
  and keys_cached = 200000.0
  and key_cache_save_period = 14400
  and read_repair_chance = 1.0
  and gc_grace = 864000
  and min_compaction_threshold = 4
  and max_compaction_threshold = 32
  and replicate_on_write = true
  and row_cache_provider = 'ConcurrentLinkedHashCacheProvider'
  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy';

Then I try to 'put' rows into the column family:

letterleaf.models.document> (hector/put cass/keyspace "Documents" "bob@hotmail.com" {"123" {"sec-0" "bob"}})

Which throws this exception:

InvalidRequestException(why:supercolumn parameter is not optional for super CF Documents)
  [Thrown class me.prettyprint.hector.api.exceptions.HInvalidRequestException]

Restarts:
 0: [QUIT] Quit to the SLIME top level
 1: [CAUSE1] Invoke debugger on cause   [Thrown class org.apache.cassandra.thrift.InvalidRequestException]

Backtrace:
  0: ExceptionsTranslatorImpl.java:52 me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate
  1: HConnectionManager.java:252 me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover
  2:   ExecutingKeyspace.java:97 me.prettyprint.cassandra.model.ExecutingKeyspace.doExecuteOperation
  3:        MutatorImpl.java:243 me.prettyprint.cassandra.model.MutatorImpl.execute
  4:                core.clj:164 clj-hector.core/put
  5:             RestFn.java:470 clojure.lang.RestFn.invoke
  6:            NO_SOURCE_FILE:1 letterleaf.models.document$eval2464.invoke
  7:          Compiler.java:5424 clojure.lang.Compiler.eval
  8:          Compiler.java:5391 clojure.lang.Compiler.eval
  9:               core.clj:2382 clojure.core/eval
 10:                core.clj:532 swank.core/eval719[fn]
 11:            MultiFn.java:163 clojure.lang.MultiFn.invoke
 12:                basic.clj:54 swank.commands.basic/eval-region
 13:                basic.clj:44 swank.commands.basic/eval-region
 14:                basic.clj:78 swank.commands.basic/eval989[fn]
 15:                Var.java:365 clojure.lang.Var.invoke
 16:            (Unknown Source) letterleaf.models.document$eval2462.invoke
 17:          Compiler.java:5424 clojure.lang.Compiler.eval
 18:          Compiler.java:5391 clojure.lang.Compiler.eval
 19:               core.clj:2382 clojure.core/eval
 20:                core.clj:100 swank.core/eval-in-emacs-package
 21:                core.clj:256 swank.core/eval-for-emacs
 22:                Var.java:373 clojure.lang.Var.invoke
 23:                AFn.java:167 clojure.lang.AFn.applyToHelper
 24:                Var.java:482 clojure.lang.Var.applyTo
 25:                core.clj:540 clojure.core/apply
 26:                core.clj:107 swank.core/eval-from-control
 27:                core.clj:112 swank.core/eval-loop
 28:                core.clj:341 swank.core/spawn-repl-thread[fn]
 29:                AFn.java:159 clojure.lang.AFn.applyToHelper
 30:                AFn.java:151 clojure.lang.AFn.applyTo
 31:                core.clj:540 clojure.core/apply
 32:                core.clj:338 swank.core/spawn-repl-thread[fn]
 33:             RestFn.java:397 clojure.lang.RestFn.invoke
 34:                 AFn.java:24 clojure.lang.AFn.run
 35:             Thread.java:680 java.lang.Thread.run

Can anyone shed any insight into this exception? I'm new to Cassandra, so I'm probably missing something obvious, but I wasn't sure if it was something specifically with clj-hector.

Thanks!

Blake

@nickmbailey
Collaborator

When doing a put with super columns, you need to explicitly pass the super argument. So in your case:

(hector/put cass/keyspace "Documents" "bob@hotmail.com" {"123" {"sec-0" "bob"}} :type :super)

That being said, you almost certainly shouldn't be using super columns. This quora answer does a good job of explaining why:

http://www.quora.com/Cassandra-database/Why-is-it-bad-to-use-supercolumns-in-Cassandra

Cassandra now has the concept of composite columns that can be used as a replacement for super columns and should generally be used going forward. These links might be helpful:

http://www.datastax.com/dev/blog/schema-in-cassandra-1-1
http://www.datastax.com/dev/blog/introduction-to-composite-columns-part-1

@nickmbailey nickmbailey was assigned Apr 23, 2012
@blakesmith
Contributor

Hey Nick,

Thanks a bunch for the help and advice. I'm still modeling out my domain, so this is extremely helpful - I'll rewrite what I have using regular columns.

In the meantime, I sent a pull request to update the README to reflect the correct syntax for those who might try this later: #27

Thanks again!

Blake

@blakesmith blakesmith closed this Apr 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment