Search in sources :

Example 6 with MappingField

use of com.datastax.oss.dsbulk.mapping.MappingField in project dsbulk by datastax.

the class SchemaSettings method inferFieldsToVariablesMap.

private ImmutableMultimap<MappingField, CQLFragment> inferFieldsToVariablesMap(Collection<CQLFragment> columns) {
    // use a builder to preserve iteration order
    ImmutableMultimap.Builder<MappingField, CQLFragment> fieldsToVariables = ImmutableMultimap.builder();
    List<CQLFragment> excludedVariables = new ArrayList<>(mapping.getExcludedVariables());
    if (!isCounterTable() && schemaGenerationStrategy.isMapping()) {
        for (CQLWord variable : mapping.getExcludedVariables()) {
            if (preserveTimestamp) {
                excludedVariables.add(new FunctionCall(null, WRITETIME, variable));
            }
            if (preserveTtl) {
                excludedVariables.add(new FunctionCall(null, TTL, variable));
            }
        }
    }
    int i = 0;
    for (CQLFragment colName : columns) {
        if (!excludedVariables.contains(colName)) {
            if (mappingPreference == INDEXED_ONLY) {
                fieldsToVariables.put(new IndexedMappingField(i), colName);
            } else {
                fieldsToVariables.put(new MappedMappingField(colName.render(INTERNAL)), colName);
            }
        }
        i++;
    }
    return fieldsToVariables.build();
}
Also used : MappedMappingField(com.datastax.oss.dsbulk.mapping.MappedMappingField) ArrayList(java.util.ArrayList) IndexedMappingField(com.datastax.oss.dsbulk.mapping.IndexedMappingField) CQLWord(com.datastax.oss.dsbulk.mapping.CQLWord) ImmutableMultimap(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMultimap) CQLFragment(com.datastax.oss.dsbulk.mapping.CQLFragment) FunctionCall(com.datastax.oss.dsbulk.mapping.FunctionCall) IndexedMappingField(com.datastax.oss.dsbulk.mapping.IndexedMappingField) MappingField(com.datastax.oss.dsbulk.mapping.MappingField) MappedMappingField(com.datastax.oss.dsbulk.mapping.MappedMappingField)

Aggregations

CQLFragment (com.datastax.oss.dsbulk.mapping.CQLFragment)6 IndexedMappingField (com.datastax.oss.dsbulk.mapping.IndexedMappingField)6 MappedMappingField (com.datastax.oss.dsbulk.mapping.MappedMappingField)6 MappingField (com.datastax.oss.dsbulk.mapping.MappingField)6 CQLWord (com.datastax.oss.dsbulk.mapping.CQLWord)5 FunctionCall (com.datastax.oss.dsbulk.mapping.FunctionCall)5 ImmutableMultimap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMultimap)4 DseGraphKeyspaceMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseGraphKeyspaceMetadata)3 CQLLiteral (com.datastax.oss.dsbulk.mapping.CQLLiteral)3 TypedCQLLiteral (com.datastax.oss.dsbulk.mapping.TypedCQLLiteral)3 DseEdgeMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseEdgeMetadata)2 DseGraphTableMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseGraphTableMetadata)2 DseTableMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseTableMetadata)2 DseVertexMetadata (com.datastax.dse.driver.api.core.metadata.schema.DseVertexMetadata)2 CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)2 CqlSession (com.datastax.oss.driver.api.core.CqlSession)2 DefaultProtocolVersion (com.datastax.oss.driver.api.core.DefaultProtocolVersion)2 ProtocolVersion (com.datastax.oss.driver.api.core.ProtocolVersion)2 BatchType (com.datastax.oss.driver.api.core.cql.BatchType)2 ColumnDefinitions (com.datastax.oss.driver.api.core.cql.ColumnDefinitions)2