Java Code Examples for org.iq80.leveldb.Options#compressionType()

The following examples show how to use org.iq80.leveldb.Options#compressionType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LevelDB.java    From aion with MIT License 6 votes vote down vote up
private Options setupLevelDbOptions() {
    Options options = new Options();

    options.createIfMissing(true);
    options.compressionType(
            enableDbCompression ? CompressionType.SNAPPY : CompressionType.NONE);
    options.blockSize(this.blockSize);
    options.writeBufferSize(this.writeBufferSize); // (levelDb default: 8mb)
    options.cacheSize(enableDbCache ? this.cacheSize : 0);
    options.paranoidChecks(true);
    options.verifyChecksums(true);
    options.maxOpenFiles(this.maxOpenFiles);

    LOG.info("LevelDb Options: EnableCompression:{} MaxOpenFiles:{} BlockSize:{} WriteBuffer:{} EnableCache:{} CacheSize:{}"
        , enableDbCompression, maxOpenFiles, blockSize, writeBufferSize, enableDbCache, cacheSize);

    return options;
}
 
Example 2
Source File: WarpDB.java    From warp10-platform with Apache License 2.0 6 votes vote down vote up
public Options getOptions() {
  //
  // Clone the current options
  //
  
  Options opt = new Options();
  opt.blockRestartInterval(options.blockRestartInterval());
  opt.blockSize(options.blockSize());
  opt.cacheSize(options.cacheSize());
  opt.comparator(options.comparator());
  opt.compressionType(options.compressionType());
  opt.createIfMissing(options.createIfMissing());
  opt.errorIfExists(options.errorIfExists());
  opt.logger(options.logger());
  opt.maxOpenFiles(options.maxOpenFiles());
  opt.paranoidChecks(options.paranoidChecks());
  opt.verifyChecksums(options.verifyChecksums());
  opt.writeBufferSize(options.writeBufferSize());
  
  return opt;
}
 
Example 3
Source File: LevelDB.java    From SPADE with GNU General Public License v3.0 6 votes vote down vote up
public boolean initialize(String arguments)
    {
        try
        {
            WriteOptions writeOptions = new WriteOptions();
            writeOptions.sync(false);

            directoryPath = arguments;
            Options options = new Options();
            options.createIfMissing(true);
            options.compressionType(CompressionType.NONE);
//            scaffoldDatabase = factory.open(new File(directoryPath), options);
            childDatabase = factory.open(new File(directoryPath + "child"), options);
            parentDatabase = factory.open(new File(directoryPath + "parent"), options);
            logger.log(Level.INFO, "Scaffold initialized");
//            globalTxCheckin(true);
        }
        catch(IOException ex)
        {
            logger.log(Level.SEVERE, null, ex);
            return false;
        }

        return true;
    }
 
Example 4
Source File: LevelDbDataSourceImpl.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Deprecated
private Options createDbOptions() {
    Options dbOptions = new Options();
    dbOptions.createIfMissing(true);
    dbOptions.compressionType(CompressionType.NONE);
    dbOptions.blockSize(10 * 1024 * 1024);
    dbOptions.writeBufferSize(10 * 1024 * 1024);
    dbOptions.cacheSize(0);
    dbOptions.paranoidChecks(true);
    dbOptions.verifyChecksums(true);
    dbOptions.maxOpenFiles(32);
    return dbOptions;
}
 
Example 5
Source File: Storage.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Options createDefaultDbOptions() {
    Options dbOptions = new Options();

    dbOptions.createIfMissing(true);
    dbOptions.paranoidChecks(true);
    dbOptions.verifyChecksums(true);

    dbOptions.compressionType(DEFAULT_COMPRESSION_TYPE);
    dbOptions.blockSize(DEFAULT_BLOCK_SIZE);
    dbOptions.writeBufferSize(DEFAULT_WRITE_BUFFER_SIZE);
    dbOptions.cacheSize(DEFAULT_CACHE_SIZE);
    dbOptions.maxOpenFiles(DEFAULT_MAX_OPEN_FILES);

    return dbOptions;
}
 
Example 6
Source File: DatabaseImpl.java    From ethereumj with MIT License 5 votes vote down vote up
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");
		}		
	}
 
Example 7
Source File: LevelDBEntityStoreMixin.java    From attic-polygene-java with Apache License 2.0 4 votes vote down vote up
@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 );
}