本文整理汇总了Java中com.sleepycat.persist.EntityIndex类的典型用法代码示例。如果您正苦于以下问题:Java EntityIndex类的具体用法?Java EntityIndex怎么用?Java EntityIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityIndex类属于com.sleepycat.persist包,在下文中一共展示了EntityIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}