Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5969 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
borg-0300 committed May 21, 2009
1 parent 734680d commit 3ebb904
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions source/de/anomic/kelondro/index/RowSet.java
Expand Up @@ -2,9 +2,9 @@
// (C) 2006 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
// first published 20.06.2006 on http://www.anomic.de
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// LICENSE
//
Expand Down Expand Up @@ -96,11 +96,11 @@ public synchronized boolean has(final byte[] key) {
return index >= 0;
}

public synchronized Row.Entry get(final byte[] key) {
public Row.Entry get(final byte[] key) {
return get(key, 0, key.length);
}

private Row.Entry get(final byte[] key, final int astart, final int alength) {
private synchronized Row.Entry get(final byte[] key, final int astart, final int alength) {
final int index = find(key, astart, alength);
final Row.Entry entry = (index >= 0) ? get(index, true) : null;
return entry;
Expand Down Expand Up @@ -167,18 +167,20 @@ public synchronized long inc(byte[] key, int col, long add, Row.Entry initrow) {
return Long.MIN_VALUE;
}
}

private synchronized Row.Entry remove(final byte[] a, final int start, final int length) {
int index;
Row.Entry entry = null;
int s = this.size();
final int s = this.size();
while ((index = find(a, start, length)) >= 0) {
entry = super.get(index, true);
super.removeRow(index, true); // keep order of collection!
// in case that the RowSet is not uniq, we must search again to delete all entries
// the following check will ensure that the process terminates
assert (this.size() < s);
if (this.size() >= s) return entry;
entry = super.get(index, true);
super.removeRow(index, true); // keep order of collection!
// in case that the RowSet is not uniq, we must search again to delete all entries
// the following check will ensure that the process terminates
assert (this.size() < s);
if (this.size() >= s) {
return entry;
}
//assert (findagainindex = find(a, start, length)) < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + NaturalOrder.arrayList(super.chunkcache, super.rowdef.objectsize * findagainindex, length) + ", searchkey=" + NaturalOrder.arrayList(a, start, length); // check if the remove worked
}
return entry;
Expand All @@ -189,11 +191,11 @@ private synchronized Row.Entry remove(final byte[] a, final int start, final int
* if the entry was found, return the entry, but delete the entry from the set
* if the entry was not found, return null.
*/
public Row.Entry remove(final byte[] a) {
public final synchronized Row.Entry remove(final byte[] a) {
return remove(a, 0, a.length);
}

private int find(final byte[] a, final int astart, final int alength) {
private synchronized int find(final byte[] a, final int astart, final int alength) {
// returns the chunknumber; -1 if not found

if (rowdef.objectOrder == null) return iterativeSearch(a, astart, alength, 0, this.chunkcount);
Expand Down

0 comments on commit 3ebb904

Please sign in to comment.