Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

less memory usage during collectionIndex-rebuild should also speed up that process a little bit

orbiter847349358bac
diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.java
index c54c03da6..97616a4f4 100644
--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java
+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java
@@ -174,11 +174,10 @@ public class kelondroCollectionIndex {
key = aentry.getColBytes(0);
assert (key != null);
if (key == null) continue; // skip deleted entries
- kelondroRowSet indexrows = new kelondroRowSet(this.payloadrow, aentry.getColBytes(1));
ientry = irow.newEntry();
ientry.setCol(idx_col_key, key);
ientry.setCol(idx_col_chunksize, chunksize);
- ientry.setCol(idx_col_chunkcount, indexrows.size());
+ ientry.setCol(idx_col_chunkcount, kelondroRowCollection.sizeOfExportedCollectionRows(this.payloadrow, aentry.getColBytes(1)));
ientry.setCol(idx_col_clusteridx, (byte) partitionNumber);
ientry.setCol(idx_col_flags, (byte) 0);
ientry.setCol(idx_col_indexpos, aentry.index());
diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.java
index d8a59bd40..a1d6402e5 100644
--- a/source/de/anomic/kelondro/kelondroRow.java
+++ b/source/de/anomic/kelondro/kelondroRow.java
@@ -138,6 +138,35 @@ public class kelondroRow {
return new String(s);
}
+ public long getColLong(byte[] rowinstance, int column) {
+ // uses the column definition to choose the right encoding
+ return getColLong(rowinstance, row[column].encoder(), colstart[column], row[column].cellwidth());
+ }
+
+ protected static final long getColLong(byte[] rowinstance, int encoder, int offset, int length) {
+ // start - fix for badly stored parameters
+ if ((length >= 3) && (rowinstance[offset] == '[') && (rowinstance[offset + 1] == 'B') && (rowinstance[offset + 2] == '@')) return 0;
+ if ((length == 2) && (rowinstance[offset] == '[') && (rowinstance[offset + 1] == 'B')) return 0;
+ if ((length == 1) && (rowinstance[offset] == '[')) return 0;
+ // stop - fix for badly stored parameters
+ switch (encoder) {
+ case kelondroColumn.encoder_none:
+ throw new kelondroException("ROW", "getColLong has celltype none, no encoder given");
+ case kelondroColumn.encoder_b64e:
+ // start - fix for badly stored parameters
+ boolean maxvalue = true;
+ for (int i = 0; i < length; i++) if (rowinstance[offset + i] != '_') {maxvalue = false; break;}
+ if (maxvalue) return 0;
+ // stop - fix for badly stored parameters
+ return kelondroBase64Order.enhancedCoder.decodeLong(rowinstance, offset, length);
+ case kelondroColumn.encoder_b256:
+ return kelondroNaturalOrder.decodeLong(rowinstance, offset, length);
+ case kelondroColumn.encoder_bytes:
+ throw new kelondroException("ROW", "getColLong of celltype bytes not applicable");
+ }
+ throw new kelondroException("ROW", "getColLong did not find appropriate encoding");
+ }
+
public Entry newEntry() {
return new Entry();
}
@@ -405,36 +434,12 @@ public class kelondroRow {
if (ref == null) return dflt;
kelondroColumn col = (kelondroColumn) ref[0];
int colstart = ((Integer) ref[1]).intValue();
- return getColLong(col.encoder(), colstart, col.cellwidth());
+ return kelondroRow.getColLong(rowinstance, col.encoder(), colstart, col.cellwidth());
}
public long getColLong(int column) {
// uses the column definition to choose the right encoding
- return getColLong(row[column].encoder(), colstart[column], row[column].cellwidth());
- }
-
- private long getColLong(int encoder, int offset, int length) {
- // start - fix for badly stored parameters
- if ((length >= 3) && (rowinstance[offset] == '[') && (rowinstance[offset + 1] == 'B') && (rowinstance[offset + 2] == '@')) return 0;
- if ((length == 2) && (rowinstance[offset] == '[') && (rowinstance[offset + 1] == 'B')) return 0;
- if ((length == 1) && (rowinstance[offset] == '[')) return 0;
- // stop - fix for badly stored parameters
- switch (encoder) {
- case kelondroColumn.encoder_none:
- throw new kelondroException("ROW", "getColLong has celltype none, no encoder given");
- case kelondroColumn.encoder_b64e:
- // start - fix for badly stored parameters
- boolean maxvalue = true;
- for (int i = 0; i < length; i++) if (rowinstance[offset + i] != '_') {maxvalue = false; break;}
- if (maxvalue) return 0;
- // stop - fix for badly stored parameters
- return kelondroBase64Order.enhancedCoder.decodeLong(rowinstance, offset, length);
- case kelondroColumn.encoder_b256:
- return kelondroNaturalOrder.decodeLong(rowinstance, offset, length);
- case kelondroColumn.encoder_bytes:
- throw new kelondroException("ROW", "getColLong of celltype bytes not applicable");
- }
- throw new kelondroException("ROW", "getColLong did not find appropriate encoding");
+ return kelondroRow.getColLong(rowinstance, row[column].encoder(), colstart[column], row[column].cellwidth());
}
public byte getColByte(String nickname, byte dflt) {
diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.java
index ac689083a..d7920cb9d 100644
--- a/source/de/anomic/kelondro/kelondroRowCollection.java
+++ b/source/de/anomic/kelondro/kelondroRowCollection.java
@@ -113,13 +113,20 @@ public class kelondroRowCollection {
this.chunkcache = exportedCollection.getColBytes(exp_collection);
}
+ private static final kelondroRow exportMeasureRow = exportRow(0 /* no relevance */);
+
+ protected static final int sizeOfExportedCollectionRows(kelondroRow rowdef, byte[] exportedCollectionRowinstance) {
+ int chunkcount = (int) exportMeasureRow.getColLong(exportedCollectionRowinstance, exp_chunkcount);
+ return chunkcount;
+ }
+
private static final long day = 1000 * 60 * 60 * 24;
public static int daysSince2000(long time) {
return (int) (time / day) - 10957;
}
- private kelondroRow exportRow(int chunkcachelength) {
+ private static kelondroRow exportRow(int chunkcachelength) {
// find out the size of this collection
return new kelondroRow(
"int size-4 {b256}," +