Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 0 additions & 161 deletions lib/metadata/data-collection.js

This file was deleted.

86 changes: 46 additions & 40 deletions lib/metadata/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ export interface ColumnInfo {
type: DataTypeInfo;
}

export enum ColumnKind {
Regular = 0,
Static = 1,
ClusteringKey = 2,
PartitionKey = 3,
}

export interface ColumnMetadata {
type: string;
kind: ColumnKind;
}

export enum IndexKind {
custom = 0,
keys,
Expand All @@ -58,48 +70,15 @@ export interface Index {
isKeysKind(): boolean;
}

export interface DataCollection {
bloomFilterFalsePositiveChance: number;
caching: string;
clusteringKeys: ColumnInfo[];
clusteringOrder: string[];
columns: ColumnInfo[];
columnsByName: { [key: string]: ColumnInfo };
comment: string;
compactionClass: string;
compactionOptions: { [option: string]: any };
compression: {
class?: string;
[option: string]: any;
};
crcCheckChange?: number;
defaultTtl: number;
extensions: { [option: string]: any };
gcGraceSeconds: number;
localReadRepairChance: number;
maxIndexInterval?: number;
minIndexInterval?: number;
name: string;
partitionKeys: ColumnInfo[];
populateCacheOnFlush: boolean;
readRepairChance: number;
speculativeRetry: string;
}

export interface MaterializedView extends DataCollection {
export interface MaterializedView extends TableMetadata {
tableName: string;
whereClause: string;
includeAllColumns: boolean;
}

export interface TableMetadata extends DataCollection {
indexes: Index[];
indexInterval?: number;
isCompact: boolean;
memtableFlushPeriod: number;
replicateOnWrite: boolean;
cdc?: boolean;
virtual: boolean;
export interface TableMetadata {
columns: { [name: string]: ColumnMetadata };
partitionKey: string[];
clusteringKey: string[];
partitioner: string | null;
}

export interface QueryTrace {
Expand Down Expand Up @@ -130,9 +109,36 @@ export interface SchemaFunction {
signature: string[];
}

export interface UdtField {
name: string;
type: DataTypeInfo;
}

export interface Udt {
name: string;
fields: ColumnInfo[];
keyspace: string;
fields: UdtField[];
}

export enum StrategyKind {
SimpleStrategy = 0,
NetworkTopologyStrategy = 1,
LocalStrategy = 2,
Other = 3,
}

export type Strategy =
| { kind: StrategyKind.SimpleStrategy; replicationFactor: number }
| { kind: StrategyKind.NetworkTopologyStrategy; datacenterRepfactors: { [datacenter: string]: number } }
| { kind: StrategyKind.LocalStrategy }
| { kind: StrategyKind.Other; name: string; data: { [key: string]: string } };

export interface KeyspaceMetadata {
strategy: Strategy;
durableWrites: boolean;
tables: { [name: string]: TableMetadata };
views: { [name: string]: MaterializedView };
userDefinedTypes: { [name: string]: Udt };
}

export interface Metadata {
Expand Down
125 changes: 125 additions & 0 deletions lib/metadata/keyspace-metadata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
"use strict";

// Imports for the purpose of type hints in JS docs.
// eslint-disable-next-line no-unused-vars
const { TableMetadata } = require("./table-metadata");
// eslint-disable-next-line no-unused-vars
const { MaterializedView } = require("./materialized-view");
// eslint-disable-next-line no-unused-vars
const { UserDefinedType } = require("./user-defined-type");

/**
* Identifies the replication strategy variant.
* @readonly
* @enum {number}
* @alias module:metadata~StrategyKind
*/
const StrategyKind = {
/**
* Deprecated in ScyllaDB.
*
* **Use only for a single datacenter and one rack.**
*
* Places the first replica on a node determined by the partitioner.
* Additional replicas are placed on the next nodes clockwise in the ring
* without considering topology (rack or datacenter location).
*/
SimpleStrategy: 0,
/**
* Use this strategy when you have (or plan to have) your cluster deployed across
* multiple datacenters. This strategy specifies how many replicas you want in each
* datacenter.
*
* `NetworkTopologyStrategy` places replicas in the same datacenter by walking the ring
* clockwise until reaching the first node in another rack. It attempts to place replicas
* on distinct racks because nodes in the same rack (or similar physical grouping) often
* fail at the same time due to power, cooling, or network issues.
*/
NetworkTopologyStrategy: 1,
/**
* Used for internal purposes, e.g. for system tables.
*/
LocalStrategy: 2,
/**
* Unknown other strategy, which is not supported by the driver.
*/
Other: 3,
};

/**
* Describes the replication strategy used by a keyspace.
* @alias module:metadata~Strategy
*/
class Strategy {
/**
* Identifies which strategy variant this is.
* @type {StrategyKind}
*/
kind;

/**
* Replication factor, i.e. how many replicas of each piece of data there are.
* (only set when {@link kind} is {@link StrategyKind.SimpleStrategy}).
* @type {number?}
*/
replicationFactor;

/**
* Replication factors of datacenters with given names, i.e. how many replicas of each piece
* of data there are in each datacenter.
* (only set when {@link kind} is {@link StrategyKind.NetworkTopologyStrategy}).
* @type {Object.<String, number>?}
*/
datacenterRepfactors;

/**
* Name of the strategy (only set when {@link kind} is {@link StrategyKind.Other}).
* @type {String?}
*/
name;

/**
* Additional parameters of the strategy, which the driver does not understand.
* (only set when {@link kind} is {@link StrategyKind.Other}).
* @type {Object.<String, String>?}
*/
data;
}

/**
* Describes a keyspace in the cluster.
* @alias module:metadata~KeyspaceMetadata
*/
class KeyspaceMetadata {
/**
* Replication strategy used by the keyspace.
* @type {Strategy}
*/
strategy;

/**
* Whether the keyspace has durable writes enabled.
* @type {Boolean}
*/
durableWrites;

/**
* Tables in the keyspace, keyed by table name.
* @type {Object.<String, TableMetadata>}
*/
tables;

/**
* Materialized views in the keyspace, keyed by view name.
* @type {Object.<String, MaterializedView>}
*/
views;

/**
* User-defined types in the keyspace, keyed by type name.
* @type {Object.<String, UserDefinedType>}
*/
userDefinedTypes;
}

module.exports = { KeyspaceMetadata, Strategy, StrategyKind };
Loading
Loading