MCPcopy Create free account
hub / github.com/BaseXdb/basex / get

Method get

basex-core/src/main/java/org/basex/index/IndexCache.java:29–45  ·  view source on GitHub ↗

Gets cached entry for the specified key. @param key key @return cached entry or null if the entry is stale

(final byte[] key)

Source from the content-addressed store, hash-verified

27 * @return cached entry or {@code null} if the entry is stale
28 */
29 public IndexEntry get(final byte[] key) {
30 final int hash = Token.hashCode(key);
31 rwl.readLock().lock();
32
33 try {
34 final int i = indexFor(hash, buckets.length);
35 BucketEntry e = buckets[i];
36 while(e != null) {
37 final IndexEntry entry = e.get();
38 if(entry != null && e.hash == hash && Token.eq(entry.key, key)) return entry;
39 e = e.next;
40 }
41 } finally {
42 rwl.readLock().unlock();
43 }
44 return null;
45 }
46
47 /**
48 * Adds a new cache entry. If an entry with the specified key already exists,

Callers

nothing calls this directly

Calls 6

hashCodeMethod · 0.95
indexForMethod · 0.95
eqMethod · 0.95
readLockMethod · 0.80
getMethod · 0.65
lockMethod · 0.45

Tested by

no test coverage detected