Search in sources :

Example 1 with IndexInfo

use of org.apache.cassandra.io.sstable.IndexHelper.IndexInfo in project eiger by wlloyd.

the class IndexHelperTest method testIndexHelper.

@Test
public void testIndexHelper() {
    List<IndexInfo> indexes = new ArrayList<IndexInfo>();
    indexes.add(new IndexInfo(bytes(0L), bytes(5L), 0, 0));
    indexes.add(new IndexInfo(bytes(10L), bytes(15L), 0, 0));
    indexes.add(new IndexInfo(bytes(20L), bytes(25L), 0, 0));
    AbstractType comp = IntegerType.instance;
    assert 0 == IndexHelper.indexFor(bytes(-1L), indexes, comp, false);
    assert 0 == IndexHelper.indexFor(bytes(5L), indexes, comp, false);
    assert 1 == IndexHelper.indexFor(bytes(12L), indexes, comp, false);
    assert 2 == IndexHelper.indexFor(bytes(17L), indexes, comp, false);
    assert 3 == IndexHelper.indexFor(bytes(100L), indexes, comp, false);
    assert -1 == IndexHelper.indexFor(bytes(-1L), indexes, comp, true);
    assert 0 == IndexHelper.indexFor(bytes(5L), indexes, comp, true);
    assert 1 == IndexHelper.indexFor(bytes(12L), indexes, comp, true);
    assert 1 == IndexHelper.indexFor(bytes(17L), indexes, comp, true);
    assert 2 == IndexHelper.indexFor(bytes(100L), indexes, comp, true);
}
Also used : ArrayList(java.util.ArrayList) AbstractType(org.apache.cassandra.db.marshal.AbstractType) IndexInfo(org.apache.cassandra.io.sstable.IndexHelper.IndexInfo) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 AbstractType (org.apache.cassandra.db.marshal.AbstractType)1 IndexInfo (org.apache.cassandra.io.sstable.IndexHelper.IndexInfo)1 Test (org.junit.Test)1