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


Java Options.compressionType方法代码示例

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


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

示例1: start

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
private void start() throws IOException {
	persister = Executors.newFixedThreadPool(config.getInt("persisterThreads"));
	Options levelDbOptions = new Options();
	levelDbOptions.createIfMissing(true);
	levelDbOptions.cacheSize(config.getInt("levelDbCache"));
	avatarDb = factory.open(new File("./db/chatAvatars"), levelDbOptions);
	chatRoomDb = factory.open(new File("./db/chatRooms"), levelDbOptions);
	if(config.getBoolean("compressMails"))
		levelDbOptions.compressionType(CompressionType.SNAPPY);
	mailDb = factory.open(new File("./db/mails"), levelDbOptions);
	getHighestAvatarIdFromDatabase();
	registrar = new ChatApiTcpListener(config.getInt("registrarPort"));
	gateway = new ChatApiTcpListener(config.getInt("gatewayPort"));
	registrar.start();
	gateway.start();
}
 
开发者ID:Rabiator1,项目名称:SWG-Station-Chat,代码行数:17,代码来源:ChatApiServer.java

示例2: open

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
public void open() {
    Options options = new Options();
    options.createIfMissing(true);
    options.cacheSize(cacheSize);
    options.compressionType(CompressionType.SNAPPY);

    try {
        File file = new File(database);
        logger.info("Opening LevelDB: " + file.getAbsolutePath());
        db = JniDBFactory.factory.open(new File(database), options);
        logger.debug(db.getProperty("leveldb.stats"));
    } catch (IOException e) {
        logger.error("Error opening LevelDB ", e);
    }
}
 
开发者ID:avoloshko,项目名称:WebCrawler,代码行数:17,代码来源:LevelDBStore.java

示例3: onOK

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
private void onOK() {
    Options options = new Options();
    options.createIfMissing(this.createBox.isSelected());
    options.compressionType((CompressionType) this.compressType.getSelectedItem());

    try{
        options.maxOpenFiles(Integer.parseInt(this.maxOpenFiles.getValue().toString()));
    }catch (NumberFormatException e){
        options.maxOpenFiles(1000);
    }

    options.verifyChecksums(this.verifyChecksumsCheckBox.isSelected());
    options.paranoidChecks(this.paranoidChecksCheckBox.isSelected());

    this.viewer.setOptions(options);

    dispose();
}
 
开发者ID:SuperMarcus,项目名称:LevelDBViewer,代码行数:19,代码来源:OpenLevelDBDialog.java

示例4: DainLevelDBStorageSystem

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
/** Constructor. */
public DainLevelDBStorageSystem(File dir, int cacheSizeMB)
		throws StorageException {
	ensureStorageDirectory(dir);

	Options options = new Options();
	options.createIfMissing(true);

	// we disable compression, as the storage framework has own support for
	// selective compression of sub-stores
	options.compressionType(CompressionType.NONE);
	options.cacheSize(cacheSizeMB * 1024 * 1024);

	try {
		database = Iq80DBFactory.factory.open(dir, options);
	} catch (IOException e) {
		throw new StorageException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:20,代码来源:DainLevelDBStorageSystem.java

示例5: LevelDBJNI

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
/**
 * @param config
 * @throws IOException
 */
public LevelDBJNI(Config config) throws IOException {
    super(config);
    this.dbPath = config.getString("leveldb.path");
    this.cacheSize = config.getBytes("leveldb.cache");
    File dbDir = new File(dbPath);
    if (!dbDir.exists()) {
        if (!dbDir.mkdirs()) {
            throw new IOException("Unable to create DB directory");
        }
    }

    Options options = new Options();
    options.createIfMissing(true);
    options.cacheSize(cacheSize);
    options.compressionType(CompressionType.NONE);	// No compression

    db = JniDBFactory.factory.open(dbDir, options);
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:23,代码来源:LevelDBJNI.java

示例6: start

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
public void start() {
    if (getFile() == null) {
        throw new IllegalArgumentException("A file must be configured");
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("Starting LevelDB using file: {}", getFile());
    }

    Options options = new Options().writeBufferSize(writeBufferSize).maxOpenFiles(maxOpenFiles)
            .blockRestartInterval(blockRestartInterval).blockSize(blockSize).verifyChecksums(verifyChecksums)
            .paranoidChecks(paranoidChecks).cacheSize(cacheSize);

    if ("snappy".equals(compressionType)) {
        options.compressionType(CompressionType.SNAPPY);
    } else {
        options.compressionType(CompressionType.NONE);
    }

    options.createIfMissing(true);
    try {
        getFile().getParentFile().mkdirs();
        db = factory.open(getFile(), options);
    } catch (IOException ioe) {
        throw new RuntimeException("Error opening LevelDB with file " + getFile(), ioe);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:LevelDBFile.java

示例7: DatabaseImpl

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
public DatabaseImpl(String name) {
    	// Initialize Database
        this.name = name;
		Options options = new Options();
		options.createIfMissing(true);
		options.compressionType(CompressionType.NONE);
		try {
			logger.debug("Opening database");
            File dbLocation = new File(System.getProperty("user.dir") + "/" +
                                       SystemProperties.CONFIG.databaseDir() + "/");
            File fileLocation = new File(dbLocation, name);

			if(SystemProperties.CONFIG.databaseReset()) {
				destroyDB(fileLocation);
			}

			logger.debug("Initializing new or existing database: '{}'", name);
			db = factory.open(fileLocation, options);
//			logger.debug("Showing database stats");
//			String stats = DATABASE.getProperty("leveldb.stats");
//			logger.debug(stats);

            if (logger.isTraceEnabled()){

                logger.trace("Dump for: {}", fileLocation.toString());
                DBIterator iter =  db.iterator();

                while(iter.hasNext()){
                    byte[] key   = iter.peekNext().getKey();
                    byte[] value = iter.peekNext().getValue();

                    logger.trace("key={}, value={}", Hex.toHexString(key), Hex.toHexString(value));
                    iter.next();
                }
            }
		} catch (IOException ioe) {
			logger.error(ioe.getMessage(), ioe);
			throw new RuntimeException("Can't initialize database");
		}		
	}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:41,代码来源:DatabaseImpl.java

示例8: MapDatabase

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
/**
 * Instantiates a new map database.
 *
 * @param basedir the basedir
 * @throws MapDatabaseException   the map database exception
 * @throws MossWorldLoadException the moss world load exception
 */
@SuppressWarnings("nls")
public MapDatabase(File basedir) throws MapDatabaseException,
        MossWorldLoadException {
    File dbDir = new File(basedir, "db"); //$NON-NLS-1$
    dbDir.mkdirs();
    try {

        Options options = new Options();
        options.paranoidChecks(false); // ACHTUNG! Corrption!
        options.verifyChecksums(true); // for now to help control the corruption
        options.blockSize(8192); // Chunks are kind of big
        options.compressionType(CompressionType.SNAPPY);
        //options.comparator(null);
        this.map = factory.open(new File(dbDir, "map"), options); //$NON-NLS-1$

        this.mapHeavies = factory.open(new File(dbDir, "mapHeavies"), //$NON-NLS-1$
                options);
        options.blockSize(4096); // Nothing is really big after this point.
        this.entities = factory.open(new File(dbDir, "entities"), options); //$NON-NLS-1$
        this.metadata = factory.open(new File(dbDir, "metadata"), options); //$NON-NLS-1$
        this.players = factory.open(new File(dbDir, "players"), options); //$NON-NLS-1$
        this.nodes = factory.open(new File(dbDir, "nodes"), options); //$NON-NLS-1$
    } catch (IOException e) {
        logger.error(MessageFormat.format(Messages.getString("DB_LOAD_IOEXCEPTION"), e.getMessage()));
        throw new MossWorldLoadException(Messages.getString("MapDatabase.ERR_DB_FAIL"), e); //$NON-NLS-1$
    }

    logger.info(Messages.getString("DB_NORMAL_LOAD"));

}
 
开发者ID:mosstest,项目名称:mosstest,代码行数:38,代码来源:MapDatabase.java

示例9: dataDbOptions

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
private Options dataDbOptions() {
   Options options = new Options().createIfMissing(true);

   options.compressionType(CompressionType.valueOf(configuration.compressionType().name()));

   if (configuration.blockSize() != null) {
      options.blockSize(configuration.blockSize());
   }

   if (configuration.cacheSize() != null) {
      options.cacheSize(configuration.cacheSize());
   }

   return options;
}
 
开发者ID:danberindei,项目名称:infinispan-cachestore-leveldb,代码行数:16,代码来源:LevelDBStore.java

示例10: activateService

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
public void activateService()
    throws Exception
{
    charset = Charset.forName( "UTF-8" );
    configuration.refresh();
    LevelDBEntityStoreConfiguration config = configuration.get();

    // Choose flavour
    String flavour = config.flavour().get();
    DBFactory factory;
    if( "jni".equalsIgnoreCase( flavour ) )
    {
        factory = newJniDBFactory();
    }
    else if( "java".equalsIgnoreCase( flavour ) )
    {
        factory = newJavaDBFactory();
    }
    else
    {
        factory = newDBFactory();
    }

    // Apply configuration
    Options options = new Options();
    options.createIfMissing( true );
    if( config.blockRestartInterval().get() != null )
    {
        options.blockRestartInterval( config.blockRestartInterval().get() );
    }
    if( config.blockSize().get() != null )
    {
        options.blockSize( config.blockSize().get() );
    }
    if( config.cacheSize().get() != null )
    {
        options.cacheSize( config.cacheSize().get() );
    }
    if( config.compression().get() != null )
    {
        options.compressionType( config.compression().get()
                                 ? CompressionType.SNAPPY
                                 : CompressionType.NONE );
    }
    if( config.maxOpenFiles().get() != null )
    {
        options.maxOpenFiles( config.maxOpenFiles().get() );
    }
    if( config.paranoidChecks().get() != null )
    {
        options.paranoidChecks( config.paranoidChecks().get() );
    }
    if( config.verifyChecksums().get() != null )
    {
        options.verifyChecksums( config.verifyChecksums().get() );
    }
    if( config.writeBufferSize().get() != null )
    {
        options.writeBufferSize( config.writeBufferSize().get() );
    }
    if( config.errorIfExists().get() != null )
    {
        options.errorIfExists( config.errorIfExists().get() );
    }

    // Open/Create the database
    File dbFile = new File( fileConfig.dataDirectory(), descriptor.identity().toString() );
    db = factory.open( dbFile, options );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:71,代码来源:LevelDBEntityStoreMixin.java


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