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


Java PrimaryIndex.get方法代码示例

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


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

示例1: readObjects

import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
@Override
void readObjects(EntityStore store, boolean doUpdate)
    throws DatabaseException {

    PrimaryIndex<Integer,DeleteSuperclass5_Top>
        index = store.getPrimaryIndex
            (Integer.class,
             DeleteSuperclass5_Top.class);
    DeleteSuperclass5_Top obj = index.get(key);
    TestCase.assertNotNull(obj);
    TestCase.assertNotNull(obj.embed);
    TestCase.assertEquals(99, obj.key);
    TestCase.assertEquals(88, obj.ff);
    TestCase.assertEquals(123, obj.embed.f);
    if (doUpdate) {
        index.put(obj);
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:19,代码来源:EvolveClasses.java

示例2: readObjects

import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
@Override
void readObjects(EntityStore store, boolean doUpdate)
    throws DatabaseException {

    PrimaryIndex<Integer,ProxiedClass_Entity>
        index = store.getPrimaryIndex
            (Integer.class,
             ProxiedClass_Entity.class);
    ProxiedClass_Entity obj = index.get(99);
    TestCase.assertNotNull(obj);
    TestCase.assertEquals(99, obj.key);
    TestCase.assertNotNull(obj.embed);
    TestCase.assertEquals(88, obj.embed.data);

    if (doUpdate) {
        index.put(obj);
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:19,代码来源:EvolveClasses.java

示例3: testReadOnly

import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
public void testReadOnly() 
    throws DatabaseException {

    open();
    PrimaryIndex<Integer,SharedSequenceEntity1> priIndex =
        store.getPrimaryIndex(Integer.class, SharedSequenceEntity1.class);
    Transaction txn = txnBegin();
    SharedSequenceEntity1 e = new SharedSequenceEntity1();
    priIndex.put(txn, e);
    assertEquals(1, e.key);
    txnCommit(txn);
    close();

    /*
     * Check that we can open the store read-only and read the records
     * written above.
     */
    openReadOnly();
    priIndex =
        store.getPrimaryIndex(Integer.class, SharedSequenceEntity1.class);
    e = priIndex.get(1);
    assertNotNull(e);
    close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:25,代码来源:OperationTest.java

示例4: gets

import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
/**
 * Returns the items with given key list
 */
public List<E> gets(List<PK> keys) {
    PrimaryIndex<PK, E> indexPK = getPK();
    E item = null; List<E> items = Lists.newArrayListWithCapacity(checkNotNull(keys).size());
    
    for (PK pk : keys) {
        if (null == (item = indexPK.get(pk))) {
            log.warn(String.format("The primary key: %s is none exists.", pk));
        } else {
            items.add(item);
        }
    }
    
    return items;
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:18,代码来源:Berkeley.java

示例5: readRaw

import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
/**
 * Reads a raw object and checks its superclass names and versions.
 */
private static RawObject readRaw(RawStore store,
                                 Object key,
                                 Object... classVersionPairs)
    throws DatabaseException {

    TestCase.assertNotNull(store);
    TestCase.assertNotNull(key);

    String entityClsName = (String) classVersionPairs[0];
    PrimaryIndex<Object,RawObject> index =
        store.getPrimaryIndex(entityClsName);
    TestCase.assertNotNull(index);

    RawObject obj = index.get(key);
    TestCase.assertNotNull(obj);

    checkRawType(obj.getType(), classVersionPairs);

    RawObject superObj = obj.getSuper();
    for (int i = 2; i < classVersionPairs.length; i += 2) {
        Object[] a = new Object[classVersionPairs.length - i];
        System.arraycopy(classVersionPairs, i, a, 0, a.length);
        TestCase.assertNotNull(superObj);
        checkRawType(superObj.getType(), a);
        superObj = superObj.getSuper();
    }

    return obj;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:33,代码来源:EvolveClasses.java

示例6: testSubclassIndex

import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
public void testSubclassIndex()
    throws DatabaseException {

    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setAllowCreate(true);
    env = new Environment(envHome, envConfig);

    StoreConfig storeConfig = new StoreConfig();
    storeConfig.setAllowCreate(true);
    EntityStore store = new EntityStore(env, "foo", storeConfig);

    PrimaryIndex<String, Employee> employeesById =
        store.getPrimaryIndex(String.class, Employee.class);

    employeesById.put(new Employee("1"));
    employeesById.put(new Manager("2", "a"));
    employeesById.put(new Manager("3", "a"));
    employeesById.put(new Manager("4", "b"));

    Employee e;
    Manager m;

    e = employeesById.get("1");
    assertNotNull(e);
    assertTrue(!(e instanceof Manager));

    /* Ensure DB exists BEFORE calling getSubclassIndex. [#15247] */
    PersistTestUtils.assertDbExists
        (true, env, "foo", Employee.class.getName(), "dept");

    /* Normal use: Subclass index for a key in the subclass. */
    SecondaryIndex<String, String, Manager> managersByDept =
        store.getSubclassIndex
            (employeesById, Manager.class, String.class, "dept");

    m = managersByDept.get("a");
    assertNotNull(m);
    assertEquals("2", m.id);

    m = managersByDept.get("b");
    assertNotNull(m);
    assertEquals("4", m.id);

    EntityCursor<Manager> managers = managersByDept.entities();
    try {
        m = managers.next();
        assertNotNull(m);
        assertEquals("2", m.id);
        m = managers.next();
        assertNotNull(m);
        assertEquals("3", m.id);
        m = managers.next();
        assertNotNull(m);
        assertEquals("4", m.id);
        m = managers.next();
        assertNull(m);
    } finally {
        managers.close();
    }

    /* Getting a subclass index for the entity class is also allowed. */
    store.getSubclassIndex
        (employeesById, Employee.class, String.class, "other");

    /* Getting a subclass index for a base class key is not allowed. */
    try {
        store.getSubclassIndex
            (employeesById, Manager.class, String.class, "other");
        fail();
    } catch (IllegalArgumentException expected) {
    }

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


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