當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。