|
|
@ -258,7 +258,7 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// now decide where to flush that container
|
|
|
|
// now decide where to flush that container
|
|
|
|
plasmaWordIndexAssortment.record singleton = singletons.read(key);
|
|
|
|
plasmaWordIndexAssortment.record singleton = singletons.remove(key);
|
|
|
|
if (singleton == null) {
|
|
|
|
if (singleton == null) {
|
|
|
|
// not found in singletons
|
|
|
|
// not found in singletons
|
|
|
|
if (container.size() == 1) {
|
|
|
|
if (container.size() == 1) {
|
|
|
@ -273,22 +273,11 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
|
|
|
|
// we have a singleton and need to integrate this in the flush
|
|
|
|
// we have a singleton and need to integrate this in the flush
|
|
|
|
plasmaWordIndexEntry oldEntry = singleton.entries[0];
|
|
|
|
plasmaWordIndexEntry oldEntry = singleton.entries[0];
|
|
|
|
long oldTime = singleton.creationTime;
|
|
|
|
long oldTime = singleton.creationTime;
|
|
|
|
if (container.contains(oldEntry.getUrlHash())) {
|
|
|
|
|
|
|
|
// we have an double-occurrence
|
|
|
|
// put new entries to the container
|
|
|
|
if (container.size() == 1) {
|
|
|
|
if (!(container.contains(oldEntry.getUrlHash()))) container.add(oldEntry);
|
|
|
|
// it is superfluous to flush this, simple do nothing
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
// possibly reintegrate
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// we flush to the backend, and the entry from the singletons
|
|
|
|
|
|
|
|
singletons.remove(key);
|
|
|
|
|
|
|
|
return backend.addEntries(container, java.lang.Math.max(time, oldTime));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// now we have more than one entry
|
|
|
|
|
|
|
|
// we must remove the key from the singleton database
|
|
|
|
|
|
|
|
singletons.remove(key);
|
|
|
|
|
|
|
|
// .. and put it to the container
|
|
|
|
|
|
|
|
container.add(oldEntry);
|
|
|
|
|
|
|
|
if (reintegrate) {
|
|
|
|
if (reintegrate) {
|
|
|
|
// put singleton together with container back to ram
|
|
|
|
// put singleton together with container back to ram
|
|
|
|
synchronized (cache) {
|
|
|
|
synchronized (cache) {
|
|
|
@ -303,19 +292,16 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean flushFromSingleton(String key) {
|
|
|
|
private boolean flushFromSingleton(String key) {
|
|
|
|
// this should only be called if the singleton shall be deleted or returned in an index entity
|
|
|
|
// this should only be called if the singleton shall be deleted or returned in an index entity
|
|
|
|
plasmaWordIndexAssortment.record singleton = singletons.read(key);
|
|
|
|
plasmaWordIndexAssortment.record singleton = singletons.remove(key);
|
|
|
|
if (singleton == null) {
|
|
|
|
if (singleton == null) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// we have a singleton
|
|
|
|
// we have a singleton
|
|
|
|
plasmaWordIndexEntry entry = (plasmaWordIndexEntry) singleton.entries[0];
|
|
|
|
plasmaWordIndexEntry entry = (plasmaWordIndexEntry) singleton.entries[0];
|
|
|
|
long time = singleton.creationTime;
|
|
|
|
long time = singleton.creationTime;
|
|
|
|
// remove it from the singleton database
|
|
|
|
|
|
|
|
singletons.remove(key);
|
|
|
|
|
|
|
|
// integrate it to the backend
|
|
|
|
// integrate it to the backend
|
|
|
|
return backend.addEntries(plasmaWordIndexEntryContainer.instantContainer(key, entry), time) > 0;
|
|
|
|
return backend.addEntries(plasmaWordIndexEntryContainer.instantContainer(key, entry), time) > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|