本文整理汇总了Java中org.lemurproject.galago.utility.CmpUtil.compare方法的典型用法代码示例。如果您正苦于以下问题:Java CmpUtil.compare方法的具体用法?Java CmpUtil.compare怎么用?Java CmpUtil.compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lemurproject.galago.utility.CmpUtil
的用法示例。
在下文中一共展示了CmpUtil.compare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: skipTo
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public void skipTo(byte[] key) throws IOException {
// if the key is not in this block:
if (CmpUtil.compare(key, this.blockInfo.nextSlotKey) >= 0) {
// restrict the vocab search to only search forward from the current block
VocabularyReader.IndexBlockInfo newBlock = vocabulary.get(key, this.blockInfo.slotId);
this.loadBlockHeader(newBlock);
}
// now linearly scan the block to find the desired key
while (keyIndex < keyCount) {
while (keyIndex >= cacheKeyCount) {
this.cacheKeys();
}
if (CmpUtil.compare(keyCache[keyIndex], key) >= 0) {
// we have found or passed the desired key
return;
}
keyIndex++;
}
// if we got here - we have not yet found the correct key
nextKey();
}
示例2: process
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public void process(ExtractedLinkIndri link) throws IOException {
// while current.url preceeds destUrl -- read on
while (current != null && CmpUtil.compare(current.url, link.destUrl) < 0) {
current = documentUrls.read();
}
if (current != null && current.url.equals(link.destUrl)) {
link.destName = current.identifier;
link.filePath = current.filePath;
link.fileLocation = current.fileLocation;
}
if (acceptExternalUrls && link.destName.isEmpty()) {
link.destName = EXTERNAL_PREFIX + link.destUrl;
externalLinks.increment();
} else {
internalLinks.increment();
}
// only named destinations can be emited.
if (!link.destName.isEmpty()) {
processor.process(link);
}
}
示例3: nextDocument
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public Document nextDocument() throws IOException {
if (reader != null && iterator.isDone()) {
return null;
}
byte[] keyBytes = iterator.getKey();
// Don't go past the end of the split.
if (split.endKey != null && split.endKey.length > 0 && CmpUtil.compare(keyBytes, split.endKey) >= 0) {
return null;
}
Document document = iterator.getDocument(extractionParameters);
iterator.nextKey();
return document;
}
示例4: run
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public void run() throws IOException {
TypeReader<PageRankScore> prevReader = tp.getTypeReader(prevScoreStream);
TypeReader<PageRankScore> currReader = tp.getTypeReader(currScoreStream);
PageRankScore prev = prevReader.read();
PageRankScore curr = currReader.read();
boolean converged = true;
while (prev != null && curr != null) {
// check difference
if (prev.docName.equals(curr.docName)) {
if (Math.abs(prev.score - curr.score) > delta) {
converged = false;
break;
}
prev = prevReader.read();
curr = currReader.read();
} else {
// MAJOR PROBLEM -- misaligned document lists... we dropped one.
System.err.println("DOCUMENT MISSING...: " + prev.docName + " - " + curr.docName + "\nAttempting to recover.");
if (CmpUtil.compare(prev.docName, curr.docName) < 0) {
prev = prevReader.read();
} else {
curr = currReader.read();
}
}
}
if (!converged) {
try {
convFile.createNewFile();
} catch(IOException e){
// may throw an error if multiple threads try simultaneously
// in this case - not a problem.
}
}
}
示例5: process
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public void process(PageRankScore docScore) throws IOException {
documents.increment();
List<String> linkedDocuments = new ArrayList<>();
while (currentLink != null && CmpUtil.compare(docScore.docName, currentLink.srcName) > 0.0) {
// This shouldn't happen....
logger.log(Level.INFO, "Processing : {0}, IGNORED LINK: {1}-{2}", new Object[]{docScore.docName, currentLink.srcName, currentLink.destName});
currentLink = linkReader.read();
}
// collect all out-going links
while (currentLink != null && docScore.docName.equals(currentLink.srcName)) {
// docuemnts are NOT allowed to link to themselves.
if (!docScore.docName.equals(currentLink.destName)) {
linkedDocuments.add(currentLink.destName);
}
currentLink = linkReader.read();
}
// if there are no links - emit a random jump of size score * (1-lambda)
if (linkedDocuments.isEmpty()) {
rndJumpScore += (1.0 - lambda) * docScore.score;
} else {
totalWalk += (1.0 - lambda) * docScore.score;
double rndWalkScore = (1.0 - lambda) * docScore.score / (double) linkedDocuments.size();
for (String destination : linkedDocuments) {
// if the destination is external -- add score mass to rndJump
if (destination.startsWith(LinkDestNamer.EXTERNAL_PREFIX)) {
rndJumpScore += rndWalkScore;
}
processor.process(new PageRankScore(destination, rndWalkScore));
}
}
}
示例6: get
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
/**
* Binary search for a key, with a minimum block id.
*/
public IndexBlockInfo get(byte[] key, int minBlock) {
if (slots.isEmpty()) {
return null;
}
int big = slots.size() - 1;
int small = minBlock;
while (big - small > 1) {
int middle = small + (big - small) / 2;
byte[] middleKey = slots.get(middle).firstKey;
if (CmpUtil.compare(middleKey, key) <= 0) {
small = middle;
} else {
big = middle;
}
}
IndexBlockInfo one = slots.get(small);
IndexBlockInfo two = slots.get(big);
if (CmpUtil.compare(two.firstKey, key) <= 0) {
return two;
} else {
return one;
}
}
示例7: find
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public void find(byte[] key) throws IOException {
// if the key is not in this block:
if ((CmpUtil.compare(this.blockInfo.firstKey, key) > 0)
|| (CmpUtil.compare(key, this.blockInfo.nextSlotKey) >= 0)) {
VocabularyReader.IndexBlockInfo newBlock = vocabulary.get(key);
this.loadBlockHeader(newBlock);
}
// since we are 'finding' the key we can move backwards in the current block
if (CmpUtil.compare(key, keyCache[keyIndex]) < 0) {
this.keyIndex = 0;
}
// now linearly scan the block to find the desired key
while (keyIndex < keyCount) {
while (keyIndex >= cacheKeyCount) {
this.cacheKeys();
}
if (CmpUtil.compare(keyCache[keyIndex], key) >= 0) {
// we have found or passed the desired key
return;
}
keyIndex++;
}
// if we got here - we have not yet found the correct key
// this function will ensure we are consistent
nextKey();
}
示例8: compareTo
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public int compareTo(KeyIterator t) {
try {
return CmpUtil.compare(this.getKey(), t.getKey());
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
示例9: compareTo
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public int compareTo(ScoredDocument other) {
int cmp = CmpUtil.compare(score, other.score);
if (cmp != 0) {
return cmp;
}
if ((source != null) && (other.source != null)
&& (!source.equals(other.source))) {
return source.compareTo(other.source);
}
return CmpUtil.compare(other.document, document);
}
示例10: compareTo
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
default int compareTo(@Nonnull BaseIterator other) {
if (isDone() && !other.isDone()) {
return 1;
}
if (other.isDone() && !isDone()) {
return -1;
}
if (isDone() && other.isDone()) {
return 0;
}
return CmpUtil.compare(currentCandidate(), other.currentCandidate());
}
示例11: compareTo
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
public int compareTo(KeyIteratorWrapper o) {
try {
return CmpUtil.compare(getKeyBytes(), o.getKeyBytes());
} catch (IOException ex) {
Logger.getLogger(KeyIteratorWrapper.class.getName()).log(Level.SEVERE, "There is a problem comparing mapped keys.", ex);
throw new RuntimeException (ex);
}
}
示例12: getIterator
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public BaseIterator getIterator(Node node) throws IOException {
if (node.getOperator().equals("counts")) {
String stem = stemAsRequired(node.getDefaultParameter());
KeyIterator ki = new KeyIterator(reader);
ki.findKey(ByteUtil.fromString(stem));
if (CmpUtil.compare(ki.getKey(), ByteUtil.fromString(stem)) == 0) {
return new BackgroundStatsIterator(ki);
}
return null;
} else {
throw new UnsupportedOperationException(
"Index doesn't support operator: " + node.getOperator());
}
}
示例13: compare
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public int compare(Ranked lhs, Ranked rhs) {
return -CmpUtil.compare(lhs.score, rhs.score);
}
示例14: compare
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public int compare(EvalDoc lhs, EvalDoc rhs) {
return CmpUtil.compare(lhs.getRank(), rhs.getRank());
}
示例15: compareTo
import org.lemurproject.galago.utility.CmpUtil; //导入方法依赖的package包/类
@Override
public int compareTo(DeltaScoringIteratorWrapper t) {
return CmpUtil.compare(currentCandidate, t.currentCandidate);
}