本文整理汇总了Java中com.sleepycat.collections.StoredSortedMap类的典型用法代码示例。如果您正苦于以下问题:Java StoredSortedMap类的具体用法?Java StoredSortedMap怎么用?Java StoredSortedMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StoredSortedMap类属于com.sleepycat.collections包,在下文中一共展示了StoredSortedMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindDatabase
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
* 绑定数据库
* @param db 数据库
* @param valueClass 值类型
* @param classCatalog StoredClassCatalog
*/
public void bindDatabase(Database db, Class<E> valueClass, StoredClassCatalog classCatalog) {
EntryBinding<E> valueBinding = TupleBinding.getPrimitiveBinding(valueClass);
if(valueBinding == null) {
valueBinding = new SerialBinding<E>(classCatalog, valueClass); // 序列化绑定
}
queueDb = db;
queueMap = new StoredSortedMap<Long,E>(
db, // db
TupleBinding.getPrimitiveBinding(Long.class), //Key
valueBinding, // Value
true); // allow write
}
示例2: bindDatabase
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
* 绑定数据库
*
* @param db
* @param valueClass
* @param classCatalog
*/
public void bindDatabase(Database db, Class<E> valueClass, StoredClassCatalog classCatalog){
EntryBinding<E> valueBinding = TupleBinding.getPrimitiveBinding(valueClass);
if(valueBinding == null) {
valueBinding = new SerialBinding<E>(classCatalog, valueClass); // 序列化绑定
}
queueDb = db;
queueMap = new StoredSortedMap<Long,E>(
db, // db
TupleBinding.getPrimitiveBinding(Long.class), //Key
valueBinding, // Value
true); // allow write
}
示例3: testReadUncommittedCollection
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
public void testReadUncommittedCollection()
throws Exception {
StoredSortedMap dirtyMap = (StoredSortedMap)
StoredCollections.configuredSortedMap
(map, CursorConfig.READ_UNCOMMITTED);
// original map is not read-uncommitted
assertTrue(!isReadUncommitted(map));
// all read-uncommitted containers are read-uncommitted
assertTrue(isReadUncommitted(dirtyMap));
assertTrue(isReadUncommitted
(StoredCollections.configuredMap
(map, CursorConfig.READ_UNCOMMITTED)));
assertTrue(isReadUncommitted
(StoredCollections.configuredCollection
(map.values(), CursorConfig.READ_UNCOMMITTED)));
assertTrue(isReadUncommitted
(StoredCollections.configuredSet
(map.keySet(), CursorConfig.READ_UNCOMMITTED)));
assertTrue(isReadUncommitted
(StoredCollections.configuredSortedSet
((SortedSet) map.keySet(), CursorConfig.READ_UNCOMMITTED)));
if (DbCompat.RECNO_METHOD) {
// create a list just so we can call configuredList()
Database listStore = TestStore.RECNO_RENUM.open(env, null);
List list = new StoredList(listStore, TestStore.VALUE_BINDING,
true);
assertTrue(isReadUncommitted
(StoredCollections.configuredList
(list, CursorConfig.READ_UNCOMMITTED)));
listStore.close();
}
doReadUncommitted(dirtyMap);
}
示例4: setUp
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
public void setUp()
throws Exception {
SharedTestUtils.printTestName(SharedTestUtils.qualifiedTestName(this));
env = TestEnv.TXN.open("TransactionTests");
currentTxn = CurrentTransaction.getInstance(env);
store = testStore.open(env, dbName(0));
map = new StoredSortedMap(store, testStore.getKeyBinding(),
testStore.getValueBinding(), true);
}
示例5: AccessExample
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
* Constructor for the AccessExample object
*/
public AccessExample(Environment env, String databaseName)
throws Exception {
this.env = env;
/*
* Lets mimic the db.AccessExample 100% and use plain old byte arrays
* to store the key and data strings.
*/
ByteArrayBinding keyBinding = new ByteArrayBinding();
ByteArrayBinding dataBinding = new ByteArrayBinding();
/* Open a data store. */
DatabaseConfig dbConfig = new DatabaseConfig();
if (create) {
dbConfig.setAllowCreate(true);
}
this.db = env.openDatabase(null, databaseName, dbConfig);
/*
* Now create a collection style map view of the data store so that it
* is easy to work with the data in the database.
*/
this.map = new StoredSortedMap<byte[], byte[]>
(db, keyBinding, dataBinding, true);
}
示例6: doReadUncommitted
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
private synchronized void doReadUncommitted(StoredSortedMap dirtyMap)
throws Exception {
// start thread one
ReadUncommittedThreadOne t1 = new ReadUncommittedThreadOne(env, this);
t1.start();
wait();
// put ONE
synchronized (t1) { t1.notify(); }
wait();
readCheck(dirtyMap, ONE, ONE);
assertTrue(!dirtyMap.isEmpty());
// abort ONE
synchronized (t1) { t1.notify(); }
t1.join();
readCheck(dirtyMap, ONE, null);
assertTrue(dirtyMap.isEmpty());
// start thread two
ReadUncommittedThreadTwo t2 = new ReadUncommittedThreadTwo(env, this);
t2.start();
wait();
// put TWO
synchronized (t2) { t2.notify(); }
wait();
readCheck(dirtyMap, TWO, TWO);
assertTrue(!dirtyMap.isEmpty());
// commit TWO
synchronized (t2) { t2.notify(); }
t2.join();
readCheck(dirtyMap, TWO, TWO);
assertTrue(!dirtyMap.isEmpty());
}
示例7: open
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/** Opens the database and creates the Map. */
private void open()
throws Exception {
// use a generic database configuration
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
if (create) {
dbConfig.setAllowCreate(true);
}
// catalog is needed for serial bindings (java serialization)
Database catalogDb = env.openDatabase(null, "catalog", dbConfig);
catalog = new StoredClassCatalog(catalogDb);
// use Integer tuple binding for key entries
TupleBinding keyBinding =
TupleBinding.getPrimitiveBinding(Integer.class);
// use String serial binding for data entries
SerialBinding dataBinding = new SerialBinding(catalog, String.class);
this.db = env.openDatabase(null, "helloworld", dbConfig);
// create a map view of the database
this.map = new StoredSortedMap(db, keyBinding, dataBinding, true);
}
示例8: testReadCommittedCollection
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
public void testReadCommittedCollection()
throws Exception {
StoredSortedMap degree2Map = (StoredSortedMap)
StoredCollections.configuredSortedMap
(map, CursorConfig.READ_COMMITTED);
// original map is not read-committed
assertTrue(!isReadCommitted(map));
// all read-committed containers are read-uncommitted
assertTrue(isReadCommitted(degree2Map));
assertTrue(isReadCommitted
(StoredCollections.configuredMap
(map, CursorConfig.READ_COMMITTED)));
assertTrue(isReadCommitted
(StoredCollections.configuredCollection
(map.values(), CursorConfig.READ_COMMITTED)));
assertTrue(isReadCommitted
(StoredCollections.configuredSet
(map.keySet(), CursorConfig.READ_COMMITTED)));
assertTrue(isReadCommitted
(StoredCollections.configuredSortedSet
((SortedSet) map.keySet(),
CursorConfig.READ_COMMITTED)));
if (DbCompat.RECNO_METHOD) {
// create a list just so we can call configuredList()
Database listStore = TestStore.RECNO_RENUM.open(env, null);
List list = new StoredList(listStore, TestStore.VALUE_BINDING,
true);
assertTrue(isReadCommitted
(StoredCollections.configuredList
(list, CursorConfig.READ_COMMITTED)));
listStore.close();
}
map.put(ONE, ONE);
doReadCommitted(degree2Map, null);
}
示例9: setUp
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
public void setUp()
throws Exception {
env = TestEnv.TXN.open("IterDeadlockTest");
store1 = openDb("store1.db");
store2 = openDb("store2.db");
map1 = new StoredSortedMap(store1, binding, binding, true);
map2 = new StoredSortedMap(store2, binding, binding, true);
}
示例10: setUp
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
public void setUp()
throws Exception {
env = TestEnv.TXN.open("SecondaryDeadlockTest");
store = TestStore.BTREE_UNIQ.open(env, "store.db");
index = TestStore.BTREE_UNIQ.openIndex(store, "index.db");
storeMap = new StoredSortedMap(store,
TestStore.BTREE_UNIQ.getKeyBinding(),
TestStore.BTREE_UNIQ.getValueBinding(),
true);
indexMap = new StoredSortedMap(index,
TestStore.BTREE_UNIQ.getKeyBinding(),
TestStore.BTREE_UNIQ.getValueBinding(),
true);
}
示例11: doReadCommitted
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
private void doReadCommitted(final StoredSortedMap degree2Map,
TransactionConfig txnConfig)
throws Exception {
map.put(ONE, ONE);
TransactionRunner runner = new TransactionRunner(env);
runner.setTransactionConfig(txnConfig);
assertNull(currentTxn.getTransaction());
runner.run(new TransactionWorker() {
public void doWork() throws Exception {
assertNotNull(currentTxn.getTransaction());
/* Do a read-committed get(), the lock is not retained. */
assertEquals(ONE, degree2Map.get(ONE));
/*
* If we were not using read-committed, the following write of
* key ONE with an auto-commit transaction would self-deadlock
* since two transactions in the same thread would be
* attempting to lock the same key, one for write and one for
* read. This test passes if we do not deadlock.
*/
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
testStore.getKeyBinding().objectToEntry(ONE, key);
testStore.getValueBinding().objectToEntry(TWO, value);
store.put(null, key, value);
}
});
assertNull(currentTxn.getTransaction());
}
示例12: setUp
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
public void setUp()
throws Exception {
DbTestUtil.printTestName(DbTestUtil.qualifiedTestName(this));
env = TestEnv.TXN.open("TransactionTests");
currentTxn = CurrentTransaction.getInstance(env);
store = testStore.open(env, dbName(0));
map = new StoredSortedMap(store, testStore.getKeyBinding(),
testStore.getValueBinding(), true);
}
示例13: getStoredSortedMap
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public <K, V> StoredSortedMap<K, V> getStoredSortedMap(
EntryBinding<?> keyBinding, EntryBinding<?> valueBinding, boolean writeAllowed) {
return new StoredSortedMap(getDatabase(), keyBinding, valueBinding, writeAllowed);
}
示例14: getSupplierByCityMap
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
* Return a map view of the supplier-by-city index.
*/
public final StoredSortedMap getSupplierByCityMap() {
return supplierByCityMap;
}
示例15: getSupplierMap
import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
* Return a map view of the supplier storage container.
*/
public StoredSortedMap getSupplierMap() {
return supplierMap;
}