Search in sources :

Example 1 with IntegerDateStore

use of com.bakdata.conquery.models.events.stores.primitive.IntegerDateStore 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 2 with IntegerDateStore

use of com.bakdata.conquery.models.events.stores.primitive.IntegerDateStore in project conquery by bakdata.

the class DateRangeParserTest method onlyClosed.

@Test
public void onlyClosed() {
    final DateRangeParser parser = new DateRangeParser(new ConqueryConfig());
    List.of(CDateRange.of(10, 11), CDateRange.exactly(10)).forEach(parser::addLine);
    final ColumnStore actual = parser.decideType();
    assertThat(actual).isInstanceOf(DateRangeTypeDateRange.class);
    assertThat(((IntegerDateStore) ((DateRangeTypeDateRange) actual).getMinStore()).getStore()).isInstanceOfAny(ByteArrayStore.class, RebasingStore.class);
}
Also used : ColumnStore(com.bakdata.conquery.models.events.stores.root.ColumnStore) ConqueryConfig(com.bakdata.conquery.models.config.ConqueryConfig) IntegerDateStore(com.bakdata.conquery.models.events.stores.primitive.IntegerDateStore) Test(org.junit.jupiter.api.Test)

Aggregations

IntegerDateStore (com.bakdata.conquery.models.events.stores.primitive.IntegerDateStore)2 ColumnStore (com.bakdata.conquery.models.events.stores.root.ColumnStore)2 Test (org.junit.jupiter.api.Test)2 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)1 Injectable (com.bakdata.conquery.io.jackson.Injectable)1 MutableInjectableValues (com.bakdata.conquery.io.jackson.MutableInjectableValues)1 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)1 Column (com.bakdata.conquery.models.datasets.Column)1 Dataset (com.bakdata.conquery.models.datasets.Dataset)1 Import (com.bakdata.conquery.models.datasets.Import)1 Table (com.bakdata.conquery.models.datasets.Table)1 Bucket (com.bakdata.conquery.models.events.Bucket)1 BitSetStore (com.bakdata.conquery.models.events.stores.primitive.BitSetStore)1 ShortArrayStore (com.bakdata.conquery.models.events.stores.primitive.ShortArrayStore)1 DateRangeTypeCompound (com.bakdata.conquery.models.events.stores.specific.DateRangeTypeCompound)1 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)1 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)1 BitSet (java.util.BitSet)1 Validator (javax.validation.Validator)1