Exemplo n.º 1
0
 public void test_IteratorFunctionality(GeoRecordBTree grbt) throws IOException {
   GeoConverter gc = new GeoConverter();
   ArrayList<LatitudeLongitudeDocId> lldida = getArrayListLLDID(2);
   GeoRecord minRecord, maxRecord;
   minRecord = gc.toGeoRecord((byte) 0, lldida.get(0));
   maxRecord = gc.toGeoRecord((byte) 0, lldida.get(1));
   GeoUtil gu = new GeoUtil();
   if (gu.compare(minRecord, maxRecord) == 1) {
     minRecord = gc.toGeoRecord((byte) 0, lldida.get(1));
     maxRecord = gc.toGeoRecord((byte) 0, lldida.get(0));
   }
   Iterator<GeoRecord> gIt = grbt.getIterator(minRecord, maxRecord);
   GeoRecord current = null, next = null;
   while (gIt.hasNext()) {
     if (next != null) {
       current = next;
     }
     next = gIt.next();
     if (current != null) {
       assertTrue("The indexer is out of order.", gu.compare(current, next) != 1);
     }
     assertTrue(
         "Iterator is out of range ",
         gu.compare(next, minRecord) != -1 || gu.compare(next, maxRecord) != 1);
   }
 }
Exemplo n.º 2
0
 public TreeSet<GeoRecord> getRandomBTreeOrderedByBitMag(int len) {
   Iterator<LatitudeLongitudeDocId> lldidIter = getArrayListLLDID(len).iterator();
   TreeSet<GeoRecord> tree = new TreeSet<GeoRecord>(new GeoRecordComparator());
   GeoConverter gc = new GeoConverter();
   while (lldidIter.hasNext()) {
     byte filterByte = GeoRecord.DEFAULT_FILTER_BYTE;
     tree.add(gc.toGeoRecord(filterByte, lldidIter.next()));
   }
   return tree;
 }