• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StoredSortedMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sleepycat.collections.StoredSortedMap的典型用法代码示例。如果您正苦于以下问题:Java StoredSortedMap类的具体用法?Java StoredSortedMap怎么用?Java StoredSortedMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StoredSortedMap类属于com.sleepycat.collections包,在下文中一共展示了StoredSortedMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:19,代码来源:BdbPersistentQueue.java


示例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
}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:20,代码来源:BdbPersistentQueue.java


示例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);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:39,代码来源:TransactionTest.java


示例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);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:11,代码来源:TransactionTest.java


示例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);
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:30,代码来源:AccessExample.java


示例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());
}
 
开发者ID:nologic,项目名称:nabs,代码行数:38,代码来源:TransactionTest.java


示例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);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:28,代码来源:HelloDatabaseWorld.java


示例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);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:41,代码来源:TransactionTest.java


示例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);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:10,代码来源:IterDeadlockTest.java


示例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);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:16,代码来源:SecondaryDeadlockTest.java


示例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());
}
 
开发者ID:nologic,项目名称:nabs,代码行数:32,代码来源:TransactionTest.java


示例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);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:11,代码来源:TransactionTest.java


示例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);
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:6,代码来源:Berkeley.java


示例14: getSupplierByCityMap

import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
 * Return a map view of the supplier-by-city index.
 */
public final StoredSortedMap getSupplierByCityMap() {

    return supplierByCityMap;
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:8,代码来源:SampleViews.java


示例15: getSupplierMap

import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
 * Return a map view of the supplier storage container.
 */
public StoredSortedMap getSupplierMap() {

    return supplierMap;
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:8,代码来源:SampleViews.java


示例16: getShipmentMap

import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
 * Return a map view of the shipment storage container.
 */
public StoredSortedMap getShipmentMap() {

    return shipmentMap;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:8,代码来源:SampleViews.java


示例17: getShipmentByPartMap

import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
 * Return a map view of the shipment-by-part index.
 */
public StoredSortedMap getShipmentByPartMap() {

    return shipmentByPartMap;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:8,代码来源:SampleViews.java


示例18: getShipmentBySupplierMap

import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
 * Return a map view of the shipment-by-supplier index.
 */
public StoredSortedMap getShipmentBySupplierMap() {

    return shipmentBySupplierMap;
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:8,代码来源:SampleViews.java


示例19: SampleViews

import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
 * Create the data bindings and collection views.
 */
public SampleViews(SampleDatabase db) {

    // Create the data bindings.
    // In this sample, EntityBinding classes are used to bind the stored
    // key/data entry pair to a combined data object.  For keys, a
    // one-to-one binding is implemented with EntryBinding classes to bind
    // the stored tuple entry to a key Object.
    //
    ClassCatalog catalog = db.getClassCatalog();
    EntryBinding partKeyBinding =
        new PartKeyBinding();
    EntityBinding partDataBinding =
        new PartBinding(catalog, PartData.class);
    EntryBinding supplierKeyBinding =
        new SupplierKeyBinding();
    EntityBinding supplierDataBinding =
        new SupplierBinding(catalog, SupplierData.class);
    EntryBinding shipmentKeyBinding =
        new ShipmentKeyBinding();
    EntityBinding shipmentDataBinding =
        new ShipmentBinding(catalog, ShipmentData.class);
    EntryBinding cityKeyBinding =
        TupleBinding.getPrimitiveBinding(String.class);

    // Create map views for all stores and indices.
    // StoredSortedMap is used since the stores and indices are ordered
    // (they use the DB_BTREE access method).
    //
    partMap =
        new StoredSortedMap(db.getPartDatabase(),
partKeyBinding, partDataBinding, true);
    supplierMap =
        new StoredSortedMap(db.getSupplierDatabase(),
supplierKeyBinding, supplierDataBinding, true);
    shipmentMap =
        new StoredSortedMap(db.getShipmentDatabase(),
shipmentKeyBinding, shipmentDataBinding, true);
    shipmentByPartMap =
        new StoredSortedMap(db.getShipmentByPartDatabase(),
                            partKeyBinding, shipmentDataBinding, true);
    shipmentBySupplierMap =
        new StoredSortedMap(db.getShipmentBySupplierDatabase(),
                            supplierKeyBinding, shipmentDataBinding, true);
    supplierByCityMap =
        new StoredSortedMap(db.getSupplierByCityDatabase(),
                            cityKeyBinding, supplierDataBinding, true);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:51,代码来源:SampleViews.java


示例20: SampleViews

import com.sleepycat.collections.StoredSortedMap; //导入依赖的package包/类
/**
 * Create the data bindings and collection views.
 */
public SampleViews(SampleDatabase db) {

    // Create the data bindings.
    // In this sample, EntityBinding classes are used to bind the stored
    // key/data entry pair to a combined data object; a "tricky" binding
    // that uses transient fields is used--see PartBinding, etc, for
    // details.  For keys, a one-to-one binding is implemented with
    // EntryBinding classes to bind the stored tuple entry to a key Object.
    //
    ClassCatalog catalog = db.getClassCatalog();
    EntryBinding partKeyBinding =
        new PartKeyBinding();
    EntityBinding partDataBinding =
        new PartBinding(catalog, Part.class);
    EntryBinding supplierKeyBinding =
        new SupplierKeyBinding();
    EntityBinding supplierDataBinding =
        new SupplierBinding(catalog, Supplier.class);
    EntryBinding shipmentKeyBinding =
        new ShipmentKeyBinding();
    EntityBinding shipmentDataBinding =
        new ShipmentBinding(catalog, Shipment.class);
    EntryBinding cityKeyBinding =
        TupleBinding.getPrimitiveBinding(String.class);

    // Create map views for all stores and indices.
    // StoredSortedMap is used since the stores and indices are ordered
    // (they use the DB_BTREE access method).
    //
    partMap =
        new StoredSortedMap(db.getPartDatabase(),
                            partKeyBinding, partDataBinding, true);
    supplierMap =
        new StoredSortedMap(db.getSupplierDatabase(),
                            supplierKeyBinding, supplierDataBinding, true);
    shipmentMap =
        new StoredSortedMap(db.getShipmentDatabase(),
                            shipmentKeyBinding, shipmentDataBinding, true);
    shipmentByPartMap =
        new StoredSortedMap(db.getShipmentByPartDatabase(),
                            partKeyBinding, shipmentDataBinding, true);
    shipmentBySupplierMap =
        new StoredSortedMap(db.getShipmentBySupplierDatabase(),
                            supplierKeyBinding, shipmentDataBinding, true);
    supplierByCityMap =
        new StoredSortedMap(db.getSupplierByCityDatabase(),
                            cityKeyBinding, supplierDataBinding, true);
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:52,代码来源:SampleViews.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Token类代码示例发布时间:2022-05-23
下一篇:
Java SimpleComboBox类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap