use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.
the class VarianceAggregatorTest method testObjectVarianceBufferAggregatorWithZeroCount.
@Test
public void testObjectVarianceBufferAggregatorWithZeroCount() {
VarianceAggregatorCollector holder1 = new VarianceAggregatorCollector().add(1.1f);
VarianceAggregatorCollector holder2 = new VarianceAggregatorCollector().add(2.7f);
VarianceAggregatorCollector holder3 = new VarianceAggregatorCollector();
VarianceAggregatorCollector[] values = { holder1, holder2, holder3 };
TestObjectColumnSelector<VarianceAggregatorCollector> selector = new TestObjectColumnSelector(values);
colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(selector);
EasyMock.expect(colSelectorFactory.getColumnCapabilities("nilly")).andReturn(new ColumnCapabilitiesImpl().setType(VarianceAggregatorFactory.TYPE));
EasyMock.replay(colSelectorFactory);
VarianceBufferAggregator agg = (VarianceBufferAggregator) aggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[aggFactory.getMaxIntermediateSizeWithNulls()]);
agg.init(buffer, 0);
assertValues((VarianceAggregatorCollector) agg.get(buffer, 0), 0, 0d, 0d);
aggregate(selector, agg, buffer, 0);
assertValues((VarianceAggregatorCollector) agg.get(buffer, 0), 1, 1.1d, 0d);
aggregate(selector, agg, buffer, 0);
assertValues((VarianceAggregatorCollector) agg.get(buffer, 0), 2, 3.8d, 1.28d);
aggregate(selector, agg, buffer, 0);
assertValues((VarianceAggregatorCollector) agg.get(buffer, 0), 2, 3.8d, 1.28d);
}
use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.
the class StringLastAggregationTest method setup.
@Before
public void setup() {
NullHandling.initializeForTests();
stringLastAggFactory = new StringLastAggregatorFactory("billy", "nilly", null, MAX_STRING_SIZE);
combiningAggFactory = stringLastAggFactory.getCombiningFactory();
timeSelector = new TestLongColumnSelector(times);
customTimeSelector = new TestLongColumnSelector(customTimes);
valueSelector = new TestObjectColumnSelector<>(strings);
objectSelector = new TestObjectColumnSelector<>(pairs);
colSelectorFactory = EasyMock.createMock(ColumnSelectorFactory.class);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector(ColumnHolder.TIME_COLUMN_NAME)).andReturn(timeSelector);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("customTime")).andReturn(customTimeSelector);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("nilly")).andReturn(valueSelector);
EasyMock.expect(colSelectorFactory.makeColumnValueSelector("billy")).andReturn(objectSelector);
EasyMock.expect(colSelectorFactory.getColumnCapabilities("nilly")).andReturn(new ColumnCapabilitiesImpl().setType(ColumnType.STRING));
EasyMock.expect(colSelectorFactory.getColumnCapabilities("billy")).andReturn(null);
EasyMock.replay(colSelectorFactory);
}
use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.
the class ApproximateHistogramFoldingVectorAggregatorTest method setup.
@Before
public void setup() {
h1 = new ApproximateHistogram(5);
h2 = new ApproximateHistogram(5);
for (int i = 0; i < 5; ++i) {
h1.offer(FLOATS[i]);
}
for (int i = 5; i < FLOATS.length; ++i) {
h2.offer(FLOATS[i]);
}
VectorObjectSelector vectorObjectSelector = createMock(VectorObjectSelector.class);
expect(vectorObjectSelector.getObjectVector()).andReturn(new Object[] { h1, null, h2, null }).anyTimes();
EasyMock.replay(vectorObjectSelector);
vectorColumnSelectorFactory = createMock(VectorColumnSelectorFactory.class);
expect(vectorColumnSelectorFactory.makeObjectSelector("field")).andReturn(vectorObjectSelector).anyTimes();
expect(vectorColumnSelectorFactory.getColumnCapabilities("field")).andReturn(new ColumnCapabilitiesImpl().setType(ApproximateHistogramAggregatorFactory.TYPE));
expect(vectorColumnSelectorFactory.getColumnCapabilities("string_field")).andReturn(new ColumnCapabilitiesImpl().setType(ColumnType.STRING));
expect(vectorColumnSelectorFactory.getColumnCapabilities("double_field")).andReturn(new ColumnCapabilitiesImpl().setType(ColumnType.STRING));
EasyMock.replay(vectorColumnSelectorFactory);
}
use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.
the class IncrementalIndex method loadDimensionIterable.
/**
* Currently called to initialize IncrementalIndex dimension order during index creation
* Index dimension ordering could be changed to initialize from DimensionsSpec after resolution of
* https://github.com/apache/druid/issues/2011
*/
public void loadDimensionIterable(Iterable<String> oldDimensionOrder, Map<String, ColumnCapabilities> oldColumnCapabilities) {
synchronized (dimensionDescs) {
if (!dimensionDescs.isEmpty()) {
throw new ISE("Cannot load dimension order when existing order[%s] is not empty.", dimensionDescs.keySet());
}
for (String dim : oldDimensionOrder) {
if (dimensionDescs.get(dim) == null) {
ColumnCapabilitiesImpl capabilities = ColumnCapabilitiesImpl.snapshot(oldColumnCapabilities.get(dim), IndexMergerV9.DIMENSION_CAPABILITY_MERGE_LOGIC);
DimensionHandler handler = DimensionHandlerUtils.getHandlerFromCapabilities(dim, capabilities, null);
addNewDimension(dim, handler);
}
}
}
}
use of org.apache.druid.segment.column.ColumnCapabilitiesImpl in project druid by druid-io.
the class VectorValueMatcherColumnProcessorFactoryTest method testMultiValueString.
@Test
public void testMultiValueString() {
IdLookup lookup = EasyMock.createMock(IdLookup.class);
MultiValueDimensionVectorSelector selector = EasyMock.createMock(MultiValueDimensionVectorSelector.class);
EasyMock.expect(selector.getCurrentVectorSize()).andReturn(CURRENT_SIZE).anyTimes();
EasyMock.expect(selector.getMaxVectorSize()).andReturn(VECTOR_SIZE).anyTimes();
EasyMock.expect(selector.getValueCardinality()).andReturn(11).anyTimes();
EasyMock.expect(selector.nameLookupPossibleInAdvance()).andReturn(false).anyTimes();
EasyMock.expect(selector.idLookup()).andReturn(lookup).anyTimes();
EasyMock.expect(lookup.lookupId("any value")).andReturn(-1).anyTimes();
EasyMock.expect(lookup.lookupId(null)).andReturn(0).anyTimes();
EasyMock.replay(selector, lookup);
VectorValueMatcherFactory matcherFactory = VectorValueMatcherColumnProcessorFactory.instance().makeMultiValueDimensionProcessor(new ColumnCapabilitiesImpl().setType(ColumnType.STRING).setHasMultipleValues(false).setHasBitmapIndexes(true).setDictionaryValuesUnique(true).setDictionaryValuesSorted(true).setDictionaryEncoded(true), selector);
Assert.assertTrue(matcherFactory instanceof MultiValueStringVectorValueMatcher);
VectorValueMatcher valueNotExistMatcher = matcherFactory.makeMatcher("any value");
Assert.assertTrue(valueNotExistMatcher instanceof BooleanVectorValueMatcher);
Assert.assertEquals(VECTOR_SIZE, valueNotExistMatcher.getMaxVectorSize());
Assert.assertEquals(CURRENT_SIZE, valueNotExistMatcher.getCurrentVectorSize());
VectorValueMatcher valueExistMatcher = matcherFactory.makeMatcher((String) null);
Assert.assertFalse(valueExistMatcher instanceof BooleanVectorValueMatcher);
Assert.assertEquals(VECTOR_SIZE, valueExistMatcher.getMaxVectorSize());
Assert.assertEquals(CURRENT_SIZE, valueExistMatcher.getCurrentVectorSize());
EasyMock.verify(selector, lookup);
}
Aggregations