Search in sources :

Example 1 with OffHeapBitSet

use of org.apache.cassandra.utils.obs.OffHeapBitSet in project cassandra by apache.

the class LongBitSetTest method timeit.

@Test
public void timeit() {
    // about 214 million
    long size_to_test = Integer.MAX_VALUE / 10;
    long size_and_excess = size_to_test + 20;
    OpenBitSet obs = new OpenBitSet(size_and_excess);
    OffHeapBitSet offbs = new OffHeapBitSet(size_and_excess);
    logger.info("||Open BS set's|Open BS get's|Open BS clear's|Offheap BS set's|Offheap BS get's|Offheap BS clear's|");
    // System.out.println("||Open BS set's|Open BS get's|Open BS clear's|Offheap BS set's|Offheap BS get's|Offheap BS clear's|");
    loopOnce(obs, offbs, size_to_test);
}
Also used : OpenBitSet(org.apache.cassandra.utils.obs.OpenBitSet) OffHeapBitSet(org.apache.cassandra.utils.obs.OffHeapBitSet) Test(org.junit.Test)

Example 2 with OffHeapBitSet

use of org.apache.cassandra.utils.obs.OffHeapBitSet in project cassandra by apache.

the class LongBitSetTest method testBitSetOperations.

@Test
public void testBitSetOperations() {
    long size_to_test = Integer.MAX_VALUE / 40;
    long size_and_excess = size_to_test + 20;
    OffHeapBitSet offbs = new OffHeapBitSet(size_and_excess);
    OpenBitSet obs = new OpenBitSet(size_and_excess);
    for (long i = 0; i < size_to_test; i++) populateRandom(offbs, obs, i);
    for (long i = 0; i < size_to_test; i++) compare(offbs, obs, i);
}
Also used : OpenBitSet(org.apache.cassandra.utils.obs.OpenBitSet) OffHeapBitSet(org.apache.cassandra.utils.obs.OffHeapBitSet) Test(org.junit.Test)

Example 3 with OffHeapBitSet

use of org.apache.cassandra.utils.obs.OffHeapBitSet in project cassandra by apache.

the class BitSetTest method populateAndReserialize.

private static void populateAndReserialize(IBitSet bs) throws IOException {
    for (long i = 0; i < bs.capacity(); i++) if (random.nextBoolean())
        bs.set(i);
    DataOutputBuffer out = new DataOutputBuffer();
    bs.serialize(out);
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(out.getData()));
    try (OffHeapBitSet newbs = OffHeapBitSet.deserialize(in)) {
        compare(bs, newbs);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) OffHeapBitSet(org.apache.cassandra.utils.obs.OffHeapBitSet) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer) DataInputStream(java.io.DataInputStream)

Example 4 with OffHeapBitSet

use of org.apache.cassandra.utils.obs.OffHeapBitSet in project cassandra by apache.

the class FilterFactory method createFilter.

@SuppressWarnings("resource")
private static IFilter createFilter(int hash, long numElements, int bucketsPer, boolean offheap) {
    long numBits = (numElements * bucketsPer) + BITSET_EXCESS;
    IBitSet bitset = offheap ? new OffHeapBitSet(numBits) : new OpenBitSet(numBits);
    return new BloomFilter(hash, bitset);
}
Also used : OpenBitSet(org.apache.cassandra.utils.obs.OpenBitSet) OffHeapBitSet(org.apache.cassandra.utils.obs.OffHeapBitSet) IBitSet(org.apache.cassandra.utils.obs.IBitSet)

Example 5 with OffHeapBitSet

use of org.apache.cassandra.utils.obs.OffHeapBitSet in project cassandra by apache.

the class LongBitSetTest method loopIt.

/**
     * Just to make sure JIT doesn't come on our way
     */
@Test
public // @Ignore
void loopIt() {
    // about 214 million
    long size_to_test = Integer.MAX_VALUE / 10;
    long size_and_excess = size_to_test + 20;
    OpenBitSet obs = new OpenBitSet(size_and_excess);
    OffHeapBitSet offbs = new OffHeapBitSet(size_and_excess);
    for (int i = 0; i < 10; i++) // 10 times to do approx 2B keys each.
    loopOnce(obs, offbs, size_to_test);
}
Also used : OpenBitSet(org.apache.cassandra.utils.obs.OpenBitSet) OffHeapBitSet(org.apache.cassandra.utils.obs.OffHeapBitSet) Test(org.junit.Test)

Aggregations

OffHeapBitSet (org.apache.cassandra.utils.obs.OffHeapBitSet)5 OpenBitSet (org.apache.cassandra.utils.obs.OpenBitSet)4 Test (org.junit.Test)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputBuffer (org.apache.cassandra.io.util.DataOutputBuffer)1 IBitSet (org.apache.cassandra.utils.obs.IBitSet)1