當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyspaceMetadata.getTable方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.KeyspaceMetadata.getTable方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyspaceMetadata.getTable方法的具體用法?Java KeyspaceMetadata.getTable怎麽用?Java KeyspaceMetadata.getTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.KeyspaceMetadata的用法示例。


在下文中一共展示了KeyspaceMetadata.getTable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: get

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public TableInfo get(@Nonnull @NonNull final ConnectorRequestContext context,
                     @Nonnull @NonNull final QualifiedName name) {
    final String keyspace = name.getDatabaseName();
    final String table = name.getTableName();
    log.debug("Attempting to get metadata for Cassandra table {}.{} for request {}", keyspace, table, context);
    try {
        final KeyspaceMetadata keyspaceMetadata = this.getCluster().getMetadata().getKeyspace(keyspace);
        if (keyspaceMetadata == null) {
            throw new DatabaseNotFoundException(name);
        }
        final TableMetadata tableMetadata = keyspaceMetadata.getTable(table);
        if (tableMetadata == null) {
            throw new TableNotFoundException(name);
        }

        final TableInfo tableInfo = this.getTableInfo(name, tableMetadata);
        log.debug("Successfully got metadata for Cassandra table {}.{} for request {}", keyspace, table, context);
        return tableInfo;
    } catch (final DriverException de) {
        log.error(de.getMessage(), de);
        throw this.getExceptionMapper().toConnectorException(de, name);
    }
}
 
開發者ID:Netflix,項目名稱:metacat,代碼行數:28,代碼來源:CassandraConnectorTableService.java

示例2: existsTable

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
/**
 * Checks if the main table exists in the database.
 * @param appid name of the {@link com.erudika.para.core.App}
 * @return true if the table exists
 */
public static boolean existsTable(String appid) {
	if (StringUtils.isBlank(appid)) {
		return false;
	}
	if (cluster == null) {
		throw new IllegalStateException("Cassandra client not initialized.");
	}
	try {
		KeyspaceMetadata ks = cluster.getMetadata().getKeyspace(DBNAME);
		TableMetadata table = ks.getTable(getTableNameForAppid(appid));
		return table != null && table.getName() != null;
	} catch (Exception e) {
		return false;
	}
}
 
開發者ID:Erudika,項目名稱:para-dao-cassandra,代碼行數:21,代碼來源:CassandraUtils.java

示例3: insertRow

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
public boolean insertRow(String tablename, Map<String, Object> valuesMap, Map<String, String> consistencyInfo, JsonInsert insObj) throws Exception {
	// Note: https://docs.datastax.com/en/cql/3.0/cql/cql_reference/insert_r.html
	String[] parts = tablename.split("\\.");
	KeyspaceMetadata ks = cluster.getMetadata().getKeyspace(parts[0]);
	TableMetadata tableInfo =  ks.getTable(parts[1]);

	StringBuilder fields = new StringBuilder();
	StringBuilder values = new StringBuilder();
	String prefix = "";
	for (String key : valuesMap.keySet()) {
		fields.append(prefix).append(key);
		Object valueObj  = valuesMap.get(key);
		DataType colType = tableInfo.getColumn(key).getType();
		values.append(prefix).append(convertToSqlDataType(colType, valueObj));
		prefix = ", ";
	}

	String suffix = getTTLSuffix(insObj);
	String query = String.format("INSERT INTO %s (%s) VALUES (%s)%s;", tablename, fields.toString(), values.toString(), suffix);
	LOG.debug(query);

	String consistency = extractConsistencyInfo(tablename, consistencyInfo);
	executeCreateQuery(query, consistency);
	return false;
}
 
開發者ID:att,項目名稱:music,代碼行數:26,代碼來源:MusicClient.java

示例4: createColumnFamily

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
protected void createColumnFamily() {
    final String ks = getKeySpace();
    final String cf = getColumnFamily();

    final KeyspaceMetadata keySpaceMeta = this.cluster.getMetadata().getKeyspace(ks);
    final TableMetadata tableMetadata = keySpaceMeta.getTable(cf);

    // check if the table exists
    if (tableMetadata != null) {
        return;
    }

    final String stmt = String.format("CREATE TABLE %s (\n" +
            "  " + KEY_COLUMN + " text,\n" +
            "  " + COLL_COLUMN + " blob,\n" +
            "  PRIMARY KEY (" + KEY_COLUMN + ")\n" +
            ");", cf);

    getSession().execute(stmt);
}
 
開發者ID:Breinify,項目名稱:brein-time-utilities,代碼行數:21,代碼來源:CassandraIntervalCollectionPersistor.java

示例5: getTableMetadata

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
private TableMetadata getTableMetadata(SchemaTableName schemaTableName)
{
    String schemaName = schemaTableName.getSchemaName();
    String tableName = schemaTableName.getTableName();

    KeyspaceMetadata keyspaceMetadata = getCheckedKeyspaceMetadata(schemaName);
    TableMetadata tableMetadata = keyspaceMetadata.getTable(tableName);
    if (tableMetadata != null) {
        return tableMetadata;
    }

    for (TableMetadata table : keyspaceMetadata.getTables()) {
        if (table.getName().equalsIgnoreCase(tableName)) {
            return table;
        }
    }
    throw new TableNotFoundException(schemaTableName);
}
 
開發者ID:y-lan,項目名稱:presto,代碼行數:19,代碼來源:CassandraSession.java

示例6: getSchema

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
public List<Column> getSchema(String keySpace, String tableName) {
	Metadata m = session.getCluster().getMetadata();
	KeyspaceMetadata km = m.getKeyspace(keySpace);
	if (km == null)
		return null;
	TableMetadata tm = km.getTable(tableName);
	if (tm == null)
		return null;
	// build schema
	List<Column> columns = new LinkedList<Column>();
	for (ColumnMetadata cm : tm.getColumns()) {
		if (!meta.contains(cm.getName()))
			columns.add(Column.newBuilder().setName(cm.getName())
					.setType(toSimbaType(cm.getType().toString())).build());
	}

	return columns;

}
 
開發者ID:SimbaService,項目名稱:Simba,代碼行數:20,代碼來源:CassandraHandler.java

示例7: getSchemaVersion

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
private static @Nullable Integer getSchemaVersion(Session session, KeyspaceMetadata keyspace)
        throws Exception {
    ResultSet results =
            session.execute("select schema_version from schema_version where one = 1");
    Row row = results.one();
    if (row != null) {
        return row.getInt(0);
    }
    TableMetadata agentTable = keyspace.getTable("agent");
    if (agentTable != null && agentTable.getColumn("system_info") != null) {
        // special case, this is glowroot version 0.9.1, the only version supporting upgrades
        // prior to schema_version table
        return 1;
    }
    // new installation
    return null;
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:18,代碼來源:SchemaUpgrade.java

示例8: getKeyColumn

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
private String getKeyColumn(String columnFamily) {
	KeyspaceMetadata keyspaceMetadata = session.getCluster().getMetadata().getKeyspace(keyspace);
	TableMetadata tableMetadata = keyspaceMetadata.getTable(columnFamily);

	if (tableMetadata == null) {
		return null;
	}

	for (String key : new String[] { "\"KEY\"", "key" }) {
		if (tableMetadata.getColumn(key) != null) {
			return key;
		}
	}

	return null;
}
 
開發者ID:WizeCommerce,項目名稱:hecuba,代碼行數:17,代碼來源:DataStaxBasedSharedHecubaClientManager.java

示例9: ensureTableExists

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
private void ensureTableExists() {
    KeyspaceMetadata keyspaceMetadata =
        session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace());
    TableMetadata tableMetadata = keyspaceMetadata.getTable(TABLE_NAME);

    if (tableMetadata != null) {
        LOG.debug("Versioning column family already exists, skipping creation.");
        ensureTableSchema(tableMetadata);
        return;
    }

    LOG.info("Creating versioning column family.");
    session.execute(
        "CREATE TABLE " + TABLE_NAME + " ("
            + "key text PRIMARY KEY,"
            + "executed timestamp"
            + ");");

    LOG.debug("Versioning column family created.");
}
 
開發者ID:iZettle,項目名稱:izettle-toolbox,代碼行數:21,代碼來源:SchemaVersionUpdaterWithDatastaxDriver.java

示例10: ensureExists

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
static KeyspaceMetadata ensureExists(String keyspace, Session session) {
  KeyspaceMetadata result = session.getCluster().getMetadata().getKeyspace(keyspace);
  if (result == null || result.getTable("traces") == null) {
    LOG.info("Installing schema {}", SCHEMA_RESOURCE);
    applyCqlFile(keyspace, session, SCHEMA_RESOURCE);
    // refresh metadata since we've installed the schema
    result = session.getCluster().getMetadata().getKeyspace(keyspace);
  }
  return result;
}
 
開發者ID:liaominghua,項目名稱:zipkin,代碼行數:11,代碼來源:Schema.java

示例11: ensureExists

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
static void ensureExists(String keyspace, Session session) {
  KeyspaceMetadata keyspaceMetadata = session.getCluster().getMetadata().getKeyspace(keyspace);
  if (keyspaceMetadata == null || keyspaceMetadata.getTable("traces") == null) {
    LOG.info("Installing schema {}", SCHEMA);
    applyCqlFile(keyspace, session, SCHEMA);
    // refresh metadata since we've installed the schema
    keyspaceMetadata = session.getCluster().getMetadata().getKeyspace(keyspace);
  }
  if (!hasUpgrade1_defaultTtl(keyspaceMetadata)) {
    LOG.info("Upgrading schema {}", UPGRADE_1);
    applyCqlFile(keyspace, session, UPGRADE_1);
  }
}
 
開發者ID:liaominghua,項目名稱:zipkin,代碼行數:14,代碼來源:Schema.java

示例12: validateTableName

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
static void validateTableName(String tableName, KeyspaceMetadata keyspace) {
    if (!Strings.isNullOrEmpty(tableName)) {
        TableMetadata table = keyspace.getTable(tableName);
        if (table == null) {
            throw new IllegalArgumentException("table \"" + tableName + "\" does not existed!");
        }
    }
}
 
開發者ID:thangbn,項目名稱:cassandra-CQL-exporter,代碼行數:9,代碼來源:DatabaseValidator.java

示例13: isEngineTablePresent

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
@Override
public boolean isEngineTablePresent() {
  KeyspaceMetadata keyspaceMetaData = cassandraSession.getCluster()
    .getMetadata()
    .getKeyspace(cassandraSession.getLoggedKeyspace());

  return keyspaceMetaData.getTable(ProcessDefinitionTableHandler.TABLE_NAME) != null;
}
 
開發者ID:camunda,項目名稱:camunda-engine-cassandra,代碼行數:9,代碼來源:CassandraPersistenceSession.java

示例14: getColumnNames

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
public List<String> getColumnNames(String keySpace, String tableName)
{
    checkState(tableExists(keySpace, tableName), "table %s.%s does not exist", keySpace, tableName);
    KeyspaceMetadata keyspaceMetadata = session.getCluster().getMetadata().getKeyspace(keySpace);
    TableMetadata tableMetadata = keyspaceMetadata.getTable(tableName);
    return tableMetadata.getColumns().stream().map(ColumnMetadata::getName).collect(toList());
}
 
開發者ID:prestodb,項目名稱:tempto,代碼行數:8,代碼來源:CassandraQueryExecutor.java

示例15: tableExists

import com.datastax.driver.core.KeyspaceMetadata; //導入方法依賴的package包/類
public boolean tableExists(String keySpace, String tableName)
{
    KeyspaceMetadata keyspaceMetadata = cluster.getMetadata().getKeyspace(keySpace);
    if (keyspaceMetadata == null) {
        return false;
    }
    return keyspaceMetadata.getTable(tableName) != null;
}
 
開發者ID:prestodb,項目名稱:tempto,代碼行數:9,代碼來源:CassandraQueryExecutor.java


注:本文中的com.datastax.driver.core.KeyspaceMetadata.getTable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。