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


Java TableMetadata.getColumns方法代碼示例

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


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

示例1: getTableInfo

import com.datastax.driver.core.TableMetadata; //導入方法依賴的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

示例2: addColumnsToTable

import com.datastax.driver.core.TableMetadata; //導入方法依賴的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

示例3: getSchema

import com.datastax.driver.core.TableMetadata; //導入方法依賴的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

示例4: insertQuery

import com.datastax.driver.core.TableMetadata; //導入方法依賴的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

示例5: CassandraTable

import com.datastax.driver.core.TableMetadata; //導入方法依賴的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

示例6: registerNonPKColumnDefinitions

import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
private void registerNonPKColumnDefinitions(final TableMetadata tableMetadata)
{
  List<ColumnMetadata> colInfoForTable = tableMetadata.getColumns();
  for (ColumnMetadata aColumnDefinition : colInfoForTable) {
    if (aColumnDefinition.getType().isCollection()) {
      collectionColumns.add(aColumnDefinition.getName());
    }
    if (!pkColumnNames.contains(aColumnDefinition.getName())) {
      columnDefinitions.put(aColumnDefinition.getName(), aColumnDefinition.getType());
      regularColumns.add(aColumnDefinition.getName());
    }
    parseForSpecialDataType(aColumnDefinition);
  }
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:15,代碼來源:AbstractUpsertOutputOperator.java

示例7: addFields

import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
/**
 * Add fields to the class spec.
 */
private static void addFields(TypeSpec.Builder builder, TableMetadata tableMetadata, String className) {
    Map<String, Integer> partitionKeys = getMapOfKeys(tableMetadata.getPartitionKey());
    Map<String, Integer> clusteringKeys = getMapOfKeys(tableMetadata.getClusteringColumns());

    List<String> fields = new ArrayList<>();
    for (ColumnMetadata column : tableMetadata.getColumns()) {
        DataType type = column.getType();
        String name = column.getName();

        List<AnnotationSpec> extraAnnotations = new ArrayList<>();
        if(partitionKeys.containsKey(name)) {
            extraAnnotations.add(EntityGeneratorHelper.getPartitionKeyAnnotation(partitionKeys.get(name)));
        }

        if(clusteringKeys.containsKey(name)) {
            extraAnnotations.add(EntityGeneratorHelper.getClusteringAnnotation(clusteringKeys.get(name)));
        }

        builder.addField(EntityGeneratorHelper.getFieldSpec(name, type, false, extraAnnotations));
        builder.addMethod(EntityGeneratorHelper.getSetter(name, type));
        builder.addMethod(EntityGeneratorHelper.getGetter(name, type));
        fields.add(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name));
    }

    builder.addMethod(EntityGeneratorHelper.getToString(fields, className));
}
 
開發者ID:jtruelove,項目名稱:exovert,代碼行數:30,代碼來源:TableGenerator.java

示例8: selectMapper

import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
private static <T> DatastaxMapper<T> selectMapper(Type target, TableMetadata tableMetadata, DatastaxMapperFactory mapperFactory) {
    DatastaxMapperBuilder<T> mapperBuilder = mapperFactory.newBuilder(target);
    int i = 0;
    for(ColumnMetadata columnMetadata : tableMetadata.getColumns()) {
        mapperBuilder.addMapping(DatastaxColumnKey.of(columnMetadata, i++));
    }
    return mapperBuilder.mapper();
}
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:9,代碼來源:DatastaxCrudFactory.java

示例9: insertSetter

import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
private static <T> BoundStatementMapper<T> insertSetter(Type target, TableMetadata tableMetadata, DatastaxMapperFactory mapperFactory, int offset) {
    SettableDataMapperBuilder<T> mapperBuilder = mapperFactory.newBuilderFrom(target);
    int i = offset;
    for(ColumnMetadata columnMetadata : tableMetadata.getColumns()) {
        mapperBuilder.addColumn(DatastaxColumnKey.of(columnMetadata, i++));
    }
    return new BoundStatementMapper<T>(mapperBuilder.mapper());
}
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:9,代碼來源:DatastaxCrudFactory.java

示例10: loadColumnNames

import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
private static ImmutableSet<String> loadColumnNames(TableMetadata tableMetadata) {
    final Set<String> columnNames = Sets.newHashSet();
    for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) {
        columnNames.add(columnMetadata.getName());
    }
    
    return ImmutableSet.copyOf(columnNames);
}
 
開發者ID:1and1,項目名稱:Troilus,代碼行數:9,代碼來源:MetadataCatalog.java

示例11: getLuceneIndex

import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
/**
 * Retrieve the column name for the lucene indexes. Null if there is no lucene index.
 *
 * @return Lucene index; null, if doesn't exist.
 */
private String getLuceneIndex() {
    String indexName = "";

    TableMetadata tableMetadata = config.fetchTableMetadata();
    List<ColumnMetadata> columns = tableMetadata.getColumns();
    for (ColumnMetadata column : columns) {
        if (column.getIndex() != null) {
            if (column.getIndex().isCustomIndex()) {
                indexName = column.getName();
            }
        }
    }
    return indexName;
}
 
開發者ID:Stratio,項目名稱:deep-spark,代碼行數:20,代碼來源:DeepRecordReader.java

示例12: refreshTablenames

import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
public void refreshTablenames() {
    Collection<TableMetadata> tableMetadatas = session.getCluster().getMetadata()
            .getKeyspace(STREAMING.STREAMING_KEYSPACE_NAME).getTables();
    tablenames = new HashMap<>();
    for (TableMetadata tableMetadata : tableMetadatas) {
        Set<String> columns = new HashSet<>();
        for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) {
            columns.add(columnMetadata.getName());
        }
        tablenames.put(tableMetadata.getName(), columns.hashCode());
    }
}
 
開發者ID:Stratio,項目名稱:Decision,代碼行數:13,代碼來源:SaveToCassandraOperationsService.java

示例13: 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);
}
 
開發者ID:apache,項目名稱:metamodel,代碼行數:21,代碼來源:CassandraDataContext.java

示例14: setTableFieldCombo

import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
private void setTableFieldCombo() {

        Runnable fieldLoader = new Runnable() {
        	@Override
    		public void run() {
        		if (!shell.isDisposed()) {
        			String nodes = transMeta.environmentSubstitute(hostText.getText());
        			String port_s = transMeta.environmentSubstitute(portText.getText());
        			String username = transMeta.environmentSubstitute(userText.getText());
        			String password = transMeta.environmentSubstitute(passText.getText());
        			String keyspace = transMeta.environmentSubstitute(keyspaceText.getText());
        			Boolean withSSL = sslenabledBut.getSelection();
        			String truststorefile = transMeta.environmentSubstitute(truststorefileText.getText());
        			String truststorepass = transMeta.environmentSubstitute(truststorepassText.getText());
        			ConnectionCompression compression = ConnectionCompression.fromString(wCompression.getText());
        			String columnFamily = columnFamilyCombo.getText();

        			ciFields[0].setComboValues(new String[0]);
        			if (!Const.isEmpty(columnFamily)) {
        				String[] fieldNames = null;
        				try {
        					connection = Utils.connect(nodes, port_s, username, password, keyspace, withSSL,
        							truststorefile, truststorepass, compression);
        					Cluster cluster = connection.getSession().getCluster();
        					Metadata clusterMeta = cluster != null ? cluster.getMetadata() : null;
        					KeyspaceMetadata keyspaceMeta = clusterMeta != null ? clusterMeta.getKeyspace(keyspace) : null;
        					TableMetadata tableMeta = keyspaceMeta != null ? keyspaceMeta.getTable(columnFamily) : null;

        					if (tableMeta != null) {
        						List<ColumnMetadata> column = tableMeta.getColumns();
        						Iterator<ColumnMetadata> iter = column.iterator();
        						fieldNames = new String[column.size()];
        						int i = 0;
        						while (iter.hasNext()) {
        							fieldNames[(i++)] = iter.next().getName();
        						}
        					}
        				} catch (Exception localException) {
        					localException.printStackTrace();
        				}

        				if (!fieldsList.isDisposed()) {
        					ciFields[0].setComboValues(fieldNames);
        				}
        			}
        			if (connection != null)
        				connection.release();
        		}
        	}
        };
        this.shell.getDisplay().asyncExec(fieldLoader);
    }
 
開發者ID:bcolas,項目名稱:pentaho-cassandra-plugin,代碼行數:53,代碼來源:CassandraOutputDialog.java

示例15: init

import com.datastax.driver.core.TableMetadata; //導入方法依賴的package包/類
public void init(final String keyspace, final String columnFamily) {

    this.keyspace = keyspace;
    this.columnFamily = columnFamily;

    // connect to the cluster
    Cluster.Builder clusterBuilder = Cluster.builder();
    clusterBuilder.addContactPoints(host);
    if (port != -1) {
      clusterBuilder.withPort(port);
    }

    // ask for some metadata
    logger.info("getting cluster metadata for {}.{}", keyspace, columnFamily);
    final TableMetadata tableMetadata;
    try (final Cluster cluster = clusterBuilder.build()) {
      Metadata clusterMetadata = cluster.getMetadata();
      KeyspaceMetadata keyspaceMetadata = clusterMetadata.getKeyspace('"' + keyspace + '"');
      tableMetadata = keyspaceMetadata.getTable('"' + columnFamily + '"');
      cqlSchema = tableMetadata.asCQLQuery();
      partitionerClass = clusterMetadata.getPartitioner();
      Class.forName(partitionerClass);
      numClusterNodes = clusterMetadata.getAllHosts().size();
      columns = tableMetadata.getColumns();
    } catch (ClassNotFoundException cnfe) {
      throw new CrunchRuntimeException("No such partitioner: " + partitionerClass, cnfe);
    } catch (NullPointerException npe) {
      String msg = String.format("No such keyspace/table: %s/%s", keyspace, columnFamily);
      throw new CrunchRuntimeException(msg, npe);
    }

    // map the partition key columns
    final List<ColumnMetadata> partitionKeyColumns = tableMetadata.getPartitionKey();
    partitionKeyIndexes = new int[partitionKeyColumns.size()];
    for (int i = 0; i < partitionKeyColumns.size(); i++) {
      final String keyColName = partitionKeyColumns.get(i).getName();
      int j;
      for (j = 0; j < columns.size(); j++) {
        if (columns.get(j).getName().equals(keyColName)) {
          partitionKeyIndexes[i] = j;
          logger.info("partition key column {} index {}", keyColName, j);
          break;
        }
      }
      if (j == columns.size()) {
        throw new CrunchRuntimeException("no matching column for key " + keyColName);
      }
    }
  }
 
開發者ID:spotify,項目名稱:hdfs2cass,代碼行數:50,代碼來源:CassandraClusterInfo.java


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