本文整理汇总了Java中com.googlecode.concurrenttrees.radix.ConcurrentRadixTree.getValueForExactKey方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentRadixTree.getValueForExactKey方法的具体用法?Java ConcurrentRadixTree.getValueForExactKey怎么用?Java ConcurrentRadixTree.getValueForExactKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.concurrenttrees.radix.ConcurrentRadixTree
的用法示例。
在下文中一共展示了ConcurrentRadixTree.getValueForExactKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入方法依赖的package包/类
public static void main(String[] args) {
ConcurrentRadixTree<WordValue> tree = new ConcurrentRadixTree<WordValue>(new DefaultCharArrayNodeFactory());
for (String file : files) {
Set<String> wordsInFile = IOUtil.loadWordsFromTextFileOnClasspath(file, true); // true = convert to lowercase
for (String word : wordsInFile) {
WordValue wordValue = tree.getValueForExactKey(word);
if (wordValue == null) {
wordValue = new WordValue(word);
tree.put(word, wordValue); // not using concurrency support here
}
wordValue.manuscriptsContainingWord.add(file.replaceAll("/.*/.*/", "").replace(".txt", ""));
}
}
final String radixTreePrinted = PrettyPrinter.prettyPrint(tree);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JTextArea textArea = new JTextArea();
textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
textArea.setText(radixTreePrinted);
JScrollPane scrollPane = new JScrollPane(textArea);
textArea.setEditable(false);
JFrame frame = new JFrame("Shakespeare Radix Tree");
frame.add(scrollPane);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(640, 480);
frame.setVisible(true);
}
});
}
示例2: resolveChild
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入方法依赖的package包/类
private Long resolveChild(long directoryInodeNumber, String name) {
ConcurrentRadixTree<Long> parentDirectoryEntry = directoryTable.get(directoryInodeNumber);
if (parentDirectoryEntry == null) {
return null;
}
return parentDirectoryEntry.getValueForExactKey(name);
}
示例3: NFSPROC3_REMOVE_3
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入方法依赖的package包/类
@Override
public REMOVE3res NFSPROC3_REMOVE_3(RpcCall call$, REMOVE3args arg1) {
REMOVE3res res = new REMOVE3res();
long parentInodeNumber = -1;
SillyInode parentInode = null;
pre_op_attr parentPre = null;
try {
SillyInodeReference parentRef = new SillyInodeReference(arg1.object.dir.data);
parentInodeNumber = parentRef.getInodeNumber();
parentInode = resolve(parentRef);
if (!parentInode.isDirectory()) {
throw new NotDirException("inode #" + parentInodeNumber + " is not a directory");
}
parentPre = toPreAttr(parentInode);
long modCountBefore = parentInode.getModCount();
String name = arg1.object.name.value; //dont bother checking validity. worst-case it wont be found
ConcurrentRadixTree<Long> parentDirectoryEntry = resolveDirectory(parentInodeNumber, false);
Long childInodeNumber = parentDirectoryEntry == null ? null : parentDirectoryEntry.getValueForExactKey(name);
if (childInodeNumber == null) {
throw new NoEntException();
}
Lock parentLock = locks.get(parentInodeNumber);
parentLock.lock();
try {
long modCountNow = parentInode.getModCount();
if (modCountNow != modCountBefore) {
//TODO - recheck invariants
throw new UnsupportedOperationException("TBD");
}
inodeTable.remove(childInodeNumber.longValue());
//TODO - update timestamps and size on parent
if (parentInode.getSize()==0) {
//last child removed
assert (parentDirectoryEntry.size()==0);
if (parentDirectoryEntry != directoryTable.remove(parentInodeNumber)) {
throw new IllegalStateException("should never happen");
}
}
} finally {
parentLock.unlock();
}
res.status = nfsstat.NFS_OK;
res.resok = new REMOVE3resok();
res.resok.dir_wcc = new wcc_data();
res.resok.dir_wcc.before = parentPre;
res.resok.dir_wcc.after = toPostOp(parentInodeNumber, parentInode);
} catch (ChimeraNFSException hne) {
res.status = hne.getStatus();
if (parentPre == null) {
res.resfail = CONST_REMOVE_FAIL_RES;
} else {
res.resfail = new REMOVE3resfail();
res.resfail.dir_wcc = new wcc_data();
res.resfail.dir_wcc.before = parentPre;
res.resfail.dir_wcc.after = toPostOp(parentInodeNumber, parentInode);
}
} catch (Exception e) {
logger.error("remove", e);
res.status = nfsstat.NFSERR_SERVERFAULT;
if (parentPre == null) {
res.resfail = CONST_REMOVE_FAIL_RES;
} else {
res.resfail = new REMOVE3resfail();
res.resfail.dir_wcc = new wcc_data();
res.resfail.dir_wcc.before = parentPre;
res.resfail.dir_wcc.after = toPostOp(parentInodeNumber, parentInode);
}
}
return res;
}