Search in sources :

Example 6 with IntegerStore

use of com.bakdata.conquery.models.events.stores.root.IntegerStore in project conquery by bakdata.

the class DecimalParser method decideType.

@Override
protected DecimalStore decideType() {
    BigInteger unscaled = DecimalTypeScaled.unscale(maxScale, maxAbs);
    if (unscaled.bitLength() > 63) {
        return DecimalArrayStore.create(getLines());
    }
    IntegerParser sub = new IntegerParser(getConfig());
    sub.setMaxValue(unscaled.longValueExact());
    sub.setMinValue(-unscaled.longValueExact());
    sub.setLines(getLines());
    sub.setNullLines(getNullLines());
    IntegerStore subDecision = sub.findBestType();
    return new DecimalTypeScaled(maxScale, subDecision);
}
Also used : IntegerStore(com.bakdata.conquery.models.events.stores.root.IntegerStore) BigInteger(java.math.BigInteger) DecimalTypeScaled(com.bakdata.conquery.models.events.stores.specific.DecimalTypeScaled)

Example 7 with IntegerStore

use of com.bakdata.conquery.models.events.stores.root.IntegerStore in project conquery by bakdata.

the class IntArrayStoreTest method integerStore.

@Test
public void integerStore() {
    List<Long> values = Arrays.asList(1L, 2L, -10L, (long) Integer.MIN_VALUE, null);
    final IntArrayStore store = IntArrayStore.create(values.size());
    for (int index = 0; index < values.size(); index++) {
        if (values.get(index) == null) {
            store.setNull(index);
            continue;
        }
        store.setInteger(index, values.get(index));
    }
    for (int index = 0; index < values.size(); index++) {
        if (values.get(index) == null) {
            assertThat(store.has(index)).isFalse();
        } else {
            assertThat(store.getInteger(index)).isEqualTo(values.get(index));
        }
    }
    final IntegerStore selection = store.select(new int[] { 0, 4 }, new int[] { 2, 1 });
    assertThat(selection.getInteger(0)).isEqualTo(1);
    assertThat(selection.getInteger(1)).isEqualTo(2);
    assertThat(selection.has(2)).isFalse();
}
Also used : IntegerStore(com.bakdata.conquery.models.events.stores.root.IntegerStore) Test(org.junit.jupiter.api.Test)

Example 8 with IntegerStore

use of com.bakdata.conquery.models.events.stores.root.IntegerStore in project conquery by bakdata.

the class IntArrayStoreTest method byteStore.

@Test
public void byteStore() {
    List<Long> values = Arrays.asList(1L, 2L, -10L, Byte.MAX_VALUE - 1L, (long) Byte.MIN_VALUE, null);
    final ByteArrayStore store = ByteArrayStore.create(values.size());
    for (int index = 0; index < values.size(); index++) {
        if (values.get(index) == null) {
            store.setNull(index);
            continue;
        }
        store.setInteger(index, values.get(index));
    }
    for (int index = 0; index < values.size(); index++) {
        if (values.get(index) == null) {
            assertThat(store.has(index)).isFalse();
        } else {
            assertThat(store.getInteger(index)).isEqualTo(values.get(index));
        }
    }
    final IntegerStore selection = store.select(new int[] { 0, 5 }, new int[] { 2, 1 });
    assertThat(selection.getInteger(0)).isEqualTo(1);
    assertThat(selection.getInteger(1)).isEqualTo(2);
    assertThat(selection.has(2)).isFalse();
}
Also used : IntegerStore(com.bakdata.conquery.models.events.stores.root.IntegerStore) Test(org.junit.jupiter.api.Test)

Example 9 with IntegerStore

use of com.bakdata.conquery.models.events.stores.root.IntegerStore in project conquery by bakdata.

the class IntArrayStoreTest method shortStore.

@Test
public void shortStore() {
    List<Long> values = Arrays.asList(1L, 2L, -10L, Short.MAX_VALUE - 1L, (long) Short.MIN_VALUE, null);
    final ShortArrayStore store = ShortArrayStore.create(values.size());
    for (int index = 0; index < values.size(); index++) {
        if (values.get(index) == null) {
            store.setNull(index);
            continue;
        }
        store.setInteger(index, values.get(index));
    }
    for (int index = 0; index < values.size(); index++) {
        if (values.get(index) == null) {
            assertThat(store.has(index)).isFalse();
        } else {
            assertThat(store.getInteger(index)).isEqualTo(values.get(index));
        }
    }
    final IntegerStore selection = store.select(new int[] { 0, 5 }, new int[] { 2, 1 });
    assertThat(selection.getInteger(0)).isEqualTo(1);
    assertThat(selection.getInteger(1)).isEqualTo(2);
    assertThat(selection.has(2)).isFalse();
}
Also used : IntegerStore(com.bakdata.conquery.models.events.stores.root.IntegerStore) Test(org.junit.jupiter.api.Test)

Aggregations

IntegerStore (com.bakdata.conquery.models.events.stores.root.IntegerStore)9 Test (org.junit.jupiter.api.Test)3 StringTypeDictionary (com.bakdata.conquery.models.events.stores.specific.string.StringTypeDictionary)2 StringTypeEncoded (com.bakdata.conquery.models.events.stores.specific.string.StringTypeEncoded)2 IntegerParser (com.bakdata.conquery.models.preproc.parser.specific.IntegerParser)2 IntegerRange (com.bakdata.conquery.models.common.Range.IntegerRange)1 DictionaryMapping (com.bakdata.conquery.models.dictionary.DictionaryMapping)1 MapDictionary (com.bakdata.conquery.models.dictionary.MapDictionary)1 StringStore (com.bakdata.conquery.models.events.stores.root.StringStore)1 DecimalTypeScaled (com.bakdata.conquery.models.events.stores.specific.DecimalTypeScaled)1 MoneyIntStore (com.bakdata.conquery.models.events.stores.specific.MoneyIntStore)1 StringTypeNumber (com.bakdata.conquery.models.events.stores.specific.string.StringTypeNumber)1 SuccinctTrie (com.bakdata.conquery.util.dict.SuccinctTrie)1 ProgressReporter (com.bakdata.conquery.util.progressreporter.ProgressReporter)1 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 BigInteger (java.math.BigInteger)1