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


Java EntityCursor类代码示例

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


EntityCursor类属于com.sleepycat.persist包,在下文中一共展示了EntityCursor类的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();
        }
    }
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:24,代码来源:BerkeleyUsage.java

示例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;
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:37,代码来源:AddressDatabase.java

示例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;
}
 
开发者ID:classtag,项目名称:scratch_crawler,代码行数:17,代码来源:WebGraph.java

示例4: getAllPages

import com.sleepycat.persist.EntityCursor; //导入依赖的package包/类
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);
	}
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:27,代码来源:BerkeleyDBWiktionaryEdition.java

示例5: doClose

import com.sleepycat.persist.EntityCursor; //导入依赖的package包/类
/** 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);
	}
}
 
开发者ID:dkpro,项目名称:dkpro-jwktl,代码行数:20,代码来源:BerkeleyDBWiktionaryEdition.java

示例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();
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:17,代码来源:ExampleInventoryRead.java

示例7: 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();
    }
}
 
开发者ID:nologic,项目名称:nabs,代码行数:21,代码来源:CustomKeyOrderExample.java

示例8: countObjects

import com.sleepycat.persist.EntityCursor; //导入依赖的package包/类
private int countObjects(Transaction txn)  throws DatabaseException {
    int count = 0;

    CursorConfig cc = new CursorConfig();
    // This is ignored if the store is not opened with uncommitted read
    // support.
    cc.setReadUncommitted(true);
    EntityCursor<PayloadDataEntity> cursor = pdKey.entities(txn, cc);

    try {
        for (PayloadDataEntity pdi : cursor) {
                count++;
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    return count;
    
}
 
开发者ID:nologic,项目名称:nabs,代码行数:23,代码来源:StoreWriter.java

示例9: countObjects

import com.sleepycat.persist.EntityCursor; //导入依赖的package包/类
private int countObjects(Transaction txn)  throws DatabaseException {
    int count = 0;

    CursorConfig cc = new CursorConfig();
    // This is ignored if the store is not opened with uncommitted read
    // support.
    cc.setReadUncommitted(true);
    EntityCursor<PayloadDataEntity> cursor = pdIndex.entities(txn, cc);

    try {
        for (PayloadDataEntity pdi : cursor) {
                count++;
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    return count;
    
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:23,代码来源:StoreWriter.java

示例10: 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();
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:17,代码来源:ExampleInventoryRead.java

示例11: doRangeQuery

import com.sleepycat.persist.EntityCursor; //导入依赖的package包/类
/**
 * Do range query, similar to the SQL statement:
 * <blockquote><pre>
 * SELECT * FROM table WHERE col >= fromKey AND col <= toKey;
 * </pre></blockquote>
 *
 * @param index
 * @param fromKey
 * @param fromInclusive
 * @param toKey
 * @param toInclusive
 * @return
 * @throws DatabaseException
 */
public <K, V> EntityCursor<V> doRangeQuery(EntityIndex<K, V> index,
                                           K fromKey,
                                           boolean fromInclusive,
                                           K toKey,
                                           boolean toInclusive)
    throws DatabaseException {

    assert (index != null);

    /* Opens a cursor for traversing entities in a key range. */
    return index.entities(fromKey,
                          fromInclusive,
                          toKey,
                          toInclusive);
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:30,代码来源:DataAccessor.java

示例12: getEmployeeByDeptName

import com.sleepycat.persist.EntityCursor; //导入依赖的package包/类
/**
 * Query the Employee database by Department's secondary-key: deptName. 
 * <blockquote><pre>
 * SELECT * FROM employee e, department d
 * WHERE e.departmentId = d.departmentId
 * AND d.departmentName = 'deptName';
 * </pre></blockquote>
 *
 * @param deptName
 * @throws DatabaseException
 */
public void getEmployeeByDeptName(String deptName)
    throws DatabaseException {

    Department dept = departmentByName.get(deptName);
    /* Do an inner join on Department and Employee. */
    EntityCursor<Employee> empCursor =
        employeeByDepartmentId.
        subIndex(dept.getDepartmentId()).entities();
    try {
        for (Employee emp : empCursor) {
            System.out.println(emp);
        }
        System.out.println();
    } finally {
        empCursor.close();
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:29,代码来源:DataAccessor.java

示例13: 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();
            }
        }
    }
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:37,代码来源:DataAccessor.java

示例14: JECursorAdapter

import com.sleepycat.persist.EntityCursor; //导入依赖的package包/类
public JECursorAdapter(Context context, 
                       int textViewResourceId, 
                       EntityCursor<K> keyCursor,
                       EntityCursor<E> valueCursor,
                       EntityIndex<K, E> primaryIndex) {

    this.context = context;
    this.inflater = (LayoutInflater)
        context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.resource = textViewResourceId;
    this.fieldId = 0;
    this.valueCursor = valueCursor;
    this.valueCursor.first();
    this.currentCursorPosition = 0;
    this.keyCursor = keyCursor;
    this.keyCursor.first();
    this.primaryIndex = primaryIndex;
    this.itemsCount = -1;
}
 
开发者ID:prat0318,项目名称:dbms,代码行数:20,代码来源:JECursorAdapter.java

示例15: query

import com.sleepycat.persist.EntityCursor; //导入依赖的package包/类
/**
 * Do prefix query, similar to the SQL statement:
 * <blockquote><pre>
 * SELECT * FROM table WHERE col LIKE 'prefix%';
 * </pre></blockquote>
 */
public <V> EntityCursor<V> query(EntityIndex<String, V> index, String prefix) {
    checkArgument(!Strs.isBlank(prefix));
    
    char[] ca = prefix.toCharArray();
    final int lastCharIndex = ca.length - 1;
    ca[lastCharIndex]++;
    return query(index, prefix, true, String.valueOf(ca), false);
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:15,代码来源:Berkeley.java


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