CompanyMarch 14, 2016

DataStax C/C++ Driver: 2.3 GA released!

Michael Penick
Michael PenickDataStax
DataStax C/C++ Driver: 2.3 GA released!

We are pleased to announce the 2.3 GA release of the C/C++ driver for Apache Cassandra. This release includes all the features necessary to take full advantage of Apache .  Cassandra 3.0 including support for materialized view metadata. This release also brings with it:

Thanks to a community contribution this release includes supports for the blacklistblacklist DC and whitelist DC load balancing policies.

What's new

Materialized view metadata

Cassandra 3.0 added support for materialized views. The 2.3 release of the C/C++ driver adds support for inspecting the metadata for materialized views. Building from the example found in the materialized view post we can retrieve materialized views from either the keyspace metadata or the materialized view's base table.

CREATE KEYSPACE game
       WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'dc1' : 3 };
USE game;

CREATE TABLE scores
(
  user TEXT,
  game TEXT,
  year INT,
  month INT,
  day INT,
  score INT,
  PRIMARY KEY (user, game, year, month, day)
)

CREATE MATERIALIZED VIEW alltimehigh AS
       SELECT user FROM scores
       WHERE game IS NOT NULL AND score IS NOT NULL AND user IS NOT NULL AND
             year IS NOT NULL AND month IS NOT NULL AND day  IS NOT NULL
       PRIMARY KEY (game, score, user, year, month, day)
       WITH CLUSTERING ORDER BY (score desc)

Retrieving a materialized view from a keyspace

const CassSchemaMeta* schema_meta = cass_session_get_schema_meta(session);

const
CassKeyspaceMeta* keyspace_meta = cass_schema_meta_keyspace_by_name(schema_meta, "game");

const
CassMaterizedViewMeta* mv_meta;

/* Retrieve the materialized view by name from the keyspace */
mv_meta = cass_keyspace_meta_materialized_view_by_name(keyspace_meta, "alltimehigh"
);

/* ... */

/* Materialized views in a keyspace can also be iterated over */
CassIterator* iterator = cass_iterator_materialized_views_from_keyspace_meta(keyspace_meta);

/* Iterate over materialized views in the "game" keyspace */
while
(cass_iterator_next(iterator)) {
  mv_meta = cass_iterator_get_materialized_view_meta(iterator);

   /* Use materialized view metadata... */
   

}

cass_iterator_free(iterator)
cass_schema_meta_free(schema_meta);

Retrieving a materialized view from a table

const CassKeyspaceMeta* keyspace_meta = cass_schema_meta_keyspace_by_name(schema_meta, "game");

const
CassTableMeta* table_meta = cass_keyspace_meta_table_by_name(keyspace_meta, "scores");

const
CassMaterizedViewMeta* mv_meta;

/* The materialized view can be retrieved by name */
mv_meta = cass_table_meta_materialized_view_by_name(table_meta, "alltimehigh"
);

/* OR by index */
mv_meta =  cass_table_meta_materialized_view(table_meta, 0);

/* ... */

cass_schema_meta_free(schema_meta);

Materialized view metadata is almost exactly the same as the metadata for tables because they are themselves just tables. The difference is materialized views have base table that can be retrieved using cass_materialized_view_meta_base_table(). This example shows how table metadata might be used and can be applied when using materialized views.

Looking forward

This release brings with it full support for Apache Cassandra 3.0 along with several other great features including some community contributed features. We truly appreciate the community involvement, thank you. Keep the pull requests and feedback coming! Let us know what you think about the 2.3 GA release. Your involvement is important to us and it influences what features we prioritize. Use the following resources to get involved:

Discover more
DriversC++
Share

One-stop Data API for Production GenAI

Astra DB gives JavaScript developers a complete data API and out-of-the-box integrations that make it easier to build production RAG apps with high relevancy and low latency.