- fixed bug in ordering

- fixed ConcurrentModificationException in set join


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7519 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent dec4f36700
commit 0ce17d823a

@ -157,12 +157,14 @@ public class Segments implements Iterable<Segment> {
}
public long RWICount() {
if (this.segments == null) return 0;
long c = 0;
for (Segment s: this.segments.values()) c += (long) s.termIndex().sizesMax();
return c;
}
public int RWIBufferCount() {
if (this.segments == null) return 0;
int c = 0;
for (Segment s: this.segments.values()) c += s.termIndex().getBufferSize();
return c;

@ -34,32 +34,34 @@ public abstract class AbstractReference implements Reference {
protected static void a(Collection<Integer> a, int i) {
assert a != null;
if (i < 0) return; // signal for 'do nothing'
if (i == Integer.MAX_VALUE || i == Integer.MIN_VALUE) return; // signal for 'do nothing'
a.clear();
a.add(i);
}
protected static int max(Collection<Integer> a, Collection<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));
if (a == null || a.size() == 0) return max(b);
if (b == null || b.size() == 0) return max(a);
int ma = max(a);
int mb = max(b);
if (ma == Integer.MIN_VALUE) return mb;
if (mb == Integer.MIN_VALUE) return ma;
return Math.max(ma, mb);
}
protected static int min(Collection<Integer> a, Collection<Integer> b) {
assert a != null;
if (a.size() == 0) return min(b);
if (b.size() == 0) return min(a);
if (a == null || a.size() == 0) return min(b);
if (b == null || b.size() == 0) return min(a);
int ma = min(a);
int mb = min(b);
if (ma == -1) return mb;
if (mb == -1) return ma;
if (ma == Integer.MAX_VALUE) return mb;
if (mb == Integer.MAX_VALUE) return ma;
return Math.min(ma, mb);
}
private static int max(Collection<Integer> a) {
assert a != null;
if (a.size() == 0) return -1;
if (a == null || a.size() == 0) return Integer.MIN_VALUE;
Iterator<Integer> i = a.iterator();
if (a.size() == 1) return i.next();
if (a.size() == 2) return Math.max(i.next(), i.next());
@ -73,8 +75,7 @@ public abstract class AbstractReference implements Reference {
}
private static int min(Collection<Integer> a) {
assert a != null;
if (a.size() == 0) return -1;
if (a == null || a.size() == 0) return Integer.MAX_VALUE;
Iterator<Integer> i = a.iterator();
if (a.size() == 1) return i.next();
if (a.size() == 2) return Math.min(i.next(), i.next());
@ -82,18 +83,16 @@ public abstract class AbstractReference implements Reference {
int s;
while (i.hasNext()) {
s = i.next();
if (s <r) r = s;
if (s < r) r = s;
}
return r;
}
public int maxposition() {
assert positions().size() > 0;
return max(positions());
}
public int minposition() {
assert positions().size() > 0;
return min(positions());
}

@ -136,15 +136,17 @@ public final class SetTools {
@SuppressWarnings("unchecked")
private static <A, B> SortedMap<A, B> joinConstructiveByTest(final SortedMap<A, B> small, final SortedMap<A, B> large, final boolean concatStrings) {
final Iterator<Map.Entry<A, B>> mi = small.entrySet().iterator();
final SortedMap<A, B> result = new TreeMap<A, B>(large.comparator());
synchronized (mi) {
synchronized (small) {
final Iterator<Map.Entry<A, B>> mi = small.entrySet().iterator();
Map.Entry<A, B> mentry1;
B mobj2;
loop: while (mi.hasNext()) {
try {
mentry1 = mi.next();
mobj2 = large.get(mentry1.getKey());
synchronized (large) {
mobj2 = large.get(mentry1.getKey());
}
if (mobj2 != null) {
if (mentry1.getValue() instanceof String) {
result.put(mentry1.getKey(), (B) ((concatStrings) ? (mentry1.getValue() + (String) mobj2) : mentry1.getValue()));

Loading…
Cancel
Save