Skip to content

Commit

Permalink
more bugfixes (also for latest commit)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7202 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Sep 28, 2010
1 parent be6b483 commit e54cb7f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
1 change: 1 addition & 0 deletions source/de/anomic/search/SearchEvent.java
Expand Up @@ -517,6 +517,7 @@ private void prepareSecondarySearch() {
if (checkedPeers.contains(peer)) continue; // do not ask a peer again
urls = entry.getValue();
words = wordsFromPeer(peer, urls);
if (words.length() == 0) continue; // ???
assert words.length() >= 12 : "words = " + words;
//System.out.println("DEBUG-INDEXABSTRACT ***: peer " + peer + " has urls: " + urls + " from words: " + words);
rankedCache.moreFeeders(1);
Expand Down
4 changes: 2 additions & 2 deletions source/net/yacy/kelondro/data/image/ImageReferenceVars.java
Expand Up @@ -309,7 +309,7 @@ public final void min(final ImageReferenceVars other) {
if (this.virtualAge > (v = other.virtualAge)) this.virtualAge = v;
if (this.wordsintext > (v = other.wordsintext)) this.wordsintext = v;
if (this.phrasesintext > (v = other.phrasesintext)) this.phrasesintext = v;
if (other.positions != null) a(this.positions, Math.min(min(this.positions), min(other.positions)));
if (other.positions != null) a(this.positions, min(this.positions, other.positions));
if (this.posinphrase > (v = other.posinphrase)) this.posinphrase = v;
if (this.posofphrase > (v = other.posofphrase)) this.posofphrase = v;
if (this.lastModified > (w = other.lastModified)) this.lastModified = w;
Expand All @@ -331,7 +331,7 @@ public final void max(final ImageReferenceVars other) {
if (this.virtualAge < (v = other.virtualAge)) this.virtualAge = v;
if (this.wordsintext < (v = other.wordsintext)) this.wordsintext = v;
if (this.phrasesintext < (v = other.phrasesintext)) this.phrasesintext = v;
if (other.positions != null) a(this.positions, Math.max(max(this.positions), max(other.positions)));
if (other.positions != null) a(this.positions, max(this.positions, other.positions));
if (this.posinphrase < (v = other.posinphrase)) this.posinphrase = v;
if (this.posofphrase < (v = other.posofphrase)) this.posofphrase = v;
if (this.lastModified < (w = other.lastModified)) this.lastModified = w;
Expand Down
12 changes: 7 additions & 5 deletions source/net/yacy/kelondro/data/word/WordReferenceVars.java
Expand Up @@ -27,7 +27,9 @@
package net.yacy.kelondro.data.word;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.Semaphore;
Expand Down Expand Up @@ -60,7 +62,7 @@ public class WordReferenceVars extends AbstractReference implements WordReferenc
posinphrase, posofphrase,
urlcomps, urllength, virtualAge,
wordsintext, wordsintitle;
private final ArrayList<Integer> positions;
private final List<Integer> positions;
public double termFrequency;

public WordReferenceVars(
Expand All @@ -71,7 +73,7 @@ public WordReferenceVars(
final int hitcount, // how often appears this word in the text
final int wordcount, // total number of words
final int phrasecount, // total number of phrases
final ArrayList<Integer> ps, // positions of words that are joined into the reference
final List<Integer> ps, // positions of words that are joined into the reference
final int posinphrase, // position of word in its phrase
final int posofphrase, // number of the phrase where word appears
final long lastmodified, // last-modified time of the document where word appears
Expand All @@ -96,7 +98,7 @@ public WordReferenceVars(
this.llocal = outlinksSame;
this.lother = outlinksOther;
this.phrasesintext = phrasecount;
this.positions = new ArrayList<Integer>(ps.size());
this.positions = Collections.synchronizedList(new ArrayList<Integer>(ps.size()));
for (int i = 0; i < ps.size(); i++) this.positions.add(ps.get(i));
this.posinphrase = posinphrase;
this.posofphrase = posofphrase;
Expand Down Expand Up @@ -317,7 +319,7 @@ public final void min(final WordReferenceVars other) {
if (this.virtualAge > (v = other.virtualAge)) this.virtualAge = v;
if (this.wordsintext > (v = other.wordsintext)) this.wordsintext = v;
if (this.phrasesintext > (v = other.phrasesintext)) this.phrasesintext = v;
if (other.positions != null) a(this.positions, Math.min(min(this.positions), min(other.positions)));
if (other.positions != null) a(this.positions, min(this.positions, other.positions));
if (this.posinphrase > (v = other.posinphrase)) this.posinphrase = v;
if (this.posofphrase > (v = other.posofphrase)) this.posofphrase = v;
if (this.lastModified > (w = other.lastModified)) this.lastModified = w;
Expand All @@ -339,7 +341,7 @@ public final void max(final WordReferenceVars other) {
if (this.virtualAge < (v = other.virtualAge)) this.virtualAge = v;
if (this.wordsintext < (v = other.wordsintext)) this.wordsintext = v;
if (this.phrasesintext < (v = other.phrasesintext)) this.phrasesintext = v;
if (other.positions != null) a(this.positions, Math.max(max(this.positions), max(other.positions)));
if (other.positions != null) a(this.positions, max(this.positions, other.positions));
if (this.posinphrase < (v = other.posinphrase)) this.posinphrase = v;
if (this.posofphrase < (v = other.posofphrase)) this.posofphrase = v;
if (this.lastModified < (w = other.lastModified)) this.lastModified = w;
Expand Down
36 changes: 28 additions & 8 deletions source/net/yacy/kelondro/rwi/AbstractReference.java
Expand Up @@ -26,28 +26,48 @@

package net.yacy.kelondro.rwi;

import java.util.ArrayList;
import java.util.List;


public abstract class AbstractReference implements Reference {

protected static void a(ArrayList<Integer> a, int i) {
protected static void a(List<Integer> a, int i) {
assert a != null;
a.clear();
a.add(i);
if (i < 0) return; // signal for 'do nothing'
synchronized (a) {
a.clear();
a.add(i);
}
}
protected static int max(List<Integer> a, List<Integer> b) {
assert a != null;
if (a.size() == 0) return max(b);
if (b.size() == 0) return max(a);
return Math.max(max(a), max(b));
}
protected static int max(ArrayList<Integer> a) {
protected static int min(List<Integer> a, List<Integer> b) {
assert a != null;
if (a.size() == 0) return min(b);
if (b.size() == 0) return min(a);
int ma = min(a);
int mb = min(b);
if (ma == -1) return mb;
if (mb == -1) return ma;
return Math.min(ma, mb);
}

private static int max(List<Integer> a) {
assert a != null;
assert !a.isEmpty();
if (a.size() == 0) return -1;
if (a.size() == 1) return a.get(0);
if (a.size() == 2) return Math.max(a.get(0), a.get(1));
int r = a.get(0);
for (int i = 1; i < a.size(); i++) if (a.get(i) > r) r = a.get(i);
return r;
}
protected static int min(ArrayList<Integer> a) {
private static int min(List<Integer> a) {
assert a != null;
assert !a.isEmpty();
if (a.size() == 0) return -1;
if (a.size() == 1) return a.get(0);
if (a.size() == 2) return Math.min(a.get(0), a.get(1));
int r = a.get(0);
Expand Down

0 comments on commit e54cb7f

Please sign in to comment.