Skip to content

Commit

Permalink
dding more tests...
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Apr 27, 2016
1 parent 3e5412a commit cf89beb
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/googlecode/javaewah/FastAggregation.java
Expand Up @@ -26,6 +26,9 @@ private FastAggregation() {}
/**
* Compute the and aggregate using a temporary uncompressed bitmap.
*
* This function does not seek to match the "sizeinbits" attributes
* of the input bitmaps.
*
* @param bitmaps the source bitmaps
* @param bufSize buffer size used during the computation in 64-bit
* words (per input bitmap)
Expand All @@ -40,6 +43,9 @@ public static EWAHCompressedBitmap bufferedand(final int bufSize,

/**
* Compute the and aggregate using a temporary uncompressed bitmap.
*
* This function does not seek to match the "sizeinbits" attributes
* of the input bitmaps.
*
* @param container where the aggregate is written
* @param bufSize buffer size used during the computation in 64-bit
Expand Down
Expand Up @@ -26,6 +26,9 @@ private FastAggregation32() {}
/**
* Compute the and aggregate using a temporary uncompressed bitmap.
*
* This function does not seek to match the "sizeinbits" attributes
* of the input bitmaps.
*
* @param bitmaps the source bitmaps
* @param bufSize buffer size used during the computation in 64-bit
* words (per input bitmap)
Expand All @@ -41,6 +44,9 @@ public static EWAHCompressedBitmap32 bufferedand(final int bufSize,
/**
* Compute the and aggregate using a temporary uncompressed bitmap.
*
* This function does not seek to match the "sizeinbits" attributes
* of the input bitmaps.
*
* @param container where the aggregate is written
* @param bufSize buffer size used during the computation in 64-bit
* words (per input bitmap)
Expand Down
Expand Up @@ -21,6 +21,16 @@
*/
@SuppressWarnings("javadoc")
public class EWAHCompressedBitmapTest {

@Test
public void swaptest() {
EWAHCompressedBitmap x = EWAHCompressedBitmap.bitmapOf(1,2,3);
EWAHCompressedBitmap y = EWAHCompressedBitmap.bitmapOf(1,2,3,4);
x.swap(y);
Assert.assertEquals(x.cardinality(),4);
Assert.assertEquals(y.cardinality(),3);
}


@Test
public void shiftByWordSizeBits() {
Expand Down Expand Up @@ -1291,10 +1301,34 @@ public void remove() {
}
};
}

@Test
public void fastand() {
int[][] data = { {5, 6, 7, 8, 9}, {1, 5}, {2, 5}};

EWAHCompressedBitmap[] bitmaps = new EWAHCompressedBitmap[data.length];

for (int i = 0; i < bitmaps.length; ++i) {
bitmaps[i] = new EWAHCompressedBitmap();
for (int j : data[i]) {
bitmaps[i].set(j);
}
bitmaps[i].setSizeInBits(1000, false);
}
EWAHCompressedBitmap and1 = FastAggregation.bufferedand(1024, bitmaps[0],bitmaps[1],bitmaps[2]);
EWAHCompressedBitmap and2 = new EWAHCompressedBitmap();
FastAggregation.bufferedandWithContainer(and2, 32, bitmaps[0],bitmaps[1],bitmaps[2]);
EWAHCompressedBitmap and3 = EWAHCompressedBitmap.and(bitmaps[0],bitmaps[1],bitmaps[2]);
System.out.println(and1.sizeInBits());
System.out.println(and2.sizeInBits());
System.out.println(and3.sizeInBits());
assertEqualsPositions(and1, and2);
assertEqualsPositions(and2, and3);
}


@Test
public void fastagg() {
System.out.println("testing OKaserBugReportJuly2013");
int[][] data = {{}, {5, 6, 7, 8, 9}, {1}, {2}};

EWAHCompressedBitmap[] bitmaps = new EWAHCompressedBitmap[data.length];
Expand Down
Expand Up @@ -24,6 +24,15 @@
*/
@SuppressWarnings("javadoc")
public class EWAHCompressedBitmap32Test {

@Test
public void swaptest() {
EWAHCompressedBitmap32 x = EWAHCompressedBitmap32.bitmapOf(1,2,3);
EWAHCompressedBitmap32 y = EWAHCompressedBitmap32.bitmapOf(1,2,3,4);
x.swap(y);
Assert.assertEquals(x.cardinality(),4);
Assert.assertEquals(y.cardinality(),3);
}

@Test
public void shiftByWordSizeBits() {
Expand Down Expand Up @@ -1210,9 +1219,33 @@ public void remove() {
};
}

@Test
public void fastand() {
int[][] data = { {5, 6, 7, 8, 9}, {1, 5}, {2, 5}};

EWAHCompressedBitmap32[] bitmaps = new EWAHCompressedBitmap32[data.length];

for (int i = 0; i < bitmaps.length; ++i) {
bitmaps[i] = new EWAHCompressedBitmap32();
for (int j : data[i]) {
bitmaps[i].set(j);
}
bitmaps[i].setSizeInBits(1000, false);
}
EWAHCompressedBitmap32 and1 = FastAggregation32.bufferedand(1024, bitmaps[0],bitmaps[1],bitmaps[2]);
EWAHCompressedBitmap32 and2 = new EWAHCompressedBitmap32();
FastAggregation32.bufferedandWithContainer(and2, 32, bitmaps[0],bitmaps[1],bitmaps[2]);
EWAHCompressedBitmap32 and3 = EWAHCompressedBitmap32.and(bitmaps[0],bitmaps[1],bitmaps[2]);
System.out.println(and1.sizeInBits());
System.out.println(and2.sizeInBits());
System.out.println(and3.sizeInBits());
assertEqualsPositions(and1, and2);
assertEqualsPositions(and2, and3);
}


@Test
public void fastagg() {
System.out.println("testing OKaserBugReportJuly2013");
int[][] data = {{}, {5, 6, 7, 8, 9}, {1}, {2}};

EWAHCompressedBitmap32[] bitmaps = new EWAHCompressedBitmap32[data.length];
Expand Down Expand Up @@ -1253,6 +1286,7 @@ public void fastagg() {
assertEquals(xor5,xor6);
}


@SuppressWarnings({"deprecation", "boxing"})
@Test
public void OKaserBugReportJuly2013() {
Expand Down

0 comments on commit cf89beb

Please sign in to comment.