本文整理汇总了Java中org.mapdb.HTreeMap.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java HTreeMap.containsKey方法的具体用法?Java HTreeMap.containsKey怎么用?Java HTreeMap.containsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mapdb.HTreeMap
的用法示例。
在下文中一共展示了HTreeMap.containsKey方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBlock
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
* return the block at the given height, with transactions attached.
*
* @param blockHeight
* the block height to use.
* @param withTransactions
* if true, add transactions. If false, only return the block header.
* @return the block at the given height.
*/
private Block getBlock(final long blockHeight, final boolean withTransactions) {
synchronized (this) {
if (closed) {
return null;
}
}
final HTreeMap<Long, byte[]> map = getBlockHeaderByIndexMap();
if (!map.containsKey(blockHeight)) {
return null;
}
final Block block = new Block(ByteBuffer.wrap(map.get(blockHeight)));
if (withTransactions) {
getTransactionsForBlock(block);
}
return block;
}
示例2: create
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
@NotNull
@Override
public <T extends Serializable> T create(@NotNull String namespace, @NotNull String key, @NotNull T value) throws StorageBackendException, StorageOperationException {
checkArguments(namespace, key, value);
HTreeMap<String, Object> namespaceMap = internalOpenNamespace(namespace);
LOGGER.trace("Create namespace={}, key={}, value={}", namespace, key, value);
if (namespaceMap.containsKey(key)) {
LOGGER.debug("Creation failed: key {} exists already in namespace {}", key, namespace);
throw new StorageOperationException("Creation failed: key already exists", namespace, key);
} else {
LOGGER.debug("Created key {} in namespace {}", key, namespace);
namespaceMap.put(key, value);
}
return value;
}
示例3: update
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
@NotNull
@Override
public <T extends Serializable> T update(@NotNull String namespace, @NotNull String key, @NotNull T newValue) throws StorageBackendException, StorageOperationException {
checkArguments(namespace, key, newValue);
HTreeMap<String, Object> namespaceMap = internalOpenNamespace(namespace);
LOGGER.trace("Put namespace={}, key={}, value={}", namespace, key, newValue);
if (!namespaceMap.containsKey(key)) {
throw new StorageOperationException("Update failed: key doesn't exist", namespace, key);
}
namespaceMap.put(key, newValue);
return newValue;
}
示例4: containsBlockWithHash
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
* returns true if the hash is in the database.
*
* @param hash
* the hash to use.
*
* @return true if the hash is in the database.
*/
@Override
public boolean containsBlockWithHash(final UInt256 hash) {
synchronized (this) {
if (closed) {
return false;
}
}
final HTreeMap<byte[], Long> map = getBlockIndexByHashMap();
return map.containsKey(hash.toByteArray());
}
示例5: getTransactionWithHash
import org.mapdb.HTreeMap; //导入方法依赖的package包/类
@Override
public Transaction getTransactionWithHash(final UInt256 hash) {
final HTreeMap<byte[], byte[]> map = getTransactionKeyByTransactionHashMap();
final byte[] hashBa = hash.toByteArray();
if (!map.containsKey(hashBa)) {
return null;
}
return new Transaction(ByteBuffer.wrap(map.get(hashBa)));
}
示例6: 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);
}
示例7: 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();
}