本文整理匯總了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;
}
示例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;
}