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


Java HTreeMap.put方法代码示例

本文整理汇总了Java中org.mapdb.HTreeMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java HTreeMap.put方法的具体用法?Java HTreeMap.put怎么用?Java HTreeMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mapdb.HTreeMap的用法示例。


在下文中一共展示了HTreeMap.put方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: main

import org.mapdb.HTreeMap; //导入方法依赖的package包/类
public static void main(String[] args) {
	if (args.length != 2){
		logger.error(usage);
		System.exit(1);
	}
	
	RecordReader<WikipediaLabelToFreebaseRecord> reader = new RecordReader<WikipediaLabelToFreebaseRecord>(
			args[0], new WikipediaLabelToFreebaseRecord.Parser());
	File f = new File(args[1]);
	if (!f.exists()) {
		f.mkdirs();
	}
	File dbfile = new File(f, "freebase.db");
	DB db = DBMaker.fileDB(dbfile).fileMmapEnable().closeOnJvmShutdown().make();
	ProgressLogger pl = new ProgressLogger("indexed {} records", 100000);
	HTreeMap<String, String> map = db.hashMap("index", Serializer.STRING, Serializer.STRING).createOrOpen();
	HTreeMap<String, String> labels = db.hashMap("label", Serializer.STRING, Serializer.STRING).createOrOpen();
	for (WikipediaLabelToFreebaseRecord record : reader) {
		map.put(record.getCleanWikipediaLabel(), record.getFreebaseId());
		labels.put(record.getFreebaseId(), record.getLabel());
		pl.up();
	}
	db.commit();
	db.close();

	logger.info("file indexed, index in {}", args[1]);

}
 
开发者ID:marcocor,项目名称:smaph,代码行数:29,代码来源:IndexWikipediaFreebase.java

示例4: putWithByteBufferKey

import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
 * put the data in the map into the named database map.
 *
 * @param destMapName
 *            the destination map name to use.
 * @param sourceMap
 *            the source map to use.
 */
private void putWithByteBufferKey(final String destMapName, final Map<ByteBuffer, byte[]> sourceMap) {
	final HTreeMap<byte[], byte[]> map = DB.hashMap(destMapName, Serializer.BYTE_ARRAY, Serializer.BYTE_ARRAY)
			.counterEnable().createOrOpen();
	for (final ByteBuffer key : sourceMap.keySet()) {
		final byte[] ba = sourceMap.get(key);

		if (LOG.isTraceEnabled()) {
			LOG.trace("putWithByteBufferKey {} {} {}", destMapName, ModelUtil.toHexString(key.array()),
					ModelUtil.toHexString(ba));
		}

		map.put(key.array(), ba);
	}
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:23,代码来源:BlockDbMapDbImpl.java

示例5: putWithLongKey

import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
 * put the data in the map into the named database map.
 *
 * @param destMapName
 *            the destination map name to use.
 * @param sourceMap
 *            the source map to use.
 */
private void putWithLongKey(final String destMapName, final Map<Long, byte[]> sourceMap) {
	final HTreeMap<Long, byte[]> map = DB.hashMap(destMapName, Serializer.LONG, Serializer.BYTE_ARRAY)
			.counterEnable().createOrOpen();
	for (final Long key : sourceMap.keySet()) {
		final byte[] ba = sourceMap.get(key);
		map.put(key, ba);
	}
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:17,代码来源:BlockDbMapDbImpl.java

示例6: put

import org.mapdb.HTreeMap; //导入方法依赖的package包/类
@NotNull
@Override
public <T extends Serializable> T put(@NotNull String namespace, @NotNull String key, @NotNull T value) throws StorageBackendException {
    checkArguments(namespace, key, value);

    HTreeMap<String, Object> openNamespace = internalOpenNamespace(namespace);

    LOGGER.trace("Putting namespace={}, key={}", namespace, key);
    openNamespace.put(key, value);

    return value;
}
 
开发者ID:jhendess,项目名称:metadict,代码行数:13,代码来源:MapdbStorageEngine.java

示例7: 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

示例8: cleanup

import org.mapdb.HTreeMap; //导入方法依赖的package包/类
/**
 * Persists the scrum board and finalizes the persistence storage
 */
@Override
public void cleanup() {
    super.cleanup();
    HTreeMap<String, ScrumBoard> boards = db.getHashMap("boards");
    boards.put(boardName, scrumBoard);
    db.commit();
    db.close();
}
 
开发者ID:mindrunner,项目名称:scrum-tool,代码行数:12,代码来源:AbstractDbScrumController.java

示例9: testHugeDataForTreeMap

import org.mapdb.HTreeMap; //导入方法依赖的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();
    }
 
开发者ID:sizhaoliu,项目名称:MemoryManagementBenchmark,代码行数:34,代码来源:MapDBTestForUseApiCompute.java

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

示例11: main

import org.mapdb.HTreeMap; //导入方法依赖的package包/类
public static void main(String[] args) {
  
  File subdir = Files.createTempDir();    
  TxMaker txMaker = DBMaker.fileDB(new File(subdir, "db")).makeTxMaker();
      
  DB tx1 = txMaker.makeTx();
  HTreeMap<Object, Object> map1 = tx1.hashMap("test");
  map1.put("key1", "value1");
  tx1.commit();
  
  DB tx2 = txMaker.makeTx();
  HTreeMap<Object, Object> map2 = tx2.hashMap("test");
  System.err.println(map2.get("key1"));
  map2.put("key1", "value2");
  
  DB tx3 = txMaker.makeTx();
  HTreeMap<Object, Object> map3 = tx3.hashMap("test");
  System.err.println(map3.get("key1"));
  map3.put("key1", "value3");
  
  tx3.commit();
  tx2.commit();
  
  DB tx4 = txMaker.makeTx();
  HTreeMap<Object, Object> map4 = tx4.hashMap("test");
  System.err.println(map4.get("key1"));
  
}
 
开发者ID:zakgof,项目名称:velvetdb,代码行数:29,代码来源:TxTest.java


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