Search in sources :

Example 1 with MappedMappingField

use of com.datastax.oss.dsbulk.mapping.MappedMappingField 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

ImmutableMultimap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMultimap)1 CQLFragment (com.datastax.oss.dsbulk.mapping.CQLFragment)1 CQLWord (com.datastax.oss.dsbulk.mapping.CQLWord)1 FunctionCall (com.datastax.oss.dsbulk.mapping.FunctionCall)1 IndexedMappingField (com.datastax.oss.dsbulk.mapping.IndexedMappingField)1 MappedMappingField (com.datastax.oss.dsbulk.mapping.MappedMappingField)1 MappingField (com.datastax.oss.dsbulk.mapping.MappingField)1 ArrayList (java.util.ArrayList)1