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


Java Environment.compress方法代码示例

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


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

示例1: testCompressAfterSlotReuse

import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
 * Tests a fix for a bug where reusing a slot caused a non-deleted record
 * to be compressed. [#15684]
 */
public void testCompressAfterSlotReuse()
    throws DatabaseException {
	
    EnvironmentConfig envConfig = getEnvConfig(false);
    /* Disable daemons to prevent async compression. */
    envConfig.setConfigParam("je.env.runCleaner", "false");
    envConfig.setConfigParam("je.env.runCheckpointer", "false");
    envConfig.setConfigParam("je.env.runINCompressor", "false");
    env = new Environment(envHome, envConfig);

    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setAllowCreate(true);
    dbConfig.setDeferredWrite(true);
    Database db = env.openDatabase(null, DBNAME, dbConfig);

    /* Reuse slot: Insert key 0, delete 0, insert 0 */
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    IntegerBinding.intToEntry(0, key);
    IntegerBinding.intToEntry(0, data);
    assertSame(OperationStatus.SUCCESS,
               db.putNoOverwrite(null, key, data));
    assertSame(OperationStatus.SUCCESS,
               db.delete(null, key));
    assertSame(OperationStatus.SUCCESS,
               db.putNoOverwrite(null, key, data));

    /*
     * Because of the delete() above, a compressor entry is queued for key
     * 0, although it was re-inserted.  And there is no LSN for the slot
     * because it has never been logged. When we compress now, we run into
     * the BIN.compress bug where it assumes an entry is deleted if its LSN
     * is null.
     */
    env.compress();

    /*
     * Before the bug fix, the following assert would fail because the
     * entry was compressed and NOTFOUND.
     */
    assertSame(OperationStatus.SUCCESS,
               db.get(null, key, data, null));

    db.close();
    env.close();
    env = null;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:52,代码来源:DeferredWriteTest.java

示例2: testCompressAfterSlotReuse

import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
 * Tests a fix for a bug where reusing a slot caused a non-deleted record
 * to be compressed. [#15684]
 */
public void testCompressAfterSlotReuse()
    throws DatabaseException {
	
    EnvironmentConfig envConfig = getEnvConfig(false);
    /* Disable daemons to prevent async compression. */
    envConfig.setConfigParam("je.env.runCleaner", "false");
    envConfig.setConfigParam("je.env.runCheckpointer", "false");
    envConfig.setConfigParam("je.env.runINCompressor", "false");
    env = new Environment(envHome, envConfig);

    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setAllowCreate(true);
    dbConfig.setDeferredWrite(true);
    Database db = env.openDatabase(null, DBNAME, dbConfig);   

    /* Reuse slot: Insert key 0, delete 0, insert 0 */
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    IntegerBinding.intToEntry(0, key);
    IntegerBinding.intToEntry(0, data);
    assertSame(OperationStatus.SUCCESS,
               db.putNoOverwrite(null, key, data));
    assertSame(OperationStatus.SUCCESS,
               db.delete(null, key));
    assertSame(OperationStatus.SUCCESS,
               db.putNoOverwrite(null, key, data));

    /*
     * Because of the delete() above, a compressor entry is queued for key
     * 0, although it was re-inserted.  And there is no LSN for the slot
     * because it has never been logged. When we compress now, we run into
     * the BIN.compress bug where it assumes an entry is deleted if its LSN
     * is null.
     */
    env.compress();

    /*
     * Before the bug fix, the following assert would fail because the
     * entry was compressed and NOTFOUND.
     */
    assertSame(OperationStatus.SUCCESS,
               db.get(null, key, data, null));

    db.close();
    env.close();
    env = null;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:52,代码来源:DeferredWriteTest.java


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