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


Java Serializer类代码示例

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


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

示例1: ChromaPrintStrategy

import org.mapdb.Serializer; //导入依赖的package包/类
public ChromaPrintStrategy() {
	String chomaprintDBFileName = "chormaprint.db";
	 File dbFile = new File(chomaprintDBFileName);
	 db = DBMaker.fileDB(dbFile)
				.closeOnJvmShutdown() // close the database automatically
				.make();
		
	 final String chromaPrintStoreName = "chroma_print_store";
	// The meta-data store.
	 chromaPrintStore = db.treeMap(chromaPrintStoreName)
			.keySerializer(Serializer.LONG)
			.valueSerializer(Serializer.STRING)
			.counterEnable() // enable size counter
			.createOrOpen();
	// The meta-data store.
	 final String audioStoreName = "audio_store";
	audioNameStore = db.treeMap(audioStoreName)
			.keySerializer(Serializer.INTEGER)
			.valueSerializer(Serializer.STRING)
			.counterEnable() // enable size counter
			.createOrOpen();
	
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:24,代码来源:ChromaPrintStrategy.java

示例2: RafsStrategy

import org.mapdb.Serializer; //导入依赖的package包/类
public RafsStrategy(){
	
	String mapsDBFileName = Config.get(Key.RAFS_DATABASE);
	int searchRadius = Config.getInt(Key.RAFS_HAMMINNG_SEARCH_RADIUS);
	int chunks = Config.getInt(Key.RAFS_MIH_CHUNKS);
	int numBits = Config.getInt(Key.RAFS_HAMMING_SPACE_NUM_BITS);
	
	mih = new MultiIndexHasher(numBits, searchRadius, chunks, new MapDBStorage(chunks,mapsDBFileName));
	
	 File dbFile = new File(Config.get(Key.RAFS_DATABASE) + "desc.db");
	 db = DBMaker.fileDB(dbFile)
				.closeOnJvmShutdown() // close the database automatically
				.make();
		
	 final String audioStore = "audio_store";
	// The meta-data store.
	audioNameStore = db.treeMap(audioStore).keySerializer(Serializer.INTEGER).valueSerializer(Serializer.STRING)
	.counterEnable() // enable size counter
	.createOrOpen();
		
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:22,代码来源:RafsStrategy.java

示例3: addMapDataToList

import org.mapdb.Serializer; //导入依赖的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);
	}
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:34,代码来源:BlockDbMapDbImpl.java

示例4: InverseDigiMorph

import org.mapdb.Serializer; //导入依赖的package包/类
public InverseDigiMorph(String model_path) {
    if (model_path == null) {
        try {
            File file = File.createTempFile("mapdb", "mapdb");
            file.deleteOnExit();
            byte[] bytes = Resources.toByteArray(Resources.getResource("inverse-italian.db"));
            Files.write(file.toPath(), bytes);
            model_path = file.getAbsolutePath();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    this.model_path = model_path;
    volume = MappedFileVol.FACTORY.makeVolume(model_path, true);
    this.map = SortedTableMap.open(volume, Serializer.STRING, Serializer.STRING);

}
 
开发者ID:dhfbk,项目名称:tint,代码行数:19,代码来源:InverseDigiMorph.java

示例5: DigiMorph

import org.mapdb.Serializer; //导入依赖的package包/类
public DigiMorph(String model_path) {
    if (model_path == null) {
        try {
            File file = File.createTempFile("mapdb", "mapdb");
            file.deleteOnExit();
            byte[] bytes = Resources.toByteArray(Resources.getResource("italian.db"));
            Files.write(file.toPath(), bytes);
            model_path = file.getAbsolutePath();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    this.model_path = model_path;
    volume = MappedFileVol.FACTORY.makeVolume(model_path, true);
    this.map = SortedTableMap.open(volume, Serializer.STRING, Serializer.STRING);

}
 
开发者ID:dhfbk,项目名称:tint,代码行数:19,代码来源:DigiMorph.java

示例6: preProcess

import org.mapdb.Serializer; //导入依赖的package包/类
/**
 * If grouping is enabled, initialize the temporary cache that will hold grouped objects.
 */
@SuppressWarnings("unchecked")
@Override
protected final boolean preProcess(Context context) {
	if ( isGroupingEnabled(context) ) {
		IContextGrouping ctx = context.as(IContextGrouping.class);
		DB db = DBMaker.tempFileDB()
				.closeOnJvmShutdown().fileDeleteAfterClose()
				.fileMmapEnableIfSupported()
				.make();
		Map<String, List<Object>> groups = db.hashMap("groups", Serializer.STRING, Serializer.JAVA).create();
		groups.clear(); // Make sure that we start with a clean cache 
		ctx.setGroupByExpressionsMapDB(db);
		ctx.setGroupByExpressionsGroupsMap(groups);
	}
	return preProcessBeforeGrouping(context);
}
 
开发者ID:fod-dev,项目名称:FoDBugTrackerUtility,代码行数:20,代码来源:AbstractProcessorGroupByExpressions.java

示例7: setupMaps

import org.mapdb.Serializer; //导入依赖的package包/类
@Override
public void setupMaps(DB db) {
	IndexComparator ic = new IndexComparator();

	// initialize map
	// note that it uses KeyArray Serializer to minimise disk space
	// used by Map
	BTreeKeySerializer keySerializer = new BTreeKeySerializer.ArrayKeySerializer(
			new Comparator[] { ic, ic, ic }, new Serializer[] {
					Serializer.BYTE_ARRAY, Serializer.BYTE_ARRAY,
					Serializer.BYTE_ARRAY });
	
	spMap = db.treeMap("sp", keySerializer, Serializer.BYTE_ARRAY);

	poMap = db.treeMap("po", keySerializer, Serializer.BYTE_ARRAY);

	osMap = db.treeMap("os", keySerializer, Serializer.BYTE_ARRAY);

	spoMap = db.hashMap("spo", Serializer.BYTE_ARRAY,
			Serializer.BYTE_ARRAY);

	
}
 
开发者ID:simonstey,项目名称:SecureLinkedData,代码行数:24,代码来源:ThreeIndexMapDB.java

示例8: setReadOnly

import org.mapdb.Serializer; //导入依赖的package包/类
@Override
public void setReadOnly() {

	clusterContainer.close();
	
	Path projectPath = Paths.get(Configuration.getParameters().getString("Experiment.projectPath"));
	Path poolDataPath = Paths.get(projectPath.toString(), "clusterdata");
	String containerFileName = "clusters.mapdb";
	
	DB db = DBMaker
		    .fileDB(Paths.get(poolDataPath.toString(), containerFileName).toFile())
		    .fileMmapEnableIfSupported() // Only enable mmap on supported platforms
		    .concurrencyScale(8) // TODO: Number of threads make this a parameter?
		    .executorEnable()
		    .readOnly()
		    .make();

	clusterContainer = db.treeMap("map")
			.keySerializer(Serializer.INTEGER)
			.valueSerializer(Serializer.INTEGER)
	        .open();
	
	AptaLogger.log(Level.CONFIG, this.getClass(), "Reopened as read only file " + Paths.get(poolDataPath.toString(), containerFileName).toString() );
	
}
 
开发者ID:drivenbyentropy,项目名称:aptasuite,代码行数:26,代码来源:MapDBClusterContainer.java

示例9: setReadOnly

import org.mapdb.Serializer; //导入依赖的package包/类
public void setReadOnly() {
	
	poolContentCounts.close();
	
	Path projectPath = Paths.get(Configuration.getParameters().getString("Experiment.projectPath"));
	Path poolDataPath = Paths.get(projectPath.toString(), "cycledata");
	String cycleFileName = round + "_" + name + ".mapdb";
	
	DB db = DBMaker
		    .fileDB(Paths.get(poolDataPath.toString(), cycleFileName).toFile())
		    .fileMmapEnableIfSupported() // Only enable mmap on supported platforms
		    .concurrencyScale(8) // TODO: Number of threads make this a parameter?
		    .executorEnable()
		    .readOnly()
		    .make();

	poolContentCounts = db.treeMap("map")
			.keySerializer(Serializer.INTEGER)
			.valueSerializer(Serializer.INTEGER)
	        .open();
	
	AptaLogger.log(Level.CONFIG, this.getClass(), "Reopened as read only file " + Paths.get(poolDataPath.toString(), cycleFileName).toString() );
	
}
 
开发者ID:drivenbyentropy,项目名称:aptasuite,代码行数:25,代码来源:MapDBSelectionCycle.java

示例10: setReadWrite

import org.mapdb.Serializer; //导入依赖的package包/类
@Override
public void setReadWrite() {
	
	poolContentCounts.close();
	
	Path projectPath = Paths.get(Configuration.getParameters().getString("Experiment.projectPath"));
	Path poolDataPath = Paths.get(projectPath.toString(), "cycledata");
	String cycleFileName = round + "_" + name + ".mapdb";
	
	DB db = DBMaker
		    .fileDB(Paths.get(poolDataPath.toString(), cycleFileName).toFile())
		    .fileMmapEnableIfSupported() // Only enable mmap on supported platforms
		    .concurrencyScale(8) // TODO: Number of threads make this a parameter?
		    .executorEnable()
		    .make();

	poolContentCounts = db.treeMap("map")
			.keySerializer(Serializer.INTEGER)
			.valueSerializer(Serializer.INTEGER)
	        .open();
	
	AptaLogger.log(Level.CONFIG, this.getClass(), "Reopened as read/write file " + Paths.get(poolDataPath.toString(), cycleFileName).toString() );
}
 
开发者ID:drivenbyentropy,项目名称:aptasuite,代码行数:24,代码来源:MapDBSelectionCycle.java

示例11: MapDbPersistentStore

import org.mapdb.Serializer; //导入依赖的package包/类
/**
 * Creates a new MapDB based persistent store.
 *
 * @param filename filename of the database on disk
 * @param executor executor to use for tasks that write to the disk
 * @param serializer serializer for keys and values
 */
MapDbPersistentStore(String filename, ExecutorService executor,
                     KryoSerializer serializer) {
    this.executor = checkNotNull(executor);
    this.serializer = checkNotNull(serializer);

    File databaseFile = new File(filename);

    database = DBMaker.newFileDB(databaseFile).make();

    items = database.createHashMap("items")
            .keySerializer(Serializer.BYTE_ARRAY)
            .valueSerializer(Serializer.BYTE_ARRAY)
            .hasher(Hasher.BYTE_ARRAY)
            .makeOrGet();

    tombstones = database.createHashMap("tombstones")
            .keySerializer(Serializer.BYTE_ARRAY)
            .valueSerializer(Serializer.BYTE_ARRAY)
            .hasher(Hasher.BYTE_ARRAY)
            .makeOrGet();
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:29,代码来源:MapDbPersistentStore.java

示例12: GitConverter

import org.mapdb.Serializer; //导入依赖的package包/类
public GitConverter(@NotNull DB cache, @NotNull Path basePath, @NotNull String[] globs) throws IOException, InvalidPatternException {
  this.basePath = basePath;
  this.cache = cache;
  this.globs = globs.clone();
  this.matchers = convertGlobs(globs);
  Arrays.sort(globs);

  for (String glob : globs) {
    new FileNameMatcher(glob, '/');
  }

  tempPath = basePath.resolve("lfs/tmp");
  Files.createDirectories(tempPath);
  //noinspection unchecked
  cacheMeta = cache.<String, MetaData>hashMap("meta")
      .keySerializer(Serializer.STRING)
      .valueSerializer(new SerializerJava())
      .createOrOpen();
}
 
开发者ID:bozaro,项目名称:git-lfs-migrate,代码行数:20,代码来源:GitConverter.java

示例13: create

import org.mapdb.Serializer; //导入依赖的package包/类
public CachedWebsearchApi create() throws FileNotFoundException, ClassNotFoundException, IOException {
    if (cachedApi == null && cachePath == null)
        throw new IllegalArgumentException("You need to either specify a storage path or give a cached API to reuse.");
    if (cachedApi != null && cachePath != null && !cachePath.equals(cachedApi.cachePath))
        throw new IllegalArgumentException(String.format(
                "Trying to reuse Websearch cache but different path provided: %s vs %s", cachePath, cachedApi.cachePath));
    if (cachePath == null)
        cachePath = cachedApi.cachePath;
    DB db;
    if (cachedApi != null) {
        LOG.debug("Reusing already open Webcache database.");
        db = cachedApi.db;
    } else {
        db = DBMaker.fileDB(cachePath).fileMmapEnable().closeOnJvmShutdownWeakReference().make();
    }
    return new CachedWebsearchApi(api, db, cachePath,
            db.hashMap("queries", Serializer.STRING, Serializer.BYTE_ARRAY).createOrOpen());
}
 
开发者ID:marcocor,项目名称:bing-api-java,代码行数:19,代码来源:CachedWebsearchApi.java

示例14: MapDbPersistenceBackend

import org.mapdb.Serializer; //导入依赖的package包/类
/**
 * Constructs a new {@code MapDbPersistenceBackend} wrapping the provided {@code db}.
 * <p>
 * This constructor initialize the different {@link Map}s from the MapDB engine and set their respective
 * {@link Serializer}s.
 * <p>
 * This constructor is protected. To create a new {@code MapDbPersistenceBackend} use {@link
 * MapDbPersistenceBackendFactory#createPersistentBackend(java.io.File, Map)}.
 *
 * @param db the {@link DB} used to creates the used {@link Map}s and manage the database
 *
 * @see MapDbPersistenceBackendFactory
 */
@SuppressWarnings("unchecked")
protected MapDbPersistenceBackend(DB db) {

    this.db = db;

    containersMap = this.db.hashMap(KEY_CONTAINER)
            .keySerializer(new IdSerializer())
            .valueSerializer(Serializer.JAVA)
            .createOrOpen();

    instanceOfMap = this.db.hashMap(KEY_INSTANCE_OF)
            .keySerializer(new IdSerializer())
            .valueSerializer(Serializer.JAVA)
            .createOrOpen();

    features = this.db.hashMap(KEY_FEATURES)
            .keySerializer(new FeatureKeySerializer())
            .valueSerializer(Serializer.JAVA)
            .createOrOpen();

    multivaluedFeatures = this.db.hashMap(KEY_MULTIVALUED_FEATURES)
            .keySerializer(new MultivaluedFeatureKeySerializer())
            .valueSerializer(Serializer.JAVA)
            .createOrOpen();
}
 
开发者ID:atlanmod,项目名称:NeoEMF,代码行数:39,代码来源:MapDbPersistenceBackend.java

示例15: testSerialize

import org.mapdb.Serializer; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked") // Unchecked cast: 'GroupSerializer' to 'Serializer<...>'
public void testSerialize() throws Exception {
    DataOutput2 out = new DataOutput2();
    FeatureKey key1 = FeatureKey.of(new StringId("object1"), "name");

    Serializer<FeatureKey> ser = Serializer.JAVA;
    FeatureKey key2 = ser.clone(key1);

    assertThat(key1).isEqualTo(key2);

    ser.serialize(out, key1);

    FeatureKey key3 = ser.deserialize(new DataInput2.ByteArray(out.copyBytes()), out.pos);

    assertThat(key1).isEqualTo(key3);
}
 
开发者ID:atlanmod,项目名称:NeoEMF,代码行数:18,代码来源:MapDbPersistenceBackendTest.java


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