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


Java SecondaryIndex.get方法代码示例

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


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

示例1: readObjects

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

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

    SecondaryIndex<Integer,Integer,
                   RenamedEntity2_NewEntityName_WithRenamer>
        sindex = store.getSecondaryIndex(index, Integer.class, "skey");
    obj = sindex.get(88);
    TestCase.assertNotNull(obj);
    TestCase.assertEquals(99, obj.key);
    TestCase.assertEquals(88, obj.skey);

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

示例2: testToManyKeyClass

import com.sleepycat.persist.SecondaryIndex; //导入方法依赖的package包/类
/**
 * When opening an X_TO_MANY secondary that has a persistent key class, the
 * key class was not recognized as being persistent if it was never before
 * referenced when getSecondaryIndex was called.  This was a bug in JE
 * 3.0.12, reported on OTN.  [#15103]
 */
public void testToManyKeyClass()
    throws DatabaseException {

    open();

    PrimaryIndex<Integer,ToManyKeyEntity> priIndex =
        store.getPrimaryIndex(Integer.class, ToManyKeyEntity.class);
    SecondaryIndex<ToManyKey,Integer,ToManyKeyEntity> secIndex =
        store.getSecondaryIndex(priIndex, ToManyKey.class, "key2");

    priIndex.put(new ToManyKeyEntity());
    secIndex.get(new ToManyKey());

    close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:22,代码来源:OperationTest.java

示例3: testToManyReadOnly

import com.sleepycat.persist.SecondaryIndex; //导入方法依赖的package包/类
/**
 * Test a fix for a bug where opening a TO_MANY secondary index would fail
 * fail with "IllegalArgumentException: Wrong secondary key class: ..."
 * when the store was opened read-only.  [#15156]
 */
public void testToManyReadOnly()
    throws DatabaseException {

    open();
    PrimaryIndex<Integer,ToManyKeyEntity> priIndex =
        store.getPrimaryIndex(Integer.class, ToManyKeyEntity.class);
    priIndex.put(new ToManyKeyEntity());
    close();

    openReadOnly();
    priIndex = store.getPrimaryIndex(Integer.class, ToManyKeyEntity.class);
    SecondaryIndex<ToManyKey,Integer,ToManyKeyEntity> secIndex =
        store.getSecondaryIndex(priIndex, ToManyKey.class, "key2");
    secIndex.get(new ToManyKey());
    close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:22,代码来源:OperationTest.java

示例4: testSubclassIndex

import com.sleepycat.persist.SecondaryIndex; //导入方法依赖的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

示例5: testSubclassIndex

import com.sleepycat.persist.SecondaryIndex; //导入方法依赖的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

示例6: testSubclassIndex

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

    EnvironmentConfig envConfig = TestEnv.BDB.getConfig();
    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.SecondaryIndex.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。