import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
import java.util.TimeZone;
import java.util.regex.Matcher;
* Only used by unit tests
*/
Column(boolean testing) {
+ if(!testing) {
+ throw new IllegalArgumentException();
+ }
_format = JetFormat.VERSION_4;
_pageChannel = new PageChannel(testing);
}
if (_type == DataType.BOOLEAN) {
throw new IOException("Tried to read a boolean from data instead of null mask.");
} else if (_type == DataType.BYTE) {
- return new Byte(buffer.get());
+ return Byte.valueOf(buffer.get());
} else if (_type == DataType.INT) {
- return new Short(buffer.getShort());
+ return Short.valueOf(buffer.getShort());
} else if (_type == DataType.LONG) {
- return new Integer(buffer.getInt());
+ return Integer.valueOf(buffer.getInt());
} else if (_type == DataType.DOUBLE) {
- return new Double(buffer.getDouble());
+ return Double.valueOf(buffer.getDouble());
} else if (_type == DataType.FLOAT) {
- return new Float(buffer.getFloat());
+ return Float.valueOf(buffer.getFloat());
} else if (_type == DataType.SHORT_DATE_TIME) {
return readDateValue(buffer);
} else if (_type == DataType.BINARY) {
_format);
//Add this table to our internal list.
- addTable(name, new Integer(tdefPageNumber));
+ addTable(name, Integer.valueOf(tdefPageNumber));
//Add this table to system tables
addToSystemCatalog(name, tdefPageNumber);
for (iter = _systemCatalog.getColumns().iterator(); iter.hasNext(); idx++) {
Column col = (Column) iter.next();
if (COL_ID.equals(col.getName())) {
- catalogRow[idx] = new Integer(pageNumber);
+ catalogRow[idx] = Integer.valueOf(pageNumber);
} else if (COL_NAME.equals(col.getName())) {
catalogRow[idx] = name;
} else if (COL_TYPE.equals(col.getName())) {
} else if (COL_PARENT_ID.equals(col.getName())) {
catalogRow[idx] = _tableParentId;
} else if (COL_FLAGS.equals(col.getName())) {
- catalogRow[idx] = new Integer(0);
+ catalogRow[idx] = Integer.valueOf(0);
} else if (COL_OWNER.equals(col.getName())) {
byte[] owner = new byte[2];
catalogRow[idx] = owner;
} else if (col.getName().equals(COL_F_INHERITABLE)) {
aceRow[idx] = Boolean.FALSE;
} else if (col.getName().equals(COL_OBJECT_ID)) {
- aceRow[idx] = new Integer(pageNumber);
+ aceRow[idx] = Integer.valueOf(pageNumber);
} else if (col.getName().equals(COL_SID)) {
aceRow[idx] = SID;
}
private static final short COLUMN_UNUSED = -1;
- private static final int NEW_ENTRY_COLUMN_INDEX = -1;
-
- private static final byte REVERSE_ORDER_FLAG = (byte)0x01;
-
private static final byte INDEX_NODE_PAGE_TYPE = (byte)0x03;
private static final byte INDEX_LEAF_PAGE_TYPE = (byte)0x04;
_rowCount = rowCount;
}
+ public int getRowCount() {
+ return _rowCount;
+ }
+
/**
* Note, there may still be some issues around the name of an index, this
* information may not be correct. I've done a variety of testing comparing
{
for (int i = 0; i < MAX_COLUMNS; i++) {
short columnNumber = tableBuffer.getShort();
- Byte flags = new Byte(tableBuffer.get());
+ Byte flags = Byte.valueOf(tableBuffer.get());
if (columnNumber != COLUMN_UNUSED) {
_columns.put(availableColumns.get(columnNumber), flags);
}
int length = i * 8 + j - lastStart;
indexPage.position(entryPos + lastStart);
if(isLeaf) {
- entries.add(new Entry(indexPage, length, valuePrefix));
+ entries.add(new Entry(indexPage, valuePrefix));
} else {
- nodeEntries.add(new NodeEntry(indexPage, length, valuePrefix));
+ nodeEntries.add(new NodeEntry(indexPage, valuePrefix));
}
// read any shared "compressed" bytes
(col.getType() == DataType.MEMO));
}
- private static boolean isFloatingPointColumn(Column col) {
- return((col.getType() == DataType.FLOAT) ||
- (col.getType() == DataType.DOUBLE));
- }
+ // FIXME
+// private static boolean isFloatingPointColumn(Column col) {
+// return((col.getType() == DataType.FLOAT) ||
+// (col.getType() == DataType.DOUBLE));
+// }
/**
* Converts an index value for a fixed column into the index bytes
// Column column = entryCol._column;
// // if (value instanceof Integer) {
-// // value = new Integer((int) (((Integer) value).longValue() -
+// // value = Integer.valueOf((int) (((Integer) value).longValue() -
// // ((long) Integer.MAX_VALUE + 1L)));
// // } else if (value instanceof Short) {
-// // value = new Short((short) (((Short) value).longValue() -
+// // value = Short.valueOf((short) (((Short) value).longValue() -
// // ((long) Integer.MAX_VALUE + 1L)));
// // }
/**
* Read an existing entry in from a buffer
*/
- public Entry(ByteBuffer buffer, int length, byte[] valuePrefix)
+ public Entry(ByteBuffer buffer, byte[] valuePrefix)
throws IOException
{
for(Map.Entry<Column, Byte> entry : _columns.entrySet()) {
// FIXME, reverse is 0x80, reverse null is 0xFF
if (flag != (byte) 0) {
byte[] data = new byte[_column.getType().getFixedSize()];
- int numPrefixBytes = ((valuePrefix == null) ? 0 :
- (valuePrefix.length - 1));
int dataOffset = 0;
if((valuePrefix != null) && (valuePrefix.length > 1)) {
System.arraycopy(valuePrefix, 1, data, 0,
//ints and shorts are stored in index as value + 2147483648
if (_value instanceof Integer) {
- _value = new Integer((int) (((Integer) _value).longValue() +
+ _value = Integer.valueOf((int) (((Integer) _value).longValue() +
(long) Integer.MAX_VALUE + 1L));
} else if (_value instanceof Short) {
- _value = new Short((short) (((Short) _value).longValue() +
+ _value = Short.valueOf((short) (((Short) _value).longValue() +
(long) Integer.MAX_VALUE + 1L));
}
}
buffer.put((byte) 0x7F);
Comparable value = _value;
if (value instanceof Integer) {
- value = new Integer((int) (((Integer) value).longValue() -
+ value = Integer.valueOf((int) (((Integer) value).longValue() -
((long) Integer.MAX_VALUE + 1L)));
} else if (value instanceof Short) {
- value = new Short((short) (((Short) value).longValue() -
+ value = Short.valueOf((short) (((Short) value).longValue() -
((long) Integer.MAX_VALUE + 1L)));
}
buffer.put(_column.write(value, 0, ByteOrder.BIG_ENDIAN));
/**
* Read an existing node entry in from a buffer
*/
- public NodeEntry(ByteBuffer buffer, int length, byte[] valuePrefix)
+ public NodeEntry(ByteBuffer buffer, byte[] valuePrefix)
throws IOException
{
- super(buffer, length, valuePrefix);
+ super(buffer, valuePrefix);
_subPageNumber = ByteUtil.getInt(buffer, ByteOrder.BIG_ENDIAN);
}
* Only used by unit tests
*/
PageChannel(boolean testing) {
+ if(!testing) {
+ throw new IllegalArgumentException();
+ }
_channel = null;
_format = JetFormat.VERSION_4;
_autoSync = false;
import java.io.IOException;
import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
* Only used by unit tests
*/
Table(boolean testing) throws IOException {
+ if(!testing) {
+ throw new IllegalArgumentException();
+ }
_pageChannel = new PageChannel(testing);
}
Map<String, Object> rtn = new LinkedHashMap<String, Object>(
columns.size());
for(Column column : columns) {
- Object value = null;
if((columnNames == null) || (columnNames.contains(column.getName()))) {
// Add the value to the row data
rtn.put(column.getName(), getRowColumn(rowBuffer, nullMask, column));
{
boolean isNull = nullMask.isNull(column.getColumnNumber());
if(column.getType() == DataType.BOOLEAN) {
- return new Boolean(!isNull); //Boolean values are stored in the null mask
+ return Boolean.valueOf(!isNull); //Boolean values are stored in the null mask
} else if(isNull) {
// well, that's easy!
return null;
for(Column col : columns) {
// we add the number of bytes for the column name and 2 bytes for the
// length of the column name
- ByteBuffer cName = format.CHARSET.encode(col.getName());
int nameByteLen = (col.getName().length() *
JetFormat.TEXT_FIELD_UNIT_SIZE);
totalTableDefSize += nameByteLen + 2;
// reset to end of index info
tableBuffer.position(idxEndOffset);
}
-
- /**
- * Sets up the _varColumns list, assuming the _columns has already been set
- * up.
- */
- private void setupVariableColumns()
- {
- // pull out the variable length columns into a separate list
- for(Column col : _columns) {
- if(col.isVariableLength()) {
- _varColumns.add(col);
- }
- }
-
- // lastly sort these columns based on their index into the variable length
- // offset table, because we will write the columns in this order
- Collections.sort(_varColumns, VAR_LEN_COLUMN_COMPARATOR);
- }
/**
* Writes the given page data to the given page number, clears any other
if(_assumeOutOfRangeBitsOn) {
// we are using an inline map and assuming that anything not
- // within the current range is "on"
+ // within the current range is "on". so, if we attempt to set a
+ // bit which is before the current page, ignore it, we are not
+ // going back for it.
if((firstPage == PageChannel.INVALID_PAGE_NUMBER) ||
(pageNumber > lastPage)) {
// move to new start page, filling in as we move
moveToNewStartPageForRemove(firstPage, lastPage, pageNumber);
- } else {
-
- // umm, we are removing an already passed bit. whatever, we are
- // not going back for it
}
} else {
mapPageBuffer.put((byte) 0x01); //Unknown
mapPageBuffer.putShort((short) 0); //Unknown
for(int i = 0; i < mapPageBuffer.limit(); ++i) {
- byte b = mapPageBuffer.get(i);
+ mapPageBuffer.get(i);
}
int mapPageNum = _mapPageHolder.getPageNumber();
getTableBuffer().putInt(calculateMapPagePointerOffset(pageIndex),