Changes

Jump to navigation Jump to search
4,614 bytes added ,  00:52, 13 December 2020
Added information regarding pth.basex and idp.basex
==Data Types==* <code>Num</code>: compressed integer* <code>Token</code>: length (<code>Num</code>) and bytes This article is part of UTF8 byte representationthe [[Advanced User's Guide]]. It presents some low-level details on how data is stored in the database files.
=Data Types=inf The following data types are used for specifying the storage layout: {| class="wikitable" width="100%"|-! Type! Description! Example (native → hex integers)|-| {{Type|Num}}| Compressed integer (1-5 bytes), specified in [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/util/Num.java Num.java]| {{Code|15}} → {{Code|0F}}; {{Code|511}} → {{Code|41 FF}}<br/>|-| {{Type|Token}}| Length ({{Type|Num}}) and bytes of UTF8 byte representation| {{Code|Hello}} → {{Code|05 48 65 6c 6c 6f}}|-| {{Type|Double}}| Number, stored as token| {{Code|123}} → {{Code|03 31 32 33}}|-| {{Type|Boolean}}| Boolean (1 byte, {{Code|00}} or {{Code|01}})| {{Code|true}} → {{Code|01}}|-| {{Type|Nums}}, {{Type|Tokens}}, {{Type|Doubles}}| Arrays of values, introduced with the number of entries| {{Code|1,2}} → {{Code|02 01 31 01 32}}|-| {{Type|TokenSet}}| Key array ({{Type|Tokens}}), next/bucket/size arrays (3x {{Type|Nums}})||} =Database Files= The following tables illustrate the layout of the BaseX database files. All files are suffixed with {{Code|.basex}}. ==Meta Data, Name/Path/Doc Indexes: {{Code|inf}}==
{| class="wikitable" width="100%"
! Method
|-
| valign='top' | '''Disk 1. Meta Data'''| Database meta information1. Key/value pairs, in no particular order ({{Type|Token}}/{{Type|Token}}):<br/>&nbsp; &bull; Examples: {{Code|FNAME}}, {{Code|TIME}}, {{Code|SIZE}}, ...<br />&nbsp; &bull; {{Code|PERM}} → Number of users ({{Type|Num}}), and name/password/permission values for each user ({{Type|Token}}/{{Type|Token}}/{{Type|Num}})<br/>2. Empty key as finalizer| [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/data/DiskData.java DiskData()]<br/>[https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/data/MetaData.java MetaData()]<br/>[https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/core/Users.java Users()]|-| valign='top' '2. Main memory indexes'''| 1. Key/value pairs, in no particular order ({{Type|Token}}/{{Type|Token}}):<br />&nbsp; &bull; {{Code|TAGS}} → Element Name Index<br />&nbsp; &bull; {{Code|ATTS}} → Attribute Name Index<br />&nbsp; &bull; {{Code|PATH}} → Path Index<br />&nbsp; &bull; {{Code|NS}} → Namespaces<br />&nbsp; &bull; {{Code|DOCS}} → Document Index<br/>2. Empty key as finalizer| [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/data/DiskData.java DiskData()]|-| '''2 a) Name Index'''<br/>Element/attribute names| 1. Token set, storing all names ({{Type|TokenSet}})<br />2. One StatsKey instance per entry:<br/>2.1. Content kind ({{Type|Num}}):<br />2.1.1. Number: min/max ({{Type|Doubles}})<br />2.1.2. Category: number of entries ({{Type|Num}}), entries ({{Type|Tokens}})<br />2.2. Number of entries ({{Type|Num}})<br />2.3. Leaf flag ({{Type|Boolean}})<br />2.4. Maximum text length ({{Type|Double}}; legacy, could be {{Type|Num}})| [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/index/Names.java Names()]<br/>[https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/util/hash/TokenSet.java TokenSet.read()]<br/>[https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/index/StatsKey.java StatsKey()]
|-
| valign='top' | '2 b) Path Index'''| 1. Meta Data'''Flag for path definition ({{Type|Boolean}}, always {{Code| Pairs of keytrue}}; legacy)<br/value tokens, suffixed by empty key>2. PathNode:<br />&bull; 2.1. Name reference ({{Type|Num}})<br/>2.2. Node kind ({{Type|Num}})<br/>2.3. Number of occurrences ({{Type|Num}})<codebr/>PERM2.4. Number of children ({{Type|Num}})<br/code> 2.5. {{Type|Double}}; legacy, can be reused or discarded<br/>2.6. Recursive generation of child nodes (User Permissions2)| valign='top' | [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/dataindex/MetaDatapath/PathSummary.java MetaData.readPathSummary()]<br/>[https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/coreindex/path/UsersPathNode.java Users.readPathNode()]
|-
| valign='top' | '''2. Main memory indexesc) Namespaces'''| Pairs of key/value tokens1. Token set, suffixed by empty key:storing prefixes ({{Type|TokenSet}})<br />&bull; 2. Token set, storing URIs ({{Type|TokenSet}})<codebr/>TAGS3. NSNode:<br/code> → Tag Index3.1. pre value ({{Type|Num}})<br />&bull; <code>ATTS<3.2. References to prefix/code> → Attribute IndexURI pairs ({{Type|Nums}})<br />&bull; <code>PATH3.3. Number of children ({{Type|Num}})<br/code> 3.4. Recursive generation of child nodes (Path Index<br 3)| [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/>&bull; <code>NS<data/code> → Namespaces.java Namespaces()]<br />&bull; <code>DOCS</code> → Document Index| valign='top' | [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/data/DiskDataNSNode.java DiskDataNSNode()]
|-
| valign='top' | '''2.1. Name d) Document Index''' (Element/attribute Names)| Token setArray of integers, enrichted with statistical information:<br />1. Token set: key array representing the distances between all document pre values (<code>Tokens</code>), next/bucket/size arrays (<code>{{Type|Nums</code>)<br />2. Content kind (<code>Num</code>)<br />2.1 Number: min/max (<code>Doubles</code>)<br />2.2. Category: number of entries (<code>Num</code>), entries (<code>Tokens</code>)<br />2.3 Number of entries (<code>Num</code>)<br />2.4 Leaf flag (<code>Boolean</code>)<br />2.5 Maximum text length (<code>Double</code>; should be <code>Num</code>}})| valign='top' | [https://github.com/BaseXdb/basex/blob/master/src/main/java/org/basex/index/Names.java Names()]<br/>[https://github.com/BaseXdb/basex/blob/master/src/main/java/org/basex/util/hash/TokenSet.java TokenSet()]<br/>[https://github.com/BaseXdb/basex/blob/master-core/src/main/java/org/basex/index/StatsKeyDocIndex.java StatsKeyDocIndex()]
|}
 
==Node Table: {{Code|tbl}}, {{Code|tbli}}==
 
* {{Code|tbl}}: Main database table, stored in blocks.
* {{Code|tbli}}: Database directory, organizing the database blocks.
 
Some more information on the [[Node Storage|node storage]] is available.
 
==Texts: {{Code|txt}}, {{Code|atv}}==
 
* {{Code|txt}}: Heap file for text values (document names, string values of texts, comments and processing instructions)
* {{Code|atv}}: Heap file for attribute values.
 
==Value Indexes: {{Code|txtl}}, {{Code|txtr}}, {{Code|atvl}}, {{Code|atvr}}==
 
'''Text Index:'''
* {{Code|txtl}}: Heap file with ID lists.
* {{Code|txtr}}: Index file with references to ID lists.
The '''Attribute Index''' is contained in the files {{Code|atvl}} and {{Code|atvr}}, the '''Token Index''' in {{Code|tokl}} and {{Code|tokr}}. All have the same layout.
 
For a more detailed discussion and examples of these file formats please see [[Index File Structure]].
 
==Document Path Index: {{Code|pth}}==
 
Provides an index of all the document paths in the database. For databases with a large number of paths this file can be quite large so it is only generated the first time a function requesting a path lookup is run. For databases where path lookups are never used this file will not exist.
 
'''Note:''' On Windows/Mac systems this file is case insensitive (all paths are lower case). On UNIX-like systems this file is case sensitive. The behaviour of path look ups will vary between systems. Copying this file between system types may lead to unexpected behaviour.
 
==ID/Pre Mapping: {{Code|idp}}==
 
This file is only created if incremental indexing (UPDINDEX) is enabled for a database. It is used to provide a quick look up of the pre value for a database node id.
 
==Full-Text Fuzzy Index: {{Code|ftxx}}, {{Code|ftxy}}, {{Code|ftxz}}==
 
...may soon be reimplemented.
administrator, editor
33

edits

Navigation menu