Scylla Documentation Logo Documentation
  • Server
    • Scylla Open Source
    • Scylla Enterprise
    • Scylla Alternator
  • Cloud
    • Scylla Cloud
    • Scylla Cloud Docs
  • Tools
    • Scylla Manager
    • Scylla Monitoring Stack
    • Scylla Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
Download
Menu

Caution

You're viewing documentation for a previous version of Scylla Python Driver. Switch to the latest stable version.

Scylla Python Driver API Documentation cassandra.metadata - Schema and Ring Topology

cassandra.metadata - Schema and Ring Topology¶

cassandra.metadata.cql_keywords¶

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

cassandra.metadata.cql_keywords_unreserved¶

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

cassandra.metadata.cql_keywords_reserved¶

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

class cassandra.metadata.Metadata¶

Holds a representation of the cluster schema and topology.

add_or_return_host(host)¶

Returns a tuple (host, new), where host is a Host instance, and new is a bool indicating whether the host was newly added.

all_hosts()¶

Returns a list of all known Host instances in the cluster.

export_schema_as_string()¶

Returns a string that can be executed as a query in order to recreate the entire schema. The string is formatted to be human readable.

get_host(endpoint_or_address, port=None)¶

Find a host in the metadata for a specific endpoint. If a string inet address and port are passed, iterate all hosts to match the broadcast_rpc_address and broadcast_rpc_port attributes.

get_replicas(keyspace, key)¶

Returns a list of Host instances that are replicas for a given partition key.

Schemas¶

class cassandra.metadata.KeyspaceMetadata¶

A representation of the schema for a single keyspace.

as_cql_query()¶

Returns a CQL query string that can be used to recreate just this keyspace, not including user-defined types and tables.

export_as_string()¶

Returns a CQL query string that can be used to recreate the entire keyspace, including user-defined types and tables.

class cassandra.metadata.UserType¶

A user defined type, as created by CREATE TYPE statements.

User-defined types were introduced in Cassandra 2.1.

New in version 2.1.0.

as_cql_query(formatted=False)¶

Returns a CQL query that can be used to recreate this type. If formatted is set to True, extra whitespace will be added to make the query more readable.

class cassandra.metadata.Function¶

A user defined function, as created by CREATE FUNCTION statements.

User-defined functions were introduced in Cassandra 2.2

New in version 2.6.0.

as_cql_query(formatted=False)¶

Returns a CQL query that can be used to recreate this function. If formatted is set to True, extra whitespace will be added to make the query more readable.

class cassandra.metadata.Aggregate¶

A user defined aggregate function, as created by CREATE AGGREGATE statements.

Aggregate functions were introduced in Cassandra 2.2

New in version 2.6.0.

as_cql_query(formatted=False)¶

Returns a CQL query that can be used to recreate this aggregate. If formatted is set to True, extra whitespace will be added to make the query more readable.

class cassandra.metadata.TableMetadata¶

A representation of the schema for a single table.

as_cql_query(formatted=False)¶

Returns a CQL query that can be used to recreate this table (index creations are not included). If formatted is set to True, extra whitespace will be added to make the query human readable.

export_as_string()¶

Returns a string of CQL queries that can be used to recreate this table along with all indexes on it. The returned string is formatted to be human readable.

property is_cql_compatible¶

A boolean indicating if this table can be represented as CQL in export

property primary_key¶

A list of ColumnMetadata representing the components of the primary key for this table.

class cassandra.metadata.TableMetadataV3¶

For C* 3.0+. option_maps take a superset of map names, so if nothing changes structurally, new option maps can just be appended to the list.

property is_cql_compatible¶

A boolean indicating if this table can be represented as CQL in export

class cassandra.metadata.TableMetadataDSE68¶
as_cql_query(formatted=False)¶

Returns a CQL query that can be used to recreate this table (index creations are not included). If formatted is set to True, extra whitespace will be added to make the query human readable.

class cassandra.metadata.ColumnMetadata¶

A representation of a single column in a table.

class cassandra.metadata.IndexMetadata¶

A representation of a secondary index on a column.

as_cql_query()¶

Returns a CQL query that can be used to recreate this index.

export_as_string()¶

Returns a CQL query string that can be used to recreate this index.

class cassandra.metadata.MaterializedViewMetadata¶

A representation of a materialized view on a table

as_cql_query(formatted=False)¶

Returns a CQL query that can be used to recreate this function. If formatted is set to True, extra whitespace will be added to make the query more readable.

class cassandra.metadata.VertexMetadata¶

A representation of a vertex on a table

class cassandra.metadata.EdgeMetadata¶

A representation of an edge on a table

Tokens and Ring Topology¶

class cassandra.metadata.TokenMap¶

Information about the layout of the ring.

get_replicas(keyspace, token)¶

Get a set of Host instances representing all of the replica nodes for a given Token.

class cassandra.metadata.Token¶

Abstract class representing a token.

class cassandra.metadata.Murmur3Token(token)¶

A token for Murmur3Partitioner.

token is an int or string representing the token.

class cassandra.metadata.MD5Token(token)¶

A token for RandomPartitioner.

class cassandra.metadata.BytesToken(token)¶

A token for ByteOrderedPartitioner.

classmethod from_string(token_string)¶

token_string should be the string representation from the server.

cassandra.metadata.ReplicationStrategy¶

alias of cassandra.metadata._ReplicationStrategy

class cassandra.metadata.ReplicationFactor(all_replicas, transient_replicas=None)¶

Represent the replication factor of a keyspace.

class cassandra.metadata.SimpleStrategy(options_map)¶
export_for_schema()¶

Returns a string version of these replication options which are suitable for use in a CREATE KEYSPACE statement.

property replication_factor¶

The replication factor for this keyspace.

For backward compatibility, this returns the cassandra.metadata.ReplicationFactor.full_replicas value of cassandra.metadata.SimpleStrategy.replication_factor_info.

class cassandra.metadata.NetworkTopologyStrategy(dc_replication_factors)¶
export_for_schema()¶

Returns a string version of these replication options which are suitable for use in a CREATE KEYSPACE statement.

class cassandra.metadata.LocalStrategy(options_map)¶
export_for_schema()¶

Returns a string version of these replication options which are suitable for use in a CREATE KEYSPACE statement.

cassandra.metadata.group_keys_by_replica(session, keyspace, table, keys)¶

Returns a dict with the keys grouped per host. This can be used to more accurately group by IN clause or to batch the keys per host.

If a valid replica is not found for a particular key it will be grouped under NO_VALID_REPLICA

Example usage:

>>> result = group_keys_by_replica(
...     session, "system", "peers",
...     (("127.0.0.1", ), ("127.0.0.2", )))
PREVIOUS
cassandra.graph - Graph Statements, Options, and Row Factories
NEXT
cassandra.metrics - Performance Metrics
  • 3.24.8
    • 3.25.4
    • 3.24.8
    • 3.22.3
    • 3.21.0
  • API Documentation
    • cassandra - Exceptions and Enums
    • cassandra.cluster - Clusters and Sessions
    • cassandra.policies - Load balancing and Failure Handling Policies
    • cassandra.auth - Authentication
    • cassandra.graph - Graph Statements, Options, and Row Factories
    • cassandra.metadata - Schema and Ring Topology
    • cassandra.metrics - Performance Metrics
    • cassandra.query - Prepared Statements, Batch Statements, Tracing, and Row Factories
    • cassandra.pool - Hosts and Connection Pools
    • cassandra.protocol - Protocol Features
    • cassandra.encoder - Encoders for non-prepared Statements
    • cassandra.decoder - Data Return Formats
    • cassandra.concurrent - Utilities for Concurrent Statement Execution
    • cassandra.connection - Low Level Connection Info
    • cassandra.util - Utilities
    • cassandra.timestamps - Timestamp Generation
    • cassandra.io.asyncioreactor - asyncio Event Loop
    • cassandra.io.asyncorereactor - asyncore Event Loop
    • cassandra.io.eventletreactor - eventlet-compatible Connection
    • cassandra.io.libevreactor - libev Event Loop
    • cassandra.io.geventreactor - gevent-compatible Event Loop
    • cassandra.io.twistedreactor - Twisted Event Loop
    • cassandra.cqlengine.models - Table models for object mapping
    • cassandra.cqlengine.columns - Column types for object mapping models
    • cassandra.cqlengine.query - Query and filter model objects
    • cassandra.cqlengine.connection - Connection management for cqlengine
    • cassandra.cqlengine.management - Schema management for cqlengine
    • cassandra.cqlengine.usertype - Model classes for User Defined Types
    • cassandra.datastax.graph - Graph Statements, Options, and Row Factories
    • cassandra.datastax.graph.fluent
    • cassandra.datastax.graph.fluent.query
    • cassandra.datastax.graph.fluent.predicates
  • Installation
  • Getting Started
  • Scylla Specific Features
  • Upgrading
  • Execution Profiles
  • Performance Notes
  • Paging Large Queries
  • Lightweight Transactions (Compare-and-set)
  • Security
  • User Defined Types
  • Object Mapper
    • Upgrade Guide
    • Models
    • Making Queries
    • Batch Queries
    • Connections
    • Third party integrations
    • Frequently Asked Questions
  • Working with Dates and Times
  • Scylla Cloud
  • Frequently Asked Questions
  • Create an issue
  • Edit this page

On this page

  • cassandra.metadata - Schema and Ring Topology
    • Schemas
    • Tokens and Ring Topology
Logo
Docs Contact Us About Us
Mail List Icon Slack Icon
© ScyllaDB 2021 and © DataStax 2013-2017
Powered by Sphinx 4.3.2 & ScyllaDB Theme 1.2.2