Search in sources :

Example 1 with ReadableOffset

use of org.apache.druid.segment.data.ReadableOffset in project druid by druid-io.

the class QueryableIndexCursorSequenceBuilderTest method testTimeSearch.

@Test
public void testTimeSearch() {
    final int[] values = new int[] { 0, 1, 1, 1, 1, 1, 1, 1, 5, 7, 10 };
    final NumericColumn column = new NumericColumn() {

        @Override
        public int length() {
            return values.length;
        }

        @Override
        public long getLongSingleValueRow(int rowNum) {
            return values[rowNum];
        }

        @Override
        public void close() {
            throw new UnsupportedOperationException();
        }

        @Override
        public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
            throw new UnsupportedOperationException();
        }

        @Override
        public ColumnValueSelector<?> makeColumnValueSelector(ReadableOffset offset) {
            throw new UnsupportedOperationException();
        }
    };
    Assert.assertEquals(0, QueryableIndexCursorSequenceBuilder.timeSearch(column, 0, 0, values.length));
    Assert.assertEquals(2, QueryableIndexCursorSequenceBuilder.timeSearch(column, 0, 2, values.length));
    Assert.assertEquals(0, QueryableIndexCursorSequenceBuilder.timeSearch(column, 0, 0, values.length / 2));
    Assert.assertEquals(1, QueryableIndexCursorSequenceBuilder.timeSearch(column, 1, 0, values.length));
    Assert.assertEquals(2, QueryableIndexCursorSequenceBuilder.timeSearch(column, 1, 2, values.length));
    Assert.assertEquals(1, QueryableIndexCursorSequenceBuilder.timeSearch(column, 1, 0, values.length / 2));
    Assert.assertEquals(1, QueryableIndexCursorSequenceBuilder.timeSearch(column, 1, 1, 8));
    Assert.assertEquals(8, QueryableIndexCursorSequenceBuilder.timeSearch(column, 2, 0, values.length));
    Assert.assertEquals(10, QueryableIndexCursorSequenceBuilder.timeSearch(column, 10, 0, values.length));
    Assert.assertEquals(11, QueryableIndexCursorSequenceBuilder.timeSearch(column, 15, 0, values.length));
}
Also used : NumericColumn(org.apache.druid.segment.column.NumericColumn) RuntimeShapeInspector(org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector) ReadableOffset(org.apache.druid.segment.data.ReadableOffset) Test(org.junit.Test)

Aggregations

RuntimeShapeInspector (org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector)1 NumericColumn (org.apache.druid.segment.column.NumericColumn)1 ReadableOffset (org.apache.druid.segment.data.ReadableOffset)1 Test (org.junit.Test)1