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


Java SecondaryIndex类代码示例

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


SecondaryIndex类属于com.sleepycat.persist包,在下文中一共展示了SecondaryIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: doTwoConditionsJoin

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
/**
 * Do a "AND" join on a single primary database, similar to the SQL:
 * <blockquote><pre>
 * SELECT * FROM table WHERE col1 = key1 AND col2 = key2;
 * </pre></blockquote>
 *
 * @param pk
 * @param sk1
 * @param key1
 * @param sk2
 * @param key2
 * @return
 * @throws DatabaseException
 */
public <PK, SK1, SK2, E> ForwardCursor<E>
    doTwoConditionsJoin(PrimaryIndex<PK, E> pk,
                        SecondaryIndex<SK1, PK, E> sk1,
                        SK1 key1,
                        SecondaryIndex<SK2, PK, E> sk2,
                        SK2 key2)
    throws DatabaseException {

    assert (pk != null);
    assert (sk1 != null);
    assert (sk2 != null);

    EntityJoin<PK, E> join = new EntityJoin<PK, E>(pk);
    join.addCondition(sk1, key1);
    join.addCondition(sk2, key2);

    return join.entities();
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:33,代码来源:DataAccessor.java

示例5: query

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
/**
 * Do a "AND" join on a single primary database, similar to the SQL:
 * <blockquote><pre>
 * SELECT * FROM table WHERE col1 = key1 AND col2 = key2 AND col3 = key3;
 * </pre></blockquote>
 */
public <PK, SK1, SK2, SK3, E> ForwardCursor<E> query(PrimaryIndex<PK, E> pk,
                        SecondaryIndex<SK1, PK, E> sk1, SK1 key1,
                        SecondaryIndex<SK2, PK, E> sk2, SK2 key2,
                        SecondaryIndex<SK3, PK, E> sk3, SK3 key3) {
    return join(pk).join(sk1, key1).join(sk2, key2).join(sk3, key3).entities();
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:13,代码来源:Berkeley.java

示例6: getSubclassIndex

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
/**
 * @see EntityStore#getSubclassIndex(PrimaryIndex, Class, Class, String)
 */
public <SK, PK, E1, E2 extends E1> SecondaryIndex<SK, PK, E2>
    getSubclassIndex(PrimaryIndex<PK, E1> primaryIndex,
                     Class<E2> entitySubclass, Class<SK> keyClass,
                     String keyName) throws DatabaseException {
    return delegate().getSubclassIndex(primaryIndex, entitySubclass, keyClass, keyName);
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:10,代码来源:Berkeley.java

示例7: findPrefix

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
/**
 * @see BerkeleyStore#query(com.sleepycat.persist.EntityIndex, String)
 */
public <SK> List<E> findPrefix(String keyName, String prefix) {
    SecondaryIndex<SK, PK, E> secondaryIndex = getRegisterSK(keyName);
    Class<SK> classSK = secondaryIndex.getKeyClass();
    checkArgument(String.class == classSK, "The secondary index class type must be java.lang.String.class, but is %s", classSK);
    
    @SuppressWarnings("unchecked") SecondaryIndex<String, PK, E> idx = (SecondaryIndex<String, PK, E>) secondaryIndex;
    return all(store.query(idx, checkNotNull(prefix)));
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:12,代码来源:Berkeley.java

示例8: gets

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
/**
 * Returns the items with given field and key list, one key returns one item
 */
public <SK> List<E> gets(String keyName, List<SK> keys) {
    SecondaryIndex<SK, PK, E> indexSK = getRegisterSK(keyName);
    E item = null; List<E> items = Lists.newArrayListWithCapacity(checkNotNull(keys).size());
    
    for (SK sk : keys) {
        if (null == (item = one(indexSK.subIndex(sk).entities()))) {
            log.warn(String.format("The Field %s's key: %s is none exists.", keyName, sk));
        } else {
            items.add(item);
        }
    }
    
    return items;
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:18,代码来源:Berkeley.java

示例9: getSecondaryIndex

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
/**
 * Opens the secondary index for a given entity class and secondary key
 * name.
 */
public SecondaryIndex<Object,Object,RawObject>
    getSecondaryIndex(String entityClass, String keyName)
    throws DatabaseException {

    return store.getSecondaryIndex
        (getPrimaryIndex(entityClass), RawObject.class, entityClass,
         Object.class, null, keyName);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:13,代码来源:RawStore.java

示例10: checkSecondary

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
private void checkSecondary(SecondaryIndex<Integer,Integer,MyEntity> index,
                            SecondaryIndex<Object,Object,RawObject>
                            indexRaw,
                            SortedMap<Integer,SortedSet<Integer>> expected)
    throws DatabaseException {

    checkIndex(index, expected, keyGetter, entityGetter);
    checkIndex(index.keysIndex(), expected, keyGetter, keyGetter);

    checkIndex(indexRaw, expected, rawKeyGetter, rawEntityGetter);
    checkIndex(indexRaw.keysIndex(), expected, rawKeyGetter, rawKeyGetter);

    SortedMap<Integer,SortedSet<Integer>> expectedSubIndex =
        new TreeMap<Integer,SortedSet<Integer>>();

    for (Integer secKey : expected.keySet()) {
        expectedSubIndex.clear();
        for (Integer priKey : expected.get(secKey)) {
            SortedSet<Integer> values = new TreeSet<Integer>();
            values.add(priKey);
            expectedSubIndex.put(priKey, values);
        }
        checkIndex(index.subIndex(secKey),
                   expectedSubIndex,
                   keyGetter,
                   entityGetter);
        checkIndex(indexRaw.subIndex(secKey),
                   expectedSubIndex,
                   rawKeyGetter,
                   rawEntityGetter);
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:33,代码来源:IndexTest.java

示例11: testCursorCount

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
public void testCursorCount()
    throws DatabaseException {

    open();

    PrimaryIndex<Integer,MyEntity> priIndex =
        store.getPrimaryIndex(Integer.class, MyEntity.class);

    SecondaryIndex<Integer,Integer,MyEntity> secIndex =
        store.getSecondaryIndex(priIndex, Integer.class, "secKey");

    Transaction txn = txnBeginCursor();

    MyEntity e = new MyEntity();
    e.priKey = 1;
    e.secKey = 1;
    priIndex.put(txn, e);

    EntityCursor<MyEntity> cursor = secIndex.entities(txn, null);
    cursor.next();
    assertEquals(1, cursor.count());
    cursor.close();

    e.priKey = 2;
    priIndex.put(txn, e);
    cursor = secIndex.entities(txn, null);
    cursor.next();
    assertEquals(2, cursor.count());
    cursor.close();

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

示例12: testCursorCount

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
public void testCursorCount() 
    throws DatabaseException {

    open();

    PrimaryIndex<Integer,MyEntity> priIndex =
        store.getPrimaryIndex(Integer.class, MyEntity.class);

    SecondaryIndex<Integer,Integer,MyEntity> secIndex =
        store.getSecondaryIndex(priIndex, Integer.class, "secKey");

    Transaction txn = txnBeginCursor();

    MyEntity e = new MyEntity();
    e.priKey = 1;
    e.secKey = 1;
    priIndex.put(txn, e);

    EntityCursor<MyEntity> cursor = secIndex.entities(txn, null);
    cursor.next();
    assertEquals(1, cursor.count());
    cursor.close();

    e.priKey = 2;
    priIndex.put(txn, e);
    cursor = secIndex.entities(txn, null);
    cursor.next();
    assertEquals(2, cursor.count());
    cursor.close();

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

示例13: getSecondaryIndex

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
/**
 * Opens the secondary index for a given entity class and secondary key
 * name.
 *
 * @throws DatabaseException the base class for all BDB exceptions.
 */
public SecondaryIndex<Object, Object, RawObject>
    getSecondaryIndex(String entityClass, String keyName)
    throws DatabaseException {

    return store.getSecondaryIndex
        (getPrimaryIndex(entityClass), RawObject.class, entityClass,
         Object.class, null, keyName);
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:15,代码来源:RawStore.java

示例14: join

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
public <SK> EntityJoinQuery<PK, E> join(SecondaryIndex<SK, PK, E> index, SK key) {
    if (null != index && null != key) {
        addCondition(index, key);
    }
    return this;
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:7,代码来源:Berkeley.java

示例15: getSecondaryIndex

import com.sleepycat.persist.SecondaryIndex; //导入依赖的package包/类
/**
 * @see EntityStore#getSecondaryIndex(PrimaryIndex, Class, String)
 */
public <SK, PK, E> SecondaryIndex<SK, PK, E> getSecondaryIndex(
        PrimaryIndex<PK, E> primaryIndex, Class<SK> keyClass, String keyName) throws DatabaseException {
    return delegate().getSecondaryIndex(primaryIndex, keyClass, keyName);
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:8,代码来源:Berkeley.java


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