|
|
@ -1,4 +1,4 @@
|
|
|
|
// rwilist_p
|
|
|
|
// termlist_p
|
|
|
|
// ------------
|
|
|
|
// ------------
|
|
|
|
// (C) 2011 by Michael Peter Christen; mc@yacy.net
|
|
|
|
// (C) 2011 by Michael Peter Christen; mc@yacy.net
|
|
|
|
// first published 25.08.2011 on http://yacy.net
|
|
|
|
// first published 25.08.2011 on http://yacy.net
|
|
|
@ -29,7 +29,8 @@ import net.yacy.cora.document.encoding.ASCII;
|
|
|
|
import net.yacy.cora.protocol.RequestHeader;
|
|
|
|
import net.yacy.cora.protocol.RequestHeader;
|
|
|
|
import net.yacy.cora.sorting.Rating;
|
|
|
|
import net.yacy.cora.sorting.Rating;
|
|
|
|
import net.yacy.cora.util.ConcurrentLog;
|
|
|
|
import net.yacy.cora.util.ConcurrentLog;
|
|
|
|
import net.yacy.kelondro.index.Row;
|
|
|
|
import net.yacy.kelondro.data.word.WordReference;
|
|
|
|
|
|
|
|
import net.yacy.kelondro.rwi.IndexCell;
|
|
|
|
import net.yacy.search.Switchboard;
|
|
|
|
import net.yacy.search.Switchboard;
|
|
|
|
import net.yacy.search.index.Segment;
|
|
|
|
import net.yacy.search.index.Segment;
|
|
|
|
import net.yacy.server.serverObjects;
|
|
|
|
import net.yacy.server.serverObjects;
|
|
|
@ -46,51 +47,53 @@ public class termlist_p {
|
|
|
|
Segment segment = sb.index;
|
|
|
|
Segment segment = sb.index;
|
|
|
|
final boolean delete = post != null && post.containsKey("delete");
|
|
|
|
final boolean delete = post != null && post.containsKey("delete");
|
|
|
|
final long mincount = post == null ? 10000 : post.getLong("mincount", 10000);
|
|
|
|
final long mincount = post == null ? 10000 : post.getLong("mincount", 10000);
|
|
|
|
final Iterator<Rating<byte[]>> i = segment.termIndex().referenceCountIterator(null, false, false);
|
|
|
|
|
|
|
|
Rating<byte[]> e;
|
|
|
|
Rating<byte[]> e;
|
|
|
|
int c = 0, termnumber = 0;
|
|
|
|
int c = 0, termnumber = 0;
|
|
|
|
byte[] termhash, maxterm = null;
|
|
|
|
byte[] termhash, maxterm = null;
|
|
|
|
long count, mem, maxcount = 0, totalmemory = 0;
|
|
|
|
long count, mem, maxcount = 0, totalmemory = 0;
|
|
|
|
String hstring;
|
|
|
|
String hstring;
|
|
|
|
final Row referenceRow = segment.termIndex().referenceRow();
|
|
|
|
|
|
|
|
final int rowsize = referenceRow.objectsize;
|
|
|
|
|
|
|
|
final ArrayList<byte[]> deleteterms = new ArrayList<byte[]>();
|
|
|
|
final ArrayList<byte[]> deleteterms = new ArrayList<byte[]>();
|
|
|
|
long over1000 = 0, over10000 = 0, over100000 = 0, over1000000 = 0, over10000000 = 0, over100000000 = 0;
|
|
|
|
long over1000 = 0, over10000 = 0, over100000 = 0, over1000000 = 0, over10000000 = 0, over100000000 = 0;
|
|
|
|
while (i.hasNext()) {
|
|
|
|
|
|
|
|
e = i.next();
|
|
|
|
final IndexCell<WordReference> termIndex = segment.termIndex();
|
|
|
|
termnumber++;
|
|
|
|
int rowsize = 0;
|
|
|
|
count = e.getScore();
|
|
|
|
if(termIndex != null) {
|
|
|
|
if (count >= 1000) over1000++;
|
|
|
|
rowsize = termIndex.referenceRow().objectsize;
|
|
|
|
if (count >= 10000) over10000++;
|
|
|
|
final Iterator<Rating<byte[]>> i = termIndex.referenceCountIterator(null, false, false);
|
|
|
|
if (count >= 100000) over100000++;
|
|
|
|
while (i.hasNext()) {
|
|
|
|
if (count >= 1000000) over1000000++;
|
|
|
|
e = i.next();
|
|
|
|
if (count >= 10000000) over10000000++;
|
|
|
|
termnumber++;
|
|
|
|
if (count >= 100000000) over100000000++;
|
|
|
|
count = e.getScore();
|
|
|
|
if (count > maxcount) {
|
|
|
|
if (count >= 1000) over1000++;
|
|
|
|
maxcount = count;
|
|
|
|
if (count >= 10000) over10000++;
|
|
|
|
maxterm = e.getObject();
|
|
|
|
if (count >= 100000) over100000++;
|
|
|
|
}
|
|
|
|
if (count >= 1000000) over1000000++;
|
|
|
|
if (count < mincount) continue;
|
|
|
|
if (count >= 10000000) over10000000++;
|
|
|
|
termhash = e.getObject();
|
|
|
|
if (count >= 100000000) over100000000++;
|
|
|
|
if (delete) deleteterms.add(termhash);
|
|
|
|
if (count > maxcount) {
|
|
|
|
hstring = ASCII.String(termhash);
|
|
|
|
maxcount = count;
|
|
|
|
mem = 20 + count * rowsize;
|
|
|
|
maxterm = e.getObject();
|
|
|
|
prop.put("terms_" + c + "_termhash", hstring);
|
|
|
|
}
|
|
|
|
prop.put("terms_" + c + "_count", count);
|
|
|
|
if (count < mincount) continue;
|
|
|
|
prop.put("terms_" + c + "_memory", mem);
|
|
|
|
termhash = e.getObject();
|
|
|
|
//log.logWarning("termhash: " + hstring + " | count: " + count + " | memory: " + mem);
|
|
|
|
if (delete) deleteterms.add(termhash);
|
|
|
|
c++;
|
|
|
|
hstring = ASCII.String(termhash);
|
|
|
|
totalmemory += mem;
|
|
|
|
mem = 20 + count * rowsize;
|
|
|
|
}
|
|
|
|
prop.put("terms_" + c + "_termhash", hstring);
|
|
|
|
if (delete) {
|
|
|
|
prop.put("terms_" + c + "_count", count);
|
|
|
|
for (final byte[] t: deleteterms) {
|
|
|
|
prop.put("terms_" + c + "_memory", mem);
|
|
|
|
try {
|
|
|
|
c++;
|
|
|
|
segment.termIndex().delete(t);
|
|
|
|
totalmemory += mem;
|
|
|
|
} catch (final IOException e1) {
|
|
|
|
}
|
|
|
|
log.warn("Error deleting " + ASCII.String(t), e1);
|
|
|
|
if (delete) {
|
|
|
|
e1.printStackTrace();
|
|
|
|
for (final byte[] t: deleteterms) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
}
|
|
|
|
termIndex.delete(t);
|
|
|
|
|
|
|
|
} catch (final IOException e1) {
|
|
|
|
|
|
|
|
log.warn("Error deleting " + ASCII.String(t), e1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prop.put("terms", c);
|
|
|
|
prop.put("terms", c);
|
|
|
|
prop.put("maxterm", maxterm == null ? "" : ASCII.String(maxterm));
|
|
|
|
prop.put("maxterm", maxterm == null ? "" : ASCII.String(maxterm));
|
|
|
|