use of com.datastax.oss.dsbulk.mapping.IndexedMappingField 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();
}
Aggregations