@@ -128,23 +128,23 @@ public abstract class Paged implements AutoCloseable {
128
128
129
129
protected static int PAGE_SIZE = 4096 ;
130
130
131
+ protected final short fileVersion ;
132
+ private final FileHeader fileHeader ;
133
+ private final byte [] tempPageData ;
134
+ private final byte [] tempHeaderData ;
135
+
131
136
private RandomAccessFile raf ;
132
137
private Path file ;
133
- private final FileHeader fileHeader ;
134
138
private boolean readOnly = false ;
135
139
private boolean fileIsNew = false ;
136
-
137
- private final byte [] tempPageData ;
138
- private final byte [] tempHeaderData ;
139
140
140
- public Paged (final BrokerPool pool ) {
141
+ public Paged (final BrokerPool pool , final short fileVersion ) {
142
+ this .fileVersion = fileVersion ;
141
143
this .fileHeader = createFileHeader (pool .getPageSize ());
142
144
this .tempPageData = new byte [fileHeader .pageSize ];
143
145
this .tempHeaderData = new byte [fileHeader .pageHeaderSize ];
144
146
}
145
147
146
- public abstract short getFileVersion ();
147
-
148
148
public final static void setPageSize (final int pageSize ) {
149
149
PAGE_SIZE = pageSize ;
150
150
}
@@ -551,7 +551,7 @@ protected final void writeValue(final long page, final Value value) throws IOExc
551
551
* @author Wolfgang Meier <[email protected] >
552
552
*/
553
553
public abstract class FileHeader {
554
- private short versionId ;
554
+ private short version ;
555
555
556
556
private boolean dirty = false ;
557
557
private long firstFreePage = Page .NO_PAGE ;
@@ -573,7 +573,7 @@ public FileHeader(final long pageCount, final int pageSize) {
573
573
this .pageCount = pageCount ;
574
574
this .totalCount = pageCount ;
575
575
this .headerSize = (short ) pageSize ;
576
- this .versionId = getFileVersion () ;
576
+ this .version = fileVersion ;
577
577
this .buf = new byte [headerSize ];
578
578
calculateWorkSize ();
579
579
}
@@ -681,7 +681,7 @@ public final int getWorkSize() {
681
681
}
682
682
683
683
public final short getVersion () {
684
- return versionId ;
684
+ return version ;
685
685
}
686
686
687
687
/**
@@ -710,7 +710,7 @@ public final synchronized void read() throws IOException {
710
710
}
711
711
712
712
public int read (final byte [] buf ) throws IOException {
713
- versionId = ByteConversion .byteToShort (buf , OFFSET_VERSION_ID );
713
+ version = ByteConversion .byteToShort (buf , OFFSET_VERSION_ID );
714
714
headerSize = ByteConversion .byteToShort (buf , OFFSET_HEADER_SIZE );
715
715
pageSize = ByteConversion .byteToInt (buf , OFFSET_PAGE_SIZE );
716
716
pageCount = ByteConversion .byteToLong (buf , OFFSET_PAGE_COUNT );
@@ -724,7 +724,7 @@ public int read(final byte[] buf) throws IOException {
724
724
}
725
725
726
726
public int write (final byte [] buf ) throws IOException {
727
- ByteConversion .shortToByte (versionId , buf , OFFSET_VERSION_ID );
727
+ ByteConversion .shortToByte (version , buf , OFFSET_VERSION_ID );
728
728
ByteConversion .shortToByte (headerSize , buf , OFFSET_HEADER_SIZE );
729
729
ByteConversion .intToByte (pageSize , buf , OFFSET_PAGE_SIZE );
730
730
ByteConversion .longToByte (pageCount , buf , OFFSET_PAGE_COUNT );
0 commit comments