protected LexiconEntry newLexiconEntry(int termid) { LexiconEntry rtr = valueFactory.newInstance(); rtr.setTermId(termid); return rtr; }
public int term(String term, EntryStatistics es, int termid) { synchronized(modificationLock) { LexiconEntry le = this.getLexiconEntry(term); if (le != null) { le.add(es); return le.getTermId(); } Text key = keyFactory.newInstance(); key.set(term); ((LexiconEntry) es).setTermId(termid); super.map.put(key, (LexiconEntry) es); return termid; } }
/** * Add new term, or update existing term. * * @return The termid of the term. */ public int term(String term, EntryStatistics es) { synchronized(modificationLock) { LexiconEntry le = this.getLexiconEntry(term); if (le != null) { le.add(es); return le.getTermId(); } int termid = super.map.size(); Text key = keyFactory.newInstance(); key.set(term); ((LexiconEntry) es).setTermId(termid); super.map.put(key, (LexiconEntry) es); return termid; } }
int lexicographicalCompare = term1.compareTo(term2); if (lexicographicalCompare < 0) { lee1.getValue().setTermId(termId); lee1.getValue().setPointer(p); lexOutStream.writeNextEntry(term1, lee1.getValue()); lee2.getValue().setTermId(termId); lee2.getValue().setPointer(p); lexOutStream.writeNextEntry(term2, lee2.getValue()); if (hasMore2 = lexInStream2.hasNext()) lee2 = lexInStream2.next(); } else { lee1.getValue().setTermId(termId); lee1.getValue().setPointer(p); lee1.getValue().add(lee2.getValue()); lee1.getValue().setTermId(termId); lee1.getValue().setPointer(p); lexOutStream.writeNextEntry(lee1.getKey(), lee1.getValue()); lee1.getValue().setTermId(termId); lee1.getValue().setPointer(p); lexOutStream.writeNextEntry(lee2.getKey(), lee2.getValue());
/** * Ends the merging phase, writes the last entry and closes the streams. * @param lexStream LexiconOutputStream used to write the lexicon. * @throws IOException if an I/O error occurs. */ public void endMerge(LexiconOutputStream<String> lexStream) throws IOException{ termStatistics.setTermId(currentTerm++); ((BasicLexiconEntry)termStatistics).setOffset(startOffset); lexStream.writeNextEntry(lastTermWritten, termStatistics); //lexStream.writeNextEntry(lastTermWritten, new BasicLexiconEntry(currentTerm++, lastDocFreq, lastFreq, startOffset)); //startOffset.setPosition(this.getByteOffset(), this.getBitOffset()); numberOfPointers += lastDocFreq; bos.close(); myRun.close(); }
lee.getValue().setTermId(newTermId[i]); leOut.writeNextEntry(lee.getKey(), lee.getValue()); i++;
newLe.setTermId(termID);
numberOfPointers+=newPointer.getNumberOfEntries(); if (! keepTermCodeMap) lee1.getValue().setTermId(newCodes++); lexOutStream.writeNextEntry(term1, lee1.getValue()); hasMore1 = lexInStream1.hasNext(); if (keepTermCodeMap) termcodeHashmap.put(lee2.getValue().getTermId(), newCode); lee2.getValue().setTermId(newCode); lexOutStream.writeNextEntry(term2, lee2.getValue()); hasMore2 = lexInStream2.hasNext(); termcodeHashmap.put(lee2.getValue().getTermId(), lee1.getValue().getTermId()); else lee1.getValue().setTermId(newCodes++); lee1.getValue().setPointer(newPointer); if (! keepTermCodeMap) lee1.getValue().setTermId(newCodes++); numberOfPointers+=newPointer.getNumberOfEntries(); lexOutStream.writeNextEntry(lee1.getKey(), lee1.getValue()); if (keepTermCodeMap) termcodeHashmap.put(lee2.getValue().getTermId(), newCode); lee2.getValue().setTermId(newCode); lexOutStream.writeNextEntry(lee2.getKey(), lee2.getValue()); hasMore2 = lexInStream2.hasNext();
((LexiconEntry) entryStats[i]).setTermId(i); statsMap.put(queryTerms[i], entryStats[i]);
((LexiconEntry) entryStats[i]).setTermId(i); statsMap.put(queryTerms[i], entryStats[i]);
newLe.setTermId(lexTermEntry.getValue().getTermId());
termStatistics.setTermId(currentTerm++); ((BasicLexiconEntry)termStatistics).setOffset(startOffset); lexStream.writeNextEntry(lastTermWritten, termStatistics);