use of org.apache.druid.segment.SimpleAscendingOffset in project druid by druid-io.
the class BroadcastSegmentIndexedTableTest method checkColumnSelectorFactory.
private void checkColumnSelectorFactory(String columnName) {
try (final Closer closer = Closer.create()) {
final int numRows = backingSegment.asStorageAdapter().getNumRows();
final SimpleAscendingOffset offset = new SimpleAscendingOffset(numRows);
final BaseColumn theColumn = backingSegment.asQueryableIndex().getColumnHolder(columnName).getColumn();
closer.register(theColumn);
final BaseObjectColumnValueSelector<?> selector = theColumn.makeColumnValueSelector(offset);
ColumnSelectorFactory tableFactory = broadcastTable.makeColumnSelectorFactory(offset, false, closer);
final BaseObjectColumnValueSelector<?> tableSelector = tableFactory.makeColumnValueSelector(columnName);
// compare with base segment selector to make sure tables selector can read correct values
for (int row = 0; row < numRows; row++) {
offset.setCurrentOffset(row);
Assert.assertEquals(selector.getObject(), tableSelector.getObject());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.apache.druid.segment.SimpleAscendingOffset in project druid by druid-io.
the class PredicateValueMatcherFactoryTest method testDimensionProcessorMultiValuedDimensionMatchingValue.
@Test
public void testDimensionProcessorMultiValuedDimensionMatchingValue() {
// Emulate multi-valued dimension
final DictionaryEncodedColumnSupplier columnSupplier = new DictionaryEncodedColumnSupplier(GenericIndexed.fromIterable(ImmutableList.of("v1", "v2", "v3"), GenericIndexed.STRING_STRATEGY), GenericIndexed.fromIterable(ImmutableList.of(ByteBuffer.wrap(StringUtils.toUtf8("v1")), ByteBuffer.wrap(StringUtils.toUtf8("v2")), ByteBuffer.wrap(StringUtils.toUtf8("v3"))), GenericIndexed.BYTE_BUFFER_STRATEGY), null, () -> VSizeColumnarMultiInts.fromIterable(ImmutableList.of(VSizeColumnarInts.fromArray(new int[] { 1 }))), 0);
final ValueMatcher matcher = forSelector("v2").makeDimensionProcessor(columnSupplier.get().makeDimensionSelector(new SimpleAscendingOffset(1), null), true);
Assert.assertTrue(matcher.matches());
}
use of org.apache.druid.segment.SimpleAscendingOffset in project druid by druid-io.
the class BaseColumnarLongsBenchmark method setupFilters.
void setupFilters(int rows, double filteredRowCountPercentage, String filterDistribution) {
final int filteredRowCount = (int) Math.floor(rows * filteredRowCountPercentage);
if (filteredRowCount < rows) {
switch(filterDistribution) {
case "random":
setupRandomFilter(rows, filteredRowCount);
break;
case "contiguous-start":
offset = new SimpleAscendingOffset(rows);
vectorOffset = new NoFilterVectorOffset(VECTOR_SIZE, 0, filteredRowCount);
break;
case "contiguous-end":
offset = new SimpleAscendingOffset(rows);
vectorOffset = new NoFilterVectorOffset(VECTOR_SIZE, rows - filteredRowCount, rows);
break;
case "contiguous-bitmap-start":
setupContiguousBitmapFilter(rows, filteredRowCount, 0);
break;
case "contiguous-bitmap-end":
setupContiguousBitmapFilter(rows, filteredRowCount, rows - filteredRowCount);
break;
case "chunky-1000":
setupChunkyFilter(rows, filteredRowCount, 1000);
break;
case "chunky-10000":
setupChunkyFilter(rows, filteredRowCount, 10000);
break;
default:
throw new IllegalArgumentException("unknown filter distribution");
}
} else {
offset = new SimpleAscendingOffset(rows);
vectorOffset = new NoFilterVectorOffset(VECTOR_SIZE, 0, rows);
}
}
use of org.apache.druid.segment.SimpleAscendingOffset in project druid by druid-io.
the class BroadcastSegmentIndexedTableTest method checkNonIndexedReader.
private void checkNonIndexedReader(String columnName) {
checkColumnSelectorFactory(columnName);
try (final Closer closer = Closer.create()) {
final int columnIndex = columnNames.indexOf(columnName);
final int numRows = backingSegment.asStorageAdapter().getNumRows();
final IndexedTable.Reader reader = broadcastTable.columnReader(columnIndex);
closer.register(reader);
final SimpleAscendingOffset offset = new SimpleAscendingOffset(numRows);
final BaseColumn theColumn = backingSegment.asQueryableIndex().getColumnHolder(columnName).getColumn();
closer.register(theColumn);
final BaseObjectColumnValueSelector<?> selector = theColumn.makeColumnValueSelector(offset);
// compare with selector make sure reader can read correct values
for (int row = 0; row < numRows; row++) {
offset.setCurrentOffset(row);
Assert.assertEquals(selector.getObject(), reader.read(row));
}
// make sure it doesn't have an index since it isn't a key column
try {
Assert.assertEquals(null, broadcastTable.columnIndex(columnIndex));
} catch (IAE iae) {
Assert.assertEquals(StringUtils.format("Column[%d] is not a key column", columnIndex), iae.getMessage());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.apache.druid.segment.SimpleAscendingOffset in project druid by druid-io.
the class PredicateValueMatcherFactoryTest method testDimensionProcessorMultiValuedDimensionNotMatchingValue.
@Test
public void testDimensionProcessorMultiValuedDimensionNotMatchingValue() {
// Emulate multi-valued dimension
final DictionaryEncodedColumnSupplier columnSupplier = new DictionaryEncodedColumnSupplier(GenericIndexed.fromIterable(ImmutableList.of("v1", "v2", "v3"), GenericIndexed.STRING_STRATEGY), GenericIndexed.fromIterable(ImmutableList.of(ByteBuffer.wrap(StringUtils.toUtf8("v1")), ByteBuffer.wrap(StringUtils.toUtf8("v2")), ByteBuffer.wrap(StringUtils.toUtf8("v3"))), GenericIndexed.BYTE_BUFFER_STRATEGY), null, () -> VSizeColumnarMultiInts.fromIterable(ImmutableList.of(VSizeColumnarInts.fromArray(new int[] { 1 }))), 0);
final ValueMatcher matcher = forSelector("v3").makeDimensionProcessor(columnSupplier.get().makeDimensionSelector(new SimpleAscendingOffset(1), null), true);
Assert.assertFalse(matcher.matches());
}
Aggregations