本文整理汇总了Java中com.sleepycat.persist.EntityCursor.close方法的典型用法代码示例。如果您正苦于以下问题:Java EntityCursor.close方法的具体用法?Java EntityCursor.close怎么用?Java EntityCursor.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sleepycat.persist.EntityCursor
的用法示例。
在下文中一共展示了EntityCursor.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDump
import com.sleepycat.persist.EntityCursor; //导入方法依赖的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: findMunicipality
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
/**
* Returns the set of Municipalities that have the given name as their
* official name or one of their alternates, restricting the results to the
* given province (by 2-letter province code). If the given province code is
* null or invalid (TODO), all matching municipalities will be returned.
*
* @param name
* The official, valid alternate, or invalid alternate name of a
* municipality. If null, no matches will be returned (you get an
* empty set).
* @param province
* the two-letter province code to restrict the search to. If no
* provincial restriction is desired, this parameter can be set
* to null.
* @return The set of municipalities that match the search criteria
*/
public Set<Municipality> findMunicipality(String name, String province) throws DatabaseException {
if (name == null) {
return Collections.emptySet();
}
String upperName = name.toUpperCase().trim();
// TODO check if province code is valid, and ignore if not
Set<Municipality> results = new HashSet<Municipality>();
EntityCursor<Municipality> hits = municipalitySK.entities(upperName, true, upperName, true);
for (Municipality m : hits) {
if (province == null || province.equals(m.getProvince())) {
results.add(m);
}
logger.debug("Found municipality: " + m);
}
hits.close();
return results;
}
示例3: inLinks
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
public String[] inLinks(String URL) throws DatabaseException {
EntityIndex<String, Link> subIndex = inLinkIndex.subIndex(URL);
// System.out.println(subIndex.count());
String[] linkList = new String[(int) subIndex.count()];
int i = 0;
EntityCursor<Link> cursor = subIndex.entities();
try {
for (Link entity : cursor) {
linkList[i++] = entity.fromURL;
// System.out.println(entity.fromURL);
}
} finally {
cursor.close();
}
return linkList;
}
示例4: getEmployeeByDeptLocation
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
/**
* Query the Employee database by adding a filter on Department's
* non-secondary-key: deptLocation.
* <blockquote><pre>
* SELECT * FROM employee e, department d
* WHERE e.departmentId = d.departmentId
* AND d.location = 'deptLocation';
* </pre></blockquote>
*
* @param deptLocation
* @throws DatabaseException
*/
public void getEmployeeByDeptLocation(String deptLocation)
throws DatabaseException {
/* Iterate over Department database. */
Collection<Department> departments =
departmentById.sortedMap().values();
for (Department dept : departments) {
if (dept.getLocation().equals(deptLocation)) {
/* A nested loop to do an equi-join. */
EntityCursor<Employee> empCursor =
employeeByDepartmentId.
subIndex(dept.getDepartmentId()).
entities();
try {
/* Iterate over all employees in dept. */
for (Employee emp : empCursor) {
System.out.println(emp);
}
} finally {
empCursor.close();
}
}
}
}
示例5: run
import com.sleepycat.persist.EntityCursor; //导入方法依赖的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();
}
}
示例6: showAllInventory
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
private void showAllInventory()
throws DatabaseException {
// Get a cursor that will walk every
// inventory object in the store.
EntityCursor<Inventory> items =
da.inventoryBySku.entities();
try {
for (Inventory item : items) {
displayInventoryRecord(item);
}
} finally {
items.close();
}
}
示例7: dump_pt_file
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
public void dump_pt_file(PrintStream out) {
openDB();
try {
EntityCursor<PhraseNumEntry> pi_cursor =
phraseById.entities();
for (PhraseNumEntry pe : pi_cursor)
out.println(PhraseNumEntryToString(pe));
pi_cursor.close();
} catch(DatabaseException dbe) {
closeDB();
System.err.println("Error reading from phrase database (" + base + "): " + dbe.toString());
System.exit(-1);
}
closeDB();
}
示例8: containsLVRPostalCode
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
/**
* Returns true if the postal code is a large volume receiver postal code.
* False otherwise.
*/
public boolean containsLVRPostalCode(String postalCode) throws DatabaseException {
if (postalCode == null) return false;
EntityCursor<LargeVolumeReceiver> cursor = largeVolumeReceiverPK.entities(postalCode, true, postalCode, true);
try {
if (cursor.next() != null) {
return true;
}
} finally {
cursor.close();
}
return false;
}
示例9: findLargeVolumeReceiver
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
/**
* Only one large volume receiver should be found for each postal code.
* If there is no large volume receiver for the given postal code then
* the LVR returned will be null.
*/
public LargeVolumeReceiver findLargeVolumeReceiver(String postalCode) throws DatabaseException {
if (postalCode == null) return null;
EntityCursor<LargeVolumeReceiver> cursor = largeVolumeReceiverPK.entities(postalCode, true, postalCode, true);
LargeVolumeReceiver lvr = cursor.next();
cursor.close();
return lvr;
}
示例10: containsDeliveryInstallationName
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
/**
* Returns true if the database has a delivery installation with
* the given name. Returns false otherwise.
*/
public boolean containsDeliveryInstallationName(String diName) throws DatabaseException {
if (diName == null) return false;
EntityCursor<PostalCode> cursor = postalCodeDIName.entities(diName, true, diName, true);
try {
if (cursor.next() != null) return true;
} finally {
cursor.close();
}
return false;
}
示例11: printEvents
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
/**
* Print all events covered by this cursor.
*/
private void printEvents(EntityCursor<Event> eCursor)
throws DatabaseException {
try {
for (Event e: eCursor) {
System.out.println(e);
}
} finally {
/* Be sure to close the cursor. */
eCursor.close();
}
}
示例12: showItem
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
private void showItem() throws DatabaseException {
// Use the inventory name secondary key to retrieve
// these objects.
EntityCursor<Inventory> items =
da.inventoryByName.subIndex(locateItem).entities();
try {
for (Inventory item : items) {
displayInventoryRecord(item);
}
} finally {
items.close();
}
}
示例13: printEvents
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
/**
* Print all events covered by this cursor.
*/
private void printEvents(EntityCursor<Event> eCursor)
throws DatabaseException {
try {
for (Event e: eCursor) {
System.out.println(e);
}
} finally {
/* Be sure to close the cursor. */
eCursor.close();
}
}
示例14: checkEmpty
import com.sleepycat.persist.EntityCursor; //导入方法依赖的package包/类
private <K,V> void checkEmpty(EntityIndex<K,V> index)
throws DatabaseException {
EntityCursor<K> keys = index.keys();
assertNull(keys.next());
assertTrue(!keys.iterator().hasNext());
keys.close();
EntityCursor<V> entities = index.entities();
assertNull(entities.next());
assertTrue(!entities.iterator().hasNext());
entities.close();
}
示例15: testCursorCount
import com.sleepycat.persist.EntityCursor; //导入方法依赖的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();
}