summaryrefslogtreecommitdiff
blob: f99584fdff1de5022eeb4f5c71f811527934a9c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
diff -urpN src.orig/db/com/cdegroot/db/hash/EntryPage.java src/db/com/cdegroot/db/hash/EntryPage.java
--- a/src/db/com/cdegroot/db/hash/EntryPage.java	2005-02-06 00:40:17.191151504 +0100
+++ b/src/db/com/cdegroot/db/hash/EntryPage.java	2005-02-06 00:54:14.045930240 +0100
@@ -25,7 +25,7 @@ final class EntryPage extends PageHeader
     /**
      *  Constructs a page view from the indicated block.
      */
-    EntryPage(BlockIo block) {
+    public EntryPage(BlockIo block) {
 	super(block);
     }
 
@@ -33,7 +33,7 @@ final class EntryPage extends PageHeader
      *  Factory method to create or return a data page for the
      *  indicated block.
      */
-    static EntryPage getEntryPageView(BlockIo block) {
+    public static EntryPage getEntryPageView(BlockIo block) {
 	BlockView view = block.getView();
 	if (view != null && view instanceof EntryPage)
 	    return (EntryPage) view;
diff -urpN src.orig/db/com/cdegroot/db/recman/BlockIo.java src/db/com/cdegroot/db/recman/BlockIo.java
--- a/src/db/com/cdegroot/db/recman/BlockIo.java	2005-02-06 00:40:17.192151352 +0100
+++ b/src/db/com/cdegroot/db/recman/BlockIo.java	2005-02-06 00:58:02.990125432 +0100
@@ -31,7 +31,7 @@ package com.cdegroot.db.recman;
  *  @see java.io.DataInput
  *  @see java.io.DataOutput
  */
-final class BlockIo implements java.io.Serializable {
+final public class BlockIo implements java.io.Serializable {
     private long blockId;
     private final byte[] snapshot; // committed snapshot.
     private boolean snapshotValid = false;
@@ -44,7 +44,7 @@ final class BlockIo implements java.io.S
      *  Constructs a new BlockIo instance working on the indicated
      *  buffer.
      */
-    BlockIo(long blockId, byte[] data) {
+    public BlockIo(long blockId, byte[] data) {
 	// removeme for production version
 	if (blockId > 10000000000L)
 	    throw new Error("bogus block id " + blockId);
@@ -108,7 +108,7 @@ final class BlockIo implements java.io.S
     /**
      *  Returns the current view of the block.
      */
-    BlockView getView() {
+    public BlockView getView() {
 	return view;
     }
 
@@ -172,17 +172,25 @@ final class BlockIo implements java.io.S
     /**
      *  Reads a short from the indicated position
      */
-    short readShort(int pos) {
+    public short readShort(int pos) {
 	return (short)
 	    (((short) (data[pos+0] & 0xff) << 8) | 
 	     ((short) (data[pos+1] & 0xff) << 0));
 	
     }
+   
+    public byte readByte(int pos) {
+	return data[pos];
+    }
+
+    public void writeByte(int pos, byte value)
+    {	data[pos] = value;
+    }
     
     /**
      *  Writes a short to the indicated position
      */
-    void writeShort(int pos, short value) {
+    public void writeShort(int pos, short value) {
 	data[pos+0] = (byte)(0xff & (value >> 8));
 	data[pos+1] = (byte)(0xff & (value >> 0));
 	setDirty();
@@ -191,7 +199,7 @@ final class BlockIo implements java.io.S
     /**
      *  Reads an int from the indicated position
      */
-    int readInt(int pos) {
+    public int readInt(int pos) {
 	return
 	    (((int)(data[pos+0] & 0xff) << 24) |
 	     ((int)(data[pos+1] & 0xff) << 16) |
@@ -202,7 +210,7 @@ final class BlockIo implements java.io.S
     /**
      *  Writes an int to the indicated position
      */
-    void writeInt(int pos, int value) {
+    public void writeInt(int pos, int value) {
 	data[pos+0] = (byte)(0xff & (value >> 24));
 	data[pos+1] = (byte)(0xff & (value >> 16));
 	data[pos+2] = (byte)(0xff & (value >>  8));
@@ -213,7 +221,7 @@ final class BlockIo implements java.io.S
     /**
      *  Reads a long from the indicated position
      */
-    long readLong(int pos) {
+    public long readLong(int pos) {
 	return
 	    (((long)(data[pos+0] & 0xff) << 56) |
 	     ((long)(data[pos+1] & 0xff) << 48) |
@@ -228,7 +236,7 @@ final class BlockIo implements java.io.S
     /**
      *  Writes a long to the indicated position
      */
-    void writeLong(int pos, long value) {
+    public void writeLong(int pos, long value) {
 	data[pos+0] = (byte)(0xff & (value >> 56));
 	data[pos+1] = (byte)(0xff & (value >> 48));
 	data[pos+2] = (byte)(0xff & (value >> 40));
diff -urpN src.orig/db/com/cdegroot/db/recman/BlockView.java src/db/com/cdegroot/db/recman/BlockView.java
--- a/src/db/com/cdegroot/db/recman/BlockView.java	2005-02-06 00:40:17.193151200 +0100
+++ b/src/db/com/cdegroot/db/recman/BlockView.java	2005-02-06 00:47:57.632153832 +0100
@@ -28,5 +28,5 @@ package com.cdegroot.db.recman;
  *
  *  @see BlockIo.setView()
  */
-interface BlockView {
+public interface BlockView {
 }
diff -urpN src.orig/db/com/cdegroot/db/recman/Magic.java src/db/com/cdegroot/db/recman/Magic.java
--- a/src/db/com/cdegroot/db/recman/Magic.java	2005-02-06 00:40:17.193151200 +0100
+++ b/src/db/com/cdegroot/db/recman/Magic.java	2005-02-06 00:44:22.164909832 +0100
@@ -25,7 +25,7 @@ package com.cdegroot.db.recman;
 /**
  *  This interface contains magic cookies.
  */
-interface Magic {
+public interface Magic {
     /** Magic cookie at start of file */
     short FILE_HEADER = 0x1350;
   
@@ -57,4 +57,6 @@ interface Magic {
     int SZ_INT = 4;
     /** Size of an externalized long */
     int SZ_LONG = 8;
+    /** Size of byte */
+    int SZ_BYTE = 1;
 }
diff -urpN src.orig/db/com/cdegroot/db/recman/PageHeader.java src/db/com/cdegroot/db/recman/PageHeader.java
--- a/src/db/com/cdegroot/db/recman/PageHeader.java	2005-02-06 00:40:17.193151200 +0100
+++ b/src/db/com/cdegroot/db/recman/PageHeader.java	2005-02-06 00:50:10.236994832 +0100
@@ -28,15 +28,15 @@ import java.io.*;
  *  This class represents a page header. It is the common superclass for
  *  all different page views.
  */
-class PageHeader implements BlockView {
+public class PageHeader implements BlockView {
     // offsets
     private static final short O_MAGIC = 0; // short magic
     private static final short O_NEXT = Magic.SZ_SHORT;  // long next
     private static final short O_PREV = O_NEXT + Magic.SZ_LONG; // long prev
-    static final int SIZE = O_PREV + Magic.SZ_LONG;
+    public static final int SIZE = O_PREV + Magic.SZ_LONG;
     
     // my block
-    BlockIo block;
+    public BlockIo block;
     
     /**
      *  Constructs a PageHeader object from a block
@@ -45,7 +45,7 @@ class PageHeader implements BlockView {
      *  @throws IOException if the block is too short to keep the file
      *          header.
      */
-    PageHeader(BlockIo block) {
+    public PageHeader(BlockIo block) {
 	initialize(block);
 	if (!magicOk()) 
 	    throw new Error("CRITICAL: page header magic for block " 
@@ -66,7 +66,7 @@ class PageHeader implements BlockView {
      *  Factory method to create or return a page header for the
      *  indicated block.
      */
-    static PageHeader getView(BlockIo block) {
+    public static PageHeader getView(BlockIo block) {
 	BlockView view = block.getView();
 	if (view != null && view instanceof PageHeader)
 	    return (PageHeader) view;
diff -urpN src.orig/db/com/cdegroot/db/recman/RecordFile.java src/db/com/cdegroot/db/recman/RecordFile.java
--- a/src/db/com/cdegroot/db/recman/RecordFile.java	2005-02-06 00:40:17.193151200 +0100
+++ b/src/db/com/cdegroot/db/recman/RecordFile.java	2005-02-06 00:45:38.616287456 +0100
@@ -33,7 +33,7 @@ import java.util.*;
  *  The set of dirty records on the in-use list constitutes a transaction. 
  *  Later on, we will send these records to some recovery thingy.
  */
-final class RecordFile {
+final public class RecordFile {
     private final TransactionManager txnMgr;
 
     // Todo: reorganize in hashes and fifos as necessary.
@@ -48,7 +48,7 @@ final class RecordFile {
     private boolean transactionsDisabled = false;
 
     /** The length of a single block. */
-    final static int BLOCK_SIZE = 8192;//4096;
+    final public static int BLOCK_SIZE = 8192;//4096;
 
     /** The extension of a record file */
     final static String extension = ".db";