Skip to content

Commit 433790d

Browse files
committed
fixup! WIP Refactoring and cleanup of BTree storage classes
1 parent 686fb5a commit 433790d

34 files changed

Lines changed: 2101 additions & 2834 deletions

exist-core/src/main/java/org/exist/storage/NativeValueIndex.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ public class NativeValueIndex implements ContentLoadingObserver {
153153
* A collection of key-value pairs that pending modifications for this value index.
154154
* The keys are {@link org.exist.xquery.value.AtomicValue atomic values}
155155
* that implement {@link Indexable Indexable}.
156-
* The values are {@link org.exist.util.LongLinkedList lists} containing the nodes GIDs
157-
* (global identifiers).
156+
* The values are lists containing the nodes GIDs (global identifiers).
158157
*/
159158
private final PendingChanges<AtomicValue> pendingGeneric = new PendingChanges<>(IndexType.GENERIC);
160159
private final PendingChanges<QNameKey> pendingQName = new PendingChanges<>(IndexType.QNAME);

exist-core/src/main/java/org/exist/storage/btree/AbstractBTree.java

Lines changed: 104 additions & 156 deletions
Large diffs are not rendered by default.

exist-core/src/main/java/org/exist/storage/btree/AbstractPageHeader.java

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@
8181
*/
8282
package org.exist.storage.btree;
8383

84+
import org.exist.storage.btree.AbstractPagedFile.Page;
8485
import org.exist.storage.journal.Lsn;
8586
import org.exist.util.ByteConversion;
8687

87-
import java.io.IOException;
88-
8988
/**
9089
* Base class for page headers.
9190
*
@@ -94,28 +93,20 @@
9493
*/
9594
public abstract class AbstractPageHeader implements PageHeader {
9695

97-
public static final int LENGTH_PAGE_STATUS = 1; //sizeof byte
96+
public static final int LENGTH_PAGE_TYPE = 1; //sizeof byte
9897
public static final int LENGTH_PAGE_DATA_LENGTH = 4; //sizeof int
9998
public static final int LENGTH_PAGE_NEXT_PAGE = 8; //sizeof long
10099
public static final int LENGTH_PAGE_LSN = Lsn.RAW_LENGTH;
101100

102-
private int dataLen = 0;
103-
private long nextPage = Page.NO_PAGE;
104-
private boolean dirty = false;
105-
106101
/**
107102
* The status of the current page.
108103
*/
109-
private PageStatus status = PageStatus.UNUSED;
110-
104+
private PageType type = PageType.UNUSED;
105+
private int dataLen = 0;
106+
private long nextPage = Page.NO_PAGE;
111107
private Lsn lsn = Lsn.LSN_INVALID;
112108

113-
public AbstractPageHeader() {
114-
}
115-
116-
public AbstractPageHeader(final byte[] data, final int offset) throws IOException {
117-
read(data, offset);
118-
}
109+
private boolean dirty = false;
119110

120111
@Override
121112
public int getDataLen() {
@@ -150,13 +141,13 @@ public void setDirty(final boolean dirty) {
150141
}
151142

152143
@Override
153-
public PageStatus getStatus() {
154-
return this.status;
144+
public PageType getType() {
145+
return this.type;
155146
}
156147

157148
@Override
158-
public void updateStatus(final PageStatus newStatus) {
159-
this.status = newStatus;
149+
public void updateType(final PageType newType) {
150+
this.type = newType;
160151
setDirty(true);
161152
}
162153

@@ -170,14 +161,15 @@ public void setLsn(final Lsn lsn) {
170161
this.lsn = lsn;
171162
}
172163

173-
public int read(final byte[] data, int offset) throws IOException {
174-
status = PageStatus.fromValue(data[offset]);
175-
offset += LENGTH_PAGE_STATUS;
176-
dataLen = ByteConversion.byteToInt(data, offset);
164+
@Override
165+
public int read(final byte[] data, int offset) {
166+
this.type = PageType.fromValue(data[offset]);
167+
offset += LENGTH_PAGE_TYPE;
168+
this.dataLen = ByteConversion.byteToInt(data, offset);
177169
offset += LENGTH_PAGE_DATA_LENGTH;
178-
nextPage = ByteConversion.byteToLong(data, offset);
170+
this.nextPage = ByteConversion.byteToLong(data, offset);
179171
offset += LENGTH_PAGE_NEXT_PAGE;
180-
lsn = Lsn.read(data, offset);
172+
this.lsn = Lsn.read(data, offset);
181173
offset += LENGTH_PAGE_LSN;
182174

183175
// TODO(AR) should we mark this an non-dirty?
@@ -186,9 +178,10 @@ public int read(final byte[] data, int offset) throws IOException {
186178
return offset;
187179
}
188180

189-
public int write(final byte[] data, int offset) throws IOException {
190-
data[offset] = status.getValue();
191-
offset += LENGTH_PAGE_STATUS;
181+
@Override
182+
public int write(final byte[] data, int offset) {
183+
data[offset] = type.getValue();
184+
offset += LENGTH_PAGE_TYPE;
192185
ByteConversion.intToByte(dataLen, data, offset);
193186
offset += LENGTH_PAGE_DATA_LENGTH;
194187
ByteConversion.longToByte(nextPage, data, offset);

0 commit comments

Comments
 (0)