Java源码示例:com.sleepycat.persist.EntityCursor

示例1
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;
}
 
示例2
public WiktionaryIterator<IWiktionaryPage> getAllPages(
		final IWiktionaryPageFilter filter, boolean sortByTitle, 
		boolean normalize) {
	ensureOpen();
	try {
		EntityCursor<WiktionaryPage> cursor;
		if (sortByTitle)
			cursor = (normalize 
					? pageByNormalizedTitle.entities() 
					: pageByTitle.entities());
		else
			cursor = pageById.entities();
		
		return new BerkeleyDBWiktionaryIterator<IWiktionaryPage, WiktionaryPage>(
				this, cursor){
			
			@Override
			protected IWiktionaryPage loadEntity(final WiktionaryPage entity) {
				return loadPage(entity, filter);
			}
			
		};
	} catch (DatabaseException e) {
		throw new WiktionaryException(e);
	}
}
 
示例3
/** Hotspot for closing the connection. 
 *  @throws WiktionaryException if the connection could not be closed. */
protected void doClose() {
	if (store == null) 
		return; // DB already closed.
			
	try {
		openCursors.forEach(EntityCursor::close);
		openCursors.clear();

		store.close();
		env.close();
		
		env = null;
		store = null;
	} catch (DatabaseException e) {
		throw new WiktionaryException("Unable to close database", e);
	}
}
 
示例4
public K maximumIdentity(BerkeleyTransactor transactor, K from, K to) {
	CursorConfig cursorModel = transactor == null ? null : transactor.getIsolation().getCursorModel();
	Transaction transaction = transactor == null ? null : transactor.getTransaction();
	try (EntityCursor<K> cursor = primaryIndex.keys(transaction, from, true, to, false, cursorModel)) {
		return cursor.last();
	}
}
 
示例5
public K minimumIdentity(BerkeleyTransactor transactor, K from, K to) {
	CursorConfig cursorModel = transactor == null ? null : transactor.getIsolation().getCursorModel();
	Transaction transaction = transactor == null ? null : transactor.getTransaction();
	try (EntityCursor<K> cursor = primaryIndex.keys(transaction, from, true, to, false, cursorModel)) {
		return cursor.first();
	}
}
 
示例6
public List<T> queryInstances(BerkeleyTransactor transactor, StoragePagination pagination) {
	Transaction transaction = transactor == null ? null : transactor.getTransaction();
	ArrayList<T> instances = new ArrayList<>();
	long ignore = pagination.getFirst();
	long size = pagination.getSize();
	try (EntityCursor<T> cursor = primaryIndex.entities(transaction, transactor.getIsolation().getCursorModel())) {
		ignore -= ignore(cursor, ignore);
		if (ignore == 0) {
			collect(instances, cursor, size);
		}
		return instances;
	}
}
 
示例7
/** Initializes the iterator for the specified cursor. */
public BerkeleyDBWiktionaryIterator(final BerkeleyDBWiktionaryEdition edition,
		final EntityCursor<InputType> cursor) {
	this.edition = edition;
	this.cursor = cursor;
	edition.openCursors.add(cursor);
}