Cassaforte insert-batch

120 views
Skip to first unread message

Amir

unread,
Aug 29, 2013, 10:54:30 AM8/29/13
to clojure-...@googlegroups.com
Hi,

I am new to Cassandra and Cassaforte. I am try to execute batch which are in a list

  (client/prepared
    (insert-batch session :feed_data [{:feed_msg_id (long 11112) :data "ord-val" :key "ord-key" :subkey "lkz"  :format "format" :chg_flag  "chg-flag" :eod true :status (int 1) :profile "profile-id"}])
    )

but i am getting following exception
Exception in thread "main" java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String
    at clojurewerkz.cassaforte.client$build_statement.invoke(client.clj:167)
    at clojurewerkz.cassaforte.client$execute.doInvoke(client.clj:283)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojurewerkz.cassaforte.multi.cql$insert_batch.invoke(cql.clj:137)
    at wm.core.db.access.cassandra$insert_cas_batch_feed_data.invoke(cassandra.clj:40)
the single insert works fine which is as follows

(client/prepared
    (insert session :feed_data {:feed_msg_id (long 11112) :data "ord-val" :key "ord-key" :subkey "lkz"  :format "format" :chg_flag  "chg-flag" :eod true :status (int 1) :profile "profile-id"})
    )

Can someone please confirm if its the right way.

Regards,
Amir



Oleksandr Petrov

unread,
Aug 29, 2013, 12:17:41 PM8/29/13
to clojure-...@googlegroups.com
There's a bug with insert-batch in prepared mode, sorry about that. 

I'm working on it to fix it and push a new release ASAP.


--
You received this message because you are subscribed to the Google Groups "Cassaforte, a Clojure client for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-cassan...@googlegroups.com.
To post to this group, send email to clojure-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure-cassandra/fbffee00-b79c-4658-85e1-0fd16ec5dcee%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
alex p

Oleksandr Petrov

unread,
Aug 29, 2013, 12:46:49 PM8/29/13
to clojure-...@googlegroups.com
I've pushed cassaforte-1.2.0-SNAPSHOT to Clojars containing fix for your problem.

You can use it already. 
--
alex p

Amir

unread,
Aug 30, 2013, 3:23:40 AM8/30/13
to clojure-...@googlegroups.com
Hi Alex,

thanks for the update but i am still getting the same exception.


Exception in thread "main" java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String
    at clojurewerkz.cassaforte.client$build_statement.invoke(client.clj:172)
    at clojurewerkz.cassaforte.client$execute.doInvoke(client.clj:293)

    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojurewerkz.cassaforte.multi.cql$insert_batch.invoke(cql.clj:137)
    at wm.core.db.access.cassandra$_main$fn__5310.invoke(cassandra.clj:58)
    at wm.core.db.access.cassandra$_main.doInvoke(cassandra.clj:57)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.Var.invoke(Var.java:411)
    at user$eval98.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.eval(Compiler.java:6501)
    at clojure.lang.Compiler.eval(Compiler.java:6477)
    at clojure.core$eval.invoke(core.clj:2797)
    at clojure.main$eval_opt.invoke(main.clj:297)
    at clojure.main$initialize.invoke(main.clj:316)
    at clojure.main$null_opt.invoke(main.clj:349)
    at clojure.main$main.doInvoke(main.clj:427)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:419)

Here is the test-cast data
(defn get-session
  []
(let[cluster (client/build-cluster {:contact-points localhost :port 9042})
       session (client/connect cluster :demo)]
    session
    )
)

  (create-table (get-session)  "feed_data"
                (column-definitions {:feed_msg_id  :bigint
                                     :data         :varchar
                                     :key          :ascii
                                     :subkey       :ascii
                                     :format       :ascii
                                     :chg_flag     :ascii
                                     :eod          :boolean
                                     :status       :int
                                     :profile      :ascii
                                     :timestamp    :timestamp
                                     :primary-key [:feed_msg_id :profile :key :subkey]
                                     }))
 

  (client/prepared
    (insert-batch  (get-session) :feed_data [{:feed_msg_id (long 11112) :data "ord-val" :key "ord-key" :subkey "lkz"  :format "format" :chg_flag  "chg-flag" :eod true :status (int 1) :profile "profile-id"}])
    )

Regards,
Amir

Alex Petrov

unread,
Aug 30, 2013, 3:24:22 AM8/30/13
to Amir, clojure-...@googlegroups.com
Could you should the version you use in project.clj? 

Amir

unread,
Aug 30, 2013, 3:27:36 AM8/30/13
to clojure-...@googlegroups.com, Amir
                [clojurewerkz/cassaforte "1.2.0-SNAPSHOT"]

Alex Petrov

unread,
Aug 30, 2013, 3:30:53 AM8/30/13
to Amir, clojure-...@googlegroups.com
Ah, you're using multi-cql, there was same issue with multi, fixed & pushed new snapshot. 

You may want to run 
rm -fr ~/.m2/repository/clojurewerkz/cassaforte/1.2.0-SNAPSHOT
to ensure you get an updated version

Amir

unread,
Aug 30, 2013, 3:32:40 AM8/30/13
to clojure-...@googlegroups.com
Hey Alex,

It might be that out local nexus server had old snapshot from yesteday. I have asked our admin to remove it so that i can get an update.

regards,
Amir

Alex Petrov

unread,
Aug 30, 2013, 3:33:33 AM8/30/13
to Amir, clojure-...@googlegroups.com
Nono, it was my mistake, I didn't fix multi-cql, only regular one, but cleaning up caches would not hurt :)
--
You received this message because you are subscribed to the Google Groups "Cassaforte, a Clojure client for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-cassan...@googlegroups.com.
To post to this group, send email to clojure-...@googlegroups.com.

Amir

unread,
Aug 30, 2013, 3:53:22 AM8/30/13
to clojure-...@googlegroups.com
Its Working fine, probably it was our local nexus server which was holding cache for snapshots, after i expired it everything works fine.

thanks for you quick fix.

Regards,
Amir

Alex Petrov

unread,
Aug 30, 2013, 3:54:10 AM8/30/13
to Amir, clojure-...@googlegroups.com
I'll cut 1.2.0 release soon if nothing new pops up
--
You received this message because you are subscribed to the Google Groups "Cassaforte, a Clojure client for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-cassan...@googlegroups.com.
To post to this group, send email to clojure-...@googlegroups.com.

Michael Klishin

unread,
Aug 30, 2013, 7:55:16 AM8/30/13
to clojure-...@googlegroups.com

2013/8/30 Alex Petrov <oleksand...@gmail.com>

I'll cut 1.2.0 release soon if nothing new pops up
Reply all
Reply to author
Forward
0 new messages