Search in sources :

Example 6 with DictionaryThresholdReachedException

use of org.apache.carbondata.core.localdictionary.exception.DictionaryThresholdReachedException in project carbondata by apache.

the class TestLocalDictionaryGenerator method testColumnLocalDictionaryGeneratorWhenThresholdReached_ExceptionShouldBeThrown.

@Test
public void testColumnLocalDictionaryGeneratorWhenThresholdReached_ExceptionShouldBeThrown() {
    LocalDictionaryGenerator generator = new ColumnLocalDictionaryGenerator(1000, 2);
    try {
        for (int i = 1; i <= 10000; i++) {
            generator.generateDictionary(("" + i).getBytes());
        }
        Assert.assertTrue(false);
    } catch (DictionaryThresholdReachedException e) {
        Assert.assertTrue(true);
    }
    Assert.assertTrue(generator.isThresholdReached());
}
Also used : ColumnLocalDictionaryGenerator(org.apache.carbondata.core.localdictionary.generator.ColumnLocalDictionaryGenerator) LocalDictionaryGenerator(org.apache.carbondata.core.localdictionary.generator.LocalDictionaryGenerator) DictionaryThresholdReachedException(org.apache.carbondata.core.localdictionary.exception.DictionaryThresholdReachedException) ColumnLocalDictionaryGenerator(org.apache.carbondata.core.localdictionary.generator.ColumnLocalDictionaryGenerator) Test(org.junit.Test)

Example 7 with DictionaryThresholdReachedException

use of org.apache.carbondata.core.localdictionary.exception.DictionaryThresholdReachedException in project carbondata by apache.

the class TestDictionaryStore method testDictionaryStoreWithinThreshold.

@Test
public void testDictionaryStoreWithinThreshold() {
    DictionaryStore dictionaryStore = new MapBasedDictionaryStore(10);
    for (int i = 0; i < 10; i++) {
        try {
            dictionaryStore.putIfAbsent((i + "").getBytes());
            Assert.assertTrue(true);
        } catch (DictionaryThresholdReachedException e) {
            Assert.assertTrue(false);
            break;
        }
    }
}
Also used : MapBasedDictionaryStore(org.apache.carbondata.core.localdictionary.dictionaryholder.MapBasedDictionaryStore) MapBasedDictionaryStore(org.apache.carbondata.core.localdictionary.dictionaryholder.MapBasedDictionaryStore) DictionaryStore(org.apache.carbondata.core.localdictionary.dictionaryholder.DictionaryStore) DictionaryThresholdReachedException(org.apache.carbondata.core.localdictionary.exception.DictionaryThresholdReachedException) Test(org.junit.Test)

Aggregations

DictionaryThresholdReachedException (org.apache.carbondata.core.localdictionary.exception.DictionaryThresholdReachedException)7 Test (org.junit.Test)6 ColumnLocalDictionaryGenerator (org.apache.carbondata.core.localdictionary.generator.ColumnLocalDictionaryGenerator)4 LocalDictionaryGenerator (org.apache.carbondata.core.localdictionary.generator.LocalDictionaryGenerator)4 ByteBuffer (java.nio.ByteBuffer)3 IOException (java.io.IOException)2 ColumnPage (org.apache.carbondata.core.datastore.page.ColumnPage)2 ColumnPageDecoder (org.apache.carbondata.core.datastore.page.encoding.ColumnPageDecoder)2 DefaultEncodingFactory (org.apache.carbondata.core.datastore.page.encoding.DefaultEncodingFactory)2 EncodingFactory (org.apache.carbondata.core.datastore.page.encoding.EncodingFactory)2 DictionaryStore (org.apache.carbondata.core.localdictionary.dictionaryholder.DictionaryStore)2 MapBasedDictionaryStore (org.apache.carbondata.core.localdictionary.dictionaryholder.MapBasedDictionaryStore)2 Encoding (org.apache.carbondata.format.Encoding)2 LocalDictionaryChunk (org.apache.carbondata.format.LocalDictionaryChunk)2 BitSet (java.util.BitSet)1 DataType (org.apache.carbondata.core.metadata.datatype.DataType)1