cpp-driver | DataStax C/C++ Driver for Apache Cassandra
kandi X-RAY | cpp-driver Summary
kandi X-RAY | cpp-driver Summary
A modern, feature-rich and highly tunable C/C++ client library for Apache Cassandra 2.1+ using exclusively Cassandra's binary protocol and Cassandra Query Language v3. This driver can also be used with other DataStax products:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cpp-driver
cpp-driver Key Features
cpp-driver Examples and Code Snippets
Community Discussions
Trending Discussions on cpp-driver
QUESTION
I am having an issue with the cassandra api and select queries. In a single threaded context it works just fine. However, when multiple threads use the same object and call the function, even with just two threads, cassandra is returning it's futures with bad data(sometimes appears to be overwritten with data from other select queries, other times it is just garbage). I have a singleton object handling my calls to cassandra, and a byte buffer struct to hold the data returned. I have determined that, on a single thread, it all works as intended, but when I have added more threads using the same object and calling the same function, erroneous data is introduced into the data returned from cassandra.
The values sizes are ~1kb in size, and the keys are 32 bytes.
You can see the 2 lines surrounded by commented out mutex locks. If uncommented, this prevents the incorrect data issue, but also negates any performance gains from increasing the number of threads.
Additionally, the percentage of corrupted queries is about ~33%.
The cassandra api is supposed to be able to handle multiple threads and connections to the session without any issues(as per http://datastax.github.io/cpp-driver/topics/), so why am I getting back bad data?
I am using Centos7, c++14 and cassandra api 2.15 with cassandra 3.11.4
...ANSWER
Answered 2021-Jan-11 at 22:27It looks like you're freeing the results before a copy is made from the value pointers into the byteBuf
. In single-threaded version, you may be getting lucky that the dereferenced memory is still intact. Multithreaded, you're likely to overwrite.
QUESTION
currently I'm trying to connect a PHP App in Cloud Foundry with an Oracle Database. For this I need to build the binaries for php with the oci8 driver in order to use pdo_oci in my application. For this I'm using
https://github.com/cloudfoundry/binary-builder
with docker. This seems to work fine. However after this, I don't know how to move on.
I've read the Cloud Foundry Docs about custom Buildpacks ( https://docs.cloudfoundry.org/buildpacks/custom.html ). There they describe the creation of custom Buildpacks in three steps:
Ensure that you have installed the buildpack-packager.
Create a manifest.yml in your buildpack.
Run the packager in cached mode (...)
I've installed the buildpack-manager on my local machine and simply tried to run in against the binaries I've got from the binary builder. I thought it could working since there is a sources.yml file which looks similar to a manifest.yml
...ANSWER
Answered 2019-Jun-20 at 14:44To build a custom PHP buildpack, typically done to include proprietary dependencies like Oracle or SQL Server drivers you can do the following.
Build PHP. This is done with binary-builder. Follow the instructions here. Build as many versions of PHP as you require. This will produce tgz files that contain the binaries.
Host your custom binaries on a web server. This could be local or public, it depends on your needs (see step #5) below.
Clone the PHP Buildpack and checkout one of the stable release tags. Do not build from master as that makes it really hard to know what you're getting or recreate your build. When in doubt, pick the latest tagged release.
Edit the
manifest.yml
file. If it already has entries for the versions of PHP that you built, you can just modify theuri
,sha256
hash andmodules
. You need to add in the additional extensions you compiled to themodules
list. For example, appendoci8
orpdo_oci
to that list. If you're compiling a version of PHP that doesn't existing in the manifest, copy an existing entry and edit all the properties. You can also adjust the manifest to change default versions of PHP or to remove versions you don't want and slim down the buildpack.At this point, you can either commit your changes, push to a fork of the PHP buildpack and set
cf push -b
to point to your fork, or alternatively, you can run the build pack packager and create a buildpack file. You can then take that andcf create-buildpack
orcf update-buildpack
in your foundation (requires admin permissions).If you use
cf push -b
then the binaries you are hosting in step #2 must be accessible from the CF foundation where you are running your application. If you create and upload a buildpack, then the binaries only need to be accessible from the VM where you run build pack packager.
Hope that helps!
QUESTION
I've noticed that this compiles:
...ANSWER
Answered 2019-Jun-10 at 03:50That's fine. It's just the NULL
macro (which expands to just 0
on most compilers) that's causing the problem. 0
matches both the nullptr_t
and T*
constructors of unique_ptr
, so it's ambiguous and won't compile.
When initializing a unique_ptr
with a pointer variable or the return value of a function, it doesn't matter whether nullptr
, NULL
or 0
was used. They all have the same effect: a null pointer:
This is perfectly fine, for example
QUESTION
I'm trying to query cassandra from a c++ application, and return the values for a set of keys. I am using the datastax driver described here: http://datastax.github.io/cpp-driver/api/
The cassandra query string is something like this:
...ANSWER
Answered 2019-May-17 at 06:57There are several things here:
- the syntax
IN (?)
means that you are always asking only for one item - your list has only one entry; - if you want to query multiple items, you need to change syntax to
IN ?
and bind it using ass_statement_bind_collection_by_name to the value hasLIST
type. See doc on how you can create collection types; - Using
IN
for query on partition key is really anti-pattern - it adds load to the node that is performing the query, and makes your queries slower as coordinating node will need to send requests to other nodes, and wait for results, collect them, and send back. It's will be faster if you issue separate requests for each partition key, and collect answer in your application.
QUESTION
The Cassandra C++ Driver has an option used to enable the zlib library:
...ANSWER
Answered 2019-Apr-23 at 13:12The driver does not currently use zlib; it is there for future work. CPP-103 will add compression support to the driver which will utilize zlib at that time. It remained in the build system due to legacy implementation and can safely be ignored.
If you would like to see this feature implemented please vote or comment on the JIRA issue.
QUESTION
I really need some help with this, spent the last two days trying to figure it out.
I am attempting to migrate a laravel project from Mongo to Cassandra. I use docker containers for my local setup, here is the docker-compose.yml file with the relevant information
...ANSWER
Answered 2018-May-10 at 13:18Port 7199 is the JMX monitoring port; you should change the port from 7199 => 9042.
https://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/secureFireWall.html
If you are still having issues connecting to Apache Cassandra try executing the following to ensure the driver is being properly loaded via CLI:
QUESTION
I've got 2 functions, func1()
and func2()
. func2
takes a character array as input. Both functions run on different threads. I call func2
from func1
. When I passed a stack allocated array to func2
, I got garbage values when I printed the array from inside func2()
. However, when I passed a heap allocated array to func2
, I got the correct string inside func2()
i.e.
ANSWER
Answered 2018-Jun-04 at 08:17Does this mean that in multi-threaded programs, whenever some pointer has to be passed between different threads, the pointer should always be pointing at a heap-allocated memory?
No. This means that you must keep track of the lifetimes of your objects properly. When thread 1 finishes execution, the stack will be automatically cleaned up, thus spoiling the results that thread 2 is working with. Heap memory on the other hand stays if not explicitely freed. You have to check in thread 1 whether thread 2 is still executing and wait until it is finished, e.g. by using the join
function.
QUESTION
I've not been able to understand the role of a 'connection' in the execution of a query on a host.
cass_cluster_set_core_connections_per_host sets the number of connections made to each server in each IO thread. Why is this parameter configurable? What's the benefit of having more than 1 connection per IO thread? What decides the optimum value for this parameter?
...ANSWER
Answered 2018-May-08 at 12:54This function sets the initial number of connections per host, and it could be increased up to value set by cass_cluster_set_max_connections_per_host
function (by default it's 2). New connection is created when the number of in-flight request is greater than set by cass_cluster_set_max_concurrent_requests_threshold
(default 100). You can set higher value with cass_cluster_set_core_connections_per_host
if you know that you'll generate the big number of in-flight request from the beginning - in this case you won't spend time opening an additional connection when you're executing requests.
QUESTION
I'm using Datastax C++ driver. Intermittently I've noticed that cass_future_get_result() will return a NULL pointer.
The documentation says that NULL will be returned in case of an error. (http://datastax.github.io/cpp-driver/api/struct.CassFuture/) That's ambiguous to the point of being unhelpful.
What are the errors that will cause it to return NULL?
...ANSWER
Answered 2018-Apr-11 at 23:11To get more information about the error you can perform the following:
QUESTION
Which one is the primary local datacenter in cassandra as mentioned in the description of "cass_cluster_set_load_balance_dc_aware" in https://datastax.github.io/cpp-driver/api/struct.CassCluster/
...ANSWER
Answered 2018-Feb-23 at 08:39You set it as 2nd parameter (local_dc
) of the cass_cluster_set_load_balance_dc_aware
function. You need to specify correct DC name from your cluster.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install cpp-driver
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page