当前位置: 首页>>代码示例>>Java>>正文


Java HTreeMap.containsKey方法代码示例

本文整理汇总了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;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:28,代码来源:BlockDbMapDbImpl.java

示例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;
}
 
开发者ID:jhendess,项目名称:metadict,代码行数:19,代码来源:MapdbStorageEngine.java

示例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;
}
 
开发者ID:jhendess,项目名称:metadict,代码行数:18,代码来源:MapdbStorageEngine.java

示例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());
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:19,代码来源:BlockDbMapDbImpl.java

示例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)));
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:10,代码来源:BlockDbMapDbImpl.java

示例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);
}
 
开发者ID:mindrunner,项目名称:scrum-tool,代码行数:15,代码来源:AbstractDbScrumController.java

示例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();
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:20,代码来源:BlockDbMapDbImpl.java


注:本文中的org.mapdb.HTreeMap.containsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。