I'm in making a gui client for Cassandra.
How to get details of existing key-spaces, column family, column details in Cassandra?
Is there any meta data storing tables in cassandra?
All of the metadata about Cassandra is in the system keyspace.
A better solution might be to use the DataStax JavaDriver to connect to the Cluster, then use the MetaData available there so you don't have to re-invent the wheel.
com.datastax.driver.core.Cluster c = com.datastax.driver.core.Cluster.builder()
.addContactPoint(cluster.getContactPoint()).withPort(cluster.getRpcPort()).build();
c.connect();
Metadata md = c.getMetadata();
List<KeyspaceMetadata> keyspaces = md.getKeyspaces();
c.close();
There are other methods on the Metadata object to get just about anything you need from the cluster configuration.
Related
I plan to enhance the search for our retail service, which is managed by DataStax. We have data of about 500KB in raw from our wheels and tires and could be compressed and encrypted to about 20KB. This table is frequently used and changes about every day. We send the data to the frontend, which will be processed with Next.js later. Now we want to store this data in a single row table in a separate keyspace with a consistency level of TWO and RF equal to all nodes, replicating the table to all of the nodes.
Now the question: Is this solution hacky or abnormal? Is any solution rather this that fits best in this situation?
The quick answer to your question is yes, it is a hacky solution to do RF=ALL.
The table is very small so there is no benefit to replicating it to all nodes in the cluster. In practice, the tables are so small that the data will be cached anyway.
Since you are running with DataStax Enterprise (DSE), you might as well take advantage of the DSE In-Memory feature which allows you to keep data in RAM to save from disk seeks. Since your table can easily fit in RAM, it is a perfect use case for DSE In-Memory.
To configure the table to run In-Memory, set the table's compaction strategy to MemoryOnlyStrategy:
CREATE TABLE inmemorytable (
...
PRIMARY KEY ( ... )
) WITH compaction= {'class': 'MemoryOnlyStrategy'}
AND caching = {'keys':'NONE', 'rows_per_partition':'NONE'};
To alter the configuration of an existing table:
ALTER TABLE inmemorytable
WITH compaction= {'class': 'MemoryOnlyStrategy'}
AND caching = {'keys':'NONE', 'rows_per_partition':'NONE'};
Note that tables configured with DSE In-Memory are still persisted to disk so you won't lose any data in the event of a power outage or service disruption. In-Memory tables operate the same as regular tables so the same backup and restore processes still apply with the only difference being that a copy of the data is kept in memory for faster read performance.
For details, see DataStax Enterprise In-Memory. Cheers!
I am using JanusGraph with Cassandra as its storage backend. Its a fairly large graph with over 70 million vertices. What is the best way to get a list of all the vertex IDs. The query g.V() will take a long time to return.
Is there a way I can pull out this data (all vertex IDs and if possible all edge IDs) directly from the Cassandra tables. I couldn't figure out how the data is stored. Can anybody help me please, or is there any clear documentation on how data is laid out in the backend tables.
The way JanusGraph data is stored in Cassandra is documented at https://docs.janusgraph.org/advanced-topics/data-model/ but if you use CQL or Nodetool to look at the tables created you will see the data is stored as blobs. I think the only way to get IDs is using Gremlin.
I know I can use a custom dialect for having a correct mapping between my db and spark but how can I create a custom table schema with specific field data types and lengths when I use spark's jdbc.write options? I would like to have granular control over my table schemas when I load a table from spark.
There is a minimal flexibility for writes, implemented by
SPARK-10101 - Spark JDBC writer mapping String to TEXT or VARCHAR
SPARK-10849 - Allow user to specify database column type for data frame fields when writing data to jdbc data sources
but if you want
to have granular control over my table schemas when I load a table from spark.
you might have to implement your own JdbcDialect. It is internal developer API and as far as I can tell it is not plugable so you may need customized Spark binaries (it might be possible to registerDialect but I haven't tried this).
https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html
You can use the createTableColumnTypes option.
Here is the example from the documentation.
Specifying create table column data types on write
jdbcDF.write \
.option("createTableColumnTypes", "name CHAR(64), comments VARCHAR(1024)") \
.jdbc("jdbc:postgresql:dbserver", "schema.tablename",
properties={"user": "username", "password": "password"})
Can we refer a Cassandra table with multiple names ?
Say I have created a table with keyspacename.maintable
Now I want to refer keyspacename.maintable table as
keyspacename.alternatename1,
keyspacename.alternatename2,
keyspacename.alternatename3.
Is it possible ?
Hope Cassandra doesn't have this feature of alais, but this could be achieved using Cassandra datastax driver, cqlengine object mapper. Using object mapper, you can access a table as object with different object names.
I am using hector-core1.0-5 from prettyprint for connecting to cassandra. Using this API I am able to create the keyspace. But I am unable to find the method which configures the "caching" property of column family. So as default it assigns "KEYS_ONLY" as "caching" value for all column families created. I wan to change this property value to "ALL" so that I can use both the key cache and row cache in cassandra.My cassandra version1.2.0. Anyone help me in finding the way to alter the "caching" property at the time a keyspace is created.
There is not support for get or set caching in ColumnFamilyDefinition interface. Hector community has to patch the code.
No idea about Hector as such. But we are using Playorm for Cassandra and it uses Caches like hibernate. Read more information at http://buffalosw.com/wiki/Caching-in-Playorm/.