Search in sources :

Example 1 with DictionaryStore

use of org.apache.carbondata.core.localdictionary.dictionaryholder.DictionaryStore in project carbondata by apache.

the class TestDictionaryStore method testDictionaryStoreWithMoreThanThreshold.

@Test
public void testDictionaryStoreWithMoreThanThreshold() {
    DictionaryStore dictionaryStore = new MapBasedDictionaryStore(10);
    boolean isException = false;
    for (int i = 0; i < 15; i++) {
        try {
            dictionaryStore.putIfAbsent((i + "").getBytes());
        } catch (DictionaryThresholdReachedException e) {
            isException = true;
            break;
        }
    }
    Assert.assertTrue(isException);
    Assert.assertTrue(dictionaryStore.isThresholdReached());
}
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)

Example 2 with DictionaryStore

use of org.apache.carbondata.core.localdictionary.dictionaryholder.DictionaryStore 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

DictionaryStore (org.apache.carbondata.core.localdictionary.dictionaryholder.DictionaryStore)2 MapBasedDictionaryStore (org.apache.carbondata.core.localdictionary.dictionaryholder.MapBasedDictionaryStore)2 DictionaryThresholdReachedException (org.apache.carbondata.core.localdictionary.exception.DictionaryThresholdReachedException)2 Test (org.junit.Test)2