Skip to content

Commit

Permalink
Unit test output (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzaeschke authored Jul 31, 2024
1 parent 6eaf712 commit fc48350
Show file tree
Hide file tree
Showing 16 changed files with 263 additions and 235 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [2.1.4 - Unreleased]

### Fixed
- Fixed tree corruption after remove() in QT2. [#40](https://github.com/tzaeschke/tinspin-indexes/issues/40)
- Fixed tree consistency (single-entry leaf after remove)
- Fixed tree consistency (nValues) -> verify
- Fixed bug in qt2.contains()
- Fixed QT2 inconsistency after root resizing after insert(). [#42](https://github.com/tzaeschke/tinspin-indexes/issues/42)
Essentially, we enforce all radii and the center of the root to be a power of two.
This should immensely reduce and problems with precision errors.
Essentially, we force all radii and the center of the root to be powers of two.
This should immensely reduce precision problems.
- Removed unnecessary JUnit test console output. [#45](https://github.com/tzaeschke/tinspin-indexes/pull/45)

## [2.1.3] - 2023-11-19

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/tinspin/index/critbit/Examples.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
public class Examples {

public static boolean PRINT = true;

public static void main(String[] args) {
ex1D_32();
ex1D_float();
Expand Down Expand Up @@ -123,6 +125,8 @@ private static void ex4D() {
}

private static void log(String msg) {
System.out.println(msg);
if (PRINT) {
System.out.println(msg);
}
}
}
7 changes: 6 additions & 1 deletion src/test/java/org/tinspin/index/critbit/TestCritBit.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.Random;

import org.junit.BeforeClass;
import org.junit.Test;
import org.tinspin.index.critbit.CritBit;
import org.tinspin.index.critbit.CritBit1D;
Expand All @@ -48,7 +49,11 @@ public class TestCritBit {
private CritBit1D<Integer> newCritBit(int depth) {
return CritBit.create1D(depth);
}


@BeforeClass public static void beforeClass() {
Examples.PRINT = false;
}

@Test
public void testInsertIntRBug1() {
randomInsertCheck(1000, 7374, 32);
Expand Down
35 changes: 25 additions & 10 deletions src/test/java/org/tinspin/index/phtree/PhTreeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
import java.util.Random;

import ch.ethz.globis.tinspin.TestStats;
import org.junit.BeforeClass;
import org.junit.Test;
import org.tinspin.index.BoxMap;
import org.tinspin.index.array.RectArray;
import org.tinspin.index.test.util.JmxTools;
import org.tinspin.index.test.util.TestBox;
import org.tinspin.index.test.util.TestBoxCube;
import org.tinspin.index.test.util.TestInstances.TST;
import org.tinspin.index.test.util.TestRunner;

import static org.tinspin.index.Index.*;

Expand All @@ -42,6 +44,11 @@ public class PhTreeTest {
private static final double param1 = 0.01;
private static final RectComp COMP = new RectComp();

@BeforeClass
public static void beforeClass() {
TestRunner.PRINT = false;
}

@Test
public void testR() {
Random R = new Random(0);
Expand Down Expand Up @@ -76,7 +83,7 @@ private void load(BoxMap<Integer> tree, double[] data) {
private void repeatQuery(TestBox test, BoxMap<Integer> tree1, BoxMap<Integer> tree2, int repeat) {
int dims = DIM;
//log("N=" + N);
log("querying index ... repeat = " + repeat);
println("querying index ... repeat = " + repeat);
double[][] lower = new double[repeat][dims];
double[][] upper = new double[repeat][dims];
test.generateWindowQueries(lower, upper);
Expand All @@ -85,7 +92,7 @@ private void repeatQuery(TestBox test, BoxMap<Integer> tree1, BoxMap<Integer> tr
int n = 0;
n = repeatQueries(tree1, tree2, lower, upper);
long t2 = System.currentTimeMillis();
log("Query time: " + (t2-t1) + " ms -> " + (t2-t1)/(double)repeat + " ms/q -> " +
println("Query time: " + (t2-t1) + " ms -> " + (t2-t1)/(double)repeat + " ms/q -> " +
(t2-t1)*1000*1000/(double)n + " ns/q/r (n=" + n + ")");
}

Expand All @@ -107,24 +114,24 @@ private int repeatQueries(BoxMap<Integer> tree1, BoxMap<Integer> tree2, double[]
n2++;
}
if (n1 != n2) {
log("n1/n2=" + n1 + "/" + n2);
log("q=" + Arrays.toString(lower[i]) + "/" + Arrays.toString(upper[i]));
println("n1/n2=" + n1 + "/" + n2);
println("q=" + Arrays.toString(lower[i]) + "/" + Arrays.toString(upper[i]));
set1.sort(COMP);
set2.sort(COMP);
for (int j = 0; j < set1.size(); j++) {
BoxEntry<Integer> e1 = set1.get(j);
BoxEntry<Integer> e2 = set2.get(j);
if (!Arrays.equals(e1.min(), e2.min()) ||
!Arrays.equals(e1.max(), e2.max())) {
log("j=" + j + " mismatch: " + e1 + " -/- " + e2);
println("j=" + j + " mismatch: " + e1 + " -/- " + e2);
}
}
}
assertEquals(n1, n2);
n += n1;
if (i%10 == 0) System.out.print('.');
if (i%10 == 0) print(".");
}
System.out.println();
println("");
//log("n=" + n/(double)lower.length);
return n;
}
Expand All @@ -146,9 +153,17 @@ public int compare(BoxEntry<?> o1, BoxEntry<?> o2) {
return 0;
}
}

private static void log(String string) {
System.out.println(string);

private static void println(String string) {
if (TestRunner.PRINT) {
System.out.println(string);
}
}

private static void print(String string) {
if (TestRunner.PRINT) {
System.out.print(string);
}
}

}
Loading

0 comments on commit fc48350

Please sign in to comment.