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

Class Stores

basex-core/src/main/java/org/basex/core/Stores.java:26–433  ·  view source on GitHub ↗

This class provides access to main-memory key/value stores. @author BaseX Team, BSD License @author Christian Gruen

Source from the content-addressed store, hash-verified

24 * @author Christian Gruen
25 */
26public final class Stores implements Closeable {
27 /** Name of store files. */
28 private static final String NAME = "store";
29
30 /** Stores. */
31 private final HashMap<String, Store> stores = new HashMap<>();
32 /** Database context. */
33 private final Context context;
34
35 /**
36 * Constructor.
37 * @param context database context
38 */
39 public Stores(final Context context) {
40 this.context = context;
41 }
42
43 /**
44 * Returns all keys.
45 * @param name name of store
46 * @param info input info
47 * @param qc query context
48 * @return keys
49 * @throws QueryException query exception
50 */
51 public synchronized Value keys(final String name, final InputInfo info, final QueryContext qc)
52 throws QueryException {
53 final Store store = get(name, false, info, qc);
54 if(store != null) {
55 final TokenList list = new TokenList(store.map.size());
56 for(final String key : store.map.keySet()) list.add(key);
57 return StrSeq.get(list);
58 }
59 return Empty.VALUE;
60 }
61
62 /**
63 * Returns a value.
64 * @param key key
65 * @param name name of store
66 * @param info input info
67 * @param qc query context
68 * @return value or empty sequence
69 * @throws QueryException query exception
70 */
71 public synchronized Value get(final String key, final String name, final InputInfo info,
72 final QueryContext qc) throws QueryException {
73 final Store store = get(name, false, info, qc);
74 if(store != null) {
75 final Value value = store.map.get(key);
76 if(value != null) return value;
77 }
78 return Empty.VALUE;
79 }
80
81 /**
82 * Stores a value.
83 * @param key key

Callers

nothing calls this directly

Calls 3

stackMethod · 0.95
notExpectedMethod · 0.95
putMethod · 0.45

Tested by

no test coverage detected