本文整理匯總了Java中com.datastax.driver.core.TableMetadata.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java TableMetadata.getName方法的具體用法?Java TableMetadata.getName怎麽用?Java TableMetadata.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.datastax.driver.core.TableMetadata
的用法示例。
在下文中一共展示了TableMetadata.getName方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: existsTable
import com.datastax.driver.core.TableMetadata; //導入方法依賴的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;
}
}
示例2: loadTablesFromRemote
import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
public static Cluster loadTablesFromRemote(String host, int port, String cfidOverrides) throws IOException {
Map<String, UUID> cfs = parseOverrides(cfidOverrides);
Cluster.Builder builder = Cluster.builder().addContactPoints(host).withPort(port);
Cluster cluster = builder.build();
Metadata metadata = cluster.getMetadata();
IPartitioner partitioner = FBUtilities.newPartitioner(metadata.getPartitioner());
if (DatabaseDescriptor.getPartitioner() == null)
DatabaseDescriptor.setPartitionerUnsafe(partitioner);
for (com.datastax.driver.core.KeyspaceMetadata ksm : metadata.getKeyspaces()) {
if (!ksm.getName().equals("system")) {
for (TableMetadata tm : ksm.getTables()) {
String name = ksm.getName()+"."+tm.getName();
try {
CassandraUtils.tableFromCQL(
new ByteArrayInputStream(tm.asCQLQuery().getBytes()),
cfs.get(name) != null ? cfs.get(name) : tm.getId());
} catch(SyntaxException e) {
// ignore tables that we cant parse (probably dse)
logger.debug("Ignoring table " + name + " due to syntax exception " + e.getMessage());
}
}
}
}
return cluster;
}
示例3: generate
import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
/**
* Kicks off table generation.
*
* @param tables the cassandra table meta data
* @throws IOException if write to file fails
*/
public static void generate(Collection<TableMetadata> tables) throws IOException {
String namespaceToUse = MetaData.instance.getTableNamespace();
for (TableMetadata table : tables) {
String rawName = table.getName();
String name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, rawName);
TypeSpec.Builder tableClassBuilder = TypeSpec.classBuilder(name)
.addModifiers(Modifier.PUBLIC)
.addAnnotation(getTableAnnotation(table.getKeyspace().getName(), rawName));
addFields(tableClassBuilder, table, name);
tableClassBuilder.addJavadoc(GeneratorHelper.getJavaDocHeader("Table class for Cassandra - " + rawName, MetaData.instance.getUpdateTime()));
JavaFile javaFile = JavaFile.builder(namespaceToUse, tableClassBuilder.build()).build();
Disk.outputFile(javaFile);
}
}
示例4: clean
import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
public void clean() {
log.info("Cleaning all tables");
for (KeyspaceMetadata keyspaceMetadata : session.getCluster().getMetadata().getKeyspaces()) {
String keyspace = keyspaceMetadata.getName();
if (keyspace.startsWith("system")) {
continue;
}
for (TableMetadata metadata : keyspaceMetadata.getTables()) {
String statement = "TRUNCATE TABLE " + keyspace + "." + metadata.getName();
session.execute(statement);
}
}
}
示例5: generate
import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
public static void generate(Collection<TableMetadata> tables) throws IOException {
String namespaceToUse = MetaData.instance.getRestNamespace();
createUtilClass(namespaceToUse);
for (TableMetadata table : tables) {
String tableName = table.getName();
String rawName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, tableName);
String name = rawName + "Api";
String dalName = rawName + "Dal";
TypeSpec.Builder restBuilder = TypeSpec.classBuilder(name).addModifiers(Modifier.PUBLIC);
restBuilder.addField(GeneratorHelper.getLogger(namespaceToUse, name));
restBuilder.addJavadoc(GeneratorHelper.getJavaDocHeader("REST Api for Cassandra entity - {@link " +
ClassName.get(MetaData.instance.getTableNamespace(), rawName) + "}", MetaData.instance.getUpdateTime()));
restBuilder.addSuperinterface(RestApi.class);
addMemberVars(tableName, dalName, restBuilder);
restBuilder.addMethod(getConstructor(dalName, EntityGeneratorHelper.getPrimaryKey(table)));
addSave(restBuilder, rawName);
restBuilder.addMethod(getDelete(rawName));
restBuilder.addMethod(getGet(rawName));
getGetAll(rawName, restBuilder, table);
restBuilder.addMethod(getSupportedApi());
restBuilder.addMethod(getQueryConverter(table));
JavaFile javaFile = JavaFile.builder(namespaceToUse, restBuilder.build()).build();
Disk.outputFile(javaFile);
}
}
示例6: getTableMap
import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
@Override protected Map<String, Table> getTableMap() {
final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder();
for (TableMetadata table : getKeyspace().getTables()) {
String tableName = table.getName();
builder.put(tableName, new CassandraTable(this, tableName));
for (MaterializedViewMetadata view : table.getViews()) {
String viewName = view.getName();
builder.put(viewName, new CassandraTable(this, viewName, true));
}
}
return builder.build();
}
示例7: detectTable
import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
/**
* Performs an analysis of an available table in Cassandra.
*
* @param tableMetaData
* the table meta data
* @return a table definition for cassandra.
*/
public static SimpleTableDef detectTable(TableMetadata tableMetaData) {
final List<ColumnMetadata> columns = tableMetaData.getColumns();
final String[] columnNames = new String[columns.size()];
final ColumnType[] columnTypes = new ColumnType[columns.size()];
int i = 0;
for (final ColumnMetadata column : columns) {
columnNames[i] = column.getName();
columnTypes[i] = getColumnTypeFromMetaDataField(column.getType().getName());
i++;
}
return new SimpleTableDef(tableMetaData.getName(), columnNames, columnTypes);
}
示例8: listNames
import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public List<QualifiedName> listNames(
@Nonnull @NonNull final ConnectorRequestContext context,
@Nonnull @NonNull final QualifiedName name,
@Nullable final QualifiedName prefix,
@Nullable final Sort sort,
@Nullable final Pageable pageable
) {
final String catalog = name.getCatalogName();
final String keyspace = name.getDatabaseName();
log.debug("Attempting to list table names in Cassandra keyspace {} for request {}", keyspace, context);
try {
final KeyspaceMetadata keyspaceMetadata = this.getCluster().getMetadata().getKeyspace(keyspace);
if (keyspaceMetadata == null) {
throw new DatabaseNotFoundException(name);
}
// TODO: Should we include views?
final List<QualifiedName> tableNames = Lists.newArrayList();
for (final TableMetadata tableMetadata : keyspaceMetadata.getTables()) {
final String tableName = tableMetadata.getName();
if (prefix != null && !tableName.startsWith(prefix.getTableName())) {
continue;
}
tableNames.add(QualifiedName.ofTable(catalog, keyspace, tableName));
}
// Sort
if (sort != null) {
final Comparator<QualifiedName> tableNameComparator = Comparator.comparing(QualifiedName::getTableName);
ConnectorUtils.sort(tableNames, sort, tableNameComparator);
}
// Paging
final List<QualifiedName> paged = ConnectorUtils.paginate(tableNames, pageable);
log.debug("Listed {} table names in Cassandra keyspace {} for request {}", paged.size(), keyspace, context);
return paged;
} catch (final DriverException de) {
log.error(de.getMessage(), de);
throw this.getExceptionMapper().toConnectorException(de, name);
}
}
示例9: transform
import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
/**
* Transform TableMetadata to CellData with TableName Value
* @param value
* @return CellData with Table value
*/
@Override
public CellData transform(TableMetadata value) {
return new CellData(value.getName());
}