本文整理汇总了Java中com.sleepycat.persist.EntityIndex类的典型用法代码示例。如果您正苦于以下问题:Java EntityIndex类的具体用法?Java EntityIndex怎么用?Java EntityIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityIndex类属于com.sleepycat.persist包,在下文中一共展示了EntityIndex类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: inLinks
import com.sleepycat.persist.EntityIndex; //导入依赖的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
示例2: doRangeQuery
import com.sleepycat.persist.EntityIndex; //导入依赖的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
示例3: JECursorAdapter
import com.sleepycat.persist.EntityIndex; //导入依赖的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
示例4: openSequence
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
/**
* Opens or creates a sequence.
*
* This method tries to open an existing sequence or create a new sequence with starting value
* of the next available id number in the specified index.
*
* @param entityStore The store that contains the sequence.
* @param index The index which is used to initialize the starting value.
* @param sequenceName The name of the sequence.
* @return The opened or created sequence.
*/
public static Sequence openSequence(EntityStore entityStore, EntityIndex<Long, ?> index,
String sequenceName) {
Sequence seq = null;
try {
seq = entityStore.getSequence(sequenceName);
} catch (SequenceNotFoundException ex) {
// Establish current value
long initialValue = DatabaseUtils.getMaxId(index) + 1;
entityStore.setSequenceConfig(sequenceName,
SequenceConfig.DEFAULT.setAllowCreate(true).setInitialValue(initialValue));
seq = entityStore.getSequence(sequenceName);
} finally {
if (seq == null) {
throw new RuntimeException("Could not open sequence localIdSequence.");
}
return seq;
}
}
开发者ID:MTA-SZTAKI,项目名称:longneck-bdb,代码行数:32,代码来源:DatabaseUtils.java
示例5: query
import com.sleepycat.persist.EntityIndex; //导入依赖的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
示例6: checkClosedRanges
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
private <K,V> void checkClosedRanges(Transaction txn, int i, int j,
EntityIndex<K,V> index,
SortedMap<Integer,SortedSet<Integer>>
expected,
Getter<K> kGetter,
Getter<V> vGetter)
throws DatabaseException {
SortedMap<K,V> map = index.sortedMap();
SortedMap<Integer,SortedSet<Integer>> rangeExpected;
K k = kGetter.fromInt(i);
K kPlusOne = kGetter.fromInt(i + 1);
K l = kGetter.fromInt(j);
K lPlusOne = kGetter.fromInt(j + 1);
/* Sub range exclusive. */
rangeExpected = expected.subMap(i + 1, j);
checkCursor
(index.keys(txn, k, false, l, false, null),
map.subMap(kPlusOne, l).keySet(), true,
expandKeys(rangeExpected), kGetter);
checkCursor
(index.entities(txn, k, false, l, false, null),
map.subMap(kPlusOne, l).values(), false,
expandValues(rangeExpected), vGetter);
/* Sub range inclusive. */
rangeExpected = expected.subMap(i, j + 1);
checkCursor
(index.keys(txn, k, true, l, true, null),
map.subMap(k, lPlusOne).keySet(), true,
expandKeys(rangeExpected), kGetter);
checkCursor
(index.entities(txn, k, true, l, true, null),
map.subMap(k, lPlusOne).values(), false,
expandValues(rangeExpected), vGetter);
}
开发者ID:nologic,项目名称:nabs,代码行数:38,代码来源:IndexTest.java
示例7: checkEmpty
import com.sleepycat.persist.EntityIndex; //导入依赖的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();
}
开发者ID:nologic,项目名称:nabs,代码行数:13,代码来源:IndexTest.java
示例8: getMapsToRelationshipsByConceptId2
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
public List<MapsToRelationship> getMapsToRelationshipsByConceptId2(int conceptId) {
EntityIndex<Integer, MapsToRelationship> subIndex = mapsToRelationshipDataAccessor.secondaryIndex.subIndex(conceptId);
EntityCursor<MapsToRelationship> cursor = subIndex.entities();
List<MapsToRelationship> relationships = new ArrayList<MapsToRelationship>();
try {
for (MapsToRelationship relationship : cursor)
relationships.add(relationship);
} finally {
cursor.close();
}
return relationships;
}
开发者ID:OHDSI,项目名称:Usagi,代码行数:13,代码来源:BerkeleyDbEngine.java
示例9: getParentChildRelationshipsByParentConceptId
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
public List<ParentChildRelationShip> getParentChildRelationshipsByParentConceptId(int conceptId) {
EntityIndex<Integer, ParentChildRelationShip> subIndex = parentChildRelationshipDataAccessor.secondaryIndexParent.subIndex(conceptId);
EntityCursor<ParentChildRelationShip> cursor = subIndex.entities();
List<ParentChildRelationShip> relationships = new ArrayList<ParentChildRelationShip>();
try {
for (ParentChildRelationShip relationship : cursor)
relationships.add(relationship);
} finally {
cursor.close();
}
return relationships;
}
开发者ID:OHDSI,项目名称:Usagi,代码行数:13,代码来源:BerkeleyDbEngine.java
示例10: getParentChildRelationshipsByChildConceptId
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
public List<ParentChildRelationShip> getParentChildRelationshipsByChildConceptId(int conceptId) {
EntityIndex<Integer, ParentChildRelationShip> subIndex = parentChildRelationshipDataAccessor.secondaryIndexChild.subIndex(conceptId);
EntityCursor<ParentChildRelationShip> cursor = subIndex.entities();
List<ParentChildRelationShip> relationships = new ArrayList<ParentChildRelationShip>();
try {
for (ParentChildRelationShip relationship : cursor)
relationships.add(relationship);
} finally {
cursor.close();
}
return relationships;
}
开发者ID:OHDSI,项目名称:Usagi,代码行数:13,代码来源:BerkeleyDbEngine.java
示例11: doPrefixQuery
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
/**
* Do prefix query, similar to the SQL statement:
* <blockquote><pre>
* SELECT * FROM table WHERE col LIKE 'prefix%';
* </pre></blockquote>
*
* @param index
* @param prefix
* @return
* @throws DatabaseException
*/
public <V> EntityCursor<V> doPrefixQuery(EntityIndex<String, V> index,
String prefix)
throws DatabaseException {
assert (index != null);
assert (prefix.length() > 0);
/* Opens a cursor for traversing entities in a key range. */
char[] ca = prefix.toCharArray();
final int lastCharIndex = ca.length - 1;
ca[lastCharIndex]++;
return doRangeQuery(index, prefix, true, String.valueOf(ca), false);
}
开发者ID:prat0318,项目名称:dbms,代码行数:25,代码来源:DataAccessor.java
示例12: getMaxId
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
/**
* Returns the highest key value in the index greater than zero.
*
* This method will return at least 0.
*
* @param index The index to scan.
* @return The highest key, but at least 0.
*/
public static long getMaxId(EntityIndex<Long, ?> index) {
long maxId = 0;
for (long id : index.keys()) {
if (id > maxId) {
maxId = id;
}
}
return maxId;
}
开发者ID:MTA-SZTAKI,项目名称:longneck-bdb,代码行数:19,代码来源:DatabaseUtils.java
示例13: get_phrases
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
public Set<PhraseEntry> get_phrases(String[][] refwdsAr,
String[][] hypwdsAr) {
HashSet<PhraseEntry> toret = new HashSet<PhraseEntry>();
HashSet<String> searched = new HashSet<String>();
HashSet<Integer> hypset = new HashSet<Integer>();
for (String[] hypwds : hypwdsAr) {
Integer[] hypids = phraseStrToInt(hypwds);
hypset.addAll(Arrays.asList(hypids));
}
for (String[] refwds : refwdsAr) {
Integer[] refids = phraseStrToInt(refwds);
try {
List<Integer> li = Arrays.asList(refids);
for (int i = 0; i < refids.length; i++) {
WordInfo wi = wordById.get(refids[i]);
int max_len = 0;
if (wi != null) {
max_len = wi.maxlen;
if ((i+max_len) > refids.length)
max_len = refids.length - i;
}
for (int j = i; j < (max_len + i); j++) {
String searchkey = sjoin(refids, i, j);
if (searched.contains(searchkey)) continue;
searched.add(searchkey);
EntityIndex<Integer,PhraseNumEntry> subIndex =
phraseByRef.subIndex(sjoin(refids, i, j));
EntityCursor<PhraseNumEntry> cursor = subIndex.entities();
try {
for (PhraseNumEntry pe : cursor) {
boolean ok = true;
for (int hw : pe.getHypIds()) {
if (! hypset.contains(hw)) {
ok = false;
break;
}
}
if (ok) {
toret.add(convertPhraseEntry(pe));
}
}
} finally {
cursor.close();
}
}
}
} catch(DatabaseException dbe) {
closeDB();
System.err.println("Error scanning database(" + base +
"): " + dbe.toString());
System.exit(-1);
}
}
return toret;
}
开发者ID:snover,项目名称:terp,代码行数:59,代码来源:PhraseDB.java
示例14: checkOpenRanges
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
private <K,V> void checkOpenRanges(Transaction txn, int i,
EntityIndex<K,V> index,
SortedMap<Integer,SortedSet<Integer>>
expected,
Getter<K> kGetter,
Getter<V> vGetter)
throws DatabaseException {
SortedMap<K,V> map = index.sortedMap();
SortedMap<Integer,SortedSet<Integer>> rangeExpected;
K k = kGetter.fromInt(i);
K kPlusOne = kGetter.fromInt(i + 1);
/* Head range exclusive. */
rangeExpected = expected.headMap(i);
checkCursor
(index.keys(txn, null, false, k, false, null),
map.headMap(k).keySet(), true,
expandKeys(rangeExpected), kGetter);
checkCursor
(index.entities(txn, null, false, k, false, null),
map.headMap(k).values(), false,
expandValues(rangeExpected), vGetter);
/* Head range inclusive. */
rangeExpected = expected.headMap(i + 1);
checkCursor
(index.keys(txn, null, false, k, true, null),
map.headMap(kPlusOne).keySet(), true,
expandKeys(rangeExpected), kGetter);
checkCursor
(index.entities(txn, null, false, k, true, null),
map.headMap(kPlusOne).values(), false,
expandValues(rangeExpected), vGetter);
/* Tail range exclusive. */
rangeExpected = expected.tailMap(i + 1);
checkCursor
(index.keys(txn, k, false, null, false, null),
map.tailMap(kPlusOne).keySet(), true,
expandKeys(rangeExpected), kGetter);
checkCursor
(index.entities(txn, k, false, null, false, null),
map.tailMap(kPlusOne).values(), false,
expandValues(rangeExpected), vGetter);
/* Tail range inclusive. */
rangeExpected = expected.tailMap(i);
checkCursor
(index.keys(txn, k, true, null, false, null),
map.tailMap(k).keySet(), true,
expandKeys(rangeExpected), kGetter);
checkCursor
(index.entities(txn, k, true, null, false, null),
map.tailMap(k).values(), false,
expandValues(rangeExpected), vGetter);
}
开发者ID:nologic,项目名称:nabs,代码行数:58,代码来源:IndexTest.java
示例15: testDeleteFromSubIndex
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
public void testDeleteFromSubIndex()
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 = txnBegin();
MyEntity e = new MyEntity();
e.secKey = 1;
e.priKey = 1;
priIndex.put(txn, e);
e.priKey = 2;
priIndex.put(txn, e);
e.priKey = 3;
priIndex.put(txn, e);
e.priKey = 4;
priIndex.put(txn, e);
txnCommit(txn);
EntityIndex<Integer,MyEntity> subIndex = secIndex.subIndex(1);
txn = txnBeginCursor();
e = subIndex.get(txn, 1, null);
assertEquals(1, e.priKey);
assertEquals(Integer.valueOf(1), e.secKey);
e = subIndex.get(txn, 2, null);
assertEquals(2, e.priKey);
assertEquals(Integer.valueOf(1), e.secKey);
e = subIndex.get(txn, 3, null);
assertEquals(3, e.priKey);
assertEquals(Integer.valueOf(1), e.secKey);
e = subIndex.get(txn, 5, null);
assertNull(e);
boolean deleted = subIndex.delete(txn, 1);
assertTrue(deleted);
assertNull(subIndex.get(txn, 1, null));
assertNotNull(subIndex.get(txn, 2, null));
EntityCursor<MyEntity> cursor = subIndex.entities(txn, null);
boolean saw4 = false;
for (MyEntity e2 = cursor.first(); e2 != null; e2 = cursor.next()) {
if (e2.priKey == 3) {
cursor.delete();
}
if (e2.priKey == 4) {
saw4 = true;
}
}
cursor.close();
assertTrue(saw4);
assertNull(subIndex.get(txn, 1, null));
assertNull(subIndex.get(txn, 3, null));
assertNotNull(subIndex.get(txn, 2, null));
assertNotNull(subIndex.get(txn, 4, null));
txnCommit(txn);
close();
}
开发者ID:nologic,项目名称:nabs,代码行数:64,代码来源:OperationTest.java
示例16: testDeleteFromSubIndex
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
public void testDeleteFromSubIndex()
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 = txnBegin();
MyEntity e = new MyEntity();
e.secKey = 1;
e.priKey = 1;
priIndex.put(txn, e);
e.priKey = 2;
priIndex.put(txn, e);
e.priKey = 3;
priIndex.put(txn, e);
e.priKey = 4;
priIndex.put(txn, e);
txnCommit(txn);
EntityIndex<Integer,MyEntity> subIndex = secIndex.subIndex(1);
txn = txnBeginCursor();
e = subIndex.get(txn, 1, null);
assertEquals(1, e.priKey);
assertEquals(Integer.valueOf(1), e.secKey);
e = subIndex.get(txn, 2, null);
assertEquals(2, e.priKey);
assertEquals(Integer.valueOf(1), e.secKey);
e = subIndex.get(txn, 3, null);
assertEquals(3, e.priKey);
assertEquals(Integer.valueOf(1), e.secKey);
e = subIndex.get(txn, 5, null);
assertNull(e);
boolean deleted = subIndex.delete(txn, 1);
assertTrue(deleted);
assertNull(subIndex.get(txn, 1, null));
assertNotNull(subIndex.get(txn, 2, null));
EntityCursor<MyEntity> cursor = subIndex.entities(txn, null);
boolean saw4 = false;
for (MyEntity e2 = cursor.first(); e2 != null; e2 = cursor.next()) {
if (e2.priKey == 3) {
cursor.delete();
}
if (e2.priKey == 4) {
saw4 = true;
}
}
cursor.close();
assertTrue(saw4);
assertNull(subIndex.get(txn, 1, null));
assertNull(subIndex.get(txn, 3, null));
assertNotNull(subIndex.get(txn, 2, null));
assertNotNull(subIndex.get(txn, 4, null));
txnCommit(txn);
close();
}
开发者ID:nologic,项目名称:nabs,代码行数:64,代码来源:OperationTest.java
示例17: deleteLegoList
import com.sleepycat.persist.EntityIndex; //导入依赖的package包/类
@Override
public void deleteLegoList(String legoListUUID) throws WriteException
{
Transaction txn = null;
try
{
LegoListBDB legoListBDB = legoListByUUID.get(legoListUUID);
if (legoListBDB != null)
{
txn = myEnv.beginTransaction(null, null);
// legoList doesn't store the actual legos.
for (String legoUniqueIdToDelete : legoListBDB.getUniqueLegoIds())
{
LegoBDB legoBDBToDelete = legoByUniqueId.get(txn, legoUniqueIdToDelete, LockMode.READ_UNCOMMITTED);
// Lego doesn't store stamp, or pncs so delete them seperately
if (legoBDBToDelete != null)
{
stampByUniqueId.delete(txn, legoBDBToDelete.getStampId());
// pncs IDs might be in use by others. Only delete if not.
boolean inUse = false;
EntityCursor<LegoBDB> ec = null;
try
{
EntityIndex<String, LegoBDB> ei = legoByPncsId.subIndex(legoBDBToDelete.getPncsId());
ec = ei.entities(txn, CursorConfig.READ_UNCOMMITTED);
for (LegoBDB current = ec.first(); current != null; current = ec.nextNoDup())
{
if (!current.getUniqueId().equals(legoUniqueIdToDelete))
{
inUse = true;
break;
}
}
}
finally
{
ec.close();
}
if (!inUse)
{
pncsByUniqueId.delete(txn, legoBDBToDelete.getPncsId());
}
}
// one could check to see if the assertions from this LegoList are being used within another LegoList - but delete really isn't
// intended to be used much in practice, so user beware.
legoByUniqueId.delete(txn, legoUniqueIdToDelete);
}
// Finally, delete the legoList
legoListByUUID.delete(txn, legoListUUID);
txn.commit();
}
}
catch (DatabaseException e)
{
logger.error("Unexpected error storing data", e);
if (txn != null)
{
try
{
txn.abort();
}
catch (DatabaseException ex)
{
logger.error("Unxpected error during abort", ex);
}
}
throw new WriteException("Unexpected error during delete - Delete was not completed.", e);
}
}
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:77,代码来源:BDBDataStoreImpl.java
注:本文中的com.sleepycat.persist.EntityIndex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论