diff --git a/source/de/anomic/index/indexURLEntry.java b/source/de/anomic/index/indexURLEntry.java index 04f17d790..01a4c809a 100644 --- a/source/de/anomic/index/indexURLEntry.java +++ b/source/de/anomic/index/indexURLEntry.java @@ -37,13 +37,19 @@ import de.anomic.index.indexEntryAttribute; import de.anomic.index.indexAbstractEntry; import de.anomic.index.indexURL; import de.anomic.kelondro.kelondroBase64Order; +import de.anomic.kelondro.kelondroColumn; +import de.anomic.kelondro.kelondroRow; import de.anomic.plasma.plasmaWordIndex; public final class indexURLEntry extends indexAbstractEntry implements Cloneable, indexEntry { - // an wordEntry can be filled in either of two ways: - // by the discrete values of the entry - // or by the encoded entry-string + public static kelondroRow urlEntryRow = new kelondroRow(new kelondroColumn[]{ + new kelondroColumn( + "nickname", + kelondroColumn.celltype_undefined, 4 /*cellwidth*/, + kelondroColumn.encoder_none, 0, + "description") + }); // the class instantiation can only be done by a plasmaStore method // therefore they are all public diff --git a/source/de/anomic/kelondro/kelondroColumn.java b/source/de/anomic/kelondro/kelondroColumn.java index 72d82f6ef..2024c6129 100644 --- a/source/de/anomic/kelondro/kelondroColumn.java +++ b/source/de/anomic/kelondro/kelondroColumn.java @@ -36,12 +36,20 @@ public class kelondroColumn { public static final int celltype_cardinal = 4; public static final int celltype_real = 5; - private int celltype, cellwidth; + public static final int encoder_none = 0; + public static final int encoder_b64e = 1; + public static final int encoder_string = 2; + public static final int encoder_bytes = 3; + public static final int encoder_char = 4; + + private int celltype, cellwidth, encoder, encodedwidth; private String nickname, description; - public kelondroColumn(int celltype, int cellwidth, String nickname, String description) { + public kelondroColumn(String nickname, int celltype, int cellwidth, int encoder, int encodedwidth, String description) { this.celltype = celltype; this.cellwidth = cellwidth; + this.encoder = encoder; + this.encodedwidth = encodedwidth; this.nickname = nickname; this.description = description; } @@ -54,6 +62,14 @@ public class kelondroColumn { return this.cellwidth; } + public int encoder() { + return this.encoder; + } + + public int encodedwidth() { + return this.encodedwidth; + } + public String nickname() { return this.nickname; } diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.java index c45cc71fc..f6b90fb01 100644 --- a/source/de/anomic/kelondro/kelondroRow.java +++ b/source/de/anomic/kelondro/kelondroRow.java @@ -28,19 +28,11 @@ package de.anomic.kelondro; import java.io.UnsupportedEncodingException; -import java.util.HashMap; public class kelondroRow { - - public static final int encoder_b64e = 0; - public static final int encoder_string = 1; - public static final int encoder_bytes = 2; - public static final int encoder_char = 3; - - + private kelondroColumn[] row; protected int[] colstart; - private HashMap encodedFormConfiguration; private int encodedFormLength; private int objectsize; @@ -48,25 +40,26 @@ public class kelondroRow { this.row = row; this.colstart = new int[row.length]; this.objectsize = 0; + this.encodedFormLength = 0; for (int i = 0; i < row.length; i++) { this.colstart[i] = this.objectsize; - this.objectsize += row[i].cellwidth(); + this.objectsize += this.row[i].cellwidth(); + this.encodedFormLength += this.row[i].encodedwidth(); } - this.encodedFormConfiguration = null; - this.encodedFormLength = -1; + } - public kelondroRow(int[] row) { - this.row = new kelondroColumn[row.length]; - this.colstart = new int[row.length]; + public kelondroRow(int[] rowi) { + this.row = new kelondroColumn[rowi.length]; + this.colstart = new int[rowi.length]; this.objectsize = 0; - for (int i = 0; i < row.length; i++) { - this.row[i] = new kelondroColumn(kelondroColumn.celltype_undefined, row[i], "col_" + i, ""); + this.encodedFormLength = 0; + for (int i = 0; i < rowi.length; i++) { + this.row[i] = new kelondroColumn("col_" + i, kelondroColumn.celltype_undefined, rowi[i], kelondroColumn.encoder_none, rowi[i], ""); this.colstart[i] = this.objectsize; - this.objectsize += row[i]; + this.objectsize += this.row[i].cellwidth(); + this.encodedFormLength += this.row[i].encodedwidth(); } - this.encodedFormConfiguration = null; - this.encodedFormLength = -1; } public int columns() { @@ -87,27 +80,6 @@ public class kelondroRow { return w; } - private static int encoderCode(String encoderName) { - if (encoderName.equals("b54e")) return encoder_b64e; - if (encoderName.equals("string")) return encoder_string; - if (encoderName.equals("char")) return encoder_char; - return -1; - } - - public void configureEncodedForm(String[][] configuration) { - encodedFormConfiguration = new HashMap(); - String nick; - int encoder, length; - this.encodedFormLength = 0; - for (int i = 0; i < configuration.length; i++) { - nick = configuration[i][0]; - encoder = encoderCode(configuration[i][1]); - length = Integer.parseInt(configuration[i][2]); - encodedFormConfiguration.put(nick, new int[]{encoder, length}); - this.encodedFormLength += length; - } - } - public Entry newEntry() { return new Entry(); } @@ -194,26 +166,6 @@ public class kelondroRow { kelondroBase64Order.enhancedCoder.encodeLong(cell, rowinstance, colstart[column], row[column].cellwidth()); } - /* - public byte[][] getCols() { - byte[][] values = new byte[row.length][]; - - int length, offset; - for (int i = 0; i < row.length; i++) { - length = row[i].cellwidth(); - offset = colstart[i]; - while ((length > 0) && (rowinstance[offset + length - 1] == 0)) length--; - if (length == 0) { - values[i] = null; - } else { - values[i] = new byte[length]; - System.arraycopy(rowinstance, offset, values[i], 0, length); - } - } - - return values; - } - */ public String getColString(int column, String encoding) { int length = row[column].cellwidth(); int offset = colstart[column]; @@ -251,31 +203,29 @@ public class kelondroRow { public byte[] toEncodedBytesForm() { byte[] b = new byte[encodedFormLength]; - int[] format; - int encoder, length; + int encoder, encodedwidth; int p = 0; for (int i = 0; i < row.length; i++) { - format = (int[]) encodedFormConfiguration.get(row[i].nickname()); - encoder = format[0]; - length = format[1]; + encoder = row[i].encoder(); + encodedwidth = row[i].encodedwidth(); switch (row[i].celltype()) { case kelondroColumn.celltype_undefined: throw new kelondroException("ROW", "toEncodedForm of celltype undefined not possible"); case kelondroColumn.celltype_boolean: throw new kelondroException("ROW", "toEncodedForm of celltype boolean not yet implemented"); case kelondroColumn.celltype_binary: - System.arraycopy(rowinstance, colstart[i], b, p, length); - p += length; + System.arraycopy(rowinstance, colstart[i], b, p, encodedwidth); + p += encodedwidth; continue; case kelondroColumn.celltype_string: - System.arraycopy(rowinstance, colstart[i], b, p, length); - p += length; + System.arraycopy(rowinstance, colstart[i], b, p, encodedwidth); + p += encodedwidth; continue; case kelondroColumn.celltype_cardinal: - if (encoder == encoder_b64e) { + if (encoder == kelondroColumn.encoder_b64e) { long c = bytes2long(rowinstance, colstart[i]); - System.arraycopy(kelondroBase64Order.enhancedCoder.encodeLongSmart(c, length).getBytes(), 0, b, p, length); - p += length; + System.arraycopy(kelondroBase64Order.enhancedCoder.encodeLongSmart(c, encodedwidth).getBytes(), 0, b, p, encodedwidth); + p += encodedwidth; continue; } throw new kelondroException("ROW", "toEncodedForm of celltype cardinal has no encoder (" + encoder + ")"); diff --git a/source/de/anomic/yacy/yacyNewsDB.java b/source/de/anomic/yacy/yacyNewsDB.java index 8d5333d67..f1069f5a7 100644 --- a/source/de/anomic/yacy/yacyNewsDB.java +++ b/source/de/anomic/yacy/yacyNewsDB.java @@ -83,11 +83,11 @@ public class yacyNewsDB { } public static final kelondroRow rowdef = new kelondroRow(new kelondroColumn[]{ - new kelondroColumn(kelondroColumn.celltype_string, yacyNewsRecord.idLength(), "newsid", "id = created + originator"), - new kelondroColumn(kelondroColumn.celltype_string, yacyNewsRecord.categoryStringLength, "category", ""), - new kelondroColumn(kelondroColumn.celltype_string, yacyCore.universalDateShortPattern.length(), "received", ""), - new kelondroColumn(kelondroColumn.celltype_string, 2, "", ""), - new kelondroColumn(kelondroColumn.celltype_string, attributesMaxLength, "", ""), + new kelondroColumn("newsid", kelondroColumn.celltype_string, yacyNewsRecord.idLength(), kelondroColumn.encoder_string, yacyNewsRecord.idLength(), "id = created + originator"), + new kelondroColumn("category", kelondroColumn.celltype_string, yacyNewsRecord.categoryStringLength, kelondroColumn.encoder_string, yacyNewsRecord.categoryStringLength, ""), + new kelondroColumn("received", kelondroColumn.celltype_string, yacyCore.universalDateShortPattern.length(), kelondroColumn.encoder_string, yacyCore.universalDateShortPattern.length(), ""), + new kelondroColumn("", kelondroColumn.celltype_string, 2, kelondroColumn.encoder_string, 2, ""), + new kelondroColumn("", kelondroColumn.celltype_string, attributesMaxLength, kelondroColumn.encoder_string, attributesMaxLength, ""), }); private static kelondroTree createDB(File path, int bufferkb) { @@ -184,18 +184,6 @@ public class yacyNewsDB { ); } - /* - private static yacyNewsRecord b2r(byte[][] b) { - if (b == null) return null; - return new yacyNewsRecord( - new String(b[0]), - new String(b[1]), - (b[2] == null) ? null : yacyCore.parseUniversalDate(new String(b[2]), serverDate.UTCDiffString()), - (int) kelondroBase64Order.enhancedCoder.decodeLong(new String(b[3])), - serverCodings.string2map(new String(b[4])) - ); - } -*/ private kelondroRow.Entry r2b(yacyNewsRecord r) { if (r == null) return null; String attributes = r.attributes().toString(); diff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.java index 212dd2f29..e2dd96d65 100644 --- a/source/de/anomic/yacy/yacyNewsQueue.java +++ b/source/de/anomic/yacy/yacyNewsQueue.java @@ -77,8 +77,8 @@ public class yacyNewsQueue { } public static final kelondroRow rowdef = new kelondroRow(new kelondroColumn[]{ - new kelondroColumn(kelondroColumn.celltype_string, yacyNewsRecord.idLength(), "newsid", "id = created + originator"), - new kelondroColumn(kelondroColumn.celltype_string, yacyCore.universalDateShortPattern.length(), "last touched", "") + new kelondroColumn("newsid", kelondroColumn.celltype_string, yacyNewsRecord.idLength(), kelondroColumn.encoder_string, yacyNewsRecord.idLength(), "id = created + originator"), + new kelondroColumn("last touched", kelondroColumn.celltype_string, yacyCore.universalDateShortPattern.length(), kelondroColumn.encoder_string, yacyCore.universalDateShortPattern.length(), "") }); private static kelondroStack createStack(File path) {