@ -56,12 +56,12 @@ import java.util.LinkedList;
import java.util.StringTokenizer ;
import java.util.StringTokenizer ;
import java.util.TreeSet ;
import java.util.TreeSet ;
import java.util.Vector ;
import java.util.Vector ;
import de.anomic.server.logging.serverLog ;
import java.util.logging.Logger ;
public class kelondroTree extends kelondroRecords implements kelondroIndex {
public class kelondroTree extends kelondroRecords implements kelondroIndex {
//logging [Should be replaced to be able to split DB|YaCy - delete this, delete import, delete before "correcting iterator" message]
// logging (This probably needs someone to initialize the java.util.logging.* facilities);
public static serverLog log ;
public static Logger log = Logger . getLogger ( "KELONDRO" ) ;
// define the Over-Head-Array
// define the Over-Head-Array
private static short thisOHBytes = 2 ; // our record definition of two bytes
private static short thisOHBytes = 2 ; // our record definition of two bytes
@ -107,6 +107,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
}
}
this . objectOrder = objectOrder ;
this . objectOrder = objectOrder ;
writeOrderType ( ) ;
writeOrderType ( ) ;
super . setLogger ( log ) ;
}
}
public kelondroTree ( kelondroRA ra , long buffersize , int [ ] columns , boolean exitOnFail ) {
public kelondroTree ( kelondroRA ra , long buffersize , int [ ] columns , boolean exitOnFail ) {
@ -127,18 +128,21 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
}
}
this . objectOrder = objectOrder ;
this . objectOrder = objectOrder ;
writeOrderType ( ) ;
writeOrderType ( ) ;
super . setLogger ( log ) ;
}
}
public kelondroTree ( File file , long buffersize ) throws IOException {
public kelondroTree ( File file , long buffersize ) throws IOException {
// this opens a file with an existing tree file
// this opens a file with an existing tree file
super ( file , buffersize ) ;
super ( file , buffersize ) ;
readOrderType ( ) ;
readOrderType ( ) ;
super . setLogger ( log ) ;
}
}
public kelondroTree ( kelondroRA ra , long buffersize ) throws IOException {
public kelondroTree ( kelondroRA ra , long buffersize ) throws IOException {
// this opens a file with an existing tree in a kelondroRA
// this opens a file with an existing tree in a kelondroRA
super ( ra , buffersize ) ;
super ( ra , buffersize ) ;
readOrderType ( ) ;
readOrderType ( ) ;
super . setLogger ( log ) ;
}
}
private void writeOrderType ( ) {
private void writeOrderType ( ) {
@ -854,10 +858,11 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
int c = objectOrder . compare ( firstKey , nextNode . getKey ( ) ) ;
int c = objectOrder . compare ( firstKey , nextNode . getKey ( ) ) ;
if ( ( c > 0 ) & & ( asc ) ) {
if ( ( c > 0 ) & & ( asc ) ) {
// firstKey > nextNode.getKey()
// firstKey > nextNode.getKey()
if ( log ! = null ) log . logWarning ( "CORRECTING ITERATOR: firstKey=" + new String ( firstKey ) + ", nextNode=" + new String ( nextNode . getKey ( ) ) ) ;
logFine ( "CORRECTING ITERATOR: firstKey=" + new String ( firstKey ) + ", nextNode=" + new String ( nextNode . getKey ( ) ) ) ;
nextNode = ( ii . hasNext ( ) ) ? ( Node ) ii . next ( ) : null ;
nextNode = ( ii . hasNext ( ) ) ? ( Node ) ii . next ( ) : null ;
}
}
if ( ( c < 0 ) & & ( ! ( asc ) ) ) {
if ( ( c < 0 ) & & ( ! ( asc ) ) ) {
logFine ( "CORRECTING ITERATOR: firstKey=" + new String ( firstKey ) + ", nextNode=" + new String ( nextNode . getKey ( ) ) ) ;
nextNode = ( ii . hasNext ( ) ) ? ( Node ) ii . next ( ) : null ;
nextNode = ( ii . hasNext ( ) ) ? ( Node ) ii . next ( ) : null ;
}
}
}
}
@ -877,6 +882,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
nextNode = ( ii . hasNext ( ) ) ? ( Node ) ii . next ( ) : null ;
nextNode = ( ii . hasNext ( ) ) ? ( Node ) ii . next ( ) : null ;
if ( ( nextNode ! = null ) & & ( asc = = ( objectOrder . compare ( r , nextNode ) = = 1 ) ) ) {
if ( ( nextNode ! = null ) & & ( asc = = ( objectOrder . compare ( r , nextNode ) = = 1 ) ) ) {
// correct wrong order (this should not happen)
// correct wrong order (this should not happen)
logWarning ( "STOPPING ITERATOR: currentNode=" + new String ( r . getKey ( ) ) + ", nextNode=" + new String ( nextNode . getKey ( ) ) ) ;
if ( rot ) {
if ( rot ) {
try {
try {
ii = new nodeIterator ( asc , rot ) ;
ii = new nodeIterator ( asc , rot ) ;