001: // indexRWIVarEntry.java
002: // (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
003: // first published 07.11.2007 on http://yacy.net
004: //
005: // This is a part of YaCy, a peer-to-peer based web search engine
006: //
007: // $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
008: // $LastChangedRevision: 1986 $
009: // $LastChangedBy: orbiter $
010: //
011: // LICENSE
012: //
013: // This program is free software; you can redistribute it and/or modify
014: // it under the terms of the GNU General Public License as published by
015: // the Free Software Foundation; either version 2 of the License, or
016: // (at your option) any later version.
017: //
018: // This program is distributed in the hope that it will be useful,
019: // but WITHOUT ANY WARRANTY; without even the implied warranty of
020: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
021: // GNU General Public License for more details.
022: //
023: // You should have received a copy of the GNU General Public License
024: // along with this program; if not, write to the Free Software
025: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
026:
027: package de.anomic.index;
028:
029: import de.anomic.kelondro.kelondroBitfield;
030: import de.anomic.kelondro.kelondroRow.Entry;
031:
032: public class indexRWIVarEntry implements indexRWIEntry {
033:
034: public kelondroBitfield flags;
035: public long freshUntil, lastModified;
036: public String language, urlHash;
037: public char type;
038: public int hitcount, llocal, lother, phrasesintext, posintext,
039: posinphrase, posofphrase, quality, urlcomps, urllength,
040: virtualAge, worddistance, wordsintext, wordsintitle;
041: public double termFrequency;
042:
043: public indexRWIVarEntry(indexRWIEntry e) {
044: this .flags = e.flags();
045: this .freshUntil = e.freshUntil();
046: this .lastModified = e.lastModified();
047: this .language = e.getLanguage();
048: this .urlHash = e.urlHash();
049: this .type = e.getType();
050: this .hitcount = e.hitcount();
051: this .llocal = e.llocal();
052: this .lother = e.lother();
053: this .phrasesintext = e.phrasesintext();
054: this .posintext = e.posintext();
055: this .posinphrase = e.posinphrase();
056: this .posofphrase = e.posofphrase();
057: this .quality = e.quality();
058: this .urlcomps = e.urlcomps();
059: this .urllength = e.urllength();
060: this .virtualAge = e.virtualAge();
061: this .worddistance = e.worddistance();
062: this .wordsintext = e.wordsintext();
063: this .wordsintitle = e.wordsintitle();
064: this .termFrequency = e.termFrequency();
065: }
066:
067: public void join(indexRWIEntry oe) {
068: // combine the distance
069: this .worddistance = this .worddistance() + oe.worddistance()
070: + Math.abs(this .posintext() - oe.posintext());
071: this .posintext = Math.min(this .posintext(), oe.posintext());
072: this .posinphrase = (this .posofphrase() == oe.posofphrase()) ? Math
073: .min(this .posinphrase(), oe.posinphrase())
074: : 0;
075: this .posofphrase = Math.min(this .posofphrase(), oe
076: .posofphrase());
077:
078: // combine term frequency
079: this .wordsintext = this .wordsintext() + oe.wordsintext();
080: }
081:
082: public kelondroBitfield flags() {
083: return flags;
084: }
085:
086: public long freshUntil() {
087: return freshUntil;
088: }
089:
090: public String getLanguage() {
091: return language;
092: }
093:
094: public char getType() {
095: return type;
096: }
097:
098: public int hitcount() {
099: return hitcount;
100: }
101:
102: public boolean isNewer(indexRWIEntry other) {
103: assert false; // should not be used
104: return false;
105: }
106:
107: public boolean isOlder(indexRWIEntry other) {
108: assert false; // should not be used
109: return false;
110: }
111:
112: public long lastModified() {
113: return lastModified;
114: }
115:
116: public int llocal() {
117: return llocal;
118: }
119:
120: public int lother() {
121: return lother;
122: }
123:
124: public int phrasesintext() {
125: return phrasesintext;
126: }
127:
128: public int posinphrase() {
129: return posinphrase;
130: }
131:
132: public int posintext() {
133: return posintext;
134: }
135:
136: public int posofphrase() {
137: return posofphrase;
138: }
139:
140: public int quality() {
141: return quality;
142: }
143:
144: public Entry toKelondroEntry() {
145: assert false; // should not be used
146: return null;
147: }
148:
149: public String toPropertyForm() {
150: assert false; // should not be used
151: return null;
152: }
153:
154: public String urlHash() {
155: return urlHash;
156: }
157:
158: public int urlcomps() {
159: return urlcomps;
160: }
161:
162: public int urllength() {
163: return urllength;
164: }
165:
166: public int virtualAge() {
167: return virtualAge;
168: }
169:
170: public int worddistance() {
171: return worddistance;
172: }
173:
174: public int wordsintext() {
175: return wordsintext;
176: }
177:
178: public int wordsintitle() {
179: return wordsintitle;
180: }
181:
182: public double termFrequency() {
183: return termFrequency;
184: }
185:
186: public static final void min(indexRWIVarEntry t, indexRWIEntry other) {
187: int v;
188: long w;
189: double d;
190: if (t.hitcount() > (v = other.hitcount()))
191: t.hitcount = v;
192: if (t.llocal() > (v = other.llocal()))
193: t.llocal = v;
194: if (t.lother() > (v = other.lother()))
195: t.lother = v;
196: if (t.quality() > (v = other.quality()))
197: t.quality = v;
198: if (t.virtualAge() > (v = other.virtualAge()))
199: t.virtualAge = v;
200: if (t.wordsintext() > (v = other.wordsintext()))
201: t.wordsintext = v;
202: if (t.phrasesintext() > (v = other.phrasesintext()))
203: t.phrasesintext = v;
204: if (t.posintext() > (v = other.posintext()))
205: t.posintext = v;
206: if (t.posinphrase() > (v = other.posinphrase()))
207: t.posinphrase = v;
208: if (t.posofphrase() > (v = other.posofphrase()))
209: t.posofphrase = v;
210: if (t.worddistance() > (v = other.worddistance()))
211: t.worddistance = v;
212: if (t.lastModified() > (w = other.lastModified()))
213: t.lastModified = w;
214: if (t.freshUntil() > (w = other.freshUntil()))
215: t.freshUntil = w;
216: if (t.urllength() > (v = other.urllength()))
217: t.urllength = v;
218: if (t.urlcomps() > (v = other.urlcomps()))
219: t.urlcomps = v;
220: if (t.wordsintitle() > (v = other.wordsintitle()))
221: t.wordsintitle = v;
222: if (t.termFrequency > (d = other.termFrequency()))
223: t.termFrequency = d;
224: }
225:
226: public static final void max(indexRWIVarEntry t, indexRWIEntry other) {
227: int v;
228: long w;
229: double d;
230: if (t.hitcount() < (v = other.hitcount()))
231: t.hitcount = v;
232: if (t.llocal() < (v = other.llocal()))
233: t.llocal = v;
234: if (t.lother() < (v = other.lother()))
235: t.lother = v;
236: if (t.quality() < (v = other.quality()))
237: t.quality = v;
238: if (t.virtualAge() < (v = other.virtualAge()))
239: t.virtualAge = v;
240: if (t.wordsintext() < (v = other.wordsintext()))
241: t.wordsintext = v;
242: if (t.phrasesintext() < (v = other.phrasesintext()))
243: t.phrasesintext = v;
244: if (t.posintext() < (v = other.posintext()))
245: t.posintext = v;
246: if (t.posinphrase() < (v = other.posinphrase()))
247: t.posinphrase = v;
248: if (t.posofphrase() < (v = other.posofphrase()))
249: t.posofphrase = v;
250: if (t.worddistance() < (v = other.worddistance()))
251: t.worddistance = v;
252: if (t.lastModified() < (w = other.lastModified()))
253: t.lastModified = w;
254: if (t.freshUntil() < (w = other.freshUntil()))
255: t.freshUntil = w;
256: if (t.urllength() < (v = other.urllength()))
257: t.urllength = v;
258: if (t.urlcomps() < (v = other.urlcomps()))
259: t.urlcomps = v;
260: if (t.wordsintitle() < (v = other.wordsintitle()))
261: t.wordsintitle = v;
262: if (t.termFrequency < (d = other.termFrequency()))
263: t.termFrequency = d;
264: }
265:
266: }
|