Search in sources :

Example 1 with Import

use of com.bakdata.conquery.models.datasets.Import in project conquery by bakdata.

the class UIProcessor method getTableStatistics.

public TableStatistics getTableStatistics(Table table) {
    final NamespaceStorage storage = getDatasetRegistry().get(table.getDataset().getId()).getStorage();
    List<Import> imports = table.findImports(storage).collect(Collectors.toList());
    final long entries = imports.stream().mapToLong(Import::getNumberOfEntries).sum();
    return new TableStatistics(table, entries, // total size of dictionaries
    imports.stream().flatMap(imp -> imp.getDictionaries().stream()).filter(Objects::nonNull).map(storage::getDictionary).mapToLong(Dictionary::estimateMemoryConsumption).sum(), // total size of entries
    imports.stream().mapToLong(Import::estimateMemoryConsumption).sum(), // Total size of CBlocks
    imports.stream().mapToLong(imp -> calculateCBlocksSizeBytes(imp, storage.getAllConcepts())).sum(), imports);
}
Also used : Role(com.bakdata.conquery.models.auth.entities.Role) Dictionary(com.bakdata.conquery.models.dictionary.Dictionary) java.util(java.util) Getter(lombok.Getter) UserId(com.bakdata.conquery.models.identifiable.ids.specific.UserId) RequiredArgsConstructor(lombok.RequiredArgsConstructor) ConceptTreeNode(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeNode) Import(com.bakdata.conquery.models.datasets.Import) NamespaceStorage(com.bakdata.conquery.io.storage.NamespaceStorage) Pair(org.apache.commons.lang3.tuple.Pair) com.bakdata.conquery.resources.admin.ui.model(com.bakdata.conquery.resources.admin.ui.model) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) Group(com.bakdata.conquery.models.auth.entities.Group) ConqueryPermission(com.bakdata.conquery.models.auth.permissions.ConqueryPermission) Table(com.bakdata.conquery.models.datasets.Table) StringPermissionBuilder(com.bakdata.conquery.models.auth.permissions.StringPermissionBuilder) Concept(com.bakdata.conquery.models.datasets.concepts.Concept) CPSTypeIdResolver(com.bakdata.conquery.io.cps.CPSTypeIdResolver) User(com.bakdata.conquery.models.auth.entities.User) Collectors(java.util.stream.Collectors) AuthorizationHelper(com.bakdata.conquery.models.auth.AuthorizationHelper) Slf4j(lombok.extern.slf4j.Slf4j) Ability(com.bakdata.conquery.models.auth.permissions.Ability) CBlock(com.bakdata.conquery.models.events.CBlock) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) Dictionary(com.bakdata.conquery.models.dictionary.Dictionary) Import(com.bakdata.conquery.models.datasets.Import) NamespaceStorage(com.bakdata.conquery.io.storage.NamespaceStorage)

Example 2 with Import

use of com.bakdata.conquery.models.datasets.Import in project conquery by bakdata.

the class NamespacedStorage method decorateConceptStore.

private void decorateConceptStore(IdentifiableStore<Concept<?>> store) {
    store.onAdd(concept -> {
        if (concept.getDataset() != null && !concept.getDataset().equals(dataset.get())) {
            throw new IllegalStateException("Concept is not for this dataset.");
        }
        concept.setDataset(dataset.get());
        concept.initElements();
        concept.getSelects().forEach(centralRegistry::register);
        for (Connector connector : concept.getConnectors()) {
            centralRegistry.register(connector);
            connector.collectAllFilters().forEach(centralRegistry::register);
            connector.getSelects().forEach(centralRegistry::register);
            connector.getValidityDates().forEach(centralRegistry::register);
        }
        // add imports of table
        if (isRegisterImports()) {
            for (Import imp : getAllImports()) {
                for (Connector con : concept.getConnectors()) {
                    if (con.getTable().equals(imp.getTable())) {
                        con.addImport(imp);
                    }
                }
            }
        }
        if (concept instanceof TreeConcept) {
            ((TreeConcept) concept).getAllChildren().values().forEach(centralRegistry::register);
        }
    }).onRemove(concept -> {
        concept.getSelects().forEach(centralRegistry::remove);
        // see #146  remove from Dataset.concepts
        for (Connector connector : concept.getConnectors()) {
            connector.getSelects().forEach(centralRegistry::remove);
            connector.collectAllFilters().forEach(centralRegistry::remove);
            connector.getValidityDates().forEach(centralRegistry::remove);
            centralRegistry.remove(connector);
        }
        if (concept instanceof TreeConcept) {
            ((TreeConcept) concept).getAllChildren().values().forEach(centralRegistry::remove);
        }
    });
}
Also used : Dictionary(com.bakdata.conquery.models.dictionary.Dictionary) Getter(lombok.Getter) SneakyThrows(lombok.SneakyThrows) SecondaryIdDescriptionId(com.bakdata.conquery.models.identifiable.ids.specific.SecondaryIdDescriptionId) StoreFactory(com.bakdata.conquery.models.config.StoreFactory) Import(com.bakdata.conquery.models.datasets.Import) ArrayList(java.util.ArrayList) SingletonStore(com.bakdata.conquery.io.storage.xodus.stores.SingletonStore) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) DictionaryId(com.bakdata.conquery.models.identifiable.ids.specific.DictionaryId) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) ToString(lombok.ToString) TableId(com.bakdata.conquery.models.identifiable.ids.specific.TableId) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) Collection(java.util.Collection) Table(com.bakdata.conquery.models.datasets.Table) Concept(com.bakdata.conquery.models.datasets.concepts.Concept) Validator(javax.validation.Validator) IOException(java.io.IOException) ImportId(com.bakdata.conquery.models.identifiable.ids.specific.ImportId) Dataset(com.bakdata.conquery.models.datasets.Dataset) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Column(com.bakdata.conquery.models.datasets.Column) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) Import(com.bakdata.conquery.models.datasets.Import) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)

Example 3 with Import

use of com.bakdata.conquery.models.datasets.Import in project conquery by bakdata.

the class SerializationTests method bucketCompoundDateRange.

@Test
public void bucketCompoundDateRange() throws JSONException, IOException {
    Dataset dataset = new Dataset();
    dataset.setName("datasetName");
    Table table = new Table();
    Column startCol = new Column();
    startCol.setName("startCol");
    startCol.setType(MajorTypeId.DATE);
    startCol.setTable(table);
    Column endCol = new Column();
    endCol.setLabel("endLabel");
    endCol.setName("endCol");
    endCol.setType(MajorTypeId.DATE);
    endCol.setTable(table);
    Column compoundCol = new Column();
    compoundCol.setName("compoundCol");
    compoundCol.setType(MajorTypeId.DATE_RANGE);
    compoundCol.setTable(table);
    table.setColumns(new Column[] { startCol, endCol, compoundCol });
    table.setDataset(dataset);
    table.setName("tableName");
    Import imp = new Import(table);
    imp.setName("importTest");
    DateRangeTypeCompound compoundStore = new DateRangeTypeCompound(startCol.getName(), endCol.getName(), new BitSetStore(BitSet.valueOf(new byte[] { 0b1000 }), new BitSet(), 4));
    // 0b1000 is a binary representation of 8 so that the 4th is set to make sure that BitSet length is 4.
    ColumnStore startStore = new IntegerDateStore(new ShortArrayStore(new short[] { 1, 2, 3, 4 }, Short.MIN_VALUE));
    ColumnStore endStore = new IntegerDateStore(new ShortArrayStore(new short[] { 5, 6, 7, 8 }, Short.MIN_VALUE));
    Bucket bucket = new Bucket(0, 1, 4, new ColumnStore[] { startStore, endStore, compoundStore }, Collections.emptySet(), new int[0], new int[0], imp);
    compoundStore.setParent(bucket);
    CentralRegistry registry = new CentralRegistry();
    registry.register(dataset);
    registry.register(startCol);
    registry.register(endCol);
    registry.register(compoundCol);
    registry.register(table);
    registry.register(imp);
    registry.register(bucket);
    final Validator validator = Validators.newValidator();
    SerializationTestUtil.forType(Bucket.class).registry(registry).injectables(new Injectable() {

        @Override
        public MutableInjectableValues inject(MutableInjectableValues values) {
            return values.add(Validator.class, validator);
        }
    }).test(bucket);
}
Also used : Injectable(com.bakdata.conquery.io.jackson.Injectable) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) Table(com.bakdata.conquery.models.datasets.Table) Import(com.bakdata.conquery.models.datasets.Import) BitSetStore(com.bakdata.conquery.models.events.stores.primitive.BitSetStore) Dataset(com.bakdata.conquery.models.datasets.Dataset) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) BitSet(java.util.BitSet) ShortArrayStore(com.bakdata.conquery.models.events.stores.primitive.ShortArrayStore) DateRangeTypeCompound(com.bakdata.conquery.models.events.stores.specific.DateRangeTypeCompound) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) ColumnStore(com.bakdata.conquery.models.events.stores.root.ColumnStore) Column(com.bakdata.conquery.models.datasets.Column) Bucket(com.bakdata.conquery.models.events.Bucket) IntegerDateStore(com.bakdata.conquery.models.events.stores.primitive.IntegerDateStore) Validator(javax.validation.Validator) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 4 with Import

use of com.bakdata.conquery.models.datasets.Import in project conquery by bakdata.

the class CBlockTest method serialize.

@SneakyThrows
@Test
public void serialize() throws IOException, JSONException {
    final CentralRegistry registry = new CentralRegistry();
    final Dataset dataset = new Dataset();
    dataset.setName("dataset");
    final TreeConcept concept = new TreeConcept();
    concept.setDataset(dataset);
    concept.setName("concept");
    final ConceptTreeConnector connector = new ConceptTreeConnector();
    connector.setName("connector");
    connector.setConcept(concept);
    concept.setConnectors(List.of(connector));
    final Table table = new Table();
    table.setName("table");
    table.setDataset(dataset);
    final Import imp = new Import(table);
    imp.setName("import");
    final Bucket bucket = new Bucket(0, 0, 0, new ColumnStore[0], Collections.emptySet(), new int[10], new int[10], imp);
    final CBlock cBlock = CBlock.createCBlock(connector, bucket, 10);
    registry.register(dataset).register(table).register(concept).register(connector).register(bucket).register(imp);
    SerializationTestUtil.forType(CBlock.class).registry(registry).test(cBlock);
}
Also used : Table(com.bakdata.conquery.models.datasets.Table) Import(com.bakdata.conquery.models.datasets.Import) Dataset(com.bakdata.conquery.models.datasets.Dataset) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Test(org.junit.jupiter.api.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

Import (com.bakdata.conquery.models.datasets.Import)4 Table (com.bakdata.conquery.models.datasets.Table)4 Dataset (com.bakdata.conquery.models.datasets.Dataset)3 TreeConcept (com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)3 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)3 Column (com.bakdata.conquery.models.datasets.Column)2 Concept (com.bakdata.conquery.models.datasets.concepts.Concept)2 Dictionary (com.bakdata.conquery.models.dictionary.Dictionary)2 Validator (javax.validation.Validator)2 Getter (lombok.Getter)2 SneakyThrows (lombok.SneakyThrows)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Test (org.junit.jupiter.api.Test)2 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)1 CPSTypeIdResolver (com.bakdata.conquery.io.cps.CPSTypeIdResolver)1 Injectable (com.bakdata.conquery.io.jackson.Injectable)1 MutableInjectableValues (com.bakdata.conquery.io.jackson.MutableInjectableValues)1 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)1 NamespaceStorage (com.bakdata.conquery.io.storage.NamespaceStorage)1 SingletonStore (com.bakdata.conquery.io.storage.xodus.stores.SingletonStore)1