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