use of com.bakdata.conquery.models.preproc.parser.ColumnValues in project conquery by bakdata.
the class Preprocessed method combineStores.
/**
* Combine raw by-Entity data into column stores, appropriately formatted.
*/
@SuppressWarnings("rawtypes")
private Map<String, ColumnStore> combineStores(Int2IntMap entityStart) {
Map<String, ColumnStore> columnStores = Arrays.stream(columns).parallel().collect(Collectors.toMap(PPColumn::getName, PPColumn::findBestType));
// This object can be huge!
Int2ObjectMap<IntList> entityEvents = new Int2ObjectOpenHashMap<>(entityStart.size());
for (int pos = 0, size = rowEntities.size(); pos < size; pos++) {
int entity = rowEntities.getInt(pos);
entityEvents.computeIfAbsent(entity, (ignored) -> new IntArrayList()).add(pos);
}
for (int colIdx = 0; colIdx < columns.length; colIdx++) {
final PPColumn ppColumn = columns[colIdx];
final ColumnValues columnValues = values[colIdx];
// No need to preprocess the column further more, if it does not contain values, likely backed by a compound ColumnStore
if (columnValues == null) {
continue;
}
final ColumnStore store = columnStores.get(ppColumn.getName());
entityStart.int2IntEntrySet().forEach(entry -> {
final int entity = entry.getIntKey();
int outIndex = entry.getIntValue();
final IntList events = entityEvents.getOrDefault(entity, IntLists.emptyList());
for (int inIndex : events) {
if (columnValues.isNull(inIndex)) {
store.setNull(outIndex);
} else {
final Object raw = columnValues.get(inIndex);
ppColumn.getParser().setValue(store, outIndex, raw);
}
outIndex++;
}
});
}
return columnStores;
}
Aggregations