本文整理汇总了Java中org.mapdb.Bind类的典型用法代码示例。如果您正苦于以下问题:Java Bind类的具体用法?Java Bind怎么用?Java Bind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bind类属于org.mapdb包,在下文中一共展示了Bind类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openMap
import org.mapdb.Bind; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Map<BigInteger, Order> openMap(DB database)
{
//OPEN MAP
BTreeMap<BigInteger, Order> map = database.createTreeMap("orders")
.valueSerializer(new OrderSerializer())
.makeOrGet();
//HAVE/WANT KEY
this.haveWantKeyMap = database.createTreeMap("orders_key_have_want")
.comparator(Fun.COMPARATOR)
.makeOrGet();
//BIND HAVE/WANT KEY
Bind.secondaryKey(map, this.haveWantKeyMap, new Fun.Function2<Tuple4<Long, Long, BigDecimal, BigInteger>, BigInteger, Order>() {
@Override
public Tuple4<Long, Long, BigDecimal, BigInteger> run(BigInteger key, Order value) {
return new Tuple4<Long, Long, BigDecimal, BigInteger>(value.getHave(), value.getWant(), value.getPrice(), key);
}
});
//RETURN
return map;
}
示例2: getDirectSynonyms
import org.mapdb.Bind; //导入依赖的package包/类
@Override
public Map<String, Float> getDirectSynonyms(Node node) {
Map<String, Float> synonyms = new TreeMap<String, Float>();
for(Tuple2<String,Double> v:Bind.findVals2(nounSynonymsDB, node.getText())){
synonyms.put(v.a, v.b.floatValue());
}
synonyms.put(node.getText(), 1.f);
return synonyms;
}
示例3: getSynonyms
import org.mapdb.Bind; //导入依赖的package包/类
public Map<String, Float> getSynonyms(Node word){
Map<String, Float> synonyms = new TreeMap<String, Float>();
// longest match
if(word.getPOS().equals("名詞")){
List<Node> words = word.getNodes().getSentence().getWords(word.getSourceDesc());
int last = words.indexOf(word);
int current = last;
while(current > 0){
current--;
String ppos = words.get(current).getPOS();
if(ppos.equals("助詞")){
current++;
break;
}
}
for(;current <= last;current++){
StringBuffer sb = new StringBuffer();
for(int i = current;i <= last;i++){
if(words.get(i).getRealBase().matches(" +"))continue;
sb.append(words.get(i).getRealBase());
}
boolean found = false;
for(Tuple2<String,Double> v:Bind.findVals2(nounSynonymsDB, sb.toString())){
synonyms.put(v.a, v.b.floatValue());
found = true;
}
if(found){
synonyms.put(sb.toString(), 1.f);
break;
}
}
if(current == last){
synonyms.put(words.get(current).getRealBase(), 1.f);
}
}
return synonyms;
}
示例4: createIndex
import org.mapdb.Bind; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <V> void createIndex(int index, NavigableSet<?> indexSet, NavigableSet<?> descendingIndexSet, Function2<V, T, U> function)
{
Bind.secondaryKey((BTreeMap<T, U>) this.map, (NavigableSet<Tuple2<V, T>>) indexSet, function);
this.indexes.put(index, (NavigableSet<Tuple2<?, T>>) indexSet);
Bind.secondaryKey((BTreeMap<T, U>) this.map, (NavigableSet<Tuple2<V, T>>) descendingIndexSet, function);
this.indexes.put(index + 10000, (NavigableSet<Tuple2<?, T>>) descendingIndexSet);
}
示例5: createIndexes
import org.mapdb.Bind; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <V> void createIndexes(int index, NavigableSet<?> indexSet, NavigableSet<?> descendingIndexSet, Function2<V[], T, U> function)
{
Bind.secondaryKeys((BTreeMap<T, U>) this.map, (NavigableSet<Tuple2<V, T>>) indexSet, function);
this.indexes.put(index, (NavigableSet<Tuple2<?, T>>) indexSet);
Bind.secondaryKeys((BTreeMap<T, U>) this.map, (NavigableSet<Tuple2<V, T>>) descendingIndexSet, function);
this.indexes.put(index + 10000, (NavigableSet<Tuple2<?, T>>) descendingIndexSet);
}
示例6: getMap
import org.mapdb.Bind; //导入依赖的package包/类
@SuppressWarnings({ "unchecked"})
@Override
protected Map<Tuple2<String, Long>, BigDecimal> getMap(DB database)
{
//OPEN MAP
BTreeMap<Tuple2<String, Long>, BigDecimal> map = database.createTreeMap("balances")
.keySerializer(BTreeKeySerializer.TUPLE2)
.counterEnable()
.makeOrGet();
//HAVE/WANT KEY
this.assetKeyMap = database.createTreeMap("balances_key_asset")
.comparator(Fun.COMPARATOR)
.counterEnable()
.makeOrGet();
//BIND ASSET KEY
Bind.secondaryKey(map, this.assetKeyMap, new Fun.Function2<Tuple3<Long, BigDecimal, String>, Tuple2<String, Long>, BigDecimal>() {
@Override
public Tuple3<Long, BigDecimal, String> run(Tuple2<String, Long> key, BigDecimal value) {
return new Tuple3<Long, BigDecimal, String>(key.b, value.negate(), key.a);
}
});
//RETURN
return map;
}
示例7: testHugeDataForTreeMap
import org.mapdb.Bind; //导入依赖的package包/类
@Test
public void testHugeDataForTreeMap() throws UnsupportedEncodingException{
setStartT();
DB fileDb =DBMaker.newTempFileDB().asyncWriteFlushDelay(100).closeOnJvmShutdown().transactionDisable().make();
// BTreeMap<Long, String> dbMap = fileDb.createTreeMap("test").keySerializer(BTreeKeySerializer.ZERO_OR_POSITIVE_LONG).valueSerializer(Serializer.STRING).make();
HTreeMap<Long, String> dbMap = fileDb.createHashMap("test").keySerializer(Serializer.LONG).valueSerializer(Serializer.STRING).make();
// HTreeMap<Long, String> dbMap = fileDb.createHashMap("test").keySerializer(Serializer.LONG).valueSerializer(Serializer.STRING).make();
NavigableSet<Fun.Tuple2<String, Long>> inverseMapping = new TreeSet<Fun.Tuple2<String, Long>>();
Bind.mapInverse(dbMap, inverseMapping);
Store store = Store.forDB(fileDb);
boolean memoryIsOut=false;
int tempIndex=1;
for(int index=0;index<5e4;index++){
for(String[] dataItem:initData()){
dbMap.put(Long.valueOf(tempIndex),ConvertToKey(dataItem));
tempIndex++;
}
}
// System.out.println("Key for 'value' size is: "+inverseMapping.subSet(Fun.t2("name5id5city5", (Long)null), Fun.t2("name5id5city5", (Long)Fun.HI)));
System.out.println(store.getCurrSize()/1024);
ellipseT();
// computeResult(dbMap);
ellipseT();
// Assert.assertEquals(10l, distinctCount.longValue());
Assert.assertEquals(20l, rowCount.longValue());
Assert.assertEquals(uniqueCount.longValue(), distinctCount.longValue()-duplicateCount.longValue());
// Assert.assertEquals(0l, uniqueCount.longValue());
// Assert.assertEquals(10l, duplicateCount.longValue());
fileDb.close();
}