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

Class DiskValues

basex-core/src/main/java/org/basex/index/value/DiskValues.java:27–477  ·  view source on GitHub ↗

This class provides access to attribute values and text contents stored on disk. The data structure is described in the DiskValuesBuilder class. @author BaseX Team, BSD License @author Christian Gruen

Source from the content-addressed store, hash-verified

25 * @author Christian Gruen
26 */
27public class DiskValues extends ValueIndex {
28 /** ID references. */
29 final DataAccess idxr;
30 /** ID lists. */
31 final DataAccess idxl;
32 /** Cached index entries: mapping between keys and index entries. */
33 final IndexCache cache = new IndexCache();
34 /** Cached texts: mapping between key positions in the reference file, and the indexed texts. */
35 final IntObjectMap<byte[]> ctext = new IntObjectMap<>();
36 /** Number of current index entries. */
37 final AtomicInteger size = new AtomicInteger();
38
39 /** Synchronization object. */
40 private final Object monitor = new Object();
41
42 /**
43 * Constructor, initializing the index structure.
44 * @param data data reference
45 * @param type index type
46 * @throws IOException I/O Exception
47 */
48 public DiskValues(final Data data, final IndexType type) throws IOException {
49 this(data, type, fileSuffix(type));
50 }
51
52 /**
53 * Constructor, initializing the index structure.
54 * @param data data reference
55 * @param type index type
56 * @param prefix file prefix
57 * @throws IOException I/O Exception
58 */
59 DiskValues(final Data data, final IndexType type, final String prefix) throws IOException {
60 super(data, type);
61 idxl = new DataAccess(data.meta.dbFile(prefix + 'l'));
62 idxr = new DataAccess(data.meta.dbFile(prefix + 'r'));
63 size.set(idxl.read4());
64 }
65
66 @Override
67 public final byte[] info(final MainOptions options) {
68 final TokenBuilder tb = new TokenBuilder();
69 tb.add(LI_STRUCTURE).add(SORTED_LIST).add(NL);
70 tb.add(LI_NAMES).add(data.meta.names(type)).add(NL);
71
72 final IndexStats stats = new IndexStats(options.get(MainOptions.MAXSTAT));
73 synchronized(monitor) {
74 final long l = idxl.length() + idxr.length();
75 tb.add(LI_SIZE).add(Performance.formatHuman(l)).add(NL);
76 final int entries = size();
77 for(int index = 0; index < entries; index++) {
78 final long pos = idxr.read5(index * 5L);
79 final int count = idxl.readNum(pos);
80 if(stats.adding(count)) stats.add(key(idxl.readNum()), count);
81 }
82 }
83 stats.print(tb);
84 return tb.finish();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected