pingles / clj-hector Goto Github PK
View Code? Open in Web Editor NEWSimple Cassandra client for Clojure
Simple Cassandra client for Clojure
Hi,
I am using this clj-hector for one of my project, creating a web tool to browse cassandra cluster. I want to execute a query like "select * from my-column-family". Could you suggest me which api to be used and how to use that. I used the below code but it does not render that data
get-rows-cql-query keyspace "select * from Emp"
There's been a few changes to the API. Make sure all the documentation in GitHub Pages, the Wiki and the README are up to date.
I wanted to check to see if there was any plan to implement support composite column types. I was thinking about taking that on, but I realized it's probably going to involve significant rework of your existing codebase and didn't want to begin before first speaking with you.
Cassandra and Hector log a lot of information during the average test run. This masks the output from the tests, by default I'd like this to be suppressed, perhaps with a way of specifically enabling it for certain test runs from the repl?
We are on 1.2.1 right now. The tests right now break on 1.3. Almost certainly due to the auto boxing behavior changes in 1.3. There might be some issues with any dynamic vars we have as well.
Also 1.4 is out, which again changes boxing behavior. Ints will box to Long in 1.3 but integer in 1.4 believe. We should probably just upgrade straight to 1.4.
I've pushed a change on my fork to support composite keys, and works fine in my use. However, as it stands, it won't work if a CF has both a composite key as well as composite column (unless composites are identical). This is because ToClojure/AbstractComposite only looks for the :c-serializer
option.
Before I make any of those changes, wanted to discuss with you (and perhaps mstump) about necessary fix. Also, since a CF could have Composite values as well, might want to provision for that.
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" "[email protected]" {"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
My initial thoughts here would be to allow additional options to be passed to the already existing 'get-rows' function. Since the mongodb api seems to be often referenced as extremly developer friendly maybe something similar to a clojure lib they have?
https://github.com/aboekhoff/congomongo
Basically a ':where' option followed by a clause. Will have to be some cleverness with serializing the column name specified in the clause. I think it needs to end up as a byte array before being sent to cassandra.
See #25
Provide TTL information in defschema. Will need to update put to read values from the schema definitions.
We have some mismatch when serializing to/from hector/clojure in the serialize.clj and ddl.clj namespaces. We should rework those namespaces to make sure things match up. The conversion to clojure in serialize.clj is also returning some things still as hector objects (for example comparator type). We should avoid doing that.
This will likely have to be a backwards compatible breaking change so we may need to bump the major version number accordingly.
Currently the tests rely on having a Cassandra daemon running. cascading.cassandra creates an in-process daemon that the tests then connect to.
This could perhaps be introduced as a with-inproc-daemon macro, or perhaps a with-test-keyspace macro- could then tidy the dropping/creating keyspaces between tests
I would like to be able to add secondary index to a column family via clj-hector.
I don't believe there is a way to do this currently.
@rplevy-draker and myself would be willing to write the code to add this functionality if you have an idea of how you might like to see it implemented.
It's possible I'm just modeling my data incorrectly, but getting a range of rows with HFactory.createRangeSlicesQuery
seems quite useful in Hector. Is there a reason it's not supported in clj-hector?
Once the upgrade to Clojure 1.4.0 is settled, it's probably also worth upgrading Hector and Cassandra.
As of writing, the latest releases are: hector-core 1.0-5, and cassandra-all 1.0.10 (Cassandra has actually been updated to a 1.1.0 release although I've not done any testing with Hector 1.0.5 yet).
I'm going to leave this here so that people using clj-hector more aggressively can comment on the value of upgrading :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.