本文整理汇总了Java中com.sleepycat.persist.PrimaryIndex.entities方法的典型用法代码示例。如果您正苦于以下问题:Java PrimaryIndex.entities方法的具体用法?Java PrimaryIndex.entities怎么用?Java PrimaryIndex.entities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sleepycat.persist.PrimaryIndex
的用法示例。
在下文中一共展示了PrimaryIndex.entities方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDump
import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
public void testDump() {
RawStore rs = access.getRawStore();
EntityModel model = rs.getModel();
for (String clsName : model.getKnownClasses()) {
if (model.getEntityMetadata(clsName) != null) {
final PrimaryIndex<Object,RawObject> index;
try {
index = rs.getPrimaryIndex(clsName);
} catch (IndexNotAvailableException e) {
System.err.println("Skipping primary index that is " +
"not yet available: " + clsName);
continue;
}
EntityCursor<RawObject> entities = index.entities();
for (RawObject entity : entities) {
System.out.println(entity);
}
entities.close();
}
}
}
示例2: run
import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
private void run()
throws DatabaseException {
PrimaryIndex<ReverseOrder,Person> index =
store.getPrimaryIndex(ReverseOrder.class, Person.class);
index.put(new Person("Andy"));
index.put(new Person("Lisa"));
index.put(new Person("Zola"));
/* Print the entities in key order. */
EntityCursor<Person> people = index.entities();
try {
for (Person person : people) {
System.out.println(person);
}
} finally {
people.close();
}
}
示例3: dump
import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
private void dump()
throws DatabaseException {
StoreConfig storeConfig = new StoreConfig();
storeConfig.setReadOnly(true);
RawStore store = new RawStore(env, storeName, storeConfig);
EntityModel model = store.getModel();
for (String clsName : model.getKnownClasses()) {
EntityMetadata meta = model.getEntityMetadata(clsName);
if (meta != null) {
if (dumpMetadata) {
for (RawType type : model.getAllRawTypeVersions(clsName)) {
System.out.println(type);
}
} else {
PrimaryIndex<Object,RawObject> index =
store.getPrimaryIndex(clsName);
EntityCursor<RawObject> entities = index.entities();
for (RawObject entity : entities) {
System.out.println(entity);
}
entities.close();
}
}
}
store.close();
}
示例4: dump
import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
private void dump()
throws DatabaseException {
StoreConfig storeConfig = new StoreConfig();
storeConfig.setReadOnly(true);
RawStore store = new RawStore(env, storeName, storeConfig);
EntityModel model = store.getModel();
if (dumpMetadata) {
for (RawType type : model.getAllRawTypes()) {
System.out.println(type);
}
} else {
for (String clsName : model.getKnownClasses()) {
if (model.getEntityMetadata(clsName) != null) {
final PrimaryIndex<Object,RawObject> index;
try {
index = store.getPrimaryIndex(clsName);
} catch (IndexNotAvailableException e) {
System.err.println("Skipping primary index that is " +
"not yet available: " + clsName);
continue;
}
EntityCursor<RawObject> entities = index.entities();
for (RawObject entity : entities) {
System.out.println(entity);
}
entities.close();
}
}
}
store.close();
}
示例5: testCompositeSequence
import com.sleepycat.persist.PrimaryIndex; //导入方法依赖的package包/类
public void testCompositeSequence()
throws DatabaseException {
open();
PrimaryIndex<CompositeSequenceEntity1.Key,CompositeSequenceEntity1>
priIndex1 =
store.getPrimaryIndex
(CompositeSequenceEntity1.Key.class,
CompositeSequenceEntity1.class);
PrimaryIndex<CompositeSequenceEntity2.Key,CompositeSequenceEntity2>
priIndex2 =
store.getPrimaryIndex
(CompositeSequenceEntity2.Key.class,
CompositeSequenceEntity2.class);
Transaction txn = txnBegin();
CompositeSequenceEntity1 e1 = new CompositeSequenceEntity1();
CompositeSequenceEntity2 e2 = new CompositeSequenceEntity2();
priIndex1.put(txn, e1);
assertEquals(1, e1.key.key);
priIndex2.putNoOverwrite(txn, e2);
assertEquals(Integer.valueOf(1), e2.key.key);
e1.key = null;
priIndex1.putNoOverwrite(txn, e1);
assertEquals(2, e1.key.key);
e2.key = null;
priIndex2.put(txn, e2);
assertEquals(Integer.valueOf(2), e2.key.key);
txnCommit(txn);
EntityCursor<CompositeSequenceEntity1> c1 = priIndex1.entities();
e1 = c1.next();
assertEquals(2, e1.key.key);
e1 = c1.next();
assertEquals(1, e1.key.key);
e1 = c1.next();
assertNull(e1);
c1.close();
EntityCursor<CompositeSequenceEntity2> c2 = priIndex2.entities();
e2 = c2.next();
assertEquals(Integer.valueOf(2), e2.key.key);
e2 = c2.next();
assertEquals(Integer.valueOf(1), e2.key.key);
e2 = c2.next();
assertNull(e2);
c2.close();
close();
}