当前位置: 首页>>代码示例>>Java>>正文


Java ColumnMetadata类代码示例

本文整理汇总了Java中com.datastax.driver.core.ColumnMetadata的典型用法代码示例。如果您正苦于以下问题:Java ColumnMetadata类的具体用法?Java ColumnMetadata怎么用?Java ColumnMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ColumnMetadata类属于com.datastax.driver.core包,在下文中一共展示了ColumnMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareStatement

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private PreparedStatement prepareStatement() {
List<ColumnMetadata> partkeys = cluster.getMetadata().getKeyspace(keyspaceName).getTable(tableName).getPartitionKey();
StringBuilder sb = new StringBuilder();
sb.append("SELECT COUNT(*) FROM ");
sb.append(keyspaceName).append(".").append(tableName);
sb.append(" WHERE Token(");
sb.append(partkeys.get(0).getName());
for (int i = 1; i < partkeys.size(); i++)
    sb.append(", ").append(partkeys.get(i).getName());
sb.append(") > ? AND Token(");
sb.append(partkeys.get(0).getName());
for (int i = 1; i < partkeys.size(); i++)
    sb.append(",").append(partkeys.get(i).getName());
sb.append(") <= ?");

debugPrint("Query: " + sb.toString(), true, 2);

return session.prepare(sb.toString()).setConsistencyLevel(consistencyLevel);
   }
 
开发者ID:brianmhess,项目名称:cassandra-count,代码行数:20,代码来源:CqlCount.java

示例2: getTableInfo

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private TableInfo getTableInfo(
    @Nonnull @NonNull final QualifiedName name,
    @Nonnull @NonNull final TableMetadata tableMetadata
) {
    final ImmutableList.Builder<FieldInfo> fieldInfoBuilder = ImmutableList.builder();
    // TODO: Ignores clustering, primary key, index, etc columns. We need to rework TableInfo to support
    for (final ColumnMetadata column : tableMetadata.getColumns()) {
        final String dataType = column.getType().toString();
        fieldInfoBuilder.add(
            FieldInfo.builder()
                .name(column.getName())
                .sourceType(dataType)
                .type(this.typeConverter.toMetacatType(dataType))
                .build()
        );
    }
    return TableInfo.builder()
        .name(QualifiedName.ofTable(name.getCatalogName(), name.getDatabaseName(), tableMetadata.getName()))
        .fields(fieldInfoBuilder.build())
        .build();
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:22,代码来源:CassandraConnectorTableService.java

示例3: parseForSpecialDataType

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private void parseForSpecialDataType(final ColumnMetadata aColumnDefinition)
{
  switch (aColumnDefinition.getType().getName()) {
    case COUNTER:
      counterColumns.add(aColumnDefinition.getName());
      break;
    case MAP:
      mapColumns.add(aColumnDefinition.getName());
      break;
    case SET:
      setColumns.add(aColumnDefinition.getName());
      break;
    case LIST:
      listColumns.add(aColumnDefinition.getName());
      break;
    case UDT:
      userDefinedTypeColumns.add(aColumnDefinition.getName());
      break;
    default:
      break;
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:23,代码来源:AbstractUpsertOutputOperator.java

示例4: buildColumnHandle

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private CassandraColumnHandle buildColumnHandle(ColumnMetadata columnMeta, boolean partitionKey, boolean clusteringKey, int ordinalPosition, boolean hidden)
{
    CassandraType cassandraType = CassandraType.getCassandraType(columnMeta.getType().getName());
    List<CassandraType> typeArguments = null;
    if (cassandraType != null && cassandraType.getTypeArgumentSize() > 0) {
        List<DataType> typeArgs = columnMeta.getType().getTypeArguments();
        switch (cassandraType.getTypeArgumentSize()) {
            case 1:
                typeArguments = ImmutableList.of(CassandraType.getCassandraType(typeArgs.get(0).getName()));
                break;
            case 2:
                typeArguments = ImmutableList.of(CassandraType.getCassandraType(typeArgs.get(0).getName()), CassandraType.getCassandraType(typeArgs.get(1).getName()));
                break;
            default:
                throw new IllegalArgumentException("Invalid type arguments: " + typeArgs);
        }
    }
    boolean indexed = columnMeta.getIndex() != null;
    return new CassandraColumnHandle(connectorId, columnMeta.getName(), ordinalPosition, cassandraType, typeArguments, partitionKey, clusteringKey, indexed, hidden);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:CassandraSession.java

示例5: generateSpecificGet

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private static MethodSpec generateSpecificGet(TableMetadata table, ClassName entityTable, int desiredColumns) {
    String query = getBaseQuery(table) + " WHERE ";
    MethodSpec.Builder builder = MethodSpec.methodBuilder("getAll");

    List<ColumnMetadata> columns = table.getPrimaryKey();
    for(int i = 0; i < desiredColumns; i++) {
        ColumnMetadata column = columns.get(i);
        String name = column.getName();
        String newClause = name + "=:" + name;
        if(i != 0) {
            newClause = " AND " + newClause;
        }
        query += newClause;
        builder.addParameter(getSpec(column, true));
    }

    return builder.addModifiers(Modifier.ABSTRACT).addModifiers(Modifier.PUBLIC)
            .returns(ParameterizedTypeName.get(ClassName.get(ListenableFuture.class),
                    ParameterizedTypeName.get(ClassName.get(Result.class), entityTable)))
            .addAnnotation(AnnotationSpec.builder(Query.class).addMember("value", "$S", query).build())
            .build();

}
 
开发者ID:jtruelove,项目名称:exovert,代码行数:24,代码来源:AccessorGenerator.java

示例6: getSpec

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private static ParameterSpec getSpec(ColumnMetadata column, boolean addAnnotation) {
    String name = column.getName();
    String paramName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name);
    ParameterSpec.Builder param;

    if (Udt.instance.isUdt(column.getType())) {
        throw new IllegalArgumentException("We don't currently support UDT primary keys in the query string, field: "
                + column.getName());
    } else {
        param = ParameterSpec.builder(EntityGeneratorHelper.getRawType(column.getType()), paramName);
    }

    if(addAnnotation) {
        param.addAnnotation(AnnotationSpec.builder(Param.class).addMember("value", "$S", name).build());
    }

    return param.addModifiers(Modifier.FINAL).build();
}
 
开发者ID:jtruelove,项目名称:exovert,代码行数:19,代码来源:AccessorGenerator.java

示例7: getPartitionKey

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private String getPartitionKey(CqlDelimParser cdp, Session session) {
    String keyspace = cdp.getKeyspace();
    String table = cdp.getTable();
    if (keyspace.startsWith("\"") && keyspace.endsWith("\""))
        keyspace = keyspace.replaceAll("\"", "");
    else
        keyspace = keyspace.toLowerCase();
    if (table.startsWith("\"") && table.endsWith("\""))
        table = table.replaceAll("\"", "");
    else
        table = table.toLowerCase();

    List<ColumnMetadata> lcm = session.getCluster().getMetadata()
        .getKeyspace(keyspace).getTable(table).getPartitionKey();
    String partitionKey = lcm.get(0).getName();
    for (int i = 1; i < lcm.size(); i++) {
        partitionKey = partitionKey + "," + lcm.get(i).getName();
    }
    return partitionKey;
}
 
开发者ID:brianmhess,项目名称:cassandra-loader,代码行数:21,代码来源:CqlDelimUnload.java

示例8: addColumnsToTable

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
/**
 * Adds all columns of column family.
 * @param table			Teiid table
 * @param columnFamily	Column family
 */
private void addColumnsToTable(MetadataFactory factory, Table table, TableMetadata columnFamily) {
	for (ColumnMetadata column : columnFamily.getColumns()){

		Class<?> cqlTypeToJavaClass = column.getType().asJavaClass();
		Class<?> teiidRuntimeTypeFromJavaClass = TypeFacility.getRuntimeType(cqlTypeToJavaClass);
		String type = TypeFacility.getDataTypeName(teiidRuntimeTypeFromJavaClass);
		
		if (column.getType().getName().equals(com.datastax.driver.core.DataType.Name.TIMESTAMP)) {
			type = TypeFacility.RUNTIME_NAMES.TIMESTAMP;
		} else if (column.getType().getName().equals(com.datastax.driver.core.DataType.Name.CUSTOM)
				|| column.getType().getName().equals(com.datastax.driver.core.DataType.Name.BLOB)) {
			type = TypeFacility.RUNTIME_NAMES.VARBINARY;
		}
		
		Column c = factory.addColumn(column.getName(), type, table);
		c.setUpdatable(true);
		if (column.getIndex() != null) {
			c.setSearchType(SearchType.Searchable);
		}
		else {
			c.setSearchType(SearchType.Unsearchable);
		}
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:30,代码来源:CassandraMetadataProcessor.java

示例9: getSchema

import com.datastax.driver.core.ColumnMetadata; //导入依赖的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

示例10: fetchKeys

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private void fetchKeys()
{
    // get CF meta data
    TableMetadata tableMetadata = session.getCluster()
                                         .getMetadata()
                                         .getKeyspace(Metadata.quote(keyspace))
                                         .getTable(Metadata.quote(cfName));
    if (tableMetadata == null)
    {
        throw new RuntimeException("No table metadata found for " + keyspace + "." + cfName);
    }
    //Here we assume that tableMetadata.getPartitionKey() always
    //returns the list of columns in order of component_index
    for (ColumnMetadata partitionKey : tableMetadata.getPartitionKey())
    {
        partitionKeys.add(partitionKey.getName());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:19,代码来源:CqlRecordReader.java

示例11: insertQuery

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private static String insertQuery(TableMetadata tableMetadata, String... options) {
    Insert insert = QueryBuilder.insertInto(tableMetadata);

    if (options != null) {
        Insert.Options using = insert.using();
        for (String option : options) {
            if ("TTL".equals(option)) {
                using.and(QueryBuilder.ttl(QueryBuilder.bindMarker()));
            } else {
                using.and(QueryBuilder.timestamp(QueryBuilder.bindMarker()));
            }
        }
    }

    List<ColumnMetadata> columns = tableMetadata.getColumns();

    for(ColumnMetadata column : columns) {
        insert.value(column.getName(), QueryBuilder.bindMarker());
    }

    return insert.toString();
}
 
开发者ID:arnaudroger,项目名称:SimpleFlatMapper,代码行数:23,代码来源:DatastaxCrudFactory.java

示例12: validateAdditionalFilters

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private void validateAdditionalFilters(TableMetadata tableMetadata) {
    for (Map.Entry<String, Serializable> entry : additionalFilters.entrySet()) {
        /* check if there's an index specified on the provided column */
        ColumnMetadata columnMetadata = tableMetadata.getColumn(entry.getKey());

        if (columnMetadata == null) {
            throw new DeepNoSuchFieldException("No column with name " + entry.getKey() + " has been found on " +
                    "table " + this.catalog + "." + this.table);
        }

        if (columnMetadata.getIndex() == null) {
            throw new DeepIndexNotFoundException("No index has been found on column " + columnMetadata.getName()
                    + " on table " + this.catalog + "." + this.table);
        }
    }
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:17,代码来源:CassandraDeepJobConfig.java

示例13: deleteEntityTableNonTransactional

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private boolean deleteEntityTableNonTransactional(String tableName, ODataEntry entity) throws ODataServiceFault {
    List<ColumnMetadata> cassandraTableMetaData = this.session.getCluster().getMetadata().getKeyspace(this.keyspace)
                                                              .getTable(tableName).getColumns();
    List<String> pKeys = this.primaryKeys.get(tableName);
    String query = createDeleteCQL(tableName);
    List<Object> values = new ArrayList<>();
    for (String column : entity.getNames()) {
        if (pKeys.contains(column)) {
            bindParams(column, entity.getValue(column), values, cassandraTableMetaData);
        }
    }
    PreparedStatement statement = this.preparedStatementMap.get(query);
    if (statement == null) {
        statement = this.session.prepare(query);
        this.preparedStatementMap.put(query, statement);
    }
    ResultSet result = this.session.execute(statement.bind(values.toArray()));
    return result.wasApplied();
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:20,代码来源:CassandraDataHandler.java

示例14: generateMetaData

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
private Map<String, Map<String, DataColumn>> generateMetaData() {
    Map<String, Map<String, DataColumn>> metadata = new HashMap<>();
    for (String tableName : this.tableList) {
        Map<String, DataColumn> dataColumnMap = new HashMap<>();
        for (ColumnMetadata columnMetadata : this.session.getCluster().getMetadata().getKeyspace(this.keyspace)
                                                         .getTable(tableName).getColumns()) {
            DataColumn dataColumn;
            if (this.primaryKeys.get(tableName).contains(columnMetadata.getName())) {
                dataColumn = new DataColumn(columnMetadata.getName(),
                                            getDataType(columnMetadata.getType().getName()), false);
            } else {
                dataColumn = new DataColumn(columnMetadata.getName(),
                                            getDataType(columnMetadata.getType().getName()), true);
            }
            dataColumnMap.put(dataColumn.getColumnName(), dataColumn);
        }
        metadata.put(tableName, dataColumnMap);
    }
    return metadata;
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:21,代码来源:CassandraDataHandler.java

示例15: CassandraTable

import com.datastax.driver.core.ColumnMetadata; //导入依赖的package包/类
public CassandraTable(
    final Session session,
    final TableMetadata table,
    final ConsistencyLevel consistencyLevel,
    final String bodyColumn,
    final boolean ignoreCase) {
  this.session = session;
  this.table = table;
  this.consistencyLevel = consistencyLevel;
  this.bodyColumn = bodyColumn;

  this.columns = table.getColumns();
  this.totalColumns = this.columns.size();
  this.primaryKeys = new ArrayList<String>();
  for (final ColumnMetadata column : table.getPrimaryKey()) {
    primaryKeys.add(column.getName());
  }

  this.ignoreCase = ignoreCase;
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:21,代码来源:CassandraTable.java


注:本文中的com.datastax.driver.core.ColumnMetadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。