Skip to content

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

removed support for old database structures. The new collection index will be more generalized to support other indexes i.e. YBR block-rank computation. A clean-up of the many conditions to support the old database was necessary.

orbiter2cb16824e388
diff --git a/build.properties b/build.properties
index 6901ca457..fe66b69c2 100644
--- a/build.properties
+++ b/build.properties
@@ -3,11 +3,11 @@ javacSource=1.4
javacTarget=1.4
# Release Configuration
-releaseVersion=0.51
-#releaseFile=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
-releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
-#releaseDir=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}
-releaseDir=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}
+releaseVersion=0.511
+releaseFile=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
+#releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
+releaseDir=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}
+#releaseDir=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}
releaseFileParentDir=yacy
releaseNr=$Revision$
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index 74d50fc04..5cb9329fb 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -52,7 +52,6 @@ import java.util.List;
import de.anomic.http.httpHeader;
import de.anomic.index.indexRWIEntry;
-import de.anomic.index.indexRWIEntryNew;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.urlPattern.plasmaURLPattern;
import de.anomic.server.serverCore;
@@ -163,7 +162,7 @@ public final class transferRWI {
}
wordHash = estring.substring(0, p);
wordhashes[received] = wordHash;
- iEntry = new indexRWIEntryNew(estring.substring(p));
+ iEntry = new indexRWIEntry(estring.substring(p));
urlHash = iEntry.urlHash();
// block blacklisted entries
diff --git a/source/de/anomic/index/indexContainer.java b/source/de/anomic/index/indexContainer.java
index eaa1f3194..968b310fe 100644
--- a/source/de/anomic/index/indexContainer.java
+++ b/source/de/anomic/index/indexContainer.java
@@ -103,7 +103,7 @@ public class indexContainer extends kelondroRowSet {
assert entry.toKelondroEntry().objectsize() == super.rowdef.objectsize();
kelondroRow.Entry r = super.put(entry.toKelondroEntry());
if (r == null) return null;
- return new indexRWIEntryNew(r);
+ return new indexRWIEntry(r);
}
public boolean putRecent(indexRWIEntry entry) {
@@ -113,7 +113,7 @@ public class indexContainer extends kelondroRowSet {
if (oldEntryRow == null) {
return true;
} else {
- indexRWIEntry oldEntry = new indexRWIEntryNew(oldEntryRow);
+ indexRWIEntry oldEntry = new indexRWIEntry(oldEntryRow);
if (entry.isOlder(oldEntry)) { // A more recent Entry is already in this container
this.put(oldEntry.toKelondroEntry()); // put it back
return false;
@@ -145,13 +145,13 @@ public class indexContainer extends kelondroRowSet {
public indexRWIEntry get(String urlHash) {
kelondroRow.Entry entry = this.get(urlHash.getBytes());
if (entry == null) return null;
- return new indexRWIEntryNew(entry);
+ return new indexRWIEntry(entry);
}
public indexRWIEntry remove(String urlHash) {
kelondroRow.Entry entry = this.remove(urlHash.getBytes());
if (entry == null) return null;
- return new indexRWIEntryNew(entry);
+ return new indexRWIEntry(entry);
}
public boolean removeEntry(String wordHash, String urlHash) {
@@ -187,7 +187,7 @@ public class indexContainer extends kelondroRowSet {
public Object next() {
kelondroRow.Entry rentry = (kelondroRow.Entry) rowEntryIterator.next();
if (rentry == null) return null;
- return new indexRWIEntryNew(rentry);
+ return new indexRWIEntry(rentry);
}
public void remove() {
diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.java
index f24befe30..7cf6bc78b 100644
--- a/source/de/anomic/index/indexRAMRI.java
+++ b/source/de/anomic/index/indexRAMRI.java
@@ -212,7 +212,7 @@ public final class indexRAMRI implements indexRI {
if ((row == null) || (row.empty(0)) || (row.empty(3))) continue;
wordHash = row.getColString(0, "UTF-8");
//creationTime = kelondroRecords.bytes2long(row[2]);
- wordEntry = new indexRWIEntryNew(row.getColBytes(3));
+ wordEntry = new indexRWIEntry(row.getColBytes(3));
// store to cache
addEntry(wordHash, wordEntry, startTime, false);
urlCount++;
diff --git a/source/de/anomic/index/indexRWIEntry.java b/source/de/anomic/index/indexRWIEntry.java
index 003b0379c..7f9b4162a 100644
--- a/source/de/anomic/index/indexRWIEntry.java
+++ b/source/de/anomic/index/indexRWIEntry.java
@@ -26,41 +26,350 @@
package de.anomic.index;
-import de.anomic.kelondro.kelondroRow;
+import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroBitfield;
+import de.anomic.kelondro.kelondroColumn;
+import de.anomic.kelondro.kelondroRow;
+import de.anomic.kelondro.kelondroRow.Entry;
+import de.anomic.plasma.plasmaWordIndex;
+import de.anomic.yacy.yacySeedDB;
+
+public class indexRWIEntry implements Cloneable {
+
+ // this object stores attributes to URL references inside RWI collections
+
+
+ public static kelondroRow urlEntryRow = new kelondroRow(new kelondroColumn[]{
+ new kelondroColumn("h", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacySeedDB.commonHashLength, "urlhash"),
+ new kelondroColumn("a", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "lastModified"),
+ new kelondroColumn("s", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "freshUntil"),
+ new kelondroColumn("u", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "wordsInTitle"),
+ new kelondroColumn("w", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "wordsInText"),
+ new kelondroColumn("p", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "phrasesInText"),
+ new kelondroColumn("d", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "doctype"),
+ new kelondroColumn("l", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, 2, "language"),
+ new kelondroColumn("x", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "llocal"),
+ new kelondroColumn("y", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "lother"),
+ new kelondroColumn("m", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlLength"),
+ new kelondroColumn("n", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlComps"),
+ new kelondroColumn("g", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "typeofword"),
+ new kelondroColumn("z", kelondroColumn.celltype_bitfield, kelondroColumn.encoder_bytes, 4, "flags"),
+ new kelondroColumn("c", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "hitcount"),
+ new kelondroColumn("t", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "posintext"),
+ new kelondroColumn("r", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "posinphrase"),
+ new kelondroColumn("o", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "posofphrase"),
+ new kelondroColumn("i", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "worddistance"),
+ new kelondroColumn("k", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "reserve")
+ },
+ kelondroBase64Order.enhancedCoder,
+ 0);
+ // available chars: b,e,j,q
+
+ // static properties
+ private static final int col_urlhash = 0; // h 12 the url hash b64-encoded
+ private static final int col_lastModified = 1; // a 2 last-modified time of the document where word appears
+ private static final int col_freshUntil = 2; // s 2 TTL for the word, so it can be removed easily if the TTL is short
+ private static final int col_wordsInTitle = 3; // u 1 words in description/length (longer are better?)
+ private static final int col_wordsInText = 4; // w 2 total number of words in document
+ private static final int col_phrasesInText = 5; // p 2 total number of phrases in document
+ private static final int col_doctype = 6; // d 1 type of document
+ private static final int col_language = 7; // l 2 (guessed) language of document
+ private static final int col_llocal = 8; // x 1 outlinks to same domain
+ private static final int col_lother = 9; // y 1 outlinks to other domain
+ private static final int col_urlLength = 10; // m 1 byte-length of complete URL
+ private static final int col_urlComps = 11; // n 1 number of path components
-public interface indexRWIEntry {
-
- public Object clone();
- public String toPropertyForm();
- public kelondroRow.Entry toKelondroEntry();
-
- public String urlHash();
- public int quality();
- public int virtualAge();
- public long lastModified();
- public int hitcount();
- public int posintext();
- public int posinphrase();
- public int posofphrase();
- public int wordsintext();
- public int phrasesintext();
- public String getLanguage();
- public char getType();
- public kelondroBitfield flags();
- public int wordsintitle();
- public int llocal();
- public int lother();
- public int urllength();
- public int urlcomps();
-
- public void combineDistance(indexRWIEntry oe);
- public int worddistance();
- public void min(indexRWIEntry other);
- public void max(indexRWIEntry other);
- public void normalize(indexRWIEntry min, indexRWIEntry max);
- public indexRWIEntry generateNormalized(indexRWIEntry min, indexRWIEntry max);
- public boolean isNewer(indexRWIEntry other);
- public boolean isOlder(indexRWIEntry other);
+ // dynamic properties
+ private static final int col_typeofword = 12; // g 1 grammatical classification
+ private static final int col_flags = 13; // z 4 b64-encoded appearance flags (24 bit, see definition below)
+ private static final int col_hitcount = 14; // c 1 number of occurrences of this word in text
+ private static final int col_posintext = 15; // t 2 first appearance of word in text
+ private static final int col_posinphrase = 16; // r 1 position of word in its phrase
+ private static final int col_posofphrase = 17; // o 1 number of the phrase where word appears
+ private static final int col_worddistance = 18; // i 1 initial zero; may be used as reserve: is filled during search
+ private static final int col_reserve = 19; // k 1 reserve
+
+ // appearance flags, used in RWI entry
+ // the flags 0..23 are identical to the category flags in plasmaCondenser
+ public static final int flag_app_url = 24; // word appears in url
+ public static final int flag_app_descr = 25; // word appears in headline (or any description part)
+ public static final int flag_app_author = 26; // word appears in author
+ public static final int flag_app_tags = 27; // word appears in header tags
+ public static final int flag_app_reference = 28; // word appears in anchor description text (the reference to an url), or any alternative text field of a link
+ public static final int flag_app_emphasized = 29; // word is emphasized in text (i.e. bold, italics, special size)
-}
+ private kelondroRow.Entry entry;
+
+ public indexRWIEntry(String urlHash,
+ int urlLength, // byte-length of complete URL
+ int urlComps, // number of path components
+ int titleLength, // length of description/length (longer are better?)
+ int hitcount, // how often appears this word in the text
+ int wordcount, // total number of words
+ int phrasecount, // total number of phrases
+ int posintext, // position of word in all words
+ int posinphrase, // position of word in its phrase
+ int posofphrase, // number of the phrase where word appears
+ int worddistance, // word distance; this is 0 by default, and set to the difference of posintext from two indexes if these are combined (simultanous search). If stored, this shows that the result was obtained by remote search
+ int sizeOfPage, // # of bytes of the page TODO: not needed any more
+ long lastmodified, // last-modified time of the document where word appears
+ long updatetime, // update time; this is needed to compute a TTL for the word, so it can be removed easily if the TTL is short
+ String language, // (guessed) language of document
+ char doctype, // type of document
+ int outlinksSame, // outlinks to same domain
+ int outlinksOther, // outlinks to other domain
+ kelondroBitfield flags // attributes to the url and to the word according the url
+ ) {
+
+ assert (urlHash.length() == 12) : "urlhash = " + urlHash;
+ if ((language == null) || (language.length() != urlEntryRow.width(col_language))) language = "uk";
+ this.entry = urlEntryRow.newEntry();
+ int mddlm = plasmaWordIndex.microDateDays(lastmodified);
+ int mddct = plasmaWordIndex.microDateDays(updatetime);
+ this.entry.setCol(col_urlhash, urlHash, null);
+ this.entry.setCol(col_lastModified, mddlm);
+ this.entry.setCol(col_freshUntil, Math.max(0, mddlm + (mddct - mddlm) * 2)); // TTL computation
+ this.entry.setCol(col_wordsInTitle, titleLength / 6); // word count estimation; TODO: change value handover to number of words
+ this.entry.setCol(col_wordsInText, wordcount);
+ this.entry.setCol(col_phrasesInText, phrasecount);
+ this.entry.setCol(col_doctype, new byte[]{(byte) doctype});
+ this.entry.setCol(col_language, language, null);
+ this.entry.setCol(col_llocal, outlinksSame);
+ this.entry.setCol(col_lother, outlinksOther);
+ this.entry.setCol(col_urlLength, urlLength);
+ this.entry.setCol(col_urlComps, urlComps);
+ this.entry.setCol(col_typeofword, new byte[]{(byte) 0}); // TODO: grammatical classification
+ this.entry.setCol(col_flags, flags.bytes());
+ this.entry.setCol(col_hitcount, hitcount);
+ this.entry.setCol(col_posintext, posintext);
+ this.entry.setCol(col_posinphrase, posinphrase);
+ this.entry.setCol(col_posofphrase, posofphrase);
+ this.entry.setCol(col_worddistance, worddistance);
+ this.entry.setCol(col_reserve, 0);
+ }
+
+ public indexRWIEntry(String urlHash, String code) {
+ // the code is the external form of the row minus the leading urlHash entry
+ this.entry = urlEntryRow.newEntry((urlHash + code).getBytes());
+ }
+
+ public indexRWIEntry(String external) {
+ this.entry = urlEntryRow.newEntry(external, true);
+ }
+
+ public indexRWIEntry(byte[] row) {
+ this.entry = urlEntryRow.newEntry(row);
+ }
+
+ public indexRWIEntry(kelondroRow.Entry rentry) {
+ // FIXME: see if cloning is necessary
+ this.entry = rentry;
+ }
+
+ public static int days(long time) {
+ // calculates the number of days since 1.1.1970 and returns this as 4-byte array
+ return (int) (time / 86400000);
+ }
+
+ public Object clone() {
+ byte[] b = new byte[urlEntryRow.objectsize()];
+ System.arraycopy(entry.bytes(), 0, b, 0, urlEntryRow.objectsize());
+ return new indexRWIEntry(b);
+ }
+
+ public String toPropertyForm() {
+ return entry.toPropertyForm(true, true, false);
+ }
+
+ public Entry toKelondroEntry() {
+ return this.entry;
+ }
+
+ public String urlHash() {
+ return this.entry.getColString(col_urlhash, null);
+ }
+
+ public int quality() {
+ return 0; // not used any more
+ }
+
+ public int virtualAge() {
+ return plasmaWordIndex.microDateDays(lastModified());
+ }
+
+ public long lastModified() {
+ return plasmaWordIndex.reverseMicroDateDays((int) this.entry.getColLong(col_lastModified));
+ }
+
+ public long freshUntil() {
+ return plasmaWordIndex.reverseMicroDateDays((int) this.entry.getColLong(col_freshUntil));
+ }
+
+ public int hitcount() {
+ return (int) this.entry.getColLong(col_hitcount);
+ }
+
+ public int posintext() {
+ return (int) this.entry.getColLong(col_posintext);
+ }
+
+ public int posinphrase() {
+ return (int) this.entry.getColLong(col_posinphrase);
+ }
+
+ public int posofphrase() {
+ return (int) this.entry.getColLong(col_posofphrase);
+ }
+
+ public int wordsintext() {
+ return (int) this.entry.getColLong(col_wordsInText);
+ }
+
+ public int phrasesintext() {
+ return (int) this.entry.getColLong(col_phrasesInText);
+ }
+
+ public String getLanguage() {
+ return this.entry.getColString(col_language, null);
+ }
+
+ public char getType() {
+ return (char) this.entry.getColByte(col_doctype);
+ }
+
+ public int wordsintitle() {
+ return (int) this.entry.getColLong(col_wordsInTitle);
+ }
+
+ public int llocal() {
+ return (int) this.entry.getColLong(col_llocal);
+ }
+
+ public int lother() {
+ return (int) this.entry.getColLong(col_lother);
+ }
+
+ public int urllength() {
+ return (int) this.entry.getColLong(col_urlLength);
+ }
+
+ public int urlcomps() {
+ return (int) this.entry.getColLong(col_urlComps);
+ }
+
+ public kelondroBitfield flags() {
+ return new kelondroBitfield(this.entry.getColBytes(col_flags));
+ }
+
+ public String toString() {
+ return toPropertyForm();
+ }
+
+ public static indexRWIEntry combineDistance(indexRWIEntry ie1, indexRWIEntry ie2) {
+ // returns a modified entry of the first argument
+ ie1.entry.setCol(col_worddistance, ie1.worddistance() + ie2.worddistance() + Math.abs(ie1.posintext() - ie2.posintext()));
+ ie1.entry.setCol(col_posintext, Math.min(ie1.posintext(), ie2.posintext()));
+ ie1.entry.setCol(col_posinphrase, (ie1.posofphrase() == ie2.posofphrase()) ? ie1.posofphrase() : 0 /*unknown*/);
+ ie1.entry.setCol(col_posofphrase, Math.min(ie1.posofphrase(), ie2.posofphrase()));
+ ie1.entry.setCol(col_wordsInText, (ie1.wordsintext() + ie2.wordsintext()) / 2);
+ return ie1;
+ }
+
+ public void combineDistance(indexRWIEntry oe) {
+ combineDistance(this, oe);
+ }
+
+ public int worddistance() {
+ return (int) this.entry.getColLong(col_worddistance);
+ }
+
+ public static final void min(indexRWIEntry t, indexRWIEntry other) {
+ if (t.hitcount() > other.hitcount()) t.entry.setCol(col_hitcount, other.hitcount());
+ if (t.wordsintext() > other.wordsintext()) t.entry.setCol(col_wordsInText, other.wordsintext());
+ if (t.phrasesintext() > other.phrasesintext()) t.entry.setCol(col_phrasesInText, other.phrasesintext());
+ if (t.posintext() > other.posintext()) t.entry.setCol(col_posintext, other.posintext());
+ if (t.posinphrase() > other.posinphrase()) t.entry.setCol(col_posinphrase, other.posinphrase());
+ if (t.posofphrase() > other.posofphrase()) t.entry.setCol(col_posofphrase, other.posofphrase());
+ if (t.worddistance() > other.worddistance()) t.entry.setCol(col_worddistance, other.worddistance());
+ if (t.lastModified() > other.lastModified()) t.entry.setCol(col_lastModified, other.lastModified());
+ if (t.urllength() > other.urllength()) t.entry.setCol(col_urlLength, other.urllength());
+ if (t.urlcomps() > other.urlcomps()) t.entry.setCol(col_urlComps, other.urlcomps());
+ if (t.wordsintitle() > other.wordsintitle() ) t.entry.setCol(col_wordsInTitle, other.wordsintitle());
+ }
+
+ public static final void max(indexRWIEntry t, indexRWIEntry other) {
+ if (t.hitcount() < other.hitcount()) t.entry.setCol(col_hitcount, other.hitcount());
+ if (t.wordsintext() < other.wordsintext()) t.entry.setCol(col_wordsInText, other.wordsintext());
+ if (t.phrasesintext() < other.phrasesintext()) t.entry.setCol(col_phrasesInText, other.phrasesintext());
+ if (t.posintext() < other.posintext()) t.entry.setCol(col_posintext, other.posintext());
+ if (t.posinphrase() < other.posinphrase()) t.entry.setCol(col_posinphrase, other.posinphrase());
+ if (t.posofphrase() < other.posofphrase()) t.entry.setCol(col_posofphrase, other.posofphrase());
+ if (t.worddistance() < other.worddistance()) t.entry.setCol(col_worddistance, other.worddistance());
+ if (t.lastModified() < other.lastModified()) t.entry.setCol(col_lastModified, other.lastModified());
+ if (t.urllength() < other.urllength()) t.entry.setCol(col_urlLength, other.urllength());
+ if (t.urlcomps() < other.urlcomps()) t.entry.setCol(col_urlComps, other.urlcomps());
+ if (t.wordsintitle() < other.wordsintitle() ) t.entry.setCol(col_wordsInTitle, other.wordsintitle());
+ }
+
+
+ public void min(indexRWIEntry other) {
+ min(this, other);
+ }
+
+ public void max(indexRWIEntry other) {
+ max(this, other);
+ }
+
+ static void normalize(indexRWIEntry t, indexRWIEntry min, indexRWIEntry max) {
+ assert (t.urlHash().length() == 12) : "turlhash = " + t.urlHash();
+ assert (min.urlHash().length() == 12) : "minurlhash = " + min.urlHash();
+ assert (max.urlHash().length() == 12) : "maxurlhash = " + max.urlHash();
+ if (1 + max.worddistance() - min.worddistance() == 0) System.out.println("min = " + min.toPropertyForm() + "\nmax=" + max.toPropertyForm());
+ //System.out.println("Normalize:\nentry = " + t.toPropertyForm(true));
+ //System.out.println("min = " + min.toPropertyForm(true));
+ //System.out.println("max = " + max.toPropertyForm(true));
+ t.entry.setCol(col_hitcount , (t.hitcount() == 0) ? 0 : 1 + 255 * (t.hitcount() - min.hitcount() ) / (1 + max.hitcount() - min.hitcount()));
+ t.entry.setCol(col_wordsInText , (t.wordsintext() == 0) ? 0 : 1 + 255 * (t.wordsintext() - min.wordsintext() ) / (1 + max.wordsintext() - min.wordsintext()));
+ t.entry.setCol(col_phrasesInText, (t.phrasesintext() == 0) ? 0 : 1 + 255 * (t.phrasesintext() - min.phrasesintext() ) / (1 + max.phrasesintext() - min.phrasesintext()));
+ t.entry.setCol(col_posintext , (t.posintext() == 0) ? 0 : 1 + 255 * (t.posintext() - min.posintext() ) / (1 + max.posintext() - min.posintext()));
+ t.entry.setCol(col_posinphrase , (t.posinphrase() == 0) ? 0 : 1 + 255 * (t.posinphrase() - min.posinphrase() ) / (1 + max.posinphrase() - min.posinphrase()));
+ t.entry.setCol(col_posofphrase , (t.posofphrase() == 0) ? 0 : 1 + 255 * (t.posofphrase() - min.posofphrase() ) / (1 + max.posofphrase() - min.posofphrase()));
+ t.entry.setCol(col_worddistance , (t.worddistance() == 0) ? 0 : 1 + 255 * (t.worddistance() - min.worddistance()) / (1 + max.worddistance() - min.worddistance())); // FIXME: hier gibts ein division by zero, was nur sein kann wenn die Normalisierung nicht geklappt hat.
+ t.entry.setCol(col_lastModified , (t.lastModified() == 0) ? 0 : 1 + 255 * (t.lastModified() - min.lastModified()) / (1 + max.lastModified() - min.lastModified()));
+ t.entry.setCol(col_urlLength , (t.urllength() == 0) ? 0 : 1 + 255 * (t.urllength() - min.urllength() ) / (1 + max.urllength() - min.urllength()));
+ t.entry.setCol(col_urlComps , (t.urlcomps() == 0) ? 0 : 1 + 255 * (t.urlcomps() - min.urlcomps() ) / (1 + max.urlcomps() - min.urlcomps()));
+ t.entry.setCol(col_wordsInTitle , (t.wordsintitle() == 0) ? 0 : 1 + 255 * (t.wordsintitle() - min.wordsintitle()) / (1 + max.wordsintitle() - min.wordsintitle()));
+
+ //System.out.println("out = " + t.toPropertyForm(true));
+ }
+
+ public void normalize(indexRWIEntry min, indexRWIEntry max) {
+ normalize(this, min, max);
+ }
+
+ public indexRWIEntry generateNormalized(indexRWIEntry min, indexRWIEntry max) {
+ assert (this.urlHash().length() == 12) : "this.urlhash = " + this.urlHash();
+ indexRWIEntry e = (indexRWIEntry) this.clone();
+ e.normalize(min, max);
+ return e;
+ }
+
+ public boolean isNewer(indexRWIEntry other) {
+ if (other == null) return true;
+ if (this.lastModified() > other.lastModified()) return true;
+ if (this.lastModified() == other.lastModified()) {
+ if (this.quality() > other.quality()) return true;
+ }
+ return false;
+ }
+
+ public boolean isOlder(indexRWIEntry other) {
+ if (other == null) return false;
+ if (this.lastModified() < other.lastModified()) return true;
+ if (this.lastModified() == other.lastModified()) {
+ if (this.quality() < other.quality()) return true;
+ }
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/source/de/anomic/index/indexRWIEntryNew.java b/source/de/anomic/index/indexRWIEntryNew.java
deleted file mode 100644
index 17c6c633f..000000000
--- a/source/de/anomic/index/indexRWIEntryNew.java
+++ /dev/null
@@ -1,406 +0,0 @@
-// indexRWIEntryNew.java
-// (C) 2006 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
-// first published 17.11.2006 on http://www.anomic.de
-//
-// This is a part of YaCy, a peer-to-peer based web search engine
-//
-// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
-// $LastChangedRevision: 1986 $
-// $LastChangedBy: orbiter $
-//
-// LICENSE
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-package de.anomic.index;
-
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroColumn;
-import de.anomic.kelondro.kelondroException;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRow.Entry;
-import de.anomic.plasma.plasmaURL;
-import de.anomic.plasma.plasmaWordIndex;
-import de.anomic.yacy.yacySeedDB;
-
-public class indexRWIEntryNew implements Cloneable, indexRWIEntry {
-
- // this object stores attributes to URL references inside RWI collections
-
-
- public static kelondroRow urlEntryRow = new kelondroRow(new kelondroColumn[]{
- new kelondroColumn("h", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacySeedDB.commonHashLength, "urlhash"),
- new kelondroColumn("a", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "lastModified"),
- new kelondroColumn("s", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "freshUntil"),
- new kelondroColumn("u", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "wordsInTitle"),
- new kelondroColumn("w", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "wordsInText"),
- new kelondroColumn("p", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "phrasesInText"),
- new kelondroColumn("d", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "doctype"),
- new kelondroColumn("l", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, 2, "language"),
- new kelondroColumn("x", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "llocal"),
- new kelondroColumn("y", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "lother"),
- new kelondroColumn("m", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlLength"),
- new kelondroColumn("n", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "urlComps"),
- new kelondroColumn("g", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "typeofword"),
- new kelondroColumn("z", kelondroColumn.celltype_bitfield, kelondroColumn.encoder_bytes, 4, "flags"),
- new kelondroColumn("c", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "hitcount"),
- new kelondroColumn("t", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "posintext"),
- new kelondroColumn("r", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "posinphrase"),
- new kelondroColumn("o", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "posofphrase"),
- new kelondroColumn("i", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "worddistance"),
- new kelondroColumn("k", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 1, "reserve")
- },
- kelondroBase64Order.enhancedCoder,
- 0);
- // available chars: b,e,j,q
-
- // static properties
- private static final int col_urlhash = 0; // h 12 the url hash b64-encoded
- private static final int col_lastModified = 1; // a 2 last-modified time of the document where word appears
- private static final int col_freshUntil = 2; // s 2 TTL for the word, so it can be removed easily if the TTL is short
- private static final int col_wordsInTitle = 3; // u 1 words in description/length (longer are better?)
- private static final int col_wordsInText = 4; // w 2 total number of words in document
- private static final int col_phrasesInText = 5; // p 2 total number of phrases in document
- private static final int col_doctype = 6; // d 1 type of document
- private static final int col_language = 7; // l 2 (guessed) language of document
- private static final int col_llocal = 8; // x 1 outlinks to same domain
- private static final int col_lother = 9; // y 1 outlinks to other domain
- private static final int col_urlLength = 10; // m 1 byte-length of complete URL
- private static final int col_urlComps = 11; // n 1 number of path components
-
- // dynamic properties
- private static final int col_typeofword = 12; // g 1 grammatical classification
- private static final int col_flags = 13; // z 4 b64-encoded appearance flags (24 bit, see definition below)
- private static final int col_hitcount = 14; // c 1 number of occurrences of this word in text
- private static final int col_posintext = 15; // t 2 first appearance of word in text
- private static final int col_posinphrase = 16; // r 1 position of word in its phrase
- private static final int col_posofphrase = 17; // o 1 number of the phrase where word appears
- private static final int col_worddistance = 18; // i 1 initial zero; may be used as reserve: is filled during search
- private static final int col_reserve = 19; // k 1 reserve
-
- // appearance flags, used in RWI entry
- // the flags 0..23 are identical to the category flags in plasmaCondenser
- public static final int flag_app_url = 24; // word appears in url
- public static final int flag_app_descr = 25; // word appears in headline (or any description part)
- public static final int flag_app_author = 26; // word appears in author
- public static final int flag_app_tags = 27; // word appears in header tags
- public static final int flag_app_reference = 28; // word appears in anchor description text (the reference to an url), or any alternative text field of a link
- public static final int flag_app_emphasized = 29; // word is emphasized in text (i.e. bold, italics, special size)
-
- private kelondroRow.Entry entry;
-
- public indexRWIEntryNew(String urlHash,
- int urlLength, // byte-length of complete URL
- int urlComps, // number of path components
- int titleLength, // length of description/length (longer are better?)
- int hitcount, // how often appears this word in the text
- int wordcount, // total number of words
- int phrasecount, // total number of phrases
- int posintext, // position of word in all words
- int posinphrase, // position of word in its phrase
- int posofphrase, // number of the phrase where word appears
- int worddistance, // word distance; this is 0 by default, and set to the difference of posintext from two indexes if these are combined (simultanous search). If stored, this shows that the result was obtained by remote search
- int sizeOfPage, // # of bytes of the page TODO: not needed any more
- long lastmodified, // last-modified time of the document where word appears
- long updatetime, // update time; this is needed to compute a TTL for the word, so it can be removed easily if the TTL is short
- String language, // (guessed) language of document
- char doctype, // type of document
- int outlinksSame, // outlinks to same domain
- int outlinksOther, // outlinks to other domain
- kelondroBitfield flags // attributes to the url and to the word according the url
- ) {
-
- assert (urlHash.length() == 12) : "urlhash = " + urlHash;
- if ((language == null) || (language.length() != urlEntryRow.width(col_language))) language = "uk";
- this.entry = urlEntryRow.newEntry();
- int mddlm = plasmaWordIndex.microDateDays(lastmodified);
- int mddct = plasmaWordIndex.microDateDays(updatetime);
- this.entry.setCol(col_urlhash, urlHash, null);
- this.entry.setCol(col_lastModified, mddlm);
- this.entry.setCol(col_freshUntil, Math.max(0, mddlm + (mddct - mddlm) * 2)); // TTL computation
- this.entry.setCol(col_wordsInTitle, titleLength / 6); // word count estimation; TODO: change value handover to number of words
- this.entry.setCol(col_wordsInText, wordcount);
- this.entry.setCol(col_phrasesInText, phrasecount);
- this.entry.setCol(col_doctype, new byte[]{(byte) doctype});
- this.entry.setCol(col_language, language, null);
- this.entry.setCol(col_llocal, outlinksSame);
- this.entry.setCol(col_lother, outlinksOther);
- this.entry.setCol(col_urlLength, urlLength);
- this.entry.setCol(col_urlComps, urlComps);
- this.entry.setCol(col_typeofword, new byte[]{(byte) 0}); // TODO: grammatical classification
- this.entry.setCol(col_flags, flags.bytes());
- this.entry.setCol(col_hitcount, hitcount);
- this.entry.setCol(col_posintext, posintext);
- this.entry.setCol(col_posinphrase, posinphrase);
- this.entry.setCol(col_posofphrase, posofphrase);
- this.entry.setCol(col_worddistance, worddistance);
- this.entry.setCol(col_reserve, 0);
- }
-
- public indexRWIEntryNew(indexRWIEntryOld oldEntry) throws kelondroException {
- if (oldEntry.urlHash() == null) throw new kelondroException("hash is null");
- if (oldEntry.urlHash().length() != 12) throw new kelondroException("hash has wrong length");
- this.entry = urlEntryRow.newEntry();
- int mddlm = plasmaWordIndex.microDateDays(oldEntry.lastModified());
- this.entry.setCol(col_urlhash, oldEntry.urlHash(), null);
- this.entry.setCol(col_lastModified, mddlm);
- this.entry.setCol(col_freshUntil, 0);
- this.entry.setCol(col_wordsInTitle, 20); // guessed
- this.entry.setCol(col_wordsInText, oldEntry.wordsintext());
- this.entry.setCol(col_phrasesInText, oldEntry.phrasesintext());
- this.entry.setCol(col_doctype, new byte[]{(byte) oldEntry.doctype()});
- this.entry.setCol(col_language, (oldEntry.getLanguage() == null) ? "en" : oldEntry.getLanguage(), null);
- this.entry.setCol(col_llocal, 0);
- this.entry.setCol(col_lother, 0);
- int domlen = plasmaURL.domLengthEstimation(oldEntry.urlHash());
- this.entry.setCol(col_urlLength, domlen * 2); // estimated
- this.entry.setCol(col_urlComps, domlen / 3); // estimated
- this.entry.setCol(col_typeofword, new byte[]{(byte) 0});
- this.entry.setCol(col_flags, (new kelondroBitfield(4)).bytes());
- this.entry.setCol(col_hitcount, oldEntry.hitcount());
- this.entry.setCol(col_posintext, oldEntry.posintext());
- this.entry.setCol(col_posinphrase, oldEntry.posinphrase());
- this.entry.setCol(col_posofphrase, oldEntry.posofphrase());
- this.entry.setCol(col_worddistance, oldEntry.worddistance());
- this.entry.setCol(col_reserve, 0);
- }
-
- public indexRWIEntryNew(String urlHash, String code) {
- // the code is the external form of the row minus the leading urlHash entry
- this.entry = urlEntryRow.newEntry((urlHash + code).getBytes());
- }
-
- public indexRWIEntryNew(String external) {
- this.entry = urlEntryRow.newEntry(external, true);
- }
-
- public indexRWIEntryNew(byte[] row) {
- this.entry = urlEntryRow.newEntry(row);
- }
-
- public indexRWIEntryNew(kelondroRow.Entry rentry) {
- // FIXME: see if cloning is necessary
- this.entry = rentry;
- }
-
- public static int days(long time) {
- // calculates the number of days since 1.1.1970 and returns this as 4-byte array
- return (int) (time / 86400000);
- }
-
- public Object clone() {
- byte[] b = new byte[urlEntryRow.objectsize()];
- System.arraycopy(entry.bytes(), 0, b, 0, urlEntryRow.objectsize());
- return new indexRWIEntryNew(b);
- }
-
- public String toPropertyForm() {
- return entry.toPropertyForm(true, true, false);
- }
-
- public Entry toKelondroEntry() {
- return this.entry;
- }
-
- public String urlHash() {
- return this.entry.getColString(col_urlhash, null);
- }
-
- public int quality() {
- return 0; // not used any more
- }
-
- public int virtualAge() {
- return plasmaWordIndex.microDateDays(lastModified());
- }
-
- public long lastModified() {
- return plasmaWordIndex.reverseMicroDateDays((int) this.entry.getColLong(col_lastModified));
- }
-
- public long freshUntil() {
- return plasmaWordIndex.reverseMicroDateDays((int) this.entry.getColLong(col_freshUntil));
- }
-
- public int hitcount() {
- return (int) this.entry.getColLong(col_hitcount);
- }
-
- public int posintext() {
- return (int) this.entry.getColLong(col_posintext);
- }
-
- public int posinphrase() {
- return (int) this.entry.getColLong(col_posinphrase);
- }
-
- public int posofphrase() {
- return (int) this.entry.getColLong(col_posofphrase);
- }
-
- public int wordsintext() {
- return (int) this.entry.getColLong(col_wordsInText);
- }
-
- public int phrasesintext() {
- return (int) this.entry.getColLong(col_phrasesInText);
- }
-
- public String getLanguage() {
- return this.entry.getColString(col_language, null);
- }
-
- public char getType() {
- return (char) this.entry.getColByte(col_doctype);
- }
-
- public int wordsintitle() {
- return (int) this.entry.getColLong(col_wordsInTitle);
- }
-
- public int llocal() {
- return (int) this.entry.getColLong(col_llocal);
- }
-
- public int lother() {
- return (int) this.entry.getColLong(col_lother);
- }
-
- public int urllength() {
- return (int) this.entry.getColLong(col_urlLength);
- }
-
- public int urlcomps() {
- return (int) this.entry.getColLong(col_urlComps);
- }
-
- public kelondroBitfield flags() {
- return new kelondroBitfield(this.entry.getColBytes(col_flags));
- }
-
- public String toString() {
- return toPropertyForm();
- }
-
- public static indexRWIEntryNew combineDistance(indexRWIEntryNew ie1, indexRWIEntry ie2) {
- // returns a modified entry of the first argument
- ie1.entry.setCol(col_worddistance, ie1.worddistance() + ie2.worddistance() + Math.abs(ie1.posintext() - ie2.posintext()));
- ie1.entry.setCol(col_posintext, Math.min(ie1.posintext(), ie2.posintext()));
- ie1.entry.setCol(col_posinphrase, (ie1.posofphrase() == ie2.posofphrase()) ? ie1.posofphrase() : 0 /*unknown*/);
- ie1.entry.setCol(col_posofphrase, Math.min(ie1.posofphrase(), ie2.posofphrase()));
- ie1.entry.setCol(col_wordsInText, (ie1.wordsintext() + ie2.wordsintext()) / 2);
- return ie1;
- }
-
- public void combineDistance(indexRWIEntry oe) {
- combineDistance(this, oe);
- }
-
- public int worddistance() {
- return (int) this.entry.getColLong(col_worddistance);
- }
-
- public static final void min(indexRWIEntryNew t, indexRWIEntry other) {
- if (t.hitcount() > other.hitcount()) t.entry.setCol(col_hitcount, other.hitcount());
- if (t.wordsintext() > other.wordsintext()) t.entry.setCol(col_wordsInText, other.wordsintext());
- if (t.phrasesintext() > other.phrasesintext()) t.entry.setCol(col_phrasesInText, other.phrasesintext());
- if (t.posintext() > other.posintext()) t.entry.setCol(col_posintext, other.posintext());
- if (t.posinphrase() > other.posinphrase()) t.entry.setCol(col_posinphrase, other.posinphrase());
- if (t.posofphrase() > other.posofphrase()) t.entry.setCol(col_posofphrase, other.posofphrase());
- if (t.worddistance() > other.worddistance()) t.entry.setCol(col_worddistance, other.worddistance());
- if (t.lastModified() > other.lastModified()) t.entry.setCol(col_lastModified, other.lastModified());
- if (t.urllength() > other.urllength()) t.entry.setCol(col_urlLength, other.urllength());
- if (t.urlcomps() > other.urlcomps()) t.entry.setCol(col_urlComps, other.urlcomps());
- if (t.wordsintitle() > other.wordsintitle() ) t.entry.setCol(col_wordsInTitle, other.wordsintitle());
- }
-
- public static final void max(indexRWIEntryNew t, indexRWIEntry other) {
- if (t.hitcount() < other.hitcount()) t.entry.setCol(col_hitcount, other.hitcount());
- if (t.wordsintext() < other.wordsintext()) t.entry.setCol(col_wordsInText, other.wordsintext());
- if (t.phrasesintext() < other.phrasesintext()) t.entry.setCol(col_phrasesInText, other.phrasesintext());
- if (t.posintext() < other.posintext()) t.entry.setCol(col_posintext, other.posintext());
- if (t.posinphrase() < other.posinphrase()) t.entry.setCol(col_posinphrase, other.posinphrase());
- if (t.posofphrase() < other.posofphrase()) t.entry.setCol(col_posofphrase, other.posofphrase());
- if (t.worddistance() < other.worddistance()) t.entry.setCol(col_worddistance, other.worddistance());
- if (t.lastModified() < other.lastModified()) t.entry.setCol(col_lastModified, other.lastModified());
- if (t.urllength() < other.urllength()) t.entry.setCol(col_urlLength, other.urllength());
- if (t.urlcomps() < other.urlcomps()) t.entry.setCol(col_urlComps, other.urlcomps());
- if (t.wordsintitle() < other.wordsintitle() ) t.entry.setCol(col_wordsInTitle, other.wordsintitle());
- }
-
-
- public void min(indexRWIEntry other) {
- min(this, other);
- }
-
- public void max(indexRWIEntry other) {
- max(this, other);
- }
-
- static void normalize(indexRWIEntryNew t, indexRWIEntry min, indexRWIEntry max) {
- assert (t.urlHash().length() == 12) : "turlhash = " + t.urlHash();
- assert (min.urlHash().length() == 12) : "minurlhash = " + min.urlHash();
- assert (max.urlHash().length() == 12) : "maxurlhash = " + max.urlHash();
- if (1 + max.worddistance() - min.worddistance() == 0) System.out.println("min = " + min.toPropertyForm() + "\nmax=" + max.toPropertyForm());
- //System.out.println("Normalize:\nentry = " + t.toPropertyForm(true));
- //System.out.println("min = " + min.toPropertyForm(true));
- //System.out.println("max = " + max.toPropertyForm(true));
- t.entry.setCol(col_hitcount , (t.hitcount() == 0) ? 0 : 1 + 255 * (t.hitcount() - min.hitcount() ) / (1 + max.hitcount() - min.hitcount()));
- t.entry.setCol(col_wordsInText , (t.wordsintext() == 0) ? 0 : 1 + 255 * (t.wordsintext() - min.wordsintext() ) / (1 + max.wordsintext() - min.wordsintext()));
- t.entry.setCol(col_phrasesInText, (t.phrasesintext() == 0) ? 0 : 1 + 255 * (t.phrasesintext() - min.phrasesintext() ) / (1 + max.phrasesintext() - min.phrasesintext()));
- t.entry.setCol(col_posintext , (t.posintext() == 0) ? 0 : 1 + 255 * (t.posintext() - min.posintext() ) / (1 + max.posintext() - min.posintext()));
- t.entry.setCol(col_posinphrase , (t.posinphrase() == 0) ? 0 : 1 + 255 * (t.posinphrase() - min.posinphrase() ) / (1 + max.posinphrase() - min.posinphrase()));
- t.entry.setCol(col_posofphrase , (t.posofphrase() == 0) ? 0 : 1 + 255 * (t.posofphrase() - min.posofphrase() ) / (1 + max.posofphrase() - min.posofphrase()));
- t.entry.setCol(col_worddistance , (t.worddistance() == 0) ? 0 : 1 + 255 * (t.worddistance() - min.worddistance()) / (1 + max.worddistance() - min.worddistance())); // FIXME: hier gibts ein division by zero, was nur sein kann wenn die Normalisierung nicht geklappt hat.
- t.entry.setCol(col_lastModified , (t.lastModified() == 0) ? 0 : 1 + 255 * (t.lastModified() - min.lastModified()) / (1 + max.lastModified() - min.lastModified()));
- t.entry.setCol(col_urlLength , (t.urllength() == 0) ? 0 : 1 + 255 * (t.urllength() - min.urllength() ) / (1 + max.urllength() - min.urllength()));
- t.entry.setCol(col_urlComps , (t.urlcomps() == 0) ? 0 : 1 + 255 * (t.urlcomps() - min.urlcomps() ) / (1 + max.urlcomps() - min.urlcomps()));
- t.entry.setCol(col_wordsInTitle , (t.wordsintitle() == 0) ? 0 : 1 + 255 * (t.wordsintitle() - min.wordsintitle()) / (1 + max.wordsintitle() - min.wordsintitle()));
-
- //System.out.println("out = " + t.toPropertyForm(true));
- }
-
- public void normalize(indexRWIEntry min, indexRWIEntry max) {
- normalize(this, min, max);
- }
-
- public indexRWIEntry generateNormalized(indexRWIEntry min, indexRWIEntry max) {
- assert (this.urlHash().length() == 12) : "this.urlhash = " + this.urlHash();
- indexRWIEntryNew e = (indexRWIEntryNew) this.clone();
- e.normalize(min, max);
- return e;
- }
-
- public boolean isNewer(indexRWIEntry other) {
- if (other == null) return true;
- if (this.lastModified() > other.lastModified()) return true;
- if (this.lastModified() == other.lastModified()) {
- if (this.quality() > other.quality()) return true;
- }
- return false;
- }
-
- public boolean isOlder(indexRWIEntry other) {
- if (other == null) return false;
- if (this.lastModified() < other.lastModified()) return true;
- if (this.lastModified() == other.lastModified()) {
- if (this.quality() < other.quality()) return true;
- }
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/source/de/anomic/index/indexRWIEntryOld.java b/source/de/anomic/index/indexRWIEntryOld.java
deleted file mode 100644
index 5e41e1824..000000000
--- a/source/de/anomic/index/indexRWIEntryOld.java
+++ /dev/null
@@ -1,332 +0,0 @@
-// indexRWIEntryOld.java
-// (C) 2006 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
-// first published 17.11.2006 on http://www.anomic.de
-//
-// This is a part of YaCy, a peer-to-peer based web search engine
-//
-// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
-// $LastChangedRevision: 1986 $
-// $LastChangedBy: orbiter $
-//
-// LICENSE
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-package de.anomic.index;
-
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroColumn;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroRow.Entry;
-import de.anomic.plasma.plasmaSearchQuery;
-import de.anomic.plasma.plasmaWordIndex;
-import de.anomic.yacy.yacySeedDB;
-
-public class indexRWIEntryOld implements Cloneable, indexRWIEntry {
-
- // this object stores attributes to URL references inside RWI collections
-
-
- public static kelondroRow urlEntryRow = new kelondroRow(new kelondroColumn[]{
- new kelondroColumn("h", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacySeedDB.commonHashLength, "urlhash"),
- new kelondroColumn("q", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 3, "quality"),
- new kelondroColumn("a", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 3, "lastModified"),
- new kelondroColumn("c", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "hitcount"),
- new kelondroColumn("l", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, 2, "language"),
- new kelondroColumn("d", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "doctype"),
- new kelondroColumn("f", kelondroColumn.celltype_binary, kelondroColumn.encoder_bytes, 1, "localflag"),
- new kelondroColumn("t", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "posintext"),
- new kelondroColumn("r", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "posinphrase"),
- new kelondroColumn("o", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "posofphrase"),
- new kelondroColumn("i", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "worddistance"),
- new kelondroColumn("w", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "wordcount"),
- new kelondroColumn("p", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b64e, 2, "phrasecount")
- },
- kelondroBase64Order.enhancedCoder,
- 0);
-
- private static final int col_urlhash = 0;
- private static final int col_quality = 1;
- private static final int col_lastModified = 2;
- private static final int col_hitcount = 3;
- private static final int col_language = 4;
- private static final int col_doctype = 5;
- //private static final int col_localflag = 6;
- private static final int col_posintext = 7;
- private static final int col_posinphrase = 8;
- private static final int col_posofphrase = 9;
- private static final int col_worddistance = 10;
- private static final int col_wordcount = 11;
- private static final int col_phrasecount = 12;
-
-
- private kelondroRow.Entry entry;
-
- /*
- public indexRWIEntryOld(String urlHash,
- int urlLength, // byte-length of complete URL
- int urlComps, // number of path components
- int titleLength, // length of description/length (longer are better?)
- int hitcount, //*how often appears this word in the text
- int wordcount, //*total number of words
- int phrasecount, //*total number of phrases
- int posintext, //*position of word in all words
- int posinphrase, //*position of word in its phrase
- int posofphrase, //*number of the phrase where word appears
- int worddistance, //*word distance; this is 0 by default, and set to the difference of posintext from two indexes if these are combined (simultanous search). If stored, this shows that the result was obtained by remote search
- int sizeOfPage, // # of bytes of the page
- long lastmodified, //*last-modified time of the document where word appears
- long updatetime, // update time; this is needed to compute a TTL for the word, so it can be removed easily if the TTL is short
- String language, //*(guessed) language of document
- char doctype, //*type of document
- int outlinksSame, // outlinks to same domain
- int outlinksOther,// outlinks to other domain
- boolean local //*flag shows that this index was generated locally; othervise its from a remote peer
- ) {
-
- // more needed attributes:
- // - boolean: appearance attributes: title, appears in header, anchor-descr, image-tag, hervorhebungen, meta-tags, word in link etc
- // - boolean: URL attributes
- assert (urlHash != null);
- assert (urlHash.length() == 12) : "urlhash = " + urlHash;
- if ((language == null) || (language.length() != urlEntryRow.width(col_language))) language = "uk";
- this.entry = urlEntryRow.newEntry();
- this.entry.setCol(col_urlhash, urlHash, null);
- this.entry.setCol(col_quality, 0);
- this.entry.setCol(col_lastModified, lastmodified);
- this.entry.setCol(col_hitcount, hitcount);
- this.entry.setCol(col_language, language, null);
- this.entry.setCol(col_doctype, new byte[]{(byte) doctype});
- this.entry.setCol(col_localflag, (byte) ((local) ? plasmaURL.LT_LOCAL : plasmaURL.LT_GLOBAL));
- this.entry.setCol(col_posintext, posintext);
- this.entry.setCol(col_posinphrase, posinphrase);
- this.entry.setCol(col_posofphrase, posofphrase);
- this.entry.setCol(col_worddistance, worddistance);
- this.entry.setCol(col_wordcount, wordcount);
- this.entry.setCol(col_phrasecount, phrasecount);
- //System.out.println("DEBUG-NEWENTRY " + toPropertyForm());
- }
-*/
- public indexRWIEntryOld(String urlHash, String code) {
- // the code is the external form of the row minus the leading urlHash entry
- this.entry = urlEntryRow.newEntry((urlHash + code).getBytes());
- }
-
- public indexRWIEntryOld(String external) {
- this.entry = urlEntryRow.newEntry(external, false);
- }
-
- public indexRWIEntryOld(byte[] row) {
- this.entry = urlEntryRow.newEntry(row);
- }
-
- public indexRWIEntryOld(kelondroRow.Entry rentry) {
- // FIXME: see if cloning is necessary
- this.entry = rentry;
- }
-
- public Object clone() {
- byte[] b = new byte[urlEntryRow.objectsize()];
- System.arraycopy(entry.bytes(), 0, b, 0, urlEntryRow.objectsize());
- return new indexRWIEntryOld(b);
- }
-
- public String toPropertyForm() {
- return entry.toPropertyForm(true, false, false);
- }
-
- public Entry toKelondroEntry() {
- return this.entry;
- }
-
- public String urlHash() {
- return this.entry.getColString(col_urlhash, null);
- }
-
- public int quality() {
- return (int) this.entry.getColLong(col_quality);
- }
-
- public char doctype() {
- return (char) this.entry.getColByte(col_doctype);
- }
-
- public int virtualAge() {
- return plasmaWordIndex.microDateDays(lastModified());
- }
-
- public long lastModified() {
- return (int) this.entry.getColLong(col_lastModified);
- }
-
- public int hitcount() {
- return (int) this.entry.getColLong(col_hitcount);
- }
-
- public int posintext() {
- return (int) this.entry.getColLong(col_posintext);
- }
-
- public int posinphrase() {
- return (int) this.entry.getColLong(col_posinphrase);
- }
-
- public int posofphrase() {
- return (int) this.entry.getColLong(col_posofphrase);
- }
-
- public int wordsintext() {
- return (int) this.entry.getColLong(col_wordcount);
- }
-
- public int phrasesintext() {
- return (int) this.entry.getColLong(col_phrasecount);
- }
-
- public String getLanguage() {
- return this.entry.getColString(col_language, null);
- }
-
- public char getType() {
- return (char) this.entry.getColByte(col_doctype);
- }
-
- public kelondroBitfield flags() {
- return plasmaSearchQuery.empty_constraint;
- }
-
- public static indexRWIEntryOld combineDistance(indexRWIEntryOld ie1, indexRWIEntry ie2) {
- // returns a modified entry of the first argument
- ie1.entry.setCol(col_worddistance, ie1.worddistance() + ie2.worddistance() + Math.abs(ie1.posintext() - ie2.posintext()));
- ie1.entry.setCol(col_posintext, Math.min(ie1.posintext(), ie2.posintext()));
- ie1.entry.setCol(col_posinphrase, (ie1.posofphrase() == ie2.posofphrase()) ? ie1.posofphrase() : 0 /*unknown*/);
- ie1.entry.setCol(col_posofphrase, Math.min(ie1.posofphrase(), ie2.posofphrase()));
- ie1.entry.setCol(col_wordcount, (ie1.wordsintext() + ie2.wordsintext()) / 2);
- return ie1;
- }
-
- public void combineDistance(indexRWIEntry oe) {
- combineDistance(this, oe);
- }
-
- public int worddistance() {
- return (int) this.entry.getColLong(col_worddistance);
- }
-
- public static final void min(indexRWIEntryOld t, indexRWIEntry other) {
- if (t.hitcount() > other.hitcount()) t.entry.setCol(col_hitcount, other.hitcount());
- if (t.wordsintext() > other.wordsintext()) t.entry.setCol(col_wordcount, other.wordsintext());
- if (t.phrasesintext() > other.phrasesintext()) t.entry.setCol(col_phrasecount, other.phrasesintext());
- if (t.posintext() > other.posintext()) t.entry.setCol(col_posintext, other.posintext());
- if (t.posinphrase() > other.posinphrase()) t.entry.setCol(col_posinphrase, other.posinphrase());
- if (t.posofphrase() > other.posofphrase()) t.entry.setCol(col_posofphrase, other.posofphrase());
- if (t.worddistance() > other.worddistance()) t.entry.setCol(col_worddistance, other.worddistance());
- if (t.lastModified() > other.lastModified()) t.entry.setCol(col_lastModified, other.lastModified());
- if (t.quality() > other.quality()) t.entry.setCol(col_quality, other.quality());
- }
-
- public static final void max(indexRWIEntryOld t, indexRWIEntry other) {
- if (t.hitcount() < other.hitcount()) t.entry.setCol(col_hitcount, other.hitcount());
- if (t.wordsintext() < other.wordsintext()) t.entry.setCol(col_wordcount, other.wordsintext());
- if (t.phrasesintext() < other.phrasesintext()) t.entry.setCol(col_phrasecount, other.phrasesintext());
- if (t.posintext() < other.posintext()) t.entry.setCol(col_posintext, other.posintext());
- if (t.posinphrase() < other.posinphrase()) t.entry.setCol(col_posinphrase, other.posinphrase());
- if (t.posofphrase() < other.posofphrase()) t.entry.setCol(col_posofphrase, other.posofphrase());
- if (t.worddistance() < other.worddistance()) t.entry.setCol(col_worddistance, other.worddistance());
- if (t.lastModified() < other.lastModified()) t.entry.setCol(col_lastModified, other.lastModified());
- if (t.quality() < other.quality()) t.entry.setCol(col_quality, other.quality());
- }
-
-
- public void min(indexRWIEntry other) {
- min(this, other);
- }
-
- public void max(indexRWIEntry other) {
- max(this, other);
- }
-
- static void normalize(indexRWIEntryOld t, indexRWIEntry min, indexRWIEntry max) {
- assert (t.urlHash().length() == 12) : "turlhash = " + t.urlHash();
- assert (min.urlHash().length() == 12) : "minurlhash = " + min.urlHash();
- assert (max.urlHash().length() == 12) : "maxurlhash = " + max.urlHash();
- if (1 + max.worddistance() - min.worddistance() == 0) System.out.println("min = " + min.toPropertyForm() + "\nmax=" + max.toPropertyForm());
- //System.out.println("Normalize:\nentry = " + t.toPropertyForm(true));
- //System.out.println("min = " + min.toPropertyForm(true));
- //System.out.println("max = " + max.toPropertyForm(true));
- t.entry.setCol(col_hitcount , (t.hitcount() == 0) ? 0 : 1 + 255 * (t.hitcount() - min.hitcount() ) / (1 + max.hitcount() - min.hitcount()));
- t.entry.setCol(col_wordcount , (t.wordsintext() == 0) ? 0 : 1 + 255 * (t.wordsintext() - min.wordsintext() ) / (1 + max.wordsintext() - min.wordsintext()));
- t.entry.setCol(col_phrasecount , (t.phrasesintext() == 0) ? 0 : 1 + 255 * (t.phrasesintext() - min.phrasesintext() ) / (1 + max.phrasesintext() - min.phrasesintext()));
- t.entry.setCol(col_posintext , (t.posintext() == 0) ? 0 : 1 + 255 * (t.posintext() - min.posintext() ) / (1 + max.posintext() - min.posintext()));
- t.entry.setCol(col_posinphrase , (t.posinphrase() == 0) ? 0 : 1 + 255 * (t.posinphrase() - min.posinphrase() ) / (1 + max.posinphrase() - min.posinphrase()));
- t.entry.setCol(col_posofphrase , (t.posofphrase() == 0) ? 0 : 1 + 255 * (t.posofphrase() - min.posofphrase() ) / (1 + max.posofphrase() - min.posofphrase()));
- t.entry.setCol(col_worddistance , (t.worddistance() == 0) ? 0 : 1 + 255 * (t.worddistance() - min.worddistance()) / (1 + max.worddistance() - min.worddistance())); // FIXME: hier gibts ein division by zero, was nur sein kann wenn die Normalisierung nicht geklappt hat.
- t.entry.setCol(col_lastModified , (t.lastModified() == 0) ? 0 : 1 + 255 * (t.lastModified() - min.lastModified()) / (1 + max.lastModified() - min.lastModified()));
- t.entry.setCol(col_quality , (t.quality() == 0) ? 0 : 1 + 255 * (t.quality() - min.quality() ) / (1 + max.quality() - min.quality()));
- //System.out.println("out = " + t.toPropertyForm(true));
- }
-
- public void normalize(indexRWIEntry min, indexRWIEntry max) {
- normalize(this, min, max);
- }
-
- public indexRWIEntry generateNormalized(indexRWIEntry min, indexRWIEntry max) {
- assert (this.urlHash().length() == 12) : "this.urlhash = " + this.urlHash();
- indexRWIEntryOld e = (indexRWIEntryOld) this.clone();
- e.normalize(min, max);
- return e;
- }
-
- public boolean isNewer(indexRWIEntry other) {
- if (other == null) return true;
- if (this.lastModified() > other.lastModified()) return true;
- if (this.lastModified() == other.lastModified()) {
- if (this.quality() > other.quality()) return true;
- }
- return false;
- }
-
- public boolean isOlder(indexRWIEntry other) {
- if (other == null) return false;
- if (this.lastModified() < other.lastModified()) return true;
- if (this.lastModified() == other.lastModified()) {
- if (this.quality() < other.quality()) return true;
- }
- return false;
- }
-
- public int llocal() {
- return 0;
- }
-
- public int lother() {
- return 0;
- }
-
- public int urlcomps() {
- return 0;
- }
-
- public int urllength() {
- return 0;
- }
-
- public int wordsintitle() {
- return 0;
- }
-
-}
diff --git a/source/de/anomic/index/indexURLEntry.java b/source/de/anomic/index/indexURLEntry.java
index 2192e24e8..f579dad1f 100644
--- a/source/de/anomic/index/indexURLEntry.java
+++ b/source/de/anomic/index/indexURLEntry.java
@@ -29,40 +29,396 @@ package de.anomic.index;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.text.ParseException;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.Properties;
+import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroBitfield;
+import de.anomic.kelondro.kelondroException;
+import de.anomic.kelondro.kelondroNaturalOrder;
import de.anomic.kelondro.kelondroRow;
import de.anomic.net.URL;
import de.anomic.plasma.plasmaCrawlEntry;
+import de.anomic.plasma.plasmaSearchQuery;
+import de.anomic.plasma.plasmaURL;
+import de.anomic.server.serverCharBuffer;
+import de.anomic.server.serverCodings;
+import de.anomic.tools.crypt;
+import de.anomic.tools.nxTools;
import de.anomic.index.indexRWIEntry;
-public interface indexURLEntry {
-
- public kelondroRow.Entry toRowEntry() throws IOException;
- public String hash();
- public Components comp();
- public Date moddate();
- public Date loaddate();
- public Date freshdate();
- public String referrerHash();
- public char doctype();
- public String language();
- public int size();
- public int wordCount();
- public int llocal();
- public int lother();
- public int limage();
- public int laudio();
- public int lvideo();
- public int lapp();
- public String snippet();
- public kelondroBitfield flags();
- public indexRWIEntry word();
- public boolean isOlder(indexURLEntry other);
- public String toString(String snippet);
- public plasmaCrawlEntry toBalancerEntry();
- public String toString();
+public class indexURLEntry {
+
+ // this object stores attributes for URL entries
+
+ public static final kelondroRow rowdef = new kelondroRow(
+ "String hash-12, " + // the url's hash
+ "String comp-360, " + // components: the url, description, author and tags. As 5th element, an ETag is possible
+ "Cardinal mod-4 {b256}, " + // last-modified from the httpd
+ "Cardinal load-4 {b256}, " + // time when the url was loaded
+ "Cardinal fresh-4 {b256}, " + // time until this url is fresh
+ "String referrer-12, " + // (one of) the url's referrer hash(es)
+ "byte[] md5-8, " + // the md5 of the url content (to identify changes)
+ "Cardinal size-6 {b256}, " + // size of file in bytes
+ "Cardinal wc-3 {b256}, " + // size of file by number of words; for video and audio: seconds
+ "byte[] dt-1, " + // doctype, taken from extension or any other heuristic
+ "Bitfield flags-4, " + // flags; any stuff (see Word-Entity definition)
+ "String lang-2, " + // language
+ "Cardinal llocal-2 {b256}, " + // # of outlinks to same domain; for video and image: width
+ "Cardinal lother-2 {b256}, " + // # of outlinks to outside domain; for video and image: height
+ "Cardinal limage-2 {b256}, " + // # of embedded image links
+ "Cardinal laudio-2 {b256}, " + // # of embedded audio links; for audio: track number; for video: number of audio tracks
+ "Cardinal lvideo-2 {b256}, " + // # of embedded video links
+ "Cardinal lapp-2 {b256}", // # of embedded links to applications
+ kelondroBase64Order.enhancedCoder,
+ 0);
+
+ private static final int col_hash = 0;
+ private static final int col_comp = 1;
+ private static final int col_mod = 2;
+ private static final int col_load = 3;
+ private static final int col_fresh = 4;
+ private static final int col_referrer = 5;
+ private static final int col_md5 = 6;
+ private static final int col_size = 7;
+ private static final int col_wc = 8;
+ private static final int col_dt = 9;
+ private static final int col_flags = 10;
+ private static final int col_lang = 11;
+ private static final int col_llocal = 12;
+ private static final int col_lother = 13;
+ private static final int col_limage = 14;
+ private static final int col_laudio = 15;
+ private static final int col_lvideo = 16;
+ private static final int col_lapp = 17;
+
+ private kelondroRow.Entry entry;
+ private String snippet;
+ private indexRWIEntry word; // this is only used if the url is transported via remote search requests
+
+ public indexURLEntry(
+ URL url,
+ String descr,
+ String author,
+ String tags,
+ String ETag,
+ Date mod,
+ Date load,
+ Date fresh,
+ String referrer,
+ byte[] md5,
+ long size,
+ int wc,
+ char dt,
+ kelondroBitfield flags,
+ String lang,
+ int llocal,
+ int lother,
+ int laudio,
+ int limage,
+ int lvideo,
+ int lapp) {
+ // create new entry and store it into database
+ this.entry = rowdef.newEntry();
+ this.entry.setCol(col_hash, plasmaURL.urlHash(url), null);
+ this.entry.setCol(col_comp, encodeComp(url, descr, author, tags, ETag));
+ this.entry.setCol(col_mod, encodeDate(mod));
+ this.entry.setCol(col_load, encodeDate(load));
+ this.entry.setCol(col_fresh, encodeDate(fresh));
+ this.entry.setCol(col_referrer, referrer.getBytes());
+ this.entry.setCol(col_md5, md5);
+ this.entry.setCol(col_size, size);
+ this.entry.setCol(col_wc, wc);
+ this.entry.setCol(col_dt, new byte[]{(byte) dt});
+ this.entry.setCol(col_flags, flags.bytes());
+ this.entry.setCol(col_lang, lang.getBytes());
+ this.entry.setCol(col_llocal, llocal);
+ this.entry.setCol(col_lother, lother);
+ this.entry.setCol(col_limage, limage);
+ this.entry.setCol(col_laudio, laudio);
+ this.entry.setCol(col_lvideo, lvideo);
+ this.entry.setCol(col_lapp, lapp);
+ this.snippet = null;
+ this.word = null;
+ }
+
+ public static byte[] encodeDate(Date d) {
+ // calculates the number of days since 1.1.1970 and returns this as 4-byte array
+ return kelondroNaturalOrder.encodeLong(d.getTime() / 86400000, 4);
+ }
+
+ public static byte[] encodeComp(URL url, String descr, String author, String tags, String ETag) {
+ serverCharBuffer s = new serverCharBuffer(200);
+ s.append(url.toNormalform()).append(10);
+ s.append(descr).append(10);
+ s.append(author).append(10);
+ s.append(tags).append(10);
+ s.append(ETag).append(10);
+ return s.toString().getBytes();
+ }
+
+ public indexURLEntry(kelondroRow.Entry entry, indexRWIEntry searchedWord) {
+ this.entry = entry;
+ this.snippet = null;
+ this.word = searchedWord;
+ }
+
+ public indexURLEntry(Properties prop){
+ // generates an plasmaLURLEntry using the properties from the argument
+ // the property names must correspond to the one from toString
+ //System.out.println("DEBUG-ENTRY: prop=" + prop.toString());
+ URL url;
+ try {
+ url = new URL(crypt.simpleDecode(prop.getProperty("url", ""), null));
+ } catch (MalformedURLException e) {
+ url = null;
+ }
+ String descr = crypt.simpleDecode(prop.getProperty("descr", ""), null); if (descr == null) descr = "";
+ String author = crypt.simpleDecode(prop.getProperty("author", ""), null); if (author == null) author = "";
+ String tags = crypt.simpleDecode(prop.getProperty("tags", ""), null); if (tags == null) tags = "";
+ String ETag = crypt.simpleDecode(prop.getProperty("ETag", ""), null); if (ETag == null) ETag = "";
+
+ this.entry = rowdef.newEntry();
+ this.entry.setCol(col_hash, plasmaURL.urlHash(url), null);
+ this.entry.setCol(col_comp, encodeComp(url, descr, author, tags, ETag));
+ try {
+ this.entry.setCol(col_mod, encodeDate(plasmaURL.shortDayFormatter.parse(prop.getProperty("mod", "20000101"))));
+ } catch (ParseException e) {
+ this.entry.setCol(col_mod, encodeDate(new Date()));
+ }
+ try {
+ this.entry.setCol(col_load, encodeDate(plasmaURL.shortDayFormatter.parse(prop.getProperty("load", "20000101"))));
+ } catch (ParseException e) {
+ this.entry.setCol(col_load, encodeDate(new Date()));
+ }
+ try {
+ this.entry.setCol(col_fresh, encodeDate(plasmaURL.shortDayFormatter.parse(prop.getProperty("fresh", "20000101"))));
+ } catch (ParseException e) {
+ this.entry.setCol(col_fresh, encodeDate(new Date()));
+ }
+ this.entry.setCol(col_referrer, prop.getProperty("referrer", plasmaURL.dummyHash).getBytes());
+ this.entry.setCol(col_md5, serverCodings.decodeHex(prop.getProperty("md5", "")));
+ this.entry.setCol(col_size, Integer.parseInt(prop.getProperty("size", "0")));
+ this.entry.setCol(col_wc, Integer.parseInt(prop.getProperty("wc", "0")));
+ this.entry.setCol(col_dt, new byte[]{(byte) prop.getProperty("dt", "t").charAt(0)});
+ String flags = prop.getProperty("flags", "AAAAAA");
+ this.entry.setCol(col_flags, (flags.length() > 6) ? plasmaSearchQuery.empty_constraint.bytes() : (new kelondroBitfield(4, flags)).bytes());
+ this.entry.setCol(col_lang, prop.getProperty("lang", "uk").getBytes());
+ this.entry.setCol(col_llocal, Integer.parseInt(prop.getProperty("llocal", "0")));
+ this.entry.setCol(col_lother, Integer.parseInt(prop.getProperty("lother", "0")));
+ this.entry.setCol(col_limage, Integer.parseInt(prop.getProperty("limage", "0")));
+ this.entry.setCol(col_laudio, Integer.parseInt(prop.getProperty("laudio", "0")));
+ this.entry.setCol(col_lvideo, Integer.parseInt(prop.getProperty("lvideo", "0")));
+ this.entry.setCol(col_lapp, Integer.parseInt(prop.getProperty("lapp", "0")));
+ this.snippet = crypt.simpleDecode(prop.getProperty("snippet", ""), null);
+ this.word = null;
+ if (prop.containsKey("word")) throw new kelondroException("old database structure is not supported");
+ if (prop.containsKey("wi")) {
+ this.word = new indexRWIEntry(kelondroBase64Order.enhancedCoder.decodeString(prop.getProperty("wi", "")));
+ }
+ }
+
+ private StringBuffer corePropList() {
+ // generate a parseable string; this is a simple property-list
+ indexURLEntry.Components comp = this.comp();
+ final StringBuffer s = new StringBuffer(300);
+ //System.out.println("author=" + comp.author());
+ try {
+ s.append("hash=").append(hash());
+ s.append(",url=").append(crypt.simpleEncode(comp.url().toNormalform()));
+ s.append(",descr=").append(crypt.simpleEncode(comp.title()));
+ s.append(",author=").append(crypt.simpleEncode(comp.author()));
+ s.append(",tags=").append(crypt.simpleEncode(comp.tags()));
+ s.append(",ETag=").append(crypt.simpleEncode(comp.ETag()));
+ s.append(",mod=").append(plasmaURL.shortDayFormatter.format(moddate()));
+ s.append(",load=").append(plasmaURL.shortDayFormatter.format(loaddate()));
+ s.append(",fresh=").append(plasmaURL.shortDayFormatter.format(freshdate()));
+ s.append(",referrer=").append(referrerHash());
+ s.append(",md5=").append(md5());
+ s.append(",size=").append(size());
+ s.append(",wc=").append(wordCount());
+ s.append(",dt=").append(doctype());
+ s.append(",flags=").append(flags().exportB64());
+ s.append(",lang=").append(language());
+ s.append(",llocal=").append(llocal());
+ s.append(",lother=").append(lother());
+ s.append(",limage=").append(limage());
+ s.append(",laudio=").append(laudio());
+ s.append(",lvideo=").append(lvideo());
+ s.append(",lapp=").append(lapp());
+
+ if (this.word != null) {
+ // append also word properties
+ s.append(",wi=").append(kelondroBase64Order.enhancedCoder.encodeString(word.toPropertyForm()));
+ }
+ return s;
+
+ } catch (Exception e) {
+ // serverLog.logFailure("plasmaLURL.corePropList", e.getMessage());
+ // if (moddate == null) serverLog.logFailure("plasmaLURL.corePropList", "moddate=null");
+ // if (loaddate == null) serverLog.logFailure("plasmaLURL.corePropList", "loaddate=null");
+ // e.printStackTrace();
+ return null;
+ }
+ }
+
+ public kelondroRow.Entry toRowEntry() throws IOException {
+ return this.entry;
+ }
+
+ public String hash() {
+ // return a url-hash, based on the md5 algorithm
+ // the result is a String of 12 bytes within a 72-bit space
+ // (each byte has an 6-bit range)
+ // that should be enough for all web pages on the world
+ return this.entry.getColString(col_hash, null);
+ }
+
+ public indexURLEntry.Components comp() {
+ ArrayList cl = nxTools.strings(this.entry.getCol("comp", null), "UTF-8");
+ return new indexURLEntry.Components(
+ (cl.size() > 0) ? ((String) cl.get(0)).trim() : "",
+ (cl.size() > 1) ? ((String) cl.get(1)).trim() : "",
+ (cl.size() > 2) ? ((String) cl.get(2)).trim() : "",
+ (cl.size() > 3) ? ((String) cl.get(3)).trim() : "",
+ (cl.size() > 4) ? ((String) cl.get(4)).trim() : "");
+ }
+
+ public Date moddate() {
+ return new Date(86400000 * entry.getColLong(col_mod));
+ }
+
+ public Date loaddate() {
+ return new Date(86400000 * entry.getColLong(col_load));
+ }
+
+ public Date freshdate() {
+ return new Date(86400000 * entry.getColLong(col_fresh));
+ }
+
+ public String referrerHash() {
+ // return the creator's hash
+ return entry.getColString(col_referrer, null);
+ }
+
+ public String md5() {
+ // returns the md5 in hex representation
+ return serverCodings.encodeHex(entry.getColBytes(col_md5));
+ }
+
+ public char doctype() {
+ return (char) entry.getColByte(col_dt);
+ }
+
+ public String language() {
+ return this.entry.getColString(col_lang, null);
+ }
+
+ public int size() {
+ return (int) this.entry.getColLong(col_size);
+ }
+
+ public kelondroBitfield flags() {
+ return new kelondroBitfield(this.entry.getColBytes(col_flags));
+ }
+
+ public int wordCount() {
+ return (int) this.entry.getColLong(col_wc);
+ }
+
+ public int llocal() {
+ return (int) this.entry.getColLong(col_llocal);
+ }
+
+ public int lother() {
+ return (int) this.entry.getColLong(col_lother);
+ }
+
+ public int limage() {
+ return (int) this.entry.getColLong(col_limage);
+ }
+
+ public int laudio() {
+ return (int) this.entry.getColLong(col_laudio);
+ }
+
+ public int lvideo() {
+ return (int) this.entry.getColLong(col_lvideo);
+ }
+
+ public int lapp() {
+ return (int) this.entry.getColLong(col_lapp);
+ }
+
+ public String snippet() {
+ // the snippet may appear here if the url was transported in a remote search
+ // it will not be saved anywhere, but can only be requested here
+ return snippet;
+ }
+
+ public indexRWIEntry word() {
+ return word;
+ }
+
+ public boolean isOlder(indexURLEntry other) {
+ if (other == null) return false;
+ Date tmoddate = moddate();
+ Date omoddate = other.moddate();
+ if (tmoddate.before(omoddate)) return true;
+ if (tmoddate.equals(omoddate)) {
+ Date tloaddate = loaddate();
+ Date oloaddate = other.loaddate();
+ if (tloaddate.before(oloaddate)) return true;
+ if (tloaddate.equals(oloaddate)) return true;
+ }
+ return false;
+ }
+
+ public String toString(String snippet) {
+ // add information needed for remote transport
+ final StringBuffer core = corePropList();
+ if (core == null)
+ return null;
+
+ core.ensureCapacity(core.length() + snippet.length() * 2);
+ core.insert(0, "{");
+ core.append(",snippet=").append(crypt.simpleEncode(snippet));
+ core.append("}");
+
+ return new String(core);
+ //return "{" + core + ",snippet=" + crypt.simpleEncode(snippet) + "}";
+ }
+
+ public plasmaCrawlEntry toBalancerEntry() {
+ return new plasmaCrawlEntry(
+ null,
+ comp().url(),
+ referrerHash(),
+ comp().title(),
+ loaddate(),
+ null,
+ 0,
+ 0,
+ 0);
+ }
+
+ /**
+ * Returns this object as String.<br>
+ * This e.g. looks like this:
+ * <pre>{hash=jmqfMk7Y3NKw,referrer=------------,mod=20050610,load=20051003,size=51666,wc=1392,cc=0,local=true,q=AEn,dt=h,lang=uk,url=b|aHR0cDovL3d3dy50cmFuc3BhcmVuY3kub3JnL3N1cnZleXMv,descr=b|S25vd2xlZGdlIENlbnRyZTogQ29ycnVwdGlvbiBTdXJ2ZXlzIGFuZCBJbmRpY2Vz}</pre>
+ */
+ public String toString() {
+ final StringBuffer core = corePropList();
+ if (core == null) return null;
+
+ core.insert(0, "{");
+ core.append("}");
+
+ return new String(core);
+ //return "{" + core + "}";
+ }
public class Components {
private URL url;
diff --git a/source/de/anomic/index/indexURLEntryNew.java b/source/de/anomic/index/indexURLEntryNew.java
deleted file mode 100644
index cb3db10bf..000000000
--- a/source/de/anomic/index/indexURLEntryNew.java
+++ /dev/null
@@ -1,400 +0,0 @@
-package de.anomic.index;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Properties;
-import java.util.ArrayList;
-
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroException;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.net.URL;
-import de.anomic.plasma.plasmaCrawlEntry;
-import de.anomic.plasma.plasmaURL;
-import de.anomic.plasma.plasmaSearchQuery;
-import de.anomic.server.serverCharBuffer;
-import de.anomic.server.serverCodings;
-import de.anomic.tools.crypt;
-import de.anomic.tools.nxTools;
-
-public class indexURLEntryNew implements indexURLEntry {
-
- // this object stores attributes for URL entries
-
- public static final kelondroRow rowdef = new kelondroRow(
- "String hash-12, " + // the url's hash
- "String comp-360, " + // components: the url, description, author and tags. As 5th element, an ETag is possible
- "Cardinal mod-4 {b256}, " + // last-modified from the httpd
- "Cardinal load-4 {b256}, " + // time when the url was loaded
- "Cardinal fresh-4 {b256}, " + // time until this url is fresh
- "String referrer-12, " + // (one of) the url's referrer hash(es)
- "byte[] md5-8, " + // the md5 of the url content (to identify changes)
- "Cardinal size-6 {b256}, " + // size of file in bytes
- "Cardinal wc-3 {b256}, " + // size of file by number of words; for video and audio: seconds
- "byte[] dt-1, " + // doctype, taken from extension or any other heuristic
- "Bitfield flags-4, " + // flags; any stuff (see Word-Entity definition)
- "String lang-2, " + // language
- "Cardinal llocal-2 {b256}, " + // # of outlinks to same domain; for video and image: width
- "Cardinal lother-2 {b256}, " + // # of outlinks to outside domain; for video and image: height
- "Cardinal limage-2 {b256}, " + // # of embedded image links
- "Cardinal laudio-2 {b256}, " + // # of embedded audio links; for audio: track number; for video: number of audio tracks
- "Cardinal lvideo-2 {b256}, " + // # of embedded video links
- "Cardinal lapp-2 {b256}", // # of embedded links to applications
- kelondroBase64Order.enhancedCoder,
- 0);
-
- private static final int col_hash = 0;
- private static final int col_comp = 1;
- private static final int col_mod = 2;
- private static final int col_load = 3;
- private static final int col_fresh = 4;
- private static final int col_referrer = 5;
- private static final int col_md5 = 6;
- private static final int col_size = 7;
- private static final int col_wc = 8;
- private static final int col_dt = 9;
- private static final int col_flags = 10;
- private static final int col_lang = 11;
- private static final int col_llocal = 12;
- private static final int col_lother = 13;
- private static final int col_limage = 14;
- private static final int col_laudio = 15;
- private static final int col_lvideo = 16;
- private static final int col_lapp = 17;
-
- private kelondroRow.Entry entry;
- private String snippet;
- private indexRWIEntryNew word; // this is only used if the url is transported via remote search requests
-
- public indexURLEntryNew(
- URL url,
- String descr,
- String author,
- String tags,
- String ETag,
- Date mod,
- Date load,
- Date fresh,
- String referrer,
- byte[] md5,
- long size,
- int wc,
- char dt,
- kelondroBitfield flags,
- String lang,
- int llocal,
- int lother,
- int laudio,
- int limage,
- int lvideo,
- int lapp) {
- // create new entry and store it into database
- this.entry = rowdef.newEntry();
- this.entry.setCol(col_hash, plasmaURL.urlHash(url), null);
- this.entry.setCol(col_comp, encodeComp(url, descr, author, tags, ETag));
- this.entry.setCol(col_mod, encodeDate(mod));
- this.entry.setCol(col_load, encodeDate(load));
- this.entry.setCol(col_fresh, encodeDate(fresh));
- this.entry.setCol(col_referrer, referrer.getBytes());
- this.entry.setCol(col_md5, md5);
- this.entry.setCol(col_size, size);
- this.entry.setCol(col_wc, wc);
- this.entry.setCol(col_dt, new byte[]{(byte) dt});
- this.entry.setCol(col_flags, flags.bytes());
- this.entry.setCol(col_lang, lang.getBytes());
- this.entry.setCol(col_llocal, llocal);
- this.entry.setCol(col_lother, lother);
- this.entry.setCol(col_limage, limage);
- this.entry.setCol(col_laudio, laudio);
- this.entry.setCol(col_lvideo, lvideo);
- this.entry.setCol(col_lapp, lapp);
- this.snippet = null;
- this.word = null;
- }
-
- public static byte[] encodeDate(Date d) {
- // calculates the number of days since 1.1.1970 and returns this as 4-byte array
- return kelondroNaturalOrder.encodeLong(d.getTime() / 86400000, 4);
- }
-
- public static byte[] encodeComp(URL url, String descr, String author, String tags, String ETag) {
- serverCharBuffer s = new serverCharBuffer(200);
- s.append(url.toNormalform()).append(10);
- s.append(descr).append(10);
- s.append(author).append(10);
- s.append(tags).append(10);
- s.append(ETag).append(10);
- return s.toString().getBytes();
- }
-
- public indexURLEntryNew(kelondroRow.Entry entry, indexRWIEntryNew searchedWord) {
- this.entry = entry;
- this.snippet = null;
- this.word = searchedWord;
- }
-
- public indexURLEntryNew(Properties prop){
- // generates an plasmaLURLEntry using the properties from the argument
- // the property names must correspond to the one from toString
- //System.out.println("DEBUG-ENTRY: prop=" + prop.toString());
- URL url;
- try {
- url = new URL(crypt.simpleDecode(prop.getProperty("url", ""), null));
- } catch (MalformedURLException e) {
- url = null;
- }
- String descr = crypt.simpleDecode(prop.getProperty("descr", ""), null); if (descr == null) descr = "";
- String author = crypt.simpleDecode(prop.getProperty("author", ""), null); if (author == null) author = "";
- String tags = crypt.simpleDecode(prop.getProperty("tags", ""), null); if (tags == null) tags = "";
- String ETag = crypt.simpleDecode(prop.getProperty("ETag", ""), null); if (ETag == null) ETag = "";
-
- this.entry = rowdef.newEntry();
- this.entry.setCol(col_hash, plasmaURL.urlHash(url), null);
- this.entry.setCol(col_comp, encodeComp(url, descr, author, tags, ETag));
- try {
- this.entry.setCol(col_mod, encodeDate(plasmaURL.shortDayFormatter.parse(prop.getProperty("mod", "20000101"))));
- } catch (ParseException e) {
- this.entry.setCol(col_mod, encodeDate(new Date()));
- }
- try {
- this.entry.setCol(col_load, encodeDate(plasmaURL.shortDayFormatter.parse(prop.getProperty("load", "20000101"))));
- } catch (ParseException e) {
- this.entry.setCol(col_load, encodeDate(new Date()));
- }
- try {
- this.entry.setCol(col_fresh, encodeDate(plasmaURL.shortDayFormatter.parse(prop.getProperty("fresh", "20000101"))));
- } catch (ParseException e) {
- this.entry.setCol(col_fresh, encodeDate(new Date()));
- }
- this.entry.setCol(col_referrer, prop.getProperty("referrer", plasmaURL.dummyHash).getBytes());
- this.entry.setCol(col_md5, serverCodings.decodeHex(prop.getProperty("md5", "")));
- this.entry.setCol(col_size, Integer.parseInt(prop.getProperty("size", "0")));
- this.entry.setCol(col_wc, Integer.parseInt(prop.getProperty("wc", "0")));
- this.entry.setCol(col_dt, new byte[]{(byte) prop.getProperty("dt", "t").charAt(0)});
- String flags = prop.getProperty("flags", "AAAAAA");
- this.entry.setCol(col_flags, (flags.length() > 6) ? plasmaSearchQuery.empty_constraint.bytes() : (new kelondroBitfield(4, flags)).bytes());
- this.entry.setCol(col_lang, prop.getProperty("lang", "uk").getBytes());
- this.entry.setCol(col_llocal, Integer.parseInt(prop.getProperty("llocal", "0")));
- this.entry.setCol(col_lother, Integer.parseInt(prop.getProperty("lother", "0")));
- this.entry.setCol(col_limage, Integer.parseInt(prop.getProperty("limage", "0")));
- this.entry.setCol(col_laudio, Integer.parseInt(prop.getProperty("laudio", "0")));
- this.entry.setCol(col_lvideo, Integer.parseInt(prop.getProperty("lvideo", "0")));
- this.entry.setCol(col_lapp, Integer.parseInt(prop.getProperty("lapp", "0")));
- this.snippet = crypt.simpleDecode(prop.getProperty("snippet", ""), null);
- this.word = null;
- if (prop.containsKey("word")) try {
- // convert old data format
- this.word = new indexRWIEntryNew(new indexRWIEntryOld(kelondroBase64Order.enhancedCoder.decodeString(prop.getProperty("word", ""))));
- } catch (kelondroException e) {
- this.word = null;
- }
- if (prop.containsKey("wi")) {
- this.word = new indexRWIEntryNew(kelondroBase64Order.enhancedCoder.decodeString(prop.getProperty("wi", "")));
- }
- }
-
- private StringBuffer corePropList() {
- // generate a parseable string; this is a simple property-list
- indexURLEntry.Components comp = this.comp();
- final StringBuffer s = new StringBuffer(300);
- //System.out.println("author=" + comp.author());
- try {
- s.append("hash=").append(hash());
- s.append(",url=").append(crypt.simpleEncode(comp.url().toNormalform()));
- s.append(",descr=").append(crypt.simpleEncode(comp.title()));
- s.append(",author=").append(crypt.simpleEncode(comp.author()));
- s.append(",tags=").append(crypt.simpleEncode(comp.tags()));
- s.append(",ETag=").append(crypt.simpleEncode(comp.ETag()));
- s.append(",mod=").append(plasmaURL.shortDayFormatter.format(moddate()));
- s.append(",load=").append(plasmaURL.shortDayFormatter.format(loaddate()));
- s.append(",fresh=").append(plasmaURL.shortDayFormatter.format(freshdate()));
- s.append(",referrer=").append(referrerHash());
- s.append(",md5=").append(md5());
- s.append(",size=").append(size());
- s.append(",wc=").append(wordCount());
- s.append(",dt=").append(doctype());
- s.append(",flags=").append(flags().exportB64());
- s.append(",lang=").append(language());
- s.append(",llocal=").append(llocal());
- s.append(",lother=").append(lother());
- s.append(",limage=").append(limage());
- s.append(",laudio=").append(laudio());
- s.append(",lvideo=").append(lvideo());
- s.append(",lapp=").append(lapp());
-
- if (this.word != null) {
- // append also word properties
- s.append(",wi=").append(kelondroBase64Order.enhancedCoder.encodeString(word.toPropertyForm()));
- }
- return s;
-
- } catch (Exception e) {
- // serverLog.logFailure("plasmaLURL.corePropList", e.getMessage());
- // if (moddate == null) serverLog.logFailure("plasmaLURL.corePropList", "moddate=null");
- // if (loaddate == null) serverLog.logFailure("plasmaLURL.corePropList", "loaddate=null");
- // e.printStackTrace();
- return null;
- }
- }
-
- public kelondroRow.Entry toRowEntry() throws IOException {
- return this.entry;
- }
-
- public String hash() {
- // return a url-hash, based on the md5 algorithm
- // the result is a String of 12 bytes within a 72-bit space
- // (each byte has an 6-bit range)
- // that should be enough for all web pages on the world
- return this.entry.getColString(col_hash, null);
- }
-
- public indexURLEntry.Components comp() {
- ArrayList cl = nxTools.strings(this.entry.getCol("comp", null), "UTF-8");
- return new indexURLEntry.Components(
- (cl.size() > 0) ? ((String) cl.get(0)).trim() : "",
- (cl.size() > 1) ? ((String) cl.get(1)).trim() : "",
- (cl.size() > 2) ? ((String) cl.get(2)).trim() : "",
- (cl.size() > 3) ? ((String) cl.get(3)).trim() : "",
- (cl.size() > 4) ? ((String) cl.get(4)).trim() : "");
- }
-
- public Date moddate() {
- return new Date(86400000 * entry.getColLong(col_mod));
- }
-
- public Date loaddate() {
- return new Date(86400000 * entry.getColLong(col_load));
- }
-
- public Date freshdate() {
- return new Date(86400000 * entry.getColLong(col_fresh));
- }
-
- public String referrerHash() {
- // return the creator's hash
- return entry.getColString(col_referrer, null);
- }
-
- public String md5() {
- // returns the md5 in hex representation
- return serverCodings.encodeHex(entry.getColBytes(col_md5));
- }
-
- public char doctype() {
- return (char) entry.getColByte(col_dt);
- }
-
- public String language() {
- return this.entry.getColString(col_lang, null);
- }
-
- public int size() {
- return (int) this.entry.getColLong(col_size);
- }
-
- public kelondroBitfield flags() {
- return new kelondroBitfield(this.entry.getColBytes(col_flags));
- }
-
- public int wordCount() {
- return (int) this.entry.getColLong(col_wc);
- }
-
- public int llocal() {
- return (int) this.entry.getColLong(col_llocal);
- }
-
- public int lother() {
- return (int) this.entry.getColLong(col_lother);
- }
-
- public int limage() {
- return (int) this.entry.getColLong(col_limage);
- }
-
- public int laudio() {
- return (int) this.entry.getColLong(col_laudio);
- }
-
- public int lvideo() {
- return (int) this.entry.getColLong(col_lvideo);
- }
-
- public int lapp() {
- return (int) this.entry.getColLong(col_lapp);
- }
-
- public String snippet() {
- // the snippet may appear here if the url was transported in a remote search
- // it will not be saved anywhere, but can only be requested here
- return snippet;
- }
-
- public indexRWIEntry word() {
- return word;
- }
-
- public boolean isOlder(indexURLEntry other) {
- if (other == null) return false;
- Date tmoddate = moddate();
- Date omoddate = other.moddate();
- if (tmoddate.before(omoddate)) return true;
- if (tmoddate.equals(omoddate)) {
- Date tloaddate = loaddate();
- Date oloaddate = other.loaddate();
- if (tloaddate.before(oloaddate)) return true;
- if (tloaddate.equals(oloaddate)) return true;
- }
- return false;
- }
-
- public String toString(String snippet) {
- // add information needed for remote transport
- final StringBuffer core = corePropList();
- if (core == null)
- return null;
-
- core.ensureCapacity(core.length() + snippet.length() * 2);
- core.insert(0, "{");
- core.append(",snippet=").append(crypt.simpleEncode(snippet));
- core.append("}");
-
- return new String(core);
- //return "{" + core + ",snippet=" + crypt.simpleEncode(snippet) + "}";
- }
-
- public plasmaCrawlEntry toBalancerEntry() {
- return new plasmaCrawlEntry(
- null,
- comp().url(),
- referrerHash(),
- comp().title(),
- loaddate(),
- null,
- 0,
- 0,
- 0);
- }
-
- /**
- * Returns this object as String.<br>
- * This e.g. looks like this:
- * <pre>{hash=jmqfMk7Y3NKw,referrer=------------,mod=20050610,load=20051003,size=51666,wc=1392,cc=0,local=true,q=AEn,dt=h,lang=uk,url=b|aHR0cDovL3d3dy50cmFuc3BhcmVuY3kub3JnL3N1cnZleXMv,descr=b|S25vd2xlZGdlIENlbnRyZTogQ29ycnVwdGlvbiBTdXJ2ZXlzIGFuZCBJbmRpY2Vz}</pre>
- */
- public String toString() {
- final StringBuffer core = corePropList();
- if (core == null) return null;
-
- core.insert(0, "{");
- core.append("}");
-
- return new String(core);
- //return "{" + core + "}";
- }
-
-}
diff --git a/source/de/anomic/index/indexURLEntryOld.java b/source/de/anomic/index/indexURLEntryOld.java
deleted file mode 100644
index 3497977c1..000000000
--- a/source/de/anomic/index/indexURLEntryOld.java
+++ /dev/null
@@ -1,407 +0,0 @@
-// plasmaCrawlLURLOldEntry.java
-// (C) 2006 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
-// first published 13.10.2006 on http://www.anomic.de
-//
-// This is a part of YaCy, a peer-to-peer based web search engine
-//
-// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
-// $LastChangedRevision: 1986 $
-// $LastChangedBy: orbiter $
-//
-// LICENSE
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package de.anomic.index;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Properties;
-
-import de.anomic.http.httpc;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroBitfield;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.net.URL;
-import de.anomic.plasma.plasmaCrawlEntry;
-import de.anomic.plasma.plasmaSearchQuery;
-import de.anomic.plasma.plasmaURL;
-import de.anomic.server.logging.serverLog;
-import de.anomic.tools.crypt;
-import de.anomic.yacy.yacySeedDB;
-
-public class indexURLEntryOld implements indexURLEntry {
-
- public static final kelondroRow rowdef = new kelondroRow(
- "String urlhash-" + yacySeedDB.commonHashLength + ", " + // the url's hash
- "String urlstring-256, " + // the url as string
- "String urldescr-80, " + // the description of the url
- "Cardinal moddate-4 {b64e}, " + // last-modified from the httpd
- "Cardinal loaddate-4 {b64e}, " + // time when the url was loaded
- "String refhash-" + yacySeedDB.commonHashLength + ", " + // the url's referrer hash
- "Cardinal copycount-2 {b64e}, " + // not used
- "byte[] flags-2, " + // flags
- "Cardinal quality-3 {b64e}, " + // deprecated
- "String language-2, " + // language key; mainly the TDL
- "byte[] doctype-1, " + //
- "Cardinal size-6 {b64e}, " + // size of file in bytes
- "Cardinal wc-3 {b64e}", // word count
- kelondroBase64Order.enhancedCoder,
- 0);
-
- private URL url;
- private String descr;
- private Date moddate;
- private Date loaddate;
- private String urlHash;
- private String referrerHash;
- private int copyCount;
- private String flags;
- private int quality;
- private String language;
- private char doctype;
- private int size;
- private int wordCount;
- private String snippet;
- private indexRWIEntry word; // this is only used if the url is transported via remote search requests
-
- public indexURLEntryOld(
- URL url,
- String descr,
- String author,
- String tags,
- String ETag,
- Date mod,
- Date load,
- Date fresh,
- String referrer,
- byte[] md5,
- long size,
- int wc,
- char dt,
- kelondroBitfield flags,
- String lang,
- int llocal,
- int lother,
- int laudio,
- int limage,
- int lvideo,
- int lapp) {
- // create new entry and store it into database
- this.urlHash = plasmaURL.urlHash(url);
- this.url = url;
- this.descr = (descr == null) ? this.url.toString() : descr;
- this.moddate = mod;
- this.loaddate = load;
- this.referrerHash = (referrerHash == null) ? plasmaURL.dummyHash : referrerHash;
- this.copyCount = 0; // the number of remote (global) copies of this object without this one
- this.flags = " ";
- this.quality = 0;
- this.language = (language == null) ? "uk" : language;
- this.doctype = dt;
- this.size = (int) size;
- this.wordCount = wc;
- this.snippet = null;
- this.word = null;
- }
-
- public indexURLEntryOld(kelondroRow.Entry entry, indexRWIEntry searchedWord) throws IOException {
- try {
- this.urlHash = entry.getColString(0, null);
- this.url = new URL(entry.getColString(1, "UTF-8"));
- this.descr = (entry.empty(2)) ? this.url.toString() : entry.getColString(2, "UTF-8").trim();
- this.moddate = new Date(86400000 * entry.getColLong(3));
- this.loaddate = new Date(86400000 * entry.getColLong(4));
- this.referrerHash = (entry.empty(5)) ? plasmaURL.dummyHash : entry.getColString(5, "UTF-8");
- this.copyCount = (int) entry.getColLong(6);
- this.flags = entry.getColString(7, "UTF-8");
- this.quality = (int) entry.getColLong(8);
- this.language = entry.getColString(9, "UTF-8");
- this.doctype = (char) entry.getColByte(10);
- this.size = (int) entry.getColLong(11);
- this.wordCount = (int) entry.getColLong(12);
- this.snippet = null;
- this.word = searchedWord;
- return;
- } catch (Exception e) {
- serverLog.logSevere("PLASMA", "INTERNAL ERROR in plasmaLURL.entry/1: " + e.toString(), e);
- throw new IOException("plasmaLURL.entry/1: " + e.toString());
- }
- }
-
- public indexURLEntryOld(Properties prop) {
- // generates an plasmaLURLEntry using the properties from the argument
- // the property names must correspond to the one from toString
- //System.out.println("DEBUG-ENTRY: prop=" + prop.toString());
- this.urlHash = prop.getProperty("hash", plasmaURL.dummyHash);
- try {
- this.referrerHash = prop.getProperty("referrer", plasmaURL.dummyHash);
- this.moddate = plasmaURL.shortDayFormatter.parse(prop.getProperty("mod", "20000101"));
- //System.out.println("DEBUG: moddate = " + moddate + ", prop=" + prop.getProperty("mod"));
- this.loaddate = plasmaURL.shortDayFormatter.parse(prop.getProperty("load", "20000101"));
- this.copyCount = Integer.parseInt(prop.getProperty("cc", "0"));
- this.flags = ((prop.getProperty("local", "true").equals("true")) ? "L " : " ");
- this.url = new URL(crypt.simpleDecode(prop.getProperty("url", ""), null));
- this.descr = crypt.simpleDecode(prop.getProperty("descr", ""), null);
- if (this.descr == null) this.descr = this.url.toString();
- this.quality = (int) kelondroBase64Order.enhancedCoder.decodeLong(prop.getProperty("q", ""));
- this.language = prop.getProperty("lang", "uk");
- this.doctype = prop.getProperty("dt", "t").charAt(0);
- this.size = Integer.parseInt(prop.getProperty("size", "0"));
- this.wordCount = Integer.parseInt(prop.getProperty("wc", "0"));
- this.snippet = prop.getProperty("snippet", "");
- if (snippet.length() == 0) snippet = null;
- else snippet = crypt.simpleDecode(snippet, null);
- this.word = null;
- if (prop.containsKey("word")) {
- this.word = new indexRWIEntryOld(kelondroBase64Order.enhancedCoder.decodeString(prop.getProperty("word", "")));
- }
- if (prop.containsKey("wi")) {
- this.word = new indexRWIEntryNew(kelondroBase64Order.enhancedCoder.decodeString(prop.getProperty("wi", "")));
- }
- } catch (Exception e) {
- serverLog.logSevere("PLASMA",
- "INTERNAL ERROR in plasmaLURL.entry/2:"
- + "\nProperties: "
- + ((prop == null) ? null : prop.toString())
- + ((prop.containsKey("word")) ? "\nWord: "
- + kelondroBase64Order.enhancedCoder.decodeString(prop.getProperty("word", "")) : "") + "\nErrorMsg: "
- + e.toString(), e);
- }
- }
-
- public static kelondroRow rowdef() {
- return rowdef;
- }
-
- public kelondroRow.Entry toRowEntry() throws IOException {
- final String moddatestr = kelondroBase64Order.enhancedCoder.encodeLong(moddate.getTime() / 86400000, rowdef.width(3));
- final String loaddatestr = kelondroBase64Order.enhancedCoder.encodeLong(loaddate.getTime() / 86400000, rowdef.width(4));
-
- final byte[][] entry = new byte[][] {
- urlHash.getBytes(),
- url.toString().getBytes(),
- descr.getBytes(), // null?
- moddatestr.getBytes(),
- loaddatestr.getBytes(),
- referrerHash.getBytes(),
- kelondroBase64Order.enhancedCoder.encodeLong(copyCount, rowdef.width(6)).getBytes(),
- flags.getBytes(),
- kelondroBase64Order.enhancedCoder.encodeLong(quality, rowdef.width(8)).getBytes(),
- language.getBytes(),
- new byte[] { (byte) doctype },
- kelondroBase64Order.enhancedCoder.encodeLong(size, rowdef.width(11)).getBytes(),
- kelondroBase64Order.enhancedCoder.encodeLong(wordCount, rowdef.width(12)).getBytes()};
- return rowdef.newEntry(entry);
- }
-
- public String hash() {
- // return a url-hash, based on the md5 algorithm
- // the result is a String of 12 bytes within a 72-bit space
- // (each byte has an 6-bit range)
- // that should be enough for all web pages on the world
- return this.urlHash;
- }
-
- public Components comp() {
- return new Components(url, descr, "", "", "");
- }
-
- public Date moddate() {
- return moddate;
- }
-
- public Date loaddate() {
- return loaddate;
- }
-
- public Date freshdate() {
- return loaddate;
- }
-
- public String referrerHash() {
- // return the creator's hash
- return referrerHash;
- }
-
- public char doctype() {
- return doctype;
- }
-
- public int copyCount() {
- // return number of copies of this object in the global index
- return copyCount;
- }
-
- public boolean local() {
- // returns true if the url was created locally and is needed for own word index
- if (flags == null) return false;
- return flags.charAt(0) == 'L';
- }
-
- public int quality() {
- return quality;
- }
-
- public String language() {
- return (language == null) ? "en" : language;
- }
-
- public int size() {
- return size;
- }
-
- public int wordCount() {
- return wordCount;
- }
-
- public kelondroBitfield flags() {
- return plasmaSearchQuery.empty_constraint;
- }
-
- public String snippet() {
- // the snippet may appear here if the url was transported in a remote search
- // it will not be saved anywhere, but can only be requested here
- return snippet;
- }
-
- public indexRWIEntry word() {
- return word;
- }
-
- public boolean isOlder(indexURLEntry other) {
- if (other == null) return false;
- if (moddate.before(other.moddate())) return true;
- if (moddate.equals(other.moddate())) {
- if (loaddate.before(other.loaddate())) return true;
- if (loaddate.equals(other.loaddate())) return true;
- }
- return false;
- }
-
- private StringBuffer corePropList() {
- // generate a parseable string; this is a simple property-list
- final StringBuffer corePropStr = new StringBuffer(300);
- try {
- corePropStr.append("hash=").append(urlHash).append(",referrer=")
- .append(referrerHash).append(",mod=").append(
- plasmaURL.shortDayFormatter.format(moddate)).append(
- ",load=").append(
- plasmaURL.shortDayFormatter.format(loaddate))
- .append(",size=").append(size).append(",wc=").append(
- wordCount).append(",cc=").append(copyCount).append(
- ",local=").append(((local()) ? "true" : "false"))
- .append(",q=0")
- .append(",dt=").append(doctype).append(",lang=").append(
- language).append(",url=").append(
- crypt.simpleEncode(url.toString())).append(
- ",descr=").append(crypt.simpleEncode(descr));
-
- if (this.word != null) {
- // append also word properties
- if (this.word instanceof indexRWIEntryOld) corePropStr.append(",word=").append(kelondroBase64Order.enhancedCoder.encodeString(word.toPropertyForm()));
- if (this.word instanceof indexRWIEntryNew) corePropStr.append(",wi=").append(kelondroBase64Order.enhancedCoder.encodeString(word.toPropertyForm()));
- }
- return corePropStr;
-
- } catch (Exception e) {
- return null;
- }
- }
-
- public String toString(String snippet) {
- // add information needed for remote transport
- final StringBuffer core = corePropList();
- if (core == null)
- return null;
-
- core.ensureCapacity(core.length() + snippet.length() * 2);
- core.insert(0, "{");
- core.append(",snippet=").append(crypt.simpleEncode(snippet));
- core.append("}");
-
- return core.toString();
- //return "{" + core + ",snippet=" + crypt.simpleEncode(snippet) + "}";
- }
-
- public plasmaCrawlEntry toBalancerEntry() {
- return new plasmaCrawlEntry(
- null,
- comp().url(),
- referrerHash(),
- comp().title(),
- loaddate(),
- null,
- 0,
- 0,
- 0);
- }
-
- /**
- * Returns this object as String.<br>
- * This e.g. looks like this:
- * <pre>{hash=jmqfMk7Y3NKw,referrer=------------,mod=20050610,load=20051003,size=51666,wc=1392,cc=0,local=true,q=AEn,dt=h,lang=uk,url=b|aHR0cDovL3d3dy50cmFuc3BhcmVuY3kub3JnL3N1cnZleXMv,descr=b|S25vd2xlZGdlIENlbnRyZTogQ29ycnVwdGlvbiBTdXJ2ZXlzIGFuZCBJbmRpY2Vz}</pre>
- */
- public String toString() {
- final StringBuffer core = corePropList();
- if (core == null) return null;
-
- core.insert(0, "{");
- core.append("}");
-
- return core.toString();
- //return "{" + core + "}";
- }
-
- public void print() {
- System.out.println("URL : " + url);
- System.out.println("Description : " + descr);
- System.out.println("Modified : " + httpc.dateString(moddate));
- System.out.println("Loaded : " + httpc.dateString(loaddate));
- System.out.println("Size : " + size + " bytes, " + wordCount
- + " words");
- System.out.println("Referrer Hash : " + referrerHash);
- System.out.println("Quality : " + quality);
- System.out.println("Language : " + language);
- System.out.println("DocType : " + doctype);
- System.out.println();
- }
-
- // compatibility methods
- public int lapp() {
- return 0;
- }
-
- public int laudio() {
- return 0;
- }
-
- public int limage() {
- return 0;
- }
-
- public int llocal() {
- return 0;
- }
-
- public int lother() {
- return 0;
- }
-
- public int lvideo() {
- return 0;
- }
-
-}
diff --git a/source/de/anomic/plasma/dbImport/AssortmentImporter.java b/source/de/anomic/plasma/dbImport/AssortmentImporter.java
deleted file mode 100644
index 2ad5daaa1..000000000
--- a/source/de/anomic/plasma/dbImport/AssortmentImporter.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package de.anomic.plasma.dbImport;
-
-import java.io.File;
-import java.util.Iterator;
-
-import de.anomic.index.indexContainer;
-import de.anomic.plasma.plasmaWordIndex;
-import de.anomic.plasma.plasmaWordIndexAssortment;
-
-public class AssortmentImporter extends AbstractImporter implements dbImporter{
-
- private int importStartSize;
- private int wordEntityCount = 0;
- private int wordEntryCount = 0;
-
- private plasmaWordIndexAssortment assortmentFile;
-
- public AssortmentImporter(plasmaWordIndex wi) {
- super(wi);
- this.jobType = "ASSORTMENT";
- }
-
- public void init(File theImportAssortmentFile, int theCacheSize, long preloadTime) {
- super.init(theImportAssortmentFile);
- this.cacheSize = theCacheSize;
- if (this.cacheSize < 2*1024*1024) this.cacheSize = 2*1024*1024;
-
- String errorMsg = null;
- if (!this.importPath.getName().matches("indexAssortment0[0-6][0-9]\\.db"))
- errorMsg = "AssortmentFile '" + this.importPath + "' has an invalid name.";
- if (!this.importPath.exists())
- errorMsg = "AssortmentFile '" + this.importPath + "' does not exist.";
- else if (this.importPath.isDirectory())
- errorMsg = "AssortmentFile '" + this.importPath + "' is a directory.";
- else if (!this.importPath.canRead())
- errorMsg = "AssortmentFile '" + this.importPath + "' is not readable.";
- else if (!this.importPath.canWrite())
- errorMsg = "AssortmentFile '" + this.importPath + "' is not writeable.";
- if (errorMsg != null) {
- this.log.logSevere(errorMsg);
- throw new IllegalStateException(errorMsg);
- }
-
- // getting the assortment length
- File importAssortmentPath = null;
- int assortmentNr = -1;
- try {
- importAssortmentPath = new File(this.importPath.getParent());
- assortmentNr = Integer.valueOf(this.importPath.getName().substring("indexAssortment".length(),"indexAssortment".length()+3)).intValue();
- if (assortmentNr <1 || assortmentNr > 64) {
- errorMsg = "AssortmentFile '" + this.importPath + "' has an invalid name.";
- }
- } catch (NumberFormatException e) {
- errorMsg = "Unable to parse the assortment file number.";
- this.log.logSevere(errorMsg);
- throw new IllegalStateException(errorMsg);
- }
-
- // initializing the import assortment db
- this.log.logInfo("Initializing source assortment file " + theImportAssortmentFile);
- this.assortmentFile = new plasmaWordIndexAssortment(importAssortmentPath, assortmentNr, preloadTime, this.log);
- this.importStartSize = this.assortmentFile.size();
- }
-
- public long getEstimatedTime() {
- return (this.wordEntityCount==0)?0:((this.assortmentFile.size()*getElapsedTime())/(this.wordEntityCount))-getElapsedTime();
- }
-
- public String getJobName() {
- return this.getImportPath().toString();
- }
-
- public int getProcessingStatusPercent() {
- return (this.wordEntityCount)/((this.importStartSize<100)?1:(this.importStartSize)/100);
- }
-
- public String getStatus() {
- StringBuffer theStatus = new StringBuffer();
-
- theStatus.append("#Word Entities=").append(this.wordEntityCount).append("\n");
- theStatus.append("#Word Entries=").append(this.wordEntryCount);
-
- return theStatus.toString();
- }
-
- public void run() {
- try {
- // getting a content interator
- Iterator contentIterator = this.assortmentFile.wordContainers();
- this.log.logFine("Started import of file " + this.assortmentFile.getName());
- while (contentIterator.hasNext()) {
- this.wordEntityCount++;
-
- // getting next entry as byte array
- indexContainer container = (indexContainer) contentIterator.next();
-
- this.wordEntryCount += container.size();
-
- // importing entity container to home db
- wi.addEntries(container, System.currentTimeMillis(), false);
-
- if (this.wordEntityCount % 1000 == 0) {
- this.log.logFine(this.wordEntityCount + " word entities processed so far.");
- }
- if (isAborted()) break;
- }
- } catch (Exception e) {
- this.error = e.toString();
- this.log.logSevere("Import process had detected an error",e);
- } finally {
- this.log.logInfo("Import process finished.");
- this.globalEnd = System.currentTimeMillis();
- //this.sb.dbImportManager.finishedJobs.add(this);
- this.assortmentFile.close();
- File bkpPath = new File(importPath.getParentFile(), "imported");
- bkpPath.mkdirs();
- File bkpFile = new File(bkpPath, importPath.getName());
- importPath.renameTo(bkpFile);
- }
- }
-
-}
diff --git a/source/de/anomic/plasma/dbImport/dbImportManager.java b/source/de/anomic/plasma/dbImport/dbImportManager.java
index 0c8c253e2..6a007e4ad 100644
--- a/source/de/anomic/plasma/dbImport/dbImportManager.java
+++ b/source/de/anomic/plasma/dbImport/dbImportManager.java
@@ -58,9 +58,7 @@ public class dbImportManager {
if (type.length() == 0) return null;
dbImporter newImporter = null;
- if (type.equalsIgnoreCase("ASSORTMENT")) {
- newImporter = new AssortmentImporter(this.sb.wordIndex);
- } else if (type.equalsIgnoreCase("NURL")) {
+ if (type.equalsIgnoreCase("NURL")) {
newImporter = new plasmaCrawlNURLImporter(this.sb);
}
return newImporter;
diff --git a/source/de/anomic/plasma/plasmaCondenser.java b/source/de/anomic/plasma/plasmaCondenser.java
index 2b3efbcc6..b7b1534f3 100644
--- a/source/de/anomic/plasma/plasmaCondenser.java
+++ b/source/de/anomic/plasma/plasmaCondenser.java
@@ -66,7 +66,7 @@ import java.util.TreeSet;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterImageEntry;
-import de.anomic.index.indexRWIEntryNew;
+import de.anomic.index.indexRWIEntry;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroBitfield;
import de.anomic.kelondro.kelondroMSetTools;
@@ -151,22 +151,22 @@ public final class plasmaCondenser {
// phrase 99 is taken from the media Link url and anchor description
// phrase 100 and above are lines from the text
- insertTextToWords(document.getTitle(), 1, indexRWIEntryNew.flag_app_descr, wflags);
+ insertTextToWords(document.getTitle(), 1, indexRWIEntry.flag_app_descr, wflags);
//insertTextToWords(document.getTitle(), 2, indexRWIEntryNew.flag_app_descr, wflags);
- insertTextToWords(document.getAbstract(), 3, indexRWIEntryNew.flag_app_descr, wflags);
- insertTextToWords(document.getAuthor(), 4, indexRWIEntryNew.flag_app_descr, wflags);
+ insertTextToWords(document.getAbstract(), 3, indexRWIEntry.flag_app_descr, wflags);
+ insertTextToWords(document.getAuthor(), 4, indexRWIEntry.flag_app_descr, wflags);
// missing: tags!
String[] titles = document.getSectionTitles();
for (int i = 0; i < titles.length; i++) {
- insertTextToWords(titles[i], i + 10, indexRWIEntryNew.flag_app_emphasized, wflags);
+ insertTextToWords(titles[i], i + 10, indexRWIEntry.flag_app_emphasized, wflags);
}
// anchors
Iterator i = document.getAnchors().entrySet().iterator();
while (i.hasNext()) {
entry = (Map.Entry) i.next();
- insertTextToWords((String) entry.getKey(), 98, indexRWIEntryNew.flag_app_url, wflags);
- insertTextToWords((String) entry.getValue(), 98, indexRWIEntryNew.flag_app_url, wflags);
+ insertTextToWords((String) entry.getKey(), 98, indexRWIEntry.flag_app_url, wflags);
+ insertTextToWords((String) entry.getValue(), 98, indexRWIEntry.flag_app_url, wflags);
}
} else {
this.RESULT_NUMB_WORDS = 0;
diff --git a/source/de/anomic/plasma/plasmaCrawlLURL.java b/source/de/anomic/plasma/plasmaCrawlLURL.java
index 3521c138a..0bfd72d26 100644
--- a/source/de/anomic/plasma/plasmaCrawlLURL.java
+++ b/source/de/anomic/plasma/plasmaCrawlLURL.java
@@ -62,9 +62,8 @@ import java.util.LinkedList;
import de.anomic.http.httpc;
import de.anomic.http.httpc.response;
-import de.anomic.index.indexRWIEntryNew;
+import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexURLEntry;
-import de.anomic.index.indexURLEntryNew;
import de.anomic.kelondro.kelondroBitfield;
import de.anomic.kelondro.kelondroCache;
import de.anomic.kelondro.kelondroCloneableIterator;
@@ -96,7 +95,7 @@ public final class plasmaCrawlLURL {
super();
try {
- urlIndexFile = new kelondroFlexSplitTable(new File(indexPath, "PUBLIC/TEXT"), "urls", preloadTime, indexURLEntryNew.rowdef);
+ urlIndexFile = new kelondroFlexSplitTable(new File(indexPath, "PUBLIC/TEXT"), "urls", preloadTime, indexURLEntry.rowdef);
} catch (IOException e) {
e.printStackTrace();
System.exit(-1);
@@ -164,7 +163,7 @@ public final class plasmaCrawlLURL {
return 0;
}
- public synchronized indexURLEntry load(String urlHash, indexRWIEntryNew searchedWord) {
+ public synchronized indexURLEntry load(String urlHash, indexRWIEntry searchedWord) {
// generates an plasmaLURLEntry using the url hash
// to speed up the access, the url-hashes are buffered
// in the hash cache.
@@ -175,7 +174,7 @@ public final class plasmaCrawlLURL {
try {
kelondroRow.Entry entry = urlIndexFile.get(urlHash.getBytes());
if (entry == null) return null;
- return new indexURLEntryNew(entry, searchedWord);
+ return new indexURLEntry(entry, searchedWord);
} catch (IOException e) {
return null;
}
@@ -206,7 +205,7 @@ public final class plasmaCrawlLURL {
public synchronized indexURLEntry newEntry(String propStr) {
if (propStr != null && propStr.startsWith("{") && propStr.endsWith("}")) {
- return new indexURLEntryNew(serverCodings.s2p(propStr.substring(1, propStr.length() - 1)));
+ return new indexURLEntry(serverCodings.s2p(propStr.substring(1, propStr.length() - 1)));
} else {
return null;
}
@@ -234,7 +233,7 @@ public final class plasmaCrawlLURL {
int limage,
int lvideo,
int lapp) {
- return new indexURLEntryNew(url, descr, author, tags, ETag, mod, load, fresh, referrer, md5,
+ return new indexURLEntry(url, descr, author, tags, ETag, mod, load, fresh, referrer, md5,
size, wc, dt, flags, lang, llocal, lother, laudio, limage, lvideo, lapp);
}
@@ -372,7 +371,7 @@ public final class plasmaCrawlLURL {
if (this.iter == null) { return null; }
if (this.iter.hasNext()) { e = (kelondroRow.Entry) this.iter.next(); }
if (e == null) { return null; }
- return new indexURLEntryNew(e, null);
+ return new indexURLEntry(e, null);
}
public final void remove() {
diff --git a/source/de/anomic/plasma/plasmaDHTChunk.java b/source/de/anomic/plasma/plasmaDHTChunk.java
index afdc75aa2..dae37ac8e 100644
--- a/source/de/anomic/plasma/plasmaDHTChunk.java
+++ b/source/de/anomic/plasma/plasmaDHTChunk.java
@@ -52,7 +52,6 @@ import java.util.Iterator;
import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
-import de.anomic.index.indexRWIEntryNew;
import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
@@ -213,7 +212,7 @@ public class plasmaDHTChunk {
final Iterator indexContainerIterator = wordIndex.indexContainerSet(hash, ram, true, maxcount).iterator();
indexContainer container;
Iterator urlIter;
- indexRWIEntryNew iEntry;
+ indexRWIEntry iEntry;
indexURLEntry lurl;
int refcount = 0;
int wholesize;
@@ -243,7 +242,7 @@ public class plasmaDHTChunk {
// CPU & IO reduce
// try { Thread.sleep(50); } catch (InterruptedException e) { }
- iEntry = (indexRWIEntryNew) urlIter.next();
+ iEntry = (indexRWIEntry) urlIter.next();
if ((iEntry == null) || (iEntry.urlHash() == null)) {
urlIter.remove();
continue;
@@ -263,7 +262,7 @@ public class plasmaDHTChunk {
// remove all remaining; we have enough
while (urlIter.hasNext()) {
- iEntry = (indexRWIEntryNew) urlIter.next();
+ iEntry = (indexRWIEntry) urlIter.next();
urlIter.remove();
}
diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.java
index 21ffdf069..6b54fa357 100644
--- a/source/de/anomic/plasma/plasmaSearchEvent.java
+++ b/source/de/anomic/plasma/plasmaSearchEvent.java
@@ -50,7 +50,7 @@ import java.util.Set;
import java.util.TreeMap;
import de.anomic.index.indexContainer;
-import de.anomic.index.indexRWIEntryNew;
+import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMSetTools;
@@ -393,7 +393,7 @@ public final class plasmaSearchEvent extends Thread implements Runnable {
profileLocal.startTimer();
plasmaSearchPostOrder acc = new plasmaSearchPostOrder(query, ranking);
- indexRWIEntryNew entry;
+ indexRWIEntry entry;
indexURLEntry page;
Long preranking;
Object[] preorderEntry;
@@ -402,7 +402,7 @@ public final class plasmaSearchEvent extends Thread implements Runnable {
while (preorder.hasNext()) {
if ((System.currentTimeMillis() >= postorderLimitTime) && (acc.sizeFetched() >= minEntries)) break;
preorderEntry = preorder.next();
- entry = (indexRWIEntryNew) preorderEntry[0];
+ entry = (indexRWIEntry) preorderEntry[0];
// load only urls if there was not yet a root url of that hash
preranking = (Long) preorderEntry[1];
// find the url entry
@@ -457,11 +457,11 @@ public final class plasmaSearchEvent extends Thread implements Runnable {
if (preorder.filteredCount()> query.wantedResults) preorder.remove(true, true);
// start url-fetch
- indexRWIEntryNew entry;
+ indexRWIEntry entry;
try {
while (preorder.hasNext()) {
if (System.currentTimeMillis() >= timeout) break;
- entry = (indexRWIEntryNew) (preorder.next()[0]);
+ entry = (indexRWIEntry) (preorder.next()[0]);
// find and fetch the url entry
urlStore.load(entry.urlHash(), entry);
}
diff --git a/source/de/anomic/plasma/plasmaSearchRankingProfile.java b/source/de/anomic/plasma/plasmaSearchRankingProfile.java
index 084897d74..73f3e7572 100644
--- a/source/de/anomic/plasma/plasmaSearchRankingProfile.java
+++ b/source/de/anomic/plasma/plasmaSearchRankingProfile.java
@@ -47,7 +47,6 @@ import java.util.Map;
import java.util.Set;
import de.anomic.index.indexRWIEntry;
-import de.anomic.index.indexRWIEntryNew;
import de.anomic.plasma.plasmaURL;
import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroBitfield;
@@ -268,12 +267,12 @@ public class plasmaSearchRankingProfile {
ranking += (normalizedEntry.worddistance() == 0) ? 0 : (256 - normalizedEntry.worddistance()) << coeff_worddistance;
kelondroBitfield flags = normalizedEntry.flags();
- ranking += (flags.get(indexRWIEntryNew.flag_app_url)) ? 256 << coeff_appurl : 0;
- ranking += (flags.get(indexRWIEntryNew.flag_app_descr)) ? 256 << coeff_appdescr : 0;
- ranking += (flags.get(indexRWIEntryNew.flag_app_author)) ? 256 << coeff_appauthor : 0;
- ranking += (flags.get(indexRWIEntryNew.flag_app_tags)) ? 256 << coeff_apptags : 0;
- ranking += (flags.get(indexRWIEntryNew.flag_app_reference)) ? 256 << coeff_appref : 0;
- ranking += (flags.get(indexRWIEntryNew.flag_app_emphasized)) ? 256 << coeff_appemph : 0;
+ ranking += (flags.get(indexRWIEntry.flag_app_url)) ? 256 << coeff_appurl : 0;
+ ranking += (flags.get(indexRWIEntry.flag_app_descr)) ? 256 << coeff_appdescr : 0;
+ ranking += (flags.get(indexRWIEntry.flag_app_author)) ? 256 << coeff_appauthor : 0;
+ ranking += (flags.get(indexRWIEntry.flag_app_tags)) ? 256 << coeff_apptags : 0;
+ ranking += (flags.get(indexRWIEntry.flag_app_reference)) ? 256 << coeff_appref : 0;
+ ranking += (flags.get(indexRWIEntry.flag_app_emphasized)) ? 256 << coeff_appemph : 0;
ranking += (flags.get(plasmaCondenser.flag_cat_indexof)) ? 256 << coeff_catindexof : 0;
ranking += (flags.get(plasmaCondenser.flag_cat_hasimage)) ? 256 << coeff_cathasimage : 0;
ranking += (flags.get(plasmaCondenser.flag_cat_hasaudio)) ? 256 << coeff_cathasaudio : 0;
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index ac0e25f88..a503425d3 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -135,7 +135,6 @@ import de.anomic.http.httpd;
import de.anomic.http.httpdRobotsTxtConfig;
import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
-import de.anomic.index.indexRWIEntryNew;
import de.anomic.plasma.plasmaURL;
import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroBase64Order;
@@ -2330,7 +2329,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
String word = (String) wentry.getKey();
wordStat = (plasmaCondenser.wordStatProp) wentry.getValue();
String wordHash = plasmaCondenser.word2hash(word);
- indexRWIEntry wordIdxEntry = new indexRWIEntryNew(
+ indexRWIEntry wordIdxEntry = new indexRWIEntry(
urlHash,
urlLength, urlComps,
wordStat.count,
diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java
index f2322228e..94fe8bb6f 100644
--- a/source/de/anomic/plasma/plasmaWordIndex.java
+++ b/source/de/anomic/plasma/plasmaWordIndex.java
@@ -43,7 +43,6 @@ import de.anomic.index.indexContainerOrder;
import de.anomic.index.indexRAMRI;
import de.anomic.index.indexRI;
import de.anomic.index.indexRWIEntry;
-import de.anomic.index.indexRWIEntryNew;
import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroCloneableIterator;
@@ -74,13 +73,13 @@ public final class plasmaWordIndex implements indexRI {
public plasmaWordIndex(File indexRoot, long preloadTime, serverLog log) {
File textindexcache = new File(indexRoot, "PUBLIC/TEXT/RICACHE");
if (!(textindexcache.exists())) textindexcache.mkdirs();
- this.dhtOutCache = new indexRAMRI(textindexcache, indexRWIEntryNew.urlEntryRow, wCacheMaxChunk, wCacheMaxAge, "dump1.array", log);
- this.dhtInCache = new indexRAMRI(textindexcache, indexRWIEntryNew.urlEntryRow, wCacheMaxChunk, wCacheMaxAge, "dump2.array", log);
+ this.dhtOutCache = new indexRAMRI(textindexcache, indexRWIEntry.urlEntryRow, wCacheMaxChunk, wCacheMaxAge, "dump1.array", log);
+ this.dhtInCache = new indexRAMRI(textindexcache, indexRWIEntry.urlEntryRow, wCacheMaxChunk, wCacheMaxAge, "dump2.array", log);
// create collections storage path
File textindexcollections = new File(indexRoot, "PUBLIC/TEXT/RICOLLECTION");
if (!(textindexcollections.exists())) textindexcollections.mkdirs();
- this.collections = new indexCollectionRI(textindexcollections, "collection", preloadTime, maxCollectionPartition, indexRWIEntryNew.urlEntryRow);
+ this.collections = new indexCollectionRI(textindexcollections, "collection", preloadTime, maxCollectionPartition, indexRWIEntry.urlEntryRow);
// create LURL-db
loadedURL = new plasmaCrawlLURL(indexRoot, preloadTime);
@@ -166,12 +165,10 @@ public final class plasmaWordIndex implements indexRI {
}
public indexContainer emptyContainer(String wordHash) {
- return new indexContainer(wordHash, indexRWIEntryNew.urlEntryRow);
+ return new indexContainer(wordHash, indexRWIEntry.urlEntryRow);
}
public void addEntry(String wordHash, indexRWIEntry entry, long updateTime, boolean dhtInCase) {
- assert (entry instanceof indexRWIEntryNew);
-
// set dhtInCase depending on wordHash
if ((!dhtInCase) && (yacyDHTAction.shallBeOwnWord(wordHash))) dhtInCase = true;
@@ -186,7 +183,7 @@ public final class plasmaWordIndex implements indexRI {
}
public void addEntries(indexContainer entries, long updateTime, boolean dhtInCase) {
- assert (entries.row().objectsize() == indexRWIEntryNew.urlEntryRow.objectsize());
+ assert (entries.row().objectsize() == indexRWIEntry.urlEntryRow.objectsize());
// set dhtInCase depending on wordHash
if ((!dhtInCase) && (yacyDHTAction.shallBeOwnWord(entries.getWordHash()))) dhtInCase = true;
@@ -295,7 +292,7 @@ public final class plasmaWordIndex implements indexRI {
word = (String) wentry.getKey();
wprop = (plasmaCondenser.wordStatProp) wentry.getValue();
assert (wprop.flags != null);
- ientry = new indexRWIEntryNew(urlHash,
+ ientry = new indexRWIEntry(urlHash,
urlLength, urlComps, (document == null) ? urlLength : document.getTitle().length(),
wprop.count,
condenser.words().size(),
@@ -396,7 +393,7 @@ public final class plasmaWordIndex implements indexRI {
}
public indexContainer deleteContainer(String wordHash) {
- indexContainer c = new indexContainer(wordHash, indexRWIEntryNew.urlEntryRow);
+ indexContainer c = new indexContainer(wordHash, indexRWIEntry.urlEntryRow);
c.addAllUnique(dhtInCache.deleteContainer(wordHash));
c.addAllUnique(dhtOutCache.deleteContainer(wordHash));
c.addAllUnique(collections.deleteContainer(wordHash));
diff --git a/source/de/anomic/plasma/plasmaWordIndexAssortment.java b/source/de/anomic/plasma/plasmaWordIndexAssortment.java
deleted file mode 100644
index 793eb0191..000000000
--- a/source/de/anomic/plasma/plasmaWordIndexAssortment.java
+++ /dev/null
@@ -1,173 +0,0 @@
-// plasmaWordIndexAssortment.java
-// ------------------------------
-// part of YACY
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2005
-// last major change: 18.5.2005
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Using this software in any meaning (reading, learning, copying, compiling,
-// running) means that you agree that the Author(s) is (are) not responsible
-// for cost, loss of data or any harm that may be caused directly or indirectly
-// by usage of this softare or this documentation. The usage of this software
-// is on your own risk. The installation and usage (starting/running) of this
-// software may allow other people or application to access your computer and
-// any attached devices and is highly dependent on the configuration of the
-// software which must be done by the user of the software; the author(s) is
-// (are) also not responsible for proper configuration and usage of the
-// software, even if provoked by documentation provided together with
-// the software.
-//
-// Any changes to this file according to the GPL as documented in the file
-// gpl.txt aside this file in the shipment you received can be done to the
-// lines that follows this copyright notice here, but changes must not be
-// done inside the copyright notive above. A re-distribution must contain
-// the intact and unchanged copyright notice.
-// Contributions and changes to the program code must be marked as such.
-
-/*
- An assortment is a set of words that appear exactly on a specific
- number of different web pages. A special case is, when the the word
- appear only on a single web page: this is called a 'singleton'.
- YaCy maintains a word cache for words appearing on x web pages.
- For each 'x' there is an assortment database, where 1<=x<=max
- If a word appears on more than 'max' web pages, the corresponing url-list
- is stored to some kind of back-end database which we consider as the
- 'slowest' option to save data. This here is the fastest file-based.
- */
-
-package de.anomic.plasma;
-
-import java.io.File;
-import java.util.Iterator;
-
-import de.anomic.index.indexContainer;
-import de.anomic.index.indexRWIEntryNew;
-import de.anomic.index.indexRWIEntryOld;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroColumn;
-import de.anomic.kelondro.kelondroException;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroTree;
-import de.anomic.server.logging.serverLog;
-import de.anomic.yacy.yacySeedDB;
-
-public final class plasmaWordIndexAssortment {
-
- // environment constants
- private static final String assortmentFileName = "indexAssortment";
-
- // class variables
- private File assortmentFile;
- private serverLog log;
- private kelondroTree assortment;
-
- private static String intx(int x) {
- String s = Integer.toString(x);
- while (s.length() < 3) s = "0" + s;
- return s;
- }
-
- private kelondroRow bufferStructure(int assortmentCapacity) {
- kelondroColumn[] structure = new kelondroColumn[3 + assortmentCapacity];
- structure[0] = new kelondroColumn("byte[] wordhash-" + yacySeedDB.commonHashLength);
- structure[1] = new kelondroColumn("Cardinal occ-4 {b256}");
- structure[2] = new kelondroColumn("Cardinal time-8 {b256}");
- kelondroColumn p = new kelondroColumn("byte[] urlprops-" + indexRWIEntryOld.urlEntryRow.objectsize());
- for (int i = 0; i < assortmentCapacity; i++) structure[3 + i] = p;
- return new kelondroRow(structure, kelondroBase64Order.enhancedCoder, 0);
- }
-
- private int assortmentCapacity(int rowsize) {
- return (rowsize - yacySeedDB.commonHashLength - 12) / indexRWIEntryOld.urlEntryRow.objectsize();
- }
-
- public plasmaWordIndexAssortment(File storagePath, int assortmentLength, long preloadTime, serverLog log) {
- if (!(storagePath.exists())) storagePath.mkdirs();
- this.assortmentFile = new File(storagePath, assortmentFileName + intx(assortmentLength) + ".db");
- //this.bufferStructureLength = 3 + 2 * assortmentLength;
- this.log = log;
- // open assortment tree file
- long start = System.currentTimeMillis();
- assortment = kelondroTree.open(assortmentFile, true, preloadTime, bufferStructure(assortmentLength));
- long stop = System.currentTimeMillis();
- if (log != null) log.logConfig("Opened Assortment, " +
- assortment.size() + " entries, width " +
- preloadTime + " ms preloadTime, " +
- (stop - start) + " ms effective");
-
- }
-
- public String getName() {
- return this.assortmentFile.toString();
- }
-
- public final indexContainer row2container(kelondroRow.Entry row) {
- if (row == null) return null;
- String wordHash = row.getColString(0, null);
- final long updateTime = row.getColLong(2);
- indexContainer container = new indexContainer(wordHash, indexRWIEntryNew.urlEntryRow);
- int al = assortmentCapacity(row.objectsize());
- for (int i = 0; i < al; i++) try {
- // fill AND convert old entries to new entries
- container.add(new indexRWIEntryNew(new indexRWIEntryOld(row.getColBytes(3 + i))), updateTime);
- } catch (kelondroException e) {}
- return container;
- }
-
- public Iterator wordContainers() {
- // returns an iteration of indexContainer elements
- try {
- return new containerIterator();
- } catch (kelondroException e) {
- log.logSevere("iterateAssortment/kelondro-error: " + e.getMessage(), e);
- return null;
- }
- }
-
- public class containerIterator implements Iterator {
-
- private Iterator rowIterator;
-
- public containerIterator() {
- rowIterator = assortment.contentRows(-1);
- }
-
- public boolean hasNext() {
- return rowIterator.hasNext();
- }
-
- public Object next() {
- kelondroRow.Entry entry = (kelondroRow.Entry) rowIterator.next();
- return row2container(entry);
- }
-
- public void remove() {
- rowIterator.remove();
- }
-
- }
-
- public int size() {
- return assortment.size();
- }
-
- public void close() {
- assortment.close();
- }
-
-}
diff --git a/source/de/anomic/plasma/plasmaWordIndexFile.java b/source/de/anomic/plasma/plasmaWordIndexFile.java
deleted file mode 100644
index 65637232b..000000000
--- a/source/de/anomic/plasma/plasmaWordIndexFile.java
+++ /dev/null
@@ -1,215 +0,0 @@
-// plasmaWordIndexFile.java
-// --------------------------
-// part of YACY
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2004
-//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Using this software in any meaning (reading, learning, copying, compiling,
-// running) means that you agree that the Author(s) is (are) not responsible
-// for cost, loss of data or any harm that may be caused directly or indirectly
-// by usage of this softare or this documentation. The usage of this software
-// is on your own risk. The installation and usage (starting/running) of this
-// software may allow other people or application to access your computer and
-// any attached devices and is highly dependent on the configuration of the
-// software which must be done by the user of the software; the author(s) is
-// (are) also not responsible for proper configuration and usage of the
-// software, even if provoked by documentation provided together with
-// the software.
-//
-// Any changes to this file according to the GPL as documented in the file
-// gpl.txt aside this file in the shipment you received can be done to the
-// lines that follows this copyright notice here, but changes must not be
-// done inside the copyright notive above. A re-distribution must contain
-// the intact and unchanged copyright notice.
-// Contributions and changes to the program code must be marked as such.
-
-package de.anomic.plasma;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-
-import de.anomic.index.indexContainer;
-import de.anomic.index.indexRWIEntry;
-import de.anomic.index.indexRWIEntryNew;
-import de.anomic.index.indexRWIEntryOld;
-import de.anomic.kelondro.kelondroBase64Order;
-import de.anomic.kelondro.kelondroException;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroTree;
-import de.anomic.yacy.yacySeedDB;
-
-public final class plasmaWordIndexFile {
-
- private final String theWordHash;
- private kelondroTree theIndex;
- private File theLocation;
-
- public plasmaWordIndexFile(File databaseRoot, String wordHash) {
- theWordHash = wordHash;
- theIndex = indexFile(databaseRoot, wordHash);
- }
-
- public static boolean removePlasmaIndex(File databaseRoot, String wordHash) {
- File f = wordHash2path(databaseRoot, wordHash);
- boolean success = true;
- if (f.exists()) success = f.delete();
- // clean up directory structure
- f = f.getParentFile();
- while ((f.isDirectory()) && (f.list().length == 0)) {
- if (!(f.delete())) break;
- f = f.getParentFile();
- }
- return success;
- }
-
- private kelondroTree indexFile(File databaseRoot, String wordHash) {
- if (wordHash.length() < 12) throw new RuntimeException("word hash wrong: '" + wordHash + "'");
- theLocation = wordHash2path(databaseRoot, wordHash);
- File fp = theLocation.getParentFile();
- if (fp != null) fp.mkdirs();
- return kelondroTree.open(theLocation, true, 0,
- new kelondroRow("byte[] urlhash-" + yacySeedDB.commonHashLength + ", byte[] ba-" + (indexRWIEntryOld.urlEntryRow.objectsize() - yacySeedDB.commonHashLength),
- kelondroBase64Order.enhancedCoder, 0));
- }
-
- public static File wordHash2path(File databaseRoot, String hash) {
- // creates a path that constructs hashing on a file system
-
- return new File (databaseRoot, "WORDS/" +
- hash.substring(0,1) + "/" + hash.substring(1,2) + "/" + hash.substring(2,4) + "/" +
- hash.substring(4,6) + "/" + hash + ".db");
- }
-
- public String wordHash() {
- return theWordHash;
- }
-
- public int size() {
- if (theIndex == null) return 0;
- int size = theIndex.size();
- if (size == 0) {
- deleteComplete();
- return 0;
- } else {
- return size;
- }
- }
-
- public void close() throws IOException {
- if (theIndex != null) theIndex.close();
- theIndex = null;
- }
-
- public void finalize() {
- try {
- close();
- } catch (IOException e) {}
- }
-
- public indexRWIEntry getEntry(String urlhash) throws IOException {
- kelondroRow.Entry n = theIndex.get(urlhash.getBytes());
- if (n == null) return null;
- try {
- return new indexRWIEntryNew(new indexRWIEntryOld(n.getColString(0, null), n.getColString(1, null)));
- } catch (kelondroException e) {return null;}
- }
-
- public boolean contains(String urlhash) throws IOException {
- return (theIndex.get(urlhash.getBytes()) != null);
- }
-
- public boolean contains(indexRWIEntry entry) throws IOException {
- return (theIndex.get(entry.urlHash().getBytes()) != null);
- }
-
- public void addEntries(indexContainer container) {
- throw new UnsupportedOperationException("word files are not supported in YaCy 0.491 and above");
- }
-
- public boolean deleteComplete() {
- if (theIndex == null) return false;
- theIndex.close();
- // remove file
- boolean success = theLocation.delete();
- // and also the paren directory if that is empty
- if (success) {
- File f = theLocation.getParentFile();
- while ((f.isDirectory()) && (f.list().length == 0)) {
- if (!(f.delete())) break;
- f = f.getParentFile();
- }
- }
- // reset all values
- theIndex = null;
- theLocation = null;
- return success;
- }
-
- public boolean removeEntry(String urlHash, boolean deleteComplete) throws IOException {
- // returns true if there was an entry before, false if the key did not exist
- // if after the removal the file is empty, then the file can be deleted if
- // the flag deleteComplete is set.
- if (urlHash == null || theIndex == null) return false;
- boolean wasEntry = (theIndex.remove(urlHash.getBytes()) != null);
- if ((theIndex.size() == 0) && (deleteComplete)) deleteComplete();
- return wasEntry;
- }
-
- public Iterator elements(boolean up) {
- // returns an enumeration of plasmaWordIndexEntry objects
- return new dbenum(up);
- }
-
- public final class dbenum implements Iterator {
- Iterator i;
- public dbenum(boolean up) {
- if (theIndex == null) {
- i = null;
- } else try {
- i = theIndex.contentRows(-1);
- } catch (kelondroException e) {
- e.printStackTrace();
- new File(theIndex.filename()).delete();
- i = null;
- }
- }
- public boolean hasNext() {
- return (i != null) && (i.hasNext());
- }
- public Object next() {
- if (i == null) return null;
- kelondroRow.Entry n = (kelondroRow.Entry) i.next();
- try {
- return new indexRWIEntryNew(new indexRWIEntryOld(n.getColString(0, null), n.getColString(1, null)));
- } catch (kelondroException e) { return null; }
- }
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- public String toString() {
- return "DB:" + theIndex.toString();
- }
-
-}
diff --git a/source/de/anomic/plasma/plasmaWordIndexFileCluster.java b/source/de/anomic/plasma/plasmaWordIndexFileCluster.java
deleted file mode 100644
index 1395f7172..000000000
--- a/source/de/anomic/plasma/plasmaWordIndexFileCluster.java
+++ /dev/null
@@ -1,296 +0,0 @@
-// plasmaWordIndexClassicDB.java
-// -----------------------------
-// part of YACY
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2005
-// last major change: 6.5.2005
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Using this software in any meaning (reading, learning, copying, compiling,
-// running) means that you agree that the Author(s) is (are) not responsible
-// for cost, loss of data or any harm that may be caused directly or indirectly
-// by usage of this softare or this documentation. The usage of this software
-// is on your own risk. The installation and usage (starting/running) of this
-// software may allow other people or application to access your computer and
-// any attached devices and is highly dependent on the configuration of the
-// software which must be done by the user of the software; the author(s) is
-// (are) also not responsible for proper configuration and usage of the
-// software, even if provoked by documentation provided together with
-// the software.
-//
-// Any changes to this file according to the GPL as documented in the file
-// gpl.txt aside this file in the shipment you received can be done to the
-// lines that follows this copyright notice here, but changes must not be
-// done inside the copyright notive above. A re-distribution must contain
-// the intact and unchanged copyright notice.
-// Contributions and changes to the program code must be marked as such.
-
-
-package de.anomic.plasma;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.TreeSet;
-
-import de.anomic.index.indexContainer;
-import de.anomic.index.indexRI;
-import de.anomic.index.indexRWIEntryNew;
-import de.anomic.index.indexRWIEntryOld;
-import de.anomic.kelondro.kelondroCloneableIterator;
-import de.anomic.kelondro.kelondroException;
-import de.anomic.kelondro.kelondroNaturalOrder;
-import de.anomic.yacy.yacySeedDB;
-
-public class plasmaWordIndexFileCluster implements indexRI {
-
- // class variables
- private final File databaseRoot;
- private int size;
-
- public plasmaWordIndexFileCluster(File databaseRoot) {
- this.databaseRoot = databaseRoot;
- this.size = 0;
- }
-
- public int size() {
- return size;
- }
-
- public kelondroCloneableIterator wordContainers(String startHash, boolean rot) {
- return new containerIterator(wordHashes(startHash, rot));
- }
-
- public class containerIterator implements kelondroCloneableIterator {
-
- // this is a highly inefficient class that is here for the
- // only case to support a compatible interface until the
- // new database structure is in place and makes the
- // plasmaWordIndexFileCluster class superfluous
-
- private kelondroCloneableIterator wordIterator;
-
- public containerIterator(kelondroCloneableIterator wordIterator) {
- this.wordIterator = wordIterator;
- }
-
- public Object clone(Object modifier) {
- return new containerIterator((kelondroCloneableIterator) this.wordIterator.clone(modifier));
- }
-
- public boolean hasNext() {
- return wordIterator.hasNext();
- }
-
- public Object next() {
- return getContainer((String) wordIterator.next(), null, 100);
- }
-
- public void remove() {
- wordIterator.remove();
- }
-
- }
-
- public kelondroCloneableIterator wordHashes(String startHash, boolean rot) {
- // outdated method: to be replaced by wordContainers
- return wordHashes(startHash, true, rot);
- }
-
- public kelondroCloneableIterator wordHashes(String startHash, boolean up, boolean rot) {
- if (rot) throw new UnsupportedOperationException("no rot allowed");
- return new iterateFiles(startHash, up);
- }
-
- public class iterateFiles implements kelondroCloneableIterator {
-
- private final ArrayList hierarchy; // contains TreeSet elements, earch TreeSet contains File Entries
- private final Comparator comp; // for string-compare
- private String buffer; // the prefetch-buffer
- private boolean up;
-
- public iterateFiles(String startHash, boolean up) {
- this.up = up;
- this.hierarchy = new ArrayList();
- this.comp = new kelondroNaturalOrder(up);
-
- // the we initially fill the hierarchy with the content of the root folder
- String path = "WORDS";
- TreeSet list = list(new File(databaseRoot, path));
-
- // if we have a start hash then we find the appropriate subdirectory to start
- if ((startHash != null) && (startHash.length() == yacySeedDB.commonHashLength)) {
- delete(startHash.substring(0, 1), list);
- if (list.size() > 0) {
- hierarchy.add(list);
- String[] paths = new String[]{startHash.substring(0, 1), startHash.substring(1, 2), startHash.substring(2, 4), startHash.substring(4, 6)};
- int pathc = 0;
- while ((pathc < paths.length) &&
- (comp.compare((String) list.first(), paths[pathc]) == 0)) {
- path = path + "/" + paths[pathc];
- list = list(new File(databaseRoot, path));
- delete(paths[pathc], list);
- if (list.size() == 0) break;
- hierarchy.add(list);
- pathc++;
- }
- }
- while (((buffer = next0()) != null) && (comp.compare(buffer, startHash) < 0)) {}
- } else {
- hierarchy.add(list);
- buffer = next0();
- }
- }
-
- public Object clone(Object secondHash) {
- return new iterateFiles((String) secondHash, up);
- }
-
- private synchronized void delete(String pattern, TreeSet names) {
- String name;
- while ((names.size() > 0) && (comp.compare((new File(name = (String) names.first())).getName(), pattern) < 0)) names.remove(name);
- }
-
- private TreeSet list(File path) {
- //System.out.println("PATH: " + path);
- TreeSet t = new TreeSet(comp);
- String[] l = path.list();
- if (l != null) for (int i = 0; i < l.length; i++) t.add(path + "/" + l[i]);
- //else System.out.println("DEBUG: wrong path " + path);
- //System.out.println(t);
- return t;
- }
-
- private synchronized String next0() {
- // the object is a File pointing to the corresponding file
- File f;
- String n;
- TreeSet t;
- do {
- t = null;
- while ((t == null) && (hierarchy.size() > 0)) {
- t = (TreeSet) hierarchy.get(hierarchy.size() - 1);
- if (t.size() == 0) {
- hierarchy.remove(hierarchy.size() - 1); // we step up one hierarchy
- t = null;
- }
- }
- if ((hierarchy.size() == 0) || (t.size() == 0)) return null; // this is the end
- // fetch value
- f = new File(n = (String) t.first());
- t.remove(n);
- // if the value represents another folder, we step into the next hierarchy
- if (f.isDirectory()) {
- t = list(f);
- if (t.size() == 0) {
- // the folder is empty, delete it
- f.delete();
- } else {
- hierarchy.add(t);
- }
- f = null;
- }
- } while (f == null);
- // thats it
- if ((f == null) || ((n = f.getName()) == null) || (n.length() < yacySeedDB.commonHashLength)) {
- return null;
- } else {
- return n.substring(0, yacySeedDB.commonHashLength);
- }
- }
-
- public boolean hasNext() {
- return buffer != null;
- }
-
- public Object next() {
- String r = buffer;
- while (((buffer = next0()) != null) && (comp.compare(buffer, r) < 0)) {}
- return r;
- }
-
- public void remove() {
-
- }
- }
-
- public synchronized boolean exists(String wordHash) {
- return plasmaWordIndexFile.wordHash2path(databaseRoot, wordHash).exists();
- }
-
- public synchronized boolean hasContainer(String wordHash) {
- return getContainer(wordHash, new TreeSet(), -1) != null;
- }
-
- public synchronized indexContainer getContainer(String wordHash, Set urlselection, long maxTime) {
- long start = System.currentTimeMillis();
- if ((maxTime < 0) || (maxTime > 60000)) maxTime=60000; // maximum is one minute
- if (exists(wordHash)) {
- plasmaWordIndexFile entity = this.getEntity(wordHash, (maxTime < 0) ? -1 : maxTime * 9 / 10);
- indexContainer container = new indexContainer(wordHash, indexRWIEntryNew.urlEntryRow);
- indexRWIEntryNew entry;
- Iterator i = entity.elements(true);
- while ((i.hasNext()) && (System.currentTimeMillis() < (start + maxTime))) try {
- entry = new indexRWIEntryNew((indexRWIEntryOld) i.next());
- if ((urlselection == null) || (urlselection.contains(entry.urlHash()))) container.add(entry);
- } catch (kelondroException e) {}
- return container;
- } else {
- return new indexContainer(wordHash, indexRWIEntryNew.urlEntryRow);
- }
- }
-
- public plasmaWordIndexFile getEntity(String wordHash, long maxTime) {
- return new plasmaWordIndexFile(databaseRoot, wordHash);
- }
-
- public long getUpdateTime(String wordHash) {
- File f = plasmaWordIndexFile.wordHash2path(databaseRoot, wordHash);
- if (f.exists()) return f.lastModified(); else return -1;
- }
-
- public indexContainer deleteContainer(String wordHash) {
- plasmaWordIndexFile.removePlasmaIndex(databaseRoot, wordHash);
- return null;
- }
-
- public boolean removeEntry(String wordHash, String urlHash) {
- throw new UnsupportedOperationException("word files are not supported in YaCy 0.491 and above");
- }
-
- public int removeEntries(String wordHash, Set urlHashes) {
- throw new UnsupportedOperationException("word files are not supported in YaCy 0.491 and above");
- }
-
- public void addEntries(indexContainer container, long creationTime, boolean highPriority) {
- throw new UnsupportedOperationException("word files are not supported in YaCy 0.491 and above");
- }
-
- public void close() {
- }
-
- public int indexSize(String wordHash) {
- throw new UnsupportedOperationException();
- }
-
- public int minMem() {
- return 1024*1024;
- }
-
-}
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index d2d957459..343697edb 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -55,7 +55,6 @@ import java.util.TreeMap;
import de.anomic.http.httpc;
import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
-import de.anomic.index.indexRWIEntryNew;
import de.anomic.plasma.plasmaURL;
import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroBase64Order;
@@ -535,7 +534,6 @@ public final class yacyClient {
}
// add the url entry to the word indexes
for (int m = 0; m < words; m++) {
- assert (entry instanceof indexRWIEntryNew);
container[m].add(entry, System.currentTimeMillis());
}
// store url hash for statistics
diff --git a/source/yacy.java b/source/yacy.java
index 172fb3b1b..19b3aaf58 100644
--- a/source/yacy.java
+++ b/source/yacy.java
@@ -54,7 +54,6 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -72,16 +71,10 @@ import de.anomic.http.httpdFileHandler;
import de.anomic.http.httpdProxyHandler;
import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry;
-import de.anomic.index.indexRWIEntryNew;
import de.anomic.index.indexURLEntry;
-import de.anomic.index.indexURLEntryOld;
-import de.anomic.kelondro.kelondroBitfield;
import de.anomic.kelondro.kelondroDyn;
-import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.kelondro.kelondroMapObjects;
-import de.anomic.kelondro.kelondroRow;
-import de.anomic.kelondro.kelondroTree;
import de.anomic.net.URL;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.plasma.plasmaCrawlEntry;
@@ -90,10 +83,6 @@ import de.anomic.plasma.plasmaCrawlNURL;
import de.anomic.plasma.plasmaCrawlZURL;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaWordIndex;
-import de.anomic.plasma.plasmaWordIndexAssortment;
-import de.anomic.plasma.plasmaWordIndexFile;
-import de.anomic.plasma.plasmaWordIndexFileCluster;
-import de.anomic.plasma.dbImport.AssortmentImporter;
import de.anomic.server.serverCore;
import de.anomic.server.serverDate;
import de.anomic.server.serverFileUtils;
@@ -619,115 +608,6 @@ public final class yacy {
// finished
serverLog.logConfig("GEN-WORDSTAT", "FINISHED");
}
-
- /**
- * Migrates the PLASMA WORDS structure to the assortment cache if possible.
- * This method will be called if you start yacy with the argument
- * -migratewords.
- * Caution: This might take a long time to finish. Don't interrupt it!
- * FIXME: Shouldn't this method be private?
- *
- * @param homePath Root-path where all the information is to be found.
- */
- public static void migrateWords(String homePath) {
- // run with "java -classpath classes yacy -migratewords"
- try {serverLog.configureLogging(new File(homePath, "DATA/LOG/yacy.logging"));} catch (Exception e) {}
- File dbroot = new File(new File(homePath), "DATA/PLASMADB");
- File indexRoot = new File(new File(homePath), "DATA/INDEX");
- serverLog log = new serverLog("WORDMIGRATION");
- log.logInfo("STARTING MIGRATION");
- plasmaWordIndex wordIndexCache = new plasmaWordIndex(indexRoot, 10000, log);
- enumerateFiles words = new enumerateFiles(new File(dbroot, "WORDS"), true, false, true, true);
- String wordhash;
- File wordfile;
- int migrationCount;
- while (words.hasMoreElements())
- try {
- wordfile = (File) words.nextElement();
- wordhash = wordfile.getName().substring(0, 12);
- // System.out.println("NOW: " + wordhash);
- migrationCount = migrateWords2index(dbroot, wordhash, wordIndexCache);
- if (migrationCount >= 0) {
- if (migrationCount == 0)
- log.logInfo("SKIPPED " + wordhash + ": empty");
- else if (migrationCount > 0)
- log.logInfo("MIGRATED " + wordhash + ": " + migrationCount + " entries");
- else
- log.logInfo("REVERSED " + wordhash + ": " + (-migrationCount) + " entries");
- } else {
- log.logInfo("SKIPPED " + wordhash);
- }
- } catch (Exception e) {
- log.logSevere("Exception", e);
- }
- log.logInfo("FINISHED MIGRATION JOB, WAIT FOR DUMP");
- wordIndexCache.close();
- log.logInfo("TERMINATED MIGRATION");
- }
-
-
- public static int migrateWords2index(File oldDatabaseRoot, String wordhash, plasmaWordIndex wi) throws IOException {
- // returns the number of entries that had been added to the assortments
- // can be negative if some assortments have been moved to the backend
- File db = plasmaWordIndexFile.wordHash2path(oldDatabaseRoot, wordhash);
- if (!(db.exists())) {
- serverLog.logSevere("migrateWordIndex", "word index file for hash " + wordhash + " not found");
- return -1;
- }
- plasmaWordIndexFile entity = null;
- try {
- entity = new plasmaWordIndexFile(oldDatabaseRoot, wordhash);
- int size = entity.size();
- indexContainer container = new indexContainer(wordhash, indexRWIEntryNew.urlEntryRow);
-
- try {
- Iterator entries = entity.elements(true);
- indexRWIEntry entry;
- while (entries.hasNext()) {
- entry = (indexRWIEntry) entries.next();
- // System.out.println("ENTRY = " + entry.getUrlHash());
- container.add(entry, System.currentTimeMillis());
- }
- // we have read all elements, now delete the entity
- entity.deleteComplete();
- entity.close();
- entity = null;
-
- wi.addEntries(container, container.updated(), false);
- return size;
- } catch (kelondroException e) {
- // database corrupted, we simply give up the database and delete it
- try { entity.close(); } catch (Exception ee) { }
- entity = null;
- try { db.delete(); } catch (Exception ee) { }
- serverLog.logSevere("migrateWordIndex", "database for hash " + wordhash + " corrupted; deleted");
- return -1;
- }
- } finally {
- if (entity != null) try {entity.close();}catch(Exception e){}
- }
- }
-
- public static void migrateAssortments(String homePath) {
- // run with "java -classpath classes yacy -migrateassortments"
- try {serverLog.configureLogging(new File(homePath, "DATA/LOG/yacy.logging"));} catch (Exception e) {}
- serverLog log = new serverLog("ASSORTMENTMIGRATION");
- File aclusterroot = new File(new File(homePath), "DATA/PLASMADB/ACLUSTER");
- File indexRoot = new File(new File(homePath), "DATA/INDEX");
- plasmaWordIndex wordIndexCache = new plasmaWordIndex(indexRoot, 10000, log);
- log.logInfo("STARTING MIGRATION");
- String[] a = aclusterroot.list();
- AssortmentImporter importer = new AssortmentImporter(wordIndexCache);
- for (int i = a.length - 1; i >= 0; i--) {
- if (a[i].startsWith("indexAssortment")) {
- importer.init(new File(aclusterroot, a[i]), 16000000, 2000);
- importer.run();
- }
- }
- log.logInfo("FINISHED MIGRATION JOB, WAIT FOR DUMP");
- wordIndexCache.close();
- log.logInfo("TERMINATED MIGRATION");
- }
/**
* @param homePath path to the YaCy directory
@@ -842,25 +722,6 @@ public final class yacy {
return wordmap;
}
- /**
- * Reads all words from the given file and creats as HashSet, which contains
- * all found words.
- *
- * @param wordlist File where the words are stored.
- * @return HashSet with the words
- */
- private static HashSet loadWordSet(File wordlist) {
- // returns a set of words
- HashSet wordset = new HashSet();
- try {
- String word;
- BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(wordlist)));
- while ((word = br.readLine()) != null) wordset.add(word);
- br.close();
- } catch (IOException e) {}
- return wordset;
- }
-
/**
* Cleans a wordlist in a file according to the length of the words. The
* file with the given filename is read and then only the words in the given
@@ -914,50 +775,6 @@ public final class yacy {
serverLog.logConfig("CLEAN-WORDLIST", "FINISHED");
}
- /**
- * Gets all words from the stopword-list and removes them in the databases.
- * FIXME: Really? Don't know if I read this correctly.
- *
- * @param homePath Root-Path where all information is to be found.
- */
- private static void deleteStopwords(String homePath) {
- // start up
- System.out.println(copyright);
- System.out.println(hline);
- serverLog.logConfig("DELETE-STOPWORDS", "START");
-
- Properties config = configuration("DELETE-STOPWORDS", homePath);
- File dbRoot = new File(homePath, config.getProperty("dbPath"));
-
- // load stopwords
- HashSet stopwords = loadWordSet(new File(homePath, "yacy.stopwords"));
- serverLog.logInfo("DELETE-STOPWORDS", "loaded stopwords, " + stopwords.size() + " entries in list, starting scanning");
-
- // find all hashes
- File f;
- String w;
- int count = 0;
- long thisamount, totalamount = 0;
- Iterator i = stopwords.iterator();
- while (i.hasNext()) {
- w = (String) i.next();
- f = plasmaWordIndexFile.wordHash2path(dbRoot, plasmaCondenser.word2hash(w));
- if (f.exists()) {
- thisamount = f.length();
- if (f.delete()) {
- count++;
- totalamount += thisamount;
- serverLog.logInfo("DELETE-STOPWORDS", "deleted index for word '" + w + "', " + thisamount + " bytes");
- }
- }
- }
-
- serverLog.logInfo("DELETE-STOPWORDS", "TOTALS: deleted " + count + " indexes; " + (totalamount / 1024) + " kbytes");
-
- // finished
- serverLog.logConfig("DELETE-STOPWORDS", "FINISHED");
- }
-
private static void transferCR(String targetaddress, String crfile) {
File f = new File(crfile);
try {
@@ -1158,67 +975,6 @@ public final class yacy {
}
}
- private static void migratelurls(String homePath, File urlHash) {
- final plasmaSwitchboard sb = new plasmaSwitchboard(homePath, "yacy.init", "DATA/SETTINGS/httpProxy.conf");
- kelondroTree oldindex = null;
- try {
- oldindex = new kelondroTree(urlHash, true, -1, indexURLEntryOld.rowdef);
- } catch (IOException e) {
- System.out.println("ERROR: CANNOT OPEN OLD INDEX: " + e.getMessage());
- }
-
- long start = System.currentTimeMillis();
- long last = start;
- int tc = oldindex.size(), c = 0;
- Iterator eiter = oldindex.contentRows(-1);
- kelondroRow.Entry oldrow;
- indexURLEntry oldentry;
- indexURLEntry newentry;
- indexURLEntry.Components comp;
- byte[] dummymd5 = new byte[0];
- while (eiter.hasNext()) {
- try {
- oldrow = (kelondroRow.Entry) eiter.next();
- } catch (Exception e) {
- // an IOException may occur here
- //e.printStackTrace();
- oldrow = null;
- }
- if (oldrow != null) try {
- oldentry = new indexURLEntryOld(oldrow, null);
- comp = oldentry.comp();
- newentry = sb.wordIndex.loadedURL.newEntry(
- comp.url(),
- comp.title(),
- "",
- "",
- "",
- oldentry.moddate(),
- oldentry.loaddate(),
- oldentry.freshdate(),
- oldentry.referrerHash(),
- dummymd5,
- oldentry.size(),
- oldentry.wordCount(),
- oldentry.doctype(),
- new kelondroBitfield(4),
- oldentry.language(),
- 0, 0, 0, 0, 0, 0);
- sb.wordIndex.loadedURL.store(newentry);
- c++;
- } catch (IOException e) {
- // ignore
- }
- if (System.currentTimeMillis() - last > 60000) {
- System.out.println("Migrated " + c + " from " + tc + " urls. Estimated remaining time: " + ((System.currentTimeMillis() - start) * (tc - c) / c / 60000) + " minutes");
- last = System.currentTimeMillis();
- }
- }
- sb.close();
- oldindex.close();
- System.out.println("MIGRATION OF " + c + " URLs FINISHED");
- }
-
private static String[] shift(String[] args, int pos, int count) {
String[] newargs = new String[args.length - count];
System.arraycopy(args, 0, newargs, 0, pos);
@@ -1244,7 +1000,6 @@ public final class yacy {
private static void RWIHashList(String homePath, String targetName, String resource, String format) {
plasmaWordIndex WordIndex = null;
serverLog log = new serverLog("HASHLIST");
- File homeDBroot = new File(new File(homePath), "DATA/PLASMADB");
File indexRoot = new File(new File(homePath), "DATA/INDEX");
String wordChunkStartHash = "AAAAAAAAAAAA";
try {serverLog.configureLogging(new File(homePath, "DATA/LOG/yacy.logging"));} catch (Exception e) {}
@@ -1255,13 +1010,6 @@ public final class yacy {
if (resource.equals("all")) {
WordIndex = new plasmaWordIndex(indexRoot, 3000, log);
indexContainerIterator = WordIndex.wordContainers(wordChunkStartHash, false, false);
- } else if (resource.startsWith("assortment")) {
- int a = Integer.parseInt(resource.substring(10));
- plasmaWordIndexAssortment assortment = new plasmaWordIndexAssortment(new File(homeDBroot, "ACLUSTER"), a, 3000, null);
- indexContainerIterator = assortment.wordContainers();
- } else if (resource.equals("words")) {
- plasmaWordIndexFileCluster fileDB = new plasmaWordIndexFileCluster(homeDBroot);
- indexContainerIterator = fileDB.wordContainers(wordChunkStartHash, false);
}
int counter = 0;
indexContainer container = null;
@@ -1387,16 +1135,6 @@ public final class yacy {
// normal shutdown of yacy
if (args.length == 2) applicationRoot= args[1];
shutdown(applicationRoot);
- } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-migratewords"))) {
- // migrate words from DATA/PLASMADB/WORDS path to collection index
- // attention: this may run long and should not be interrupted!
- if (args.length == 2) applicationRoot= args[1];
- migrateWords(applicationRoot);
- } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-migrateassortments"))) {
- // migrate assortments from DATA/PLASMADB/ACLUSTER path to collection index
- // attention: this may run long and should not be interrupted!
- if (args.length == 2) applicationRoot= args[1];
- migrateAssortments(applicationRoot);
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-minimizeurldb"))) {
// migrate words from DATA/PLASMADB/WORDS path to assortment cache, if possible
// attention: this may run long and should not be interrupted!
@@ -1412,10 +1150,6 @@ public final class yacy {
System.err.println("Usage: -testPeerDB [homeDbRoot]");
}
testPeerDB(applicationRoot);
- } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-deletestopwords"))) {
- // delete those words in the index that are listed in the stopwords file
- if (args.length == 2) applicationRoot= args[1];
- deleteStopwords(applicationRoot);
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-genwordstat"))) {
// this can help to create a stop-word list
// to use this, you need a 'yacy.words' file in the root path
@@ -1472,9 +1206,6 @@ public final class yacy {
if (args.length == 2) applicationRoot= args[1];
String outfile = "urllist_" + source + "_" + System.currentTimeMillis() + ((html) ? ".html" : ".txt");
urllist(applicationRoot, source, html, outfile);
- } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-migratelurls"))) {
- File root = new File(applicationRoot);
- migratelurls(applicationRoot, new File(root, "DATA/PLASMADB/urlHash.db"));
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-urldbcleanup"))) {
// generate a url list and save it in a file
if (args.length == 2) applicationRoot= args[1];