@ -73,7 +73,7 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
private final int writeBufferSize ;
private Semaphore dumperSemaphore = new Semaphore ( 1 ) ;
private Semaphore cleanerSemaphore = new Semaphore ( 1 ) ;
private final Map < byte [ ] , HandleSet > fail edURLs; // mapping from word hashes to a list of url hashes
private final Map < byte [ ] , HandleSet > removeDelay edURLs; // mapping from word hashes to a list of url hashes
public IndexCell (
@ -100,7 +100,7 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
this . targetFileSize = targetFileSize ;
this . maxFileSize = maxFileSize ;
this . writeBufferSize = writeBufferSize ;
this . fail edURLs = new TreeMap < byte [ ] , HandleSet > ( URIMetadataRow . rowdef . objectOrder ) ;
this . removeDelay edURLs = new TreeMap < byte [ ] , HandleSet > ( URIMetadataRow . rowdef . objectOrder ) ;
}
@ -174,12 +174,13 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
assert countRam = = null | | countRam . size ( ) > = 0 ;
int c = countRam = = null ? countFile : countFile + countRam . size ( ) ;
// exclude entries from delayed remove
synchronized ( this . fail edURLs) {
HandleSet s = this . fail edURLs. get ( termHash ) ;
synchronized ( this . removeDelay edURLs) {
HandleSet s = this . removeDelay edURLs. get ( termHash ) ;
if ( s ! = null ) c - = s . size ( ) ;
if ( c < 0 ) c = 0 ;
}
// put count result into cache
if ( MemoryControl . shortStatus ( ) ) this . countCache . clear ( ) ;
this . countCache . put ( termHash , c ) ;
return c ;
}
@ -219,8 +220,8 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
}
if ( result = = null ) return null ;
// remove the failed urls
synchronized ( this . fail edURLs) {
HandleSet s = this . fail edURLs. get ( termHash ) ;
synchronized ( this . removeDelay edURLs) {
HandleSet s = this . removeDelay edURLs. get ( termHash ) ;
if ( s ! = null ) result . removeEntries ( s ) ;
}
return result ;
@ -261,8 +262,8 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
public void removeDelayed ( byte [ ] termHash , HandleSet urlHashes ) {
HandleSet r ;
synchronized ( fail edURLs) {
r = this . fail edURLs. get ( termHash ) ;
synchronized ( removeDelay edURLs) {
r = this . removeDelay edURLs. get ( termHash ) ;
}
if ( r = = null ) {
r = new HandleSet ( URIMetadataRow . rowdef . primaryKeyLength , URIMetadataRow . rowdef . objectOrder , 0 ) ;
@ -273,15 +274,15 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
try { remove ( termHash , urlHashes ) ; } catch ( IOException e1 ) { }
return ;
}
synchronized ( fail edURLs) {
this . fail edURLs. put ( termHash , r ) ;
synchronized ( removeDelay edURLs) {
this . removeDelay edURLs. put ( termHash , r ) ;
}
}
public void removeDelayed ( byte [ ] termHash , byte [ ] urlHashBytes ) {
HandleSet r ;
synchronized ( fail edURLs) {
r = this . fail edURLs. get ( termHash ) ;
synchronized ( removeDelay edURLs) {
r = this . removeDelay edURLs. get ( termHash ) ;
}
if ( r = = null ) {
r = new HandleSet ( URIMetadataRow . rowdef . primaryKeyLength , URIMetadataRow . rowdef . objectOrder , 0 ) ;
@ -292,20 +293,20 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
try { remove ( termHash , urlHashBytes ) ; } catch ( IOException e1 ) { }
return ;
}
synchronized ( fail edURLs) {
this . fail edURLs. put ( termHash , r ) ;
synchronized ( removeDelay edURLs) {
this . removeDelay edURLs. put ( termHash , r ) ;
}
}
public void removeDelayed ( ) throws IOException {
HandleSet words = new HandleSet ( URIMetadataRow . rowdef . primaryKeyLength , URIMetadataRow . rowdef . objectOrder , 0 ) ; // a set of url hashes where a worker thread tried to work on, but failed.
synchronized ( fail edURLs) {
for ( byte [ ] b : fail edURLs. keySet ( ) ) try { words . put ( b ) ; } catch ( RowSpaceExceededException e ) { }
synchronized ( removeDelay edURLs) {
for ( byte [ ] b : removeDelay edURLs. keySet ( ) ) try { words . put ( b ) ; } catch ( RowSpaceExceededException e ) { }
}
synchronized ( fail edURLs) {
synchronized ( removeDelay edURLs) {
for ( byte [ ] b : words ) {
HandleSet urls = fail edURLs. remove ( b ) ;
HandleSet urls = removeDelay edURLs. remove ( b ) ;
if ( urls ! = null ) remove ( b , urls ) ;
}
}
@ -410,7 +411,7 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
* /
public synchronized void clear ( ) throws IOException {
this . countCache . clear ( ) ;
this . fail edURLs. clear ( ) ;
this . removeDelay edURLs. clear ( ) ;
this . ram . clear ( ) ;
this . array . clear ( ) ;
}