Liking cljdoc? Tell your friends :D

qbits.alia


batchclj

(batch qs)
(batch qs type)
(batch qs type codec)

Takes a sequence of statements to be executed in batch. By default LOGGED, you can specify :logged :unlogged :counter as an optional second argument to control the type. It also accepts an optional third argument, codec instance (see execute)

Takes a sequence of statements to be executed in batch.
By default LOGGED, you can specify :logged :unlogged :counter as an
optional second argument to control the type.  It also accepts an
optional third argument, codec instance (see `execute`)
sourceraw docstring

bindclj

(bind statement values)
(bind statement values {:keys [encoder]})

Takes a statement and a collection of values and returns a com.datastax.oss.driver.api.core.cql.BoundStatement instance to be used with execute (or one of its variants)

Where values: Map: for named bindings (i.e. INSERT INTO table (id, date) VALUES (:id :date)) List: for positional bindings (i.e. INSERT INTO table (id, date) VALUES (?, ?))

It also accepts an optional third argument, codec instance (see execute)

Takes a statement and a collection of values and returns a
`com.datastax.oss.driver.api.core.cql.BoundStatement` instance to be used with
`execute` (or one of its variants)

 Where values:
   Map: for named bindings       (i.e. INSERT INTO table (id, date) VALUES (:id :date))
   List: for positional bindings (i.e. INSERT INTO table (id, date) VALUES (?, ?))

It also accepts an optional third argument, codec instance (see `execute`)
sourceraw docstring

closeclj

(close session)

close a CqlSession

close a `CqlSession`
sourceraw docstring

close-asyncclj

(close-async session)

close CqlSession async

close `CqlSession` async
sourceraw docstring

executeclj

(execute session query)
(execute session
         query
         {:keys [values codec result-set-fn row-generator] :as opts})

Executes a query against a CqlSession. Returns a collection of rows.

The query can be a raw string, a PreparedStatement (returned by prepare) with values passed via the :values option key will be bound by execute, BoundStatement (returned by qbits.alia/bind).

The following com.datastax.oss.driver.api.core.cql.Statement options are supported:

  • :values : values to be bound to a prepared query
  • :consistency-level : Keyword, consistency
  • :execution-profile : com.datastax.oss.driver.api.core.config.DriverExecutionProfile instance
  • :execution-profile-name : String, execution profile name
  • :idempotent? : Boolean, Whether this statement is idempotent, i.e. whether it can be applied multiple times without changing the result beyond the initial application
  • :node : com.datastax.oss.driver.api.core.metadata.Node instance, the node to handle the query
  • :page-size : Number, sets the number of rows in each page of the results
  • :paging-state : com.datastax.oss.driver.api.core.cql.PagingState or ByteBuffer instance. This will cause the next execution of this statement to fetch results from a given page, rather than restarting from the beginning
  • :query-timestamp : Number, sets the timestamp for query (if not specified in CQL)
  • :routing-key : ByteBuffer, the key to use for token-aware routing
  • :routing-keyspace : com.datastax.oss.driver.api.core.CqlIdentifier or String instance, setting the keyspace for token-aware routing
  • :routing-token : com.datastax.oss.driver.api.core.metadata.token.Token, the token to use for token-aware routing
  • :serial-consistency-level : Keyword, consistency
  • :timeout : java.time.Duration, the read timeout
  • :tracing? : Bool, toggles query tracing (available via query result metadata)

and these additional options specify how results are to be handled:

  • :result-set-fn : Defaults to clojure.core/seq By default a result-set is an unchunked lazy seq, you can control this using this option. the :result-set-fn will be passed a version of the java-driver com.datastax.oss.driver.api.core.cql.ResultSet object which supports Iterable and IReduceInit giving you full control over how the resultset is formed (chunked, unchunked, eager or not, etc). A common use is to pass #(into [] %) as result-set-fn, you then get an eager value, with minimal copies, no intermediary seq and potentially better performance. This can be very powerfull when used right (for instance with transducers #(into [] xform %)).
  • :row-generator : implements qbits.alia.result-set/RowGenerator, Defaults to qbits.alia.codec/row-gen->map : A RowGenerator dictates how we construct rows.
  • :codec : map of :encoder :decoder functions that control how to apply extra modifications on data sent/received (defaults to qbits.alia.codec/default).

Possible values for consistency:

:all :any :each-quorum :local-one :local-quorum :local-serial :one :quorum :serial :three :two

Executes a query against a `CqlSession`.
Returns a collection of rows.

The query can be a raw string, a PreparedStatement (returned by
`prepare`) with values passed via the `:values` option key will be bound by
`execute`, BoundStatement (returned by `qbits.alia/bind`).

The following `com.datastax.oss.driver.api.core.cql.Statement` options
are supported:

* `:values` : values to be bound to a prepared query
* `:consistency-level` : Keyword, consistency
* `:execution-profile` : `com.datastax.oss.driver.api.core.config.DriverExecutionProfile`
  instance
* `:execution-profile-name` : `String`, execution profile name
* `:idempotent?` : `Boolean`, Whether this statement is idempotent, i.e. whether
  it can be applied multiple times without changing the result beyond
  the initial application
* `:node` : `com.datastax.oss.driver.api.core.metadata.Node` instance,
  the node to handle the query
* `:page-size` : Number, sets the number of rows in each page of the results
* `:paging-state` : `com.datastax.oss.driver.api.core.cql.PagingState` or
  `ByteBuffer` instance. This will cause the next execution of this statement
  to fetch results from a given page, rather than restarting from the
  beginning
* `:query-timestamp` : Number, sets the timestamp for query
  (if not specified in CQL)
* `:routing-key` : `ByteBuffer`, the key to use for token-aware routing
* `:routing-keyspace` : `com.datastax.oss.driver.api.core.CqlIdentifier` or
   `String` instance, setting the keyspace for token-aware routing
* `:routing-token` : `com.datastax.oss.driver.api.core.metadata.token.Token`,
  the token to use for token-aware routing
* `:serial-consistency-level` : Keyword, consistency
* `:timeout` : `java.time.Duration`, the read timeout
* `:tracing?` : `Bool`, toggles query tracing (available via query result
  metadata)

and these additional options specify how results are to be handled:

* `:result-set-fn` : Defaults to `clojure.core/seq` By default a
  result-set is an unchunked lazy seq, you can control this using this
  option. the `:result-set-fn` will be passed a version of the java-driver
  `com.datastax.oss.driver.api.core.cql.ResultSet` object
  which supports `Iterable` and `IReduceInit` giving you full control
  over how the resultset is formed (chunked,
  unchunked, eager or not, etc). A common use is to pass `#(into [] %)`
  as result-set-fn, you then get an eager value, with minimal copies,
  no intermediary seq and potentially better performance. This can be
  very powerfull when used right (for instance with transducers
  `#(into [] xform %))`.
* `:row-generator` : implements `qbits.alia.result-set/RowGenerator`,
  Defaults to `qbits.alia.codec/row-gen->map` : A RowGenerator dictates
  how we construct rows.
* `:codec` : map of `:encoder` `:decoder` functions that control how to
  apply extra modifications on data sent/received (defaults to
  `qbits.alia.codec/default`).

Possible values for consistency:

 `:all` `:any` `:each-quorum` `:local-one` `:local-quorum` `:local-serial`
 `:one` `:quorum` `:serial` `:three` `:two`
 
sourceraw docstring

execute-asyncclj

(execute-async session query)
(execute-async session
               query
               {:keys [values codec result-set-fn row-generator executor]
                :as opts})

Same args as execute but executes async and returns a CompletableFuture<AliaAsyncResultSetPage>

to fetch and decode the next page use qbits.alia.result-set/fetch-next-page on the AliaAsyncResultSetPage

Same args as `execute` but executes async and returns a
`CompletableFuture<AliaAsyncResultSetPage>`

to fetch and decode the next page use
`qbits.alia.result-set/fetch-next-page` on the `AliaAsyncResultSetPage`
sourceraw docstring

lazy-queryclj

(lazy-query session query pred)
(lazy-query session query pred opts)

Takes a session, a query (raw or prepared) and a query modifier fn (that receives the last query and last chunk and returns a new query or nil). The first chunk will be the original query result, then for each subsequent chunk the query will be the result of last query modified by the modifier fn unless the fn returns nil, which would causes the iteration to stop.

It also accepts any of execute options.

ex: (lazy-query session (select :items (limit 2) (where {:x (int 1)})) (fn [q coll] (merge q (where {:si (-> coll last :x inc)}))) {:consistency :quorum :tracing? true})

Takes a session, a query (raw or prepared) and a query modifier fn (that
receives the last query and last chunk and returns a new query or nil).
The first chunk will be the original query result, then for each
subsequent chunk the query will be the result of last query
modified by the modifier fn unless the fn returns nil,
which would causes the iteration to stop.

It also accepts any of `execute` options.

ex: (lazy-query session
              (select :items (limit 2) (where {:x (int 1)}))
                      (fn [q coll]
                        (merge q (where {:si (-> coll last :x inc)})))
              {:consistency :quorum :tracing? true})
sourceraw docstring

prepareclj

(prepare session query)

Takes a CqlSession and a query (raw string or hayt) and returns a com.datastax.oss.driver.api.core.cql.PreparedStatement instance to be used in execute after it's been bound with bind. Hayt query parameter will be compiled with qbits.hayt/->raw internaly ex: (prepare session (select :foo (where {:bar ?})))

Takes a `CqlSession` and a query (raw string or hayt) and returns a
`com.datastax.oss.driver.api.core.cql.PreparedStatement` instance to be used
in `execute` after it's been bound with `bind`. Hayt query parameter
will be compiled with qbits.hayt/->raw internaly
ex: (prepare session (select :foo (where {:bar ?})))
sourceraw docstring

prepare-asyncclj

(prepare-async session query {:keys [executor] :as opts})

Takes a CqlSession, a query (raw string or hayt) and prepares a statement asynchronously.

returns CompletionState<PreparedStatement>

Takes a `CqlSession`, a query (raw string or hayt) and
prepares a statement asynchronously.

returns CompletionState<PreparedStatement>
sourceraw docstring

sessionclj

(session)
(session config)

shortcut to build a CqlSession from a config map

config map keys are keywords from the qbits.alia.enum of com.datastax.oss.driver.api.core.config.DefaultDriverOption and appropriate scalar or collection values e.g.

{:session-keyspace "alia"
 :contact-points ["localhost:9042"]
 :load-balancing-local-datacenter "Analytics"}
shortcut to build a `CqlSession` from a config map

config map keys are keywords from the
`qbits.alia.enum` of
`com.datastax.oss.driver.api.core.config.DefaultDriverOption`
and appropriate scalar or collection values e.g.

```
{:session-keyspace "alia"
 :contact-points ["localhost:9042"]
 :load-balancing-local-datacenter "Analytics"}
```
sourceraw docstring

tuple-encoderclj

(tuple-encoder session table column)
(tuple-encoder session ks table column)
(tuple-encoder session ks table column codec)
source

udt-encoderclj

(udt-encoder session type)
(udt-encoder session ks type)
(udt-encoder session ks type codec)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close