本文整理汇总了Java中org.mapdb.Fun.Tuple2类的典型用法代码示例。如果您正苦于以下问题:Java Tuple2类的具体用法?Java Tuple2怎么用?Java Tuple2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tuple2类属于org.mapdb.Fun包,在下文中一共展示了Tuple2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
static void compile(String file, String database){
DB db = DBMaker.newFileDB(new File(database)).compressionEnable().closeOnJvmShutdown().make();
NavigableSet<Tuple2<String, Tuple2<String,Double>>> multiset = db.getTreeSet("SW");
multiset.clear();
try {
BufferedReader swFile = new BufferedReader(new InputStreamReader(new BZip2InputStream(new FileInputStream(new File(file)), false), "UTF-8"));
int entry = 0;
for(String line=swFile.readLine();line != null;line = swFile.readLine()){
String key = line.trim();
String[] values = swFile.readLine().trim().split(" ");
for(int i = 1;i < values.length;i += 2){
multiset.add(Fun.t2(key, Fun.t2(values[i-1], Double.parseDouble(values[i]))));
}
if(entry++ > 100){
db.commit();
entry = 0;
}
}
swFile.close();
} catch (IOException e) {
e.printStackTrace();
}
db.commit();
db.close();
}
示例2: reset
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
public void reset()
{
//RESET MAP
this.map.clear();
//RESET INDEXES
for(Set<Tuple2<?, T>> set: this.indexes.values())
{
set.clear();
}
//NOTIFY LIST
if(this.getObservableData().containsKey(NOTIFY_LIST))
{
//CREATE LIST
SortableList<T, U> list = new SortableList<T, U>(this);
//UPDATE
this.setChanged();
this.notifyObservers(new ObserverMessage(this.getObservableData().get(NOTIFY_LIST), list));
}
}
示例3: createIndexes
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
protected void createIndexes(DB database)
{
//HEIGHT INDEX
Tuple2Comparator<Integer, byte[]> comparator = new Fun.Tuple2Comparator<Integer, byte[]>(Fun.COMPARATOR, UnsignedBytes.lexicographicalComparator());
NavigableSet<Tuple2<Integer, byte[]>> heightIndex = database.createTreeSet("blocks_index_height")
.comparator(comparator)
.makeOrGet();
NavigableSet<Tuple2<Integer, byte[]>> descendingHeightIndex = database.createTreeSet("blocks_index_height_descending")
.comparator(new ReverseComparator(comparator))
.makeOrGet();
createIndex(HEIGHT_INDEX, heightIndex, descendingHeightIndex, new Fun.Function2<Integer, byte[], Block>() {
@Override
public Integer run(byte[] key, Block value) {
return value.getHeight();
}
});
}
示例4: createIndexes
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void createIndexes(DB database)
{
//AMOUNT INDEX
NavigableSet<Tuple2<BigDecimal, String>> namesIndex = database.createTreeSet("namesales_index_amount")
.comparator(Fun.COMPARATOR)
.makeOrGet();
NavigableSet<Tuple2<BigDecimal, String>> descendingNamesIndex = database.createTreeSet("namesales_index_amount_descending")
.comparator(new ReverseComparator(Fun.COMPARATOR))
.makeOrGet();
createIndex(AMOUNT_INDEX, namesIndex, descendingNamesIndex, new Fun.Function2<BigDecimal, String, BigDecimal>() {
@Override
public BigDecimal run(String key, BigDecimal value) {
return value;
}
});
}
示例5: createIndexes
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void createIndexes(DB database)
{
//TIMESTAMP INDEX
Tuple2Comparator<Long, byte[]> comparator = new Fun.Tuple2Comparator<Long, byte[]>(Fun.COMPARATOR, UnsignedBytes.lexicographicalComparator());
NavigableSet<Tuple2<Integer, byte[]>> heightIndex = database.createTreeSet("transactions_index_timestamp")
.comparator(comparator)
.makeOrGet();
NavigableSet<Tuple2<Integer, byte[]>> descendingHeightIndex = database.createTreeSet("transactions_index_timestamp_descending")
.comparator(new ReverseComparator(comparator))
.makeOrGet();
createIndex(TIMESTAMP_INDEX, heightIndex, descendingHeightIndex, new Fun.Function2<Long, byte[], Transaction>() {
@Override
public Long run(byte[] key, Transaction value) {
return value.getTimestamp();
}
});
}
示例6: get
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<NameSale> get(Account account)
{
List<NameSale> nameSales = new ArrayList<NameSale>();
try
{
Map<Tuple2<String, String>, BigDecimal> accountNames = ((BTreeMap) this.map).subMap(
Fun.t2(account.getAddress(), null),
Fun.t2(account.getAddress(), Fun.HI()));
for(Entry<Tuple2<String, String>, BigDecimal> entry: accountNames.entrySet())
{
NameSale nameSale = new NameSale(entry.getKey().b, entry.getValue());
nameSales.add(nameSale);
}
}
catch(Exception e)
{
//ERROR
e.printStackTrace();
}
return nameSales;
}
示例7: filter
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
public QueryResult<T> filter(Tuple2<String, String> tup) throws Exception {
if (!this.is_ready)
throw new Exception();
String field = tup.a;
List<String> keys = new ArrayList<String>();
keys.add(tup.b);
if (!field.equals(pk_field.getName())) {
BTreeMap<String, List<String>> tm = db.getTreeMap(mapname + "__" + field);
keys = tm.get(tup.b);
}
QueryResult<T> ret = new QueryResult<T>();
for (String k : keys)
ret.add(pk.get(k));
return ret;
}
示例8: getInitiatedTrades
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<Trade> getInitiatedTrades(Order order)
{
//FILTER ALL TRADES
Collection<Tuple2> keys = this.getKeys(order);
//GET ALL TRADES FOR KEYS
List<Trade> trades = new ArrayList<Trade>();
for(Tuple2 key: keys)
{
trades.add(this.get(key));
}
//RETURN
return trades;
}
示例9: syncUpdate
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public synchronized void syncUpdate(Observable o, Object arg)
{
ObserverMessage message = (ObserverMessage) arg;
//CHECK IF NEW LIST
if(message.getType() == ObserverMessage.LIST_TRANSACTION_TYPE)
{
if(this.transactions == null)
{
this.transactions = (SortableList<Tuple2<String, String>, Transaction>) message.getValue();
this.transactions.registerObserver();
this.transactions.sort(TransactionMap.TIMESTAMP_INDEX, true);
}
this.fireTableDataChanged();
}
//CHECK IF LIST UPDATED
if(message.getType() == ObserverMessage.ADD_TRANSACTION_TYPE || message.getType() == ObserverMessage.REMOVE_TRANSACTION_TYPE)
{
this.fireTableDataChanged();
}
}
示例10: onDataChanged
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
public void onDataChanged()
{
//GET SELECTED ITEM
Name selected = (Name) this.getSelectedItem();
//EMPTY LIST
this.removeAllElements();
//INSERT ALL ACCOUNTS
for(Pair<Tuple2<String, String>, Name> name: this.names)
{
this.addElement(name.getB());
}
//RESET SELECTED ITEM
if(this.getIndexOf(selected) != -1)
{
this.setSelectedItem(selected);
}
}
示例11: syncUpdate
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public synchronized void syncUpdate(Observable o, Object arg)
{
ObserverMessage message = (ObserverMessage) arg;
//CHECK IF NEW LIST
if(message.getType() == ObserverMessage.LIST_POLL_TYPE)
{
if(this.polls == null)
{
this.polls = (SortableList<Tuple2<String, String>, Poll>) message.getValue();
this.polls.registerObserver();
this.polls.sort(PollMap.NAME_INDEX);
}
this.fireTableDataChanged();
}
//CHECK IF LIST UPDATED
if(message.getType() == ObserverMessage.ADD_POLL_TYPE || message.getType() == ObserverMessage.REMOVE_POLL_TYPE)
{
this.fireTableDataChanged();
}
}
示例12: syncUpdate
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public synchronized void syncUpdate(Observable o, Object arg)
{
ObserverMessage message = (ObserverMessage) arg;
//CHECK IF NEW LIST
if(message.getType() == ObserverMessage.LIST_ASSET_TYPE)
{
if(this.assets == null)
{
this.assets = (SortableList<Tuple2<String, String>, Asset>) message.getValue();
this.assets.registerObserver();
//this.assets.sort(PollMap.NAME_INDEX);
}
this.fireTableDataChanged();
}
//CHECK IF LIST UPDATED
if(message.getType() == ObserverMessage.ADD_ASSET_TYPE || message.getType() == ObserverMessage.REMOVE_ASSET_TYPE)
{
this.fireTableDataChanged();
}
}
示例13: syncUpdate
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public synchronized void syncUpdate(Observable o, Object arg)
{
ObserverMessage message = (ObserverMessage) arg;
//CHECK IF NEW LIST
if(message.getType() == ObserverMessage.LIST_NAME_TYPE)
{
if(this.names == null)
{
this.names = (SortableList<Tuple2<String, String>, Name>) message.getValue();
this.names.registerObserver();
this.names.sort(NameMap.NAME_INDEX);
}
this.fireTableDataChanged();
}
//CHECK IF LIST UPDATED
if(message.getType() == ObserverMessage.ADD_NAME_TYPE || message.getType() == ObserverMessage.REMOVE_NAME_TYPE)
{
this.fireTableDataChanged();
}
}
示例14: onDataChanged
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
public void onDataChanged()
{
//GET SELECTED ITEM
Name selected = (Name) this.getSelectedItem();
//EMPTY LIST
this.removeAllElements();
//INSERT ALL ACCOUNTS
for(Pair<Tuple2<String, String>, BigDecimal> entry: this.nameSales)
{
NameSale nameSale = new NameSale(entry.getA().b, entry.getB());
this.addElement(nameSale);
}
//RESET SELECTED ITEM
if(this.getIndexOf(selected) != -1)
{
this.setSelectedItem(selected);
}
}
示例15: getValueAt
import org.mapdb.Fun.Tuple2; //导入依赖的package包/类
@Override
public Object getValueAt(int row, int column)
{
if(this.balances == null || row > this.balances.size() - 1 )
{
return null;
}
Pair<Tuple2<String, Long>, BigDecimal> aRow = this.balances.get(row);
Account account = new Account(aRow.getA().a);
switch(column)
{
case COLUMN_ADDRESS:
return account.getAddress();
case COLUMN_BALANCE:
return account.getConfirmedBalance(this.key).toPlainString();
}
return null;
}