本文整理汇总了Java中org.mapdb.HTreeMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java HTreeMap.get方法的具体用法?Java HTreeMap.get怎么用?Java HTreeMap.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mapdb.HTreeMap
的用法示例。
在下文中一共展示了HTreeMap.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMapDataToList
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
* add data from a given map in the db to the list.
*
* @param mapName
* the map name to use.
* @param keyBa
* the key ba to use.
* @param list
* the list to add to.
* @param factory
* the factory to use.
* @param <T>
* the type of object the factory makes.
*/
private <T> void addMapDataToList(final String mapName, final byte[] keyBa, final List<T> list,
final AbstractByteBufferFactory<T> factory) {
if (LOG.isTraceEnabled()) {
LOG.trace("addMapDataToList {} keyBa:{}", mapName, ModelUtil.toHexString(keyBa));
}
final HTreeMap<byte[], byte[]> map = DB.hashMap(mapName, Serializer.BYTE_ARRAY, Serializer.BYTE_ARRAY)
.counterEnable().createOrOpen();
final byte[] listBa = map.get(keyBa);
if (LOG.isTraceEnabled()) {
LOG.trace("addMapDataToList {} listBa:{}", mapName, ModelUtil.toHexString(listBa));
}
final List<byte[]> baList = ModelUtil.toByteArrayList(listBa);
for (final byte[] ba : baList) {
final ByteBuffer bb = ByteBuffer.wrap(ba);
final T t = factory.toObject(bb);
list.add(t);
}
}
示例2: getAccountAssetValueMap
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
@Override
public Map<UInt160, Map<UInt256, Fixed8>> getAccountAssetValueMap() {
final Map<UInt160, Map<UInt256, Fixed8>> accountAssetValueMap = new TreeMap<>();
final TransactionOutputFactory objectFactory = new TransactionOutputFactory();
final HTreeMap<Long, byte[]> map = getByteArrayByBlockIndexMap(TRANSACTION_OUTPUTS_BY_HASH);
for (final long key : map.getKeys()) {
final byte[] listBa = map.get(key);
final List<byte[]> baList = ModelUtil.toByteArrayList(listBa);
for (final byte[] ba : baList) {
final TransactionOutput output = objectFactory.toObject(ByteBuffer.wrap(ba));
if (!accountAssetValueMap.containsKey(output.scriptHash)) {
accountAssetValueMap.put(output.scriptHash, new TreeMap<>());
}
final Map<UInt256, Fixed8> assetValueMap = accountAssetValueMap.get(output.scriptHash);
assetValueMap.put(output.assetId, output.value);
}
}
return accountAssetValueMap;
}
示例3: getBlock
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
* returns the block with the given hash.
*
* @param hash
* the hash to use.
* @param withTransactions
* if true, add transactions. If false, only return the block header.
* @return the block with the given hash.
*/
private Block getBlock(final UInt256 hash, final boolean withTransactions) {
synchronized (this) {
if (closed) {
return null;
}
}
final HTreeMap<byte[], Long> map = getBlockIndexByHashMap();
final byte[] hashBa = hash.toByteArray();
if (!map.containsKey(hashBa)) {
return null;
}
final long index = map.get(hashBa);
return getBlock(index, withTransactions);
}
示例4: getTransactionsForBlock
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
* return the block, with transactions added.
*
* @param block
* the block, to add transactions to.
*/
private void getTransactionsForBlock(final Block block) {
final long blockIndex = block.getIndexAsLong();
final HTreeMap<Long, byte[]> txKeyListMap = getByteArrayByBlockIndexMap(TRANSACTION_KEYS_BY_BLOCK_INDEX);
final List<byte[]> txKeyBaList = getByteArrayList(txKeyListMap, blockIndex);
final HTreeMap<byte[], byte[]> txMap = getTransactionsByKeyMap();
for (final byte[] txKey : txKeyBaList) {
if (LOG.isTraceEnabled()) {
LOG.trace("getTransactionsForBlock {} txKey:{}", blockIndex, ModelUtil.toHexString(txKey));
}
final byte[] data = txMap.get(txKey);
final Transaction transaction = new Transaction(ByteBuffer.wrap(data));
getTransactionOutputs(txKey, transaction);
getTransactionInputs(txKey, transaction);
getTransactionScripts(txKey, transaction);
block.getTransactionList().add(transaction);
}
}
示例5: init
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
*
* Initializes the scrum board from persistence storage
*
* @param boardName The scrum board to be used
*/
protected void init(String boardName) {
initDatabase();
HTreeMap<String, ScrumBoard> boards = db.getHashMap("boards");
if (!boards.containsKey(boardName)) {
boards.put(boardName, scrumFactory.createScrumBoard());
}
scrumBoard = boards.get(boardName);
}
示例6: testHugeDataForHashMap
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
@Test
public void testHugeDataForHashMap() throws UnsupportedEncodingException{
setStartT();
DB db = DBMaker.newTempFileDB().mmapFileEnablePartial().cacheSize(10*1024).asyncWriteEnable().closeOnJvmShutdown().transactionDisable().make();
HTreeMap<String, Long> dbMap = db.createHashMap("test").keySerializer(Serializer.STRING).valueSerializer(Serializer.LONG).make();
for(int index=0;index<5e7;index++){
for(String[] dataItem:initRandomData()){
Long frequency = dbMap.get(ConvertToKey(dataItem));
if(frequency!=null){
frequency++;
}else{
frequency=1l;
}
dbMap.put(ConvertToKey(dataItem), frequency);
}
}
// for(int index=0;index<1.25e5;index++){
// for(String[] dataItem:initData()){
// Long frequency = dbMap.get(ConvertToKey(dataItem));
// if(frequency!=null){
// frequency++;
// }else{
// frequency=1l;
// }
// dbMap.put(ConvertToKey(dataItem), frequency);
// }
// }
ellipseT();
computeResult(dbMap);
ellipseT();
// Assert.assertEquals(10l, distinctCount.longValue());
Assert.assertEquals(50000000l, rowCount.longValue());
Assert.assertEquals(uniqueCount.longValue(), distinctCount.longValue()-duplicateCount.longValue());
// Assert.assertEquals(0l, uniqueCount.longValue());
// Assert.assertEquals(10l, duplicateCount.longValue());
db.close();
System.out.println("end");
ellipseT();
}
示例7: computeResult
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
private void computeResult(HTreeMap<String, Long> dbMap) throws UnsupportedEncodingException{
for(String keyArrays:dbMap.keySet()){
Long frequency = dbMap.get(keyArrays);
rowCount+=frequency;
distinctCount++;
if(frequency==1){
uniqueCount++;
}else{
duplicateCount++;
}
}
}
示例8: getCellFromCache
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
private SCIFIOCell<?> getCellFromCache(final HTreeMap<?, ?> cache,
final int key)
{
SCIFIOCell<?> cell = null;
if (knownKeys.containsKey(key)) {
// Check the in-memory map to see if this entry exists on disk.
cell = (SCIFIOCell<?>) cache.get(key);
}
return cell;
}
示例9: getByteArrayList
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
* returns a list of byte arrays from the map.
*
* @param map
* the map to use.
* @param key
* the key to use.
* @param <K>
* the key type.
* @return the list of byte arrays.
*/
private <K> List<byte[]> getByteArrayList(final HTreeMap<K, byte[]> map, final K key) {
if (map.containsKey(key)) {
final byte[] keyListBa = map.get(key);
final List<byte[]> keyBaList = ModelUtil.toByteArrayList(keyListBa);
return keyBaList;
}
return Collections.emptyList();
}