Renamed Record class to DBRecord

This commit is contained in:
ghidra1 2020-12-28 13:34:09 -05:00
parent 89f46d1831
commit fca5c2997b
305 changed files with 1902 additions and 1902 deletions

View file

@ -93,7 +93,7 @@ public class FixLangId extends GhidraScript {
Msg.showError(getClass(), null, "Script Error", "Bad program database!!"); Msg.showError(getClass(), null, "Script Error", "Bad program database!!");
return false; return false;
} }
Record record = table.getRecord(new StringField(LANGUAGE_ID)); DBRecord record = table.getRecord(new StringField(LANGUAGE_ID));
if (record == null) { // must be in old style combined language/compiler spec format if (record == null) { // must be in old style combined language/compiler spec format
Msg.showError(getClass(), null, "Script Error", Msg.showError(getClass(), null, "Script Error",
"Old program file! Language fix is not appropriate."); "Old program file! Language fix is not appropriate.");

View file

@ -16,15 +16,15 @@
*/ */
package ghidra.app.plugin.debug.dbtable; package ghidra.app.plugin.debug.dbtable;
import db.Record; import db.DBRecord;
abstract class AbstractColumnAdapter { abstract class AbstractColumnAdapter {
abstract Class<?> getValueClass(); abstract Class<?> getValueClass();
abstract Object getKeyValue(Record rec); abstract Object getKeyValue(DBRecord rec);
abstract Object getValue(Record rec, int col); abstract Object getValue(DBRecord rec, int col);
protected String getByteString(byte b) { protected String getByteString(byte b) {
String str = Integer.toHexString(b); String str = Integer.toHexString(b);

View file

@ -17,7 +17,7 @@
package ghidra.app.plugin.debug.dbtable; package ghidra.app.plugin.debug.dbtable;
import db.BinaryField; import db.BinaryField;
import db.Record; import db.DBRecord;
public class BinaryColumnAdapter extends AbstractColumnAdapter { public class BinaryColumnAdapter extends AbstractColumnAdapter {
@ -27,7 +27,7 @@ public class BinaryColumnAdapter extends AbstractColumnAdapter {
} }
@Override @Override
Object getKeyValue(Record rec) { Object getKeyValue(DBRecord rec) {
byte[] bytes = ((BinaryField) rec.getKeyField()).getBinaryData(); byte[] bytes = ((BinaryField) rec.getKeyField()).getBinaryData();
StringBuffer buf = new StringBuffer(" byte[" + bytes.length + "] = "); StringBuffer buf = new StringBuffer(" byte[" + bytes.length + "] = ");
if (bytes.length > 0) { if (bytes.length > 0) {
@ -45,7 +45,7 @@ public class BinaryColumnAdapter extends AbstractColumnAdapter {
} }
@Override @Override
Object getValue(Record rec, int col) { Object getValue(DBRecord rec, int col) {
byte[] bytes = rec.getBinaryData(col); byte[] bytes = rec.getBinaryData(col);
if (bytes == null) { if (bytes == null) {
return "null"; return "null";

View file

@ -17,7 +17,7 @@
package ghidra.app.plugin.debug.dbtable; package ghidra.app.plugin.debug.dbtable;
import db.BooleanField; import db.BooleanField;
import db.Record; import db.DBRecord;
public class BooleanColumnAdapter extends AbstractColumnAdapter { public class BooleanColumnAdapter extends AbstractColumnAdapter {
@ -27,12 +27,12 @@ public class BooleanColumnAdapter extends AbstractColumnAdapter {
} }
@Override @Override
Object getKeyValue(Record rec) { Object getKeyValue(DBRecord rec) {
return new Boolean(((BooleanField) rec.getKeyField()).getBooleanValue()); return new Boolean(((BooleanField) rec.getKeyField()).getBooleanValue());
} }
@Override @Override
Object getValue(Record rec, int col) { Object getValue(DBRecord rec, int col) {
return Boolean.valueOf(rec.getBooleanValue(col)); return Boolean.valueOf(rec.getBooleanValue(col));
} }

View file

@ -17,7 +17,7 @@
package ghidra.app.plugin.debug.dbtable; package ghidra.app.plugin.debug.dbtable;
import db.ByteField; import db.ByteField;
import db.Record; import db.DBRecord;
public class ByteColumnAdapter extends AbstractColumnAdapter { public class ByteColumnAdapter extends AbstractColumnAdapter {
@ -27,12 +27,12 @@ public class ByteColumnAdapter extends AbstractColumnAdapter {
} }
@Override @Override
Object getKeyValue(Record rec) { Object getKeyValue(DBRecord rec) {
return new Byte(((ByteField) rec.getKeyField()).getByteValue()); return new Byte(((ByteField) rec.getKeyField()).getByteValue());
} }
@Override @Override
Object getValue(Record rec, int col) { Object getValue(DBRecord rec, int col) {
return new Byte(rec.getByteValue(col)); return new Byte(rec.getByteValue(col));
} }

View file

@ -31,7 +31,7 @@ public class DbLargeTableModel implements TableModel {
private Schema schema; private Schema schema;
private List<AbstractColumnAdapter> columns = new ArrayList<AbstractColumnAdapter>(); private List<AbstractColumnAdapter> columns = new ArrayList<AbstractColumnAdapter>();
private RecordIterator recIt; private RecordIterator recIt;
private Record lastRecord; private DBRecord lastRecord;
private int lastIndex; private int lastIndex;
private Field minKey; private Field minKey;
private Field maxKey; private Field maxKey;
@ -94,7 +94,7 @@ public class DbLargeTableModel implements TableModel {
private void findMinKey() throws IOException { private void findMinKey() throws IOException {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
Record rec = iter.next(); DBRecord rec = iter.next();
minKey = rec.getKeyField(); minKey = rec.getKeyField();
} }
@ -109,7 +109,7 @@ public class DbLargeTableModel implements TableModel {
max.setBinaryData(maxBytes); max.setBinaryData(maxBytes);
} }
RecordIterator iter = table.iterator(max); RecordIterator iter = table.iterator(max);
Record rec = iter.previous(); DBRecord rec = iter.previous();
maxKey = rec.getKeyField(); maxKey = rec.getKeyField();
} }
@ -152,7 +152,7 @@ public class DbLargeTableModel implements TableModel {
@Override @Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
Record rec = getRecord(rowIndex); DBRecord rec = getRecord(rowIndex);
if (columnIndex == 0) { // key column if (columnIndex == 0) { // key column
return columns.get(columnIndex).getKeyValue(rec); return columns.get(columnIndex).getKeyValue(rec);
} }
@ -177,7 +177,7 @@ public class DbLargeTableModel implements TableModel {
// no! // no!
} }
private Record getRecord(int index) { private DBRecord getRecord(int index) {
try { try {
if (index == lastIndex + 1) { if (index == lastIndex + 1) {
if (recIt.hasNext()) { if (recIt.hasNext()) {
@ -196,7 +196,7 @@ public class DbLargeTableModel implements TableModel {
recIt.previous(); recIt.previous();
} }
} }
Record rec = recIt.next(); DBRecord rec = recIt.next();
if (rec != null) { if (rec != null) {
lastRecord = rec; lastRecord = rec;
lastIndex = index; lastIndex = index;

View file

@ -24,11 +24,11 @@ import docking.widgets.table.AbstractSortedTableModel;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.exception.AssertException; import ghidra.util.exception.AssertException;
public class DbSmallTableModel extends AbstractSortedTableModel<Record> { public class DbSmallTableModel extends AbstractSortedTableModel<DBRecord> {
private Table table; private Table table;
private Schema schema; private Schema schema;
private List<AbstractColumnAdapter> columns = new ArrayList<>(); private List<AbstractColumnAdapter> columns = new ArrayList<>();
private List<Record> records; private List<DBRecord> records;
public DbSmallTableModel(Table table) { public DbSmallTableModel(Table table) {
this.table = table; this.table = table;
@ -124,7 +124,7 @@ public class DbSmallTableModel extends AbstractSortedTableModel<Record> {
} }
@Override @Override
public Object getColumnValueForRow(Record rec, int columnIndex) { public Object getColumnValueForRow(DBRecord rec, int columnIndex) {
if (columnIndex == 0) { // key column if (columnIndex == 0) { // key column
return columns.get(columnIndex).getKeyValue(rec); return columns.get(columnIndex).getKeyValue(rec);
} }
@ -134,7 +134,7 @@ public class DbSmallTableModel extends AbstractSortedTableModel<Record> {
} }
@Override @Override
public List<Record> getModelData() { public List<DBRecord> getModelData() {
return records; return records;
} }

View file

@ -17,7 +17,7 @@
package ghidra.app.plugin.debug.dbtable; package ghidra.app.plugin.debug.dbtable;
import db.IntField; import db.IntField;
import db.Record; import db.DBRecord;
public class IntegerColumnAdapter extends AbstractColumnAdapter { public class IntegerColumnAdapter extends AbstractColumnAdapter {
@ -27,12 +27,12 @@ public class IntegerColumnAdapter extends AbstractColumnAdapter {
} }
@Override @Override
Object getKeyValue(Record rec) { Object getKeyValue(DBRecord rec) {
return new Integer(((IntField) rec.getKeyField()).getIntValue()); return new Integer(((IntField) rec.getKeyField()).getIntValue());
} }
@Override @Override
Object getValue(Record rec, int col) { Object getValue(DBRecord rec, int col) {
return new Integer(rec.getIntValue(col)); return new Integer(rec.getIntValue(col));
} }

View file

@ -16,7 +16,7 @@
*/ */
package ghidra.app.plugin.debug.dbtable; package ghidra.app.plugin.debug.dbtable;
import db.Record; import db.DBRecord;
public class LongColumnAdapter extends AbstractColumnAdapter { public class LongColumnAdapter extends AbstractColumnAdapter {
@ -26,12 +26,12 @@ public class LongColumnAdapter extends AbstractColumnAdapter {
} }
@Override @Override
Object getKeyValue(Record rec) { Object getKeyValue(DBRecord rec) {
return new Long(rec.getKey()); return new Long(rec.getKey());
} }
@Override @Override
Object getValue(Record rec, int col) { Object getValue(DBRecord rec, int col) {
return new Long(rec.getLongValue(col)); return new Long(rec.getLongValue(col));
} }
} }

View file

@ -16,7 +16,7 @@
*/ */
package ghidra.app.plugin.debug.dbtable; package ghidra.app.plugin.debug.dbtable;
import db.Record; import db.DBRecord;
import db.ShortField; import db.ShortField;
public class ShortColumnAdapter extends AbstractColumnAdapter { public class ShortColumnAdapter extends AbstractColumnAdapter {
@ -27,12 +27,12 @@ public class ShortColumnAdapter extends AbstractColumnAdapter {
} }
@Override @Override
Object getKeyValue(Record rec) { Object getKeyValue(DBRecord rec) {
return new Short(((ShortField) rec.getKeyField()).getShortValue()); return new Short(((ShortField) rec.getKeyField()).getShortValue());
} }
@Override @Override
Object getValue(Record rec, int col) { Object getValue(DBRecord rec, int col) {
return new Short(rec.getShortValue(col)); return new Short(rec.getShortValue(col));
} }

View file

@ -16,7 +16,7 @@
*/ */
package ghidra.app.plugin.debug.dbtable; package ghidra.app.plugin.debug.dbtable;
import db.Record; import db.DBRecord;
import db.StringField; import db.StringField;
public class StringColumnAdapter extends AbstractColumnAdapter { public class StringColumnAdapter extends AbstractColumnAdapter {
@ -27,12 +27,12 @@ public class StringColumnAdapter extends AbstractColumnAdapter {
} }
@Override @Override
Object getKeyValue(Record rec) { Object getKeyValue(DBRecord rec) {
return ((StringField) rec.getKeyField()).getString(); return ((StringField) rec.getKeyField()).getString();
} }
@Override @Override
Object getValue(Record rec, int col) { Object getValue(DBRecord rec, int col) {
return " " + rec.getString(col); return " " + rec.getString(col);
} }
} }

View file

@ -84,7 +84,7 @@ public class AddressIndexPrimaryKeyIteratorTest extends AbstractGhidraHeadedInte
Address maxAddr = r.getMaxAddress(); Address maxAddr = r.getMaxAddress();
while (a.compareTo(maxAddr) <= 0) { while (a.compareTo(maxAddr) <= 0) {
long addrKey = addrMap.getKey(a, true); long addrKey = addrMap.getKey(a, true);
Record rec = schema.createRecord(myTable.getKey()); DBRecord rec = schema.createRecord(myTable.getKey());
rec.setLongValue(0, addrKey); rec.setLongValue(0, addrKey);
myTable.putRecord(rec); myTable.putRecord(rec);
a = a.add(1); a = a.add(1);

View file

@ -97,7 +97,7 @@ public class AddressKeyIteratorTest extends AbstractGhidraHeadedIntegrationTest
private long addRecord(Address a) throws Exception { private long addRecord(Address a) throws Exception {
long key = addrMap.getKey(a, true); long key = addrMap.getKey(a, true);
Record rec = SCHEMA.createRecord(key); DBRecord rec = SCHEMA.createRecord(key);
rec.setString(0, a.toString()); rec.setString(0, a.toString());
myTable.putRecord(rec); myTable.putRecord(rec);
return key; return key;

View file

@ -95,7 +95,7 @@ public class SharedRangeMapDBTest extends AbstractGhidraHeadedIntegrationTest
int cnt = 0; int cnt = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
++cnt; ++cnt;
Record rec = iter.next(); DBRecord rec = iter.next();
IndexRange range = IndexRange range =
new IndexRange(rec.getKey(), rec.getLongValue(SharedRangeMapDB.RANGE_TO_COL)); new IndexRange(rec.getKey(), rec.getLongValue(SharedRangeMapDB.RANGE_TO_COL));
if (indexOf(ranges, range) < 0) { if (indexOf(ranges, range) < 0) {
@ -108,7 +108,7 @@ public class SharedRangeMapDBTest extends AbstractGhidraHeadedIntegrationTest
cnt = 0; cnt = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
++cnt; ++cnt;
Record rec = iter.next(); DBRecord rec = iter.next();
IndexRange entry = new IndexRange(rec.getLongValue(SharedRangeMapDB.MAP_RANGE_KEY_COL), IndexRange entry = new IndexRange(rec.getLongValue(SharedRangeMapDB.MAP_RANGE_KEY_COL),
rec.getLongValue(SharedRangeMapDB.MAP_VALUE_COL)); rec.getLongValue(SharedRangeMapDB.MAP_VALUE_COL));
if (indexOf(mapRangeToValue, entry) < 0) { if (indexOf(mapRangeToValue, entry) < 0) {

View file

@ -59,7 +59,7 @@ public class DatabaseBenchMarks {
Schema schema = Schema schema =
new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" }); new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" });
Table table = dbh.createTable("Test", schema); Table table = dbh.createTable("Test", schema);
Record record = schema.createRecord(0); DBRecord record = schema.createRecord(0);
timer.start( timer.start(
"Inserting " + numInsertions + " sorted records with long keys and integer values"); "Inserting " + numInsertions + " sorted records with long keys and integer values");
for (int i = 0; i < numInsertions; i++) { for (int i = 0; i < numInsertions; i++) {
@ -83,7 +83,7 @@ public class DatabaseBenchMarks {
Schema schema = new Schema(1, "Key", new Field[] { StringField.INSTANCE }, Schema schema = new Schema(1, "Key", new Field[] { StringField.INSTANCE },
new String[] { "Value" }); new String[] { "Value" });
Table table = dbh.createTable("Test", schema); Table table = dbh.createTable("Test", schema);
Record record = schema.createRecord(0); DBRecord record = schema.createRecord(0);
timer.start("Inserting " + numInsertions + timer.start("Inserting " + numInsertions +
" sorted records with long keys and String (length = 8) values"); " sorted records with long keys and String (length = 8) values");
for (int i = 0; i < numInsertions; i++) { for (int i = 0; i < numInsertions; i++) {
@ -108,7 +108,7 @@ public class DatabaseBenchMarks {
Schema schema = Schema schema =
new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" }); new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" });
Table table = dbh.createTable("Test", schema); Table table = dbh.createTable("Test", schema);
Record record = schema.createRecord(0); DBRecord record = schema.createRecord(0);
timer.start( timer.start(
"Inserting " + numInsertions + " random records with long keys and integer values"); "Inserting " + numInsertions + " random records with long keys and integer values");
for (int i = 0; i < numInsertions; i++) { for (int i = 0; i < numInsertions; i++) {
@ -132,7 +132,7 @@ public class DatabaseBenchMarks {
Schema schema = Schema schema =
new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" }); new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" });
Table table = dbh.createTable("Test", schema); Table table = dbh.createTable("Test", schema);
Record record = schema.createRecord(0); DBRecord record = schema.createRecord(0);
System.out.print("building database..."); System.out.print("building database...");
for (int i = 0; i < 1000000; i++) { for (int i = 0; i < 1000000; i++) {
record.setKey(i); record.setKey(i);
@ -161,7 +161,7 @@ public class DatabaseBenchMarks {
Schema schema = Schema schema =
new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" }); new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" });
Table table = dbh.createTable("Test", schema); Table table = dbh.createTable("Test", schema);
Record record = schema.createRecord(0); DBRecord record = schema.createRecord(0);
System.out.print("building database..."); System.out.print("building database...");
for (int i = 0; i < 1000000; i++) { for (int i = 0; i < 1000000; i++) {
record.setKey(i); record.setKey(i);

View file

@ -19,7 +19,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import db.DBHandle; import db.DBHandle;
import db.Record; import db.DBRecord;
import db.RecordIterator; import db.RecordIterator;
import db.Schema; import db.Schema;
import db.Table; import db.Table;
@ -50,7 +50,7 @@ public class RepackFid extends GhidraScript {
monitor.setProgress(0); monitor.setProgress(0);
RecordIterator iterator = oldTable.iterator(); RecordIterator iterator = oldTable.iterator();
while(iterator.hasNext()) { // Iterate through old records while(iterator.hasNext()) { // Iterate through old records
Record record = iterator.next(); DBRecord record = iterator.next();
newTable.putRecord(record); // Copy as is into new table newTable.putRecord(record); // Copy as is into new table
monitor.checkCanceled(); monitor.checkCanceled();
monitor.incrementProgress(1); monitor.incrementProgress(1);

View file

@ -21,7 +21,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import db.DBHandle; import db.DBHandle;
import db.Record; import db.DBRecord;
import ghidra.feature.fid.hash.FidHashQuad; import ghidra.feature.fid.hash.FidHashQuad;
import ghidra.framework.store.db.PackedDBHandle; import ghidra.framework.store.db.PackedDBHandle;
import ghidra.framework.store.db.PackedDatabase; import ghidra.framework.store.db.PackedDatabase;
@ -384,7 +384,7 @@ public class FidDB implements Closeable {
public boolean getSuperiorFullRelation(FunctionRecord superiorFunction, public boolean getSuperiorFullRelation(FunctionRecord superiorFunction,
FidHashQuad inferiorFunction) { FidHashQuad inferiorFunction) {
try { try {
Record libraryByID = librariesTable.getLibraryByID(superiorFunction.getLibraryID()); DBRecord libraryByID = librariesTable.getLibraryByID(superiorFunction.getLibraryID());
if (libraryByID != null) { if (libraryByID != null) {
return relationsTable.getSuperiorFullRelation(superiorFunction, inferiorFunction); return relationsTable.getSuperiorFullRelation(superiorFunction, inferiorFunction);
} }
@ -405,7 +405,7 @@ public class FidDB implements Closeable {
public boolean getInferiorFullRelation(FidHashQuad superiorFunction, public boolean getInferiorFullRelation(FidHashQuad superiorFunction,
FunctionRecord inferiorFunction) { FunctionRecord inferiorFunction) {
try { try {
Record libraryByID = librariesTable.getLibraryByID(inferiorFunction.getLibraryID()); DBRecord libraryByID = librariesTable.getLibraryByID(inferiorFunction.getLibraryID());
if (libraryByID != null) { if (libraryByID != null) {
return relationsTable.getInferiorFullRelation(superiorFunction, inferiorFunction); return relationsTable.getInferiorFullRelation(superiorFunction, inferiorFunction);
} }
@ -439,7 +439,7 @@ public class FidDB implements Closeable {
*/ */
public LibraryRecord getLibraryForFunction(FunctionRecord functionRecord) { public LibraryRecord getLibraryForFunction(FunctionRecord functionRecord) {
try { try {
Record record = librariesTable.getLibraryByID(functionRecord.getLibraryID()); DBRecord record = librariesTable.getLibraryByID(functionRecord.getLibraryID());
if (record == null) { if (record == null) {
return null; return null;
} }
@ -473,7 +473,7 @@ public class FidDB implements Closeable {
try { try {
checkUpdateAllowed(); checkUpdateAllowed();
Record record = librariesTable.createLibrary(libraryFamilyName, libraryVersion, DBRecord record = librariesTable.createLibrary(libraryFamilyName, libraryVersion,
libraryVariant, ghidraVersion, languageID, languageVersion, languageMinorVersion, libraryVariant, ghidraVersion, languageID, languageVersion, languageMinorVersion,
compilerSpecID); compilerSpecID);
return new LibraryRecord(record); return new LibraryRecord(record);

View file

@ -17,7 +17,7 @@ package ghidra.feature.fid.db;
import static ghidra.feature.fid.db.FunctionsTable.*; import static ghidra.feature.fid.db.FunctionsTable.*;
import db.Record; import db.DBRecord;
import ghidra.feature.fid.hash.FidHashQuad; import ghidra.feature.fid.hash.FidHashQuad;
import ghidra.program.database.DBObjectCache; import ghidra.program.database.DBObjectCache;
import ghidra.program.database.DatabaseObject; import ghidra.program.database.DatabaseObject;
@ -36,7 +36,7 @@ public class FunctionRecord extends DatabaseObject implements FidHashQuad {
/** /**
* All values are stored in the record instead of memoized. * All values are stored in the record instead of memoized.
*/ */
final Record record; final DBRecord record;
/** /**
* Need a reference to the FidDb because all strings are stored * Need a reference to the FidDb because all strings are stored
* via foreign key (considerable duplication of string values). * via foreign key (considerable duplication of string values).
@ -49,7 +49,7 @@ public class FunctionRecord extends DatabaseObject implements FidHashQuad {
* @param cache FunctionRecord object cache * @param cache FunctionRecord object cache
* @param record record for this function * @param record record for this function
*/ */
FunctionRecord(FidDB fid, DBObjectCache<FunctionRecord> cache, Record record) { FunctionRecord(FidDB fid, DBObjectCache<FunctionRecord> cache, DBRecord record) {
super(cache, record.getKey()); super(cache, record.getKey());
this.record = record; this.record = record;
this.fidDb = fid; this.fidDb = fid;

View file

@ -112,7 +112,7 @@ public class FunctionsTable {
RecordIterator iterator = table.iterator(); RecordIterator iterator = table.iterator();
List<FunctionRecord> list = new ArrayList<>(); List<FunctionRecord> list = new ArrayList<>();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Record record = iterator.next(); DBRecord record = iterator.next();
if (record.getLongValue(SPECIFIC_HASH_COL) != hash) { if (record.getLongValue(SPECIFIC_HASH_COL) != hash) {
continue; continue;
} }
@ -143,7 +143,7 @@ public class FunctionsTable {
Field key = iterator.next(); Field key = iterator.next();
FunctionRecord functionRecord = functionCache.get(key.getLongValue()); FunctionRecord functionRecord = functionCache.get(key.getLongValue());
if (functionRecord == null) { if (functionRecord == null) {
Record record = table.getRecord(key); DBRecord record = table.getRecord(key);
functionRecord = new FunctionRecord(fidDb, functionCache, record); functionRecord = new FunctionRecord(fidDb, functionCache, record);
} }
list.add(functionRecord); list.add(functionRecord);
@ -164,7 +164,7 @@ public class FunctionsTable {
*/ */
public FunctionRecord createFunctionRecord(long libraryID, FidHashQuad hashQuad, String name, public FunctionRecord createFunctionRecord(long libraryID, FidHashQuad hashQuad, String name,
long entryPoint, String domainPath, boolean hasTerminator) throws IOException { long entryPoint, String domainPath, boolean hasTerminator) throws IOException {
Record record = SCHEMA.createRecord(UniversalIdGenerator.nextID().getValue()); DBRecord record = SCHEMA.createRecord(UniversalIdGenerator.nextID().getValue());
record.setShortValue(CODE_UNIT_SIZE_COL, hashQuad.getCodeUnitSize()); record.setShortValue(CODE_UNIT_SIZE_COL, hashQuad.getCodeUnitSize());
record.setLongValue(FULL_HASH_COL, hashQuad.getFullHash()); record.setLongValue(FULL_HASH_COL, hashQuad.getFullHash());
record.setByteValue(SPECIFIC_HASH_ADDITIONAL_SIZE_COL, record.setByteValue(SPECIFIC_HASH_ADDITIONAL_SIZE_COL,
@ -191,7 +191,7 @@ public class FunctionsTable {
* @throws IOException * @throws IOException
*/ */
void modifyFlags(long functionID, int flagMask, boolean value) throws IOException { void modifyFlags(long functionID, int flagMask, boolean value) throws IOException {
Record record = table.getRecord(functionID); DBRecord record = table.getRecord(functionID);
if (record == null) { if (record == null) {
throw new IOException("Function record does not exist"); throw new IOException("Function record does not exist");
} }
@ -227,7 +227,7 @@ public class FunctionsTable {
Field key = iterator.next(); Field key = iterator.next();
FunctionRecord functionRecord = functionCache.get(key.getLongValue()); FunctionRecord functionRecord = functionCache.get(key.getLongValue());
if (functionRecord == null) { if (functionRecord == null) {
Record record = table.getRecord(key); DBRecord record = table.getRecord(key);
long nameID = record.getLongValue(NAME_ID_COL); long nameID = record.getLongValue(NAME_ID_COL);
StringRecord nameRecord = stringsTable.lookupString(nameID); StringRecord nameRecord = stringsTable.lookupString(nameID);
String name = nameRecord.getValue(); String name = nameRecord.getValue();
@ -266,7 +266,7 @@ public class FunctionsTable {
Field key = iterator.next(); Field key = iterator.next();
FunctionRecord functionRecord = functionCache.get(key.getLongValue()); FunctionRecord functionRecord = functionCache.get(key.getLongValue());
if (functionRecord == null) { if (functionRecord == null) {
Record record = table.getRecord(key); DBRecord record = table.getRecord(key);
long nameID = record.getLongValue(NAME_ID_COL); long nameID = record.getLongValue(NAME_ID_COL);
StringRecord nameRecord = stringsTable.lookupString(nameID); StringRecord nameRecord = stringsTable.lookupString(nameID);
String name = nameRecord.getValue(); String name = nameRecord.getValue();
@ -297,7 +297,7 @@ public class FunctionsTable {
public FunctionRecord getFunctionByID(long functionID) throws IOException { public FunctionRecord getFunctionByID(long functionID) throws IOException {
FunctionRecord functionRecord = functionCache.get(functionID); FunctionRecord functionRecord = functionCache.get(functionID);
if (functionRecord == null) { if (functionRecord == null) {
Record record = table.getRecord(functionID); DBRecord record = table.getRecord(functionID);
if (record != null) { if (record != null) {
functionRecord = new FunctionRecord(fidDb, functionCache, record); functionRecord = new FunctionRecord(fidDb, functionCache, record);
} }
@ -318,7 +318,7 @@ public class FunctionsTable {
RecordIterator iterator = table.iterator(); RecordIterator iterator = table.iterator();
List<FunctionRecord> list = new ArrayList<>(); List<FunctionRecord> list = new ArrayList<>();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Record record = iterator.next(); DBRecord record = iterator.next();
long domainPathID = record.getLongValue(DOMAIN_PATH_ID_COL); long domainPathID = record.getLongValue(DOMAIN_PATH_ID_COL);
StringRecord domainPathRecord = stringsTable.lookupString(domainPathID); StringRecord domainPathRecord = stringsTable.lookupString(domainPathID);
String domainPath = domainPathRecord.getValue(); String domainPath = domainPathRecord.getValue();
@ -358,7 +358,7 @@ public class FunctionsTable {
Field key = iterator.next(); Field key = iterator.next();
FunctionRecord functionRecord = functionCache.get(key.getLongValue()); FunctionRecord functionRecord = functionCache.get(key.getLongValue());
if (functionRecord == null) { if (functionRecord == null) {
Record record = table.getRecord(key); DBRecord record = table.getRecord(key);
if (record.getLongValue(LIBRARY_ID_COL) == libraryKey) { if (record.getLongValue(LIBRARY_ID_COL) == libraryKey) {
functionRecord = new FunctionRecord(fidDb, functionCache, record); functionRecord = new FunctionRecord(fidDb, functionCache, record);
list.add(functionRecord); list.add(functionRecord);

View file

@ -110,10 +110,10 @@ public class LibrariesTable {
* @return the new library record * @return the new library record
* @throws IOException if the database create fails * @throws IOException if the database create fails
*/ */
public Record createLibrary(String libraryFamilyName, String libraryVersion, public DBRecord createLibrary(String libraryFamilyName, String libraryVersion,
String libraryVariant, String ghidraVersion, LanguageID languageID, int languageVersion, String libraryVariant, String ghidraVersion, LanguageID languageID, int languageVersion,
int languageMinorVersion, CompilerSpecID compilerSpecID) throws IOException { int languageMinorVersion, CompilerSpecID compilerSpecID) throws IOException {
Record record = SCHEMA.createRecord(UniversalIdGenerator.nextID().getValue()); DBRecord record = SCHEMA.createRecord(UniversalIdGenerator.nextID().getValue());
record.setString(LIBRARY_FAMILY_NAME_COL, libraryFamilyName); record.setString(LIBRARY_FAMILY_NAME_COL, libraryFamilyName);
record.setString(LIBRARY_VERSION_COL, libraryVersion); record.setString(LIBRARY_VERSION_COL, libraryVersion);
record.setString(LIBRARY_VARIANT_COL, libraryVariant); record.setString(LIBRARY_VARIANT_COL, libraryVariant);
@ -164,7 +164,7 @@ public class LibrariesTable {
List<LibraryRecord> list = new ArrayList<LibraryRecord>(); List<LibraryRecord> list = new ArrayList<LibraryRecord>();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Field key = iterator.next(); Field key = iterator.next();
Record record = table.getRecord(key); DBRecord record = table.getRecord(key);
LibraryRecord libraryRecord = new LibraryRecord(record); LibraryRecord libraryRecord = new LibraryRecord(record);
if (version != null) { if (version != null) {
if (!libraryRecord.getLibraryVersion().equals(version)) { if (!libraryRecord.getLibraryVersion().equals(version)) {
@ -187,8 +187,8 @@ public class LibrariesTable {
* @return the library or null if not found * @return the library or null if not found
* @throws IOException if database seek encounters an error * @throws IOException if database seek encounters an error
*/ */
public Record getLibraryByID(long id) throws IOException { public DBRecord getLibraryByID(long id) throws IOException {
Record record = table.getRecord(id); DBRecord record = table.getRecord(id);
return record; return record;
} }
} }

View file

@ -18,7 +18,7 @@ package ghidra.feature.fid.db;
import static ghidra.feature.fid.db.LibrariesTable.*; import static ghidra.feature.fid.db.LibrariesTable.*;
import ghidra.program.model.lang.CompilerSpecID; import ghidra.program.model.lang.CompilerSpecID;
import ghidra.program.model.lang.LanguageID; import ghidra.program.model.lang.LanguageID;
import db.Record; import db.DBRecord;
/** /**
* Represents a library record in the FID database. * Represents a library record in the FID database.
@ -27,13 +27,13 @@ public class LibraryRecord {
/** /**
* The record is stored, no memoization is performed. * The record is stored, no memoization is performed.
*/ */
final Record record; final DBRecord record;
/** /**
* Creates a new library record. * Creates a new library record.
* @param record the database record on which to base this library * @param record the database record on which to base this library
*/ */
public LibraryRecord(Record record) { public LibraryRecord(DBRecord record) {
if (record == null) { if (record == null) {
throw new IllegalArgumentException("null record"); throw new IllegalArgumentException("null record");
} }

View file

@ -63,12 +63,12 @@ public class RelationsTable {
RelationType relationType) throws IOException { RelationType relationType) throws IOException {
long superiorKey = long superiorKey =
FidDBUtils.generateSuperiorFullHashSmash(superiorFunction, inferiorFunction); FidDBUtils.generateSuperiorFullHashSmash(superiorFunction, inferiorFunction);
Record superiorRecord = SCHEMA.createRecord(superiorKey); DBRecord superiorRecord = SCHEMA.createRecord(superiorKey);
superiorTable.putRecord(superiorRecord); superiorTable.putRecord(superiorRecord);
if (relationType != RelationType.INTER_LIBRARY_CALL) { if (relationType != RelationType.INTER_LIBRARY_CALL) {
long inferiorKey = long inferiorKey =
FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction); FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction);
Record inferiorRecord = SCHEMA.createRecord(inferiorKey); DBRecord inferiorRecord = SCHEMA.createRecord(inferiorKey);
inferiorTable.putRecord(inferiorRecord); inferiorTable.putRecord(inferiorRecord);
} }
} }
@ -84,7 +84,7 @@ public class RelationsTable {
FunctionRecord inferiorFunction) throws IOException { FunctionRecord inferiorFunction) throws IOException {
long inferiorKey = long inferiorKey =
FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction); FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction);
Record inferiorRecord = SCHEMA.createRecord(inferiorKey); DBRecord inferiorRecord = SCHEMA.createRecord(inferiorKey);
inferiorTable.putRecord(inferiorRecord); inferiorTable.putRecord(inferiorRecord);
} }
@ -100,7 +100,7 @@ public class RelationsTable {
FidHashQuad inferiorFunction) throws IOException { FidHashQuad inferiorFunction) throws IOException {
long superiorKey = long superiorKey =
FidDBUtils.generateSuperiorFullHashSmash(superiorFunction, inferiorFunction); FidDBUtils.generateSuperiorFullHashSmash(superiorFunction, inferiorFunction);
Record record = superiorTable.getRecord(superiorKey); DBRecord record = superiorTable.getRecord(superiorKey);
return (record != null); return (record != null);
} }
@ -116,7 +116,7 @@ public class RelationsTable {
FunctionRecord inferiorFunction) throws IOException { FunctionRecord inferiorFunction) throws IOException {
long inferiorKey = long inferiorKey =
FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction); FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction);
Record record = inferiorTable.getRecord(inferiorKey); DBRecord record = inferiorTable.getRecord(inferiorKey);
return (record != null); return (record != null);
} }
} }

View file

@ -71,7 +71,7 @@ public class StringsTable {
if (records == null || records.length == 0) { if (records == null || records.length == 0) {
// create // create
long key = UniversalIdGenerator.nextID().getValue(); long key = UniversalIdGenerator.nextID().getValue();
Record record = SCHEMA.createRecord(key); DBRecord record = SCHEMA.createRecord(key);
record.setString(STRING_VALUE_COL, value); record.setString(STRING_VALUE_COL, value);
table.putRecord(record); table.putRecord(record);
return key; return key;
@ -101,7 +101,7 @@ public class StringsTable {
StringRecord lookupString(long stringID) { StringRecord lookupString(long stringID) {
StringRecord stringRecord = stringCache.get(stringID); StringRecord stringRecord = stringCache.get(stringID);
if (stringRecord == null) { if (stringRecord == null) {
Record record; DBRecord record;
try { try {
record = table.getRecord(stringID); record = table.getRecord(stringID);
if (record != null) { if (record != null) {

View file

@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import db.DBHandle; import db.DBHandle;
import db.Record; import db.DBRecord;
import generic.stl.Pair; import generic.stl.Pair;
import ghidra.program.database.map.AddressMap; import ghidra.program.database.map.AddressMap;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@ -87,8 +87,8 @@ public class AddressCorrelatorDB {
public List<Pair<Address, Address>> getAddressCorrelations(Address sourceEntryPoint) throws IOException { public List<Pair<Address, Address>> getAddressCorrelations(Address sourceEntryPoint) throws IOException {
long sourceEntryLong = getLongFromSourceAddress(sourceEntryPoint); long sourceEntryLong = getLongFromSourceAddress(sourceEntryPoint);
List<Pair<Address, Address>> addressList = new ArrayList<Pair<Address,Address>>(); List<Pair<Address, Address>> addressList = new ArrayList<Pair<Address,Address>>();
List<Record> addressRecords = adapter.getAddressRecords(sourceEntryLong); List<DBRecord> addressRecords = adapter.getAddressRecords(sourceEntryLong);
for (Record record : addressRecords) { for (DBRecord record : addressRecords) {
long sourceLong = record.getLongValue(SOURCE_ADDRESS_COL.column()); long sourceLong = record.getLongValue(SOURCE_ADDRESS_COL.column());
long destinationLong = record.getLongValue(DESTINATION_ADDRESS_COL.column()); long destinationLong = record.getLongValue(DESTINATION_ADDRESS_COL.column());
Address sourceAddress = getSourceAddressFromLong(sourceLong); Address sourceAddress = getSourceAddressFromLong(sourceLong);

View file

@ -84,7 +84,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
RecordIterator records = markupItemTableAdapter.getRecords(associationDB.getKey()); RecordIterator records = markupItemTableAdapter.getRecords(associationDB.getKey());
while (records.hasNext()) { while (records.hasNext()) {
monitor.checkCanceled(); monitor.checkCanceled();
Record record = records.next(); DBRecord record = records.next();
items.add(getMarkupItemForRecord(record)); items.add(getMarkupItemForRecord(record));
monitor.incrementProgress(1); monitor.incrementProgress(1);
} }
@ -100,7 +100,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
return items; return items;
} }
Record getMarkupItemRecord(long key) { DBRecord getMarkupItemRecord(long key) {
try { try {
return markupItemTableAdapter.getRecord(key); return markupItemTableAdapter.getRecord(key);
} }
@ -155,7 +155,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
} }
} }
private MarkupItemStorageDB getMarkupItemForRecord(Record markupItemRecord) { private MarkupItemStorageDB getMarkupItemForRecord(DBRecord markupItemRecord) {
try { try {
lock.acquire(); lock.acquire();
MarkupItemStorageDB markupItem = markupItemCache.get(markupItemRecord); MarkupItemStorageDB markupItem = markupItemCache.get(markupItemRecord);
@ -181,7 +181,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
return session.getSourceAddressFromLong(longValue); return session.getSourceAddressFromLong(longValue);
} }
Record getAssociationRecord(long key) { DBRecord getAssociationRecord(long key) {
try { try {
return associationTableAdapter.getRecord(key); return associationTableAdapter.getRecord(key);
} }
@ -194,7 +194,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
private MarkupItemStorageDB createMarkupItemDB(MarkupItemStorage markupItem) { private MarkupItemStorageDB createMarkupItemDB(MarkupItemStorage markupItem) {
try { try {
Record record = markupItemTableAdapter.createMarkupItemRecord(markupItem); DBRecord record = markupItemTableAdapter.createMarkupItemRecord(markupItem);
MarkupItemStorageDB appliedMarkupItem = getMarkupItemForRecord(record); MarkupItemStorageDB appliedMarkupItem = getMarkupItemForRecord(record);
return appliedMarkupItem; return appliedMarkupItem;
} }
@ -222,7 +222,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
VTAssociationDB newAssociation = null; VTAssociationDB newAssociation = null;
try { try {
lock.acquire(); lock.acquire();
Record record = associationTableAdapter.insertRecord(sourceLong, destinationLong, type, DBRecord record = associationTableAdapter.insertRecord(sourceLong, destinationLong, type,
isBlocked ? BLOCKED : AVAILABLE, 0); isBlocked ? BLOCKED : AVAILABLE, 0);
newAssociation = new VTAssociationDB(this, associationCache, record); newAssociation = new VTAssociationDB(this, associationCache, record);
} }
@ -260,10 +260,10 @@ public class AssociationDatabaseManager implements VTAssociationManager {
long sourceID = session.getLongFromSourceAddress(sourceAddress); long sourceID = session.getLongFromSourceAddress(sourceAddress);
long destinationID = session.getLongFromDestinationAddress(destinationAddress); long destinationID = session.getLongFromDestinationAddress(destinationAddress);
try { try {
Set<Record> relatedRecords = Set<DBRecord> relatedRecords =
associationTableAdapter.getRelatedAssociationRecordsBySourceAndDestinationAddress( associationTableAdapter.getRelatedAssociationRecordsBySourceAndDestinationAddress(
sourceID, destinationID); sourceID, destinationID);
for (Record record : relatedRecords) { for (DBRecord record : relatedRecords) {
VTAssociationDB associationDB = getAssociationForRecord(record); VTAssociationDB associationDB = getAssociationForRecord(record);
VTAssociationStatus status = associationDB.getStatus(); VTAssociationStatus status = associationDB.getStatus();
if (status == ACCEPTED) { if (status == ACCEPTED) {
@ -290,7 +290,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
try { try {
RecordIterator iterator = associationTableAdapter.getRecords(); RecordIterator iterator = associationTableAdapter.getRecords();
for (; iterator.hasNext();) { for (; iterator.hasNext();) {
Record nextRecord = iterator.next(); DBRecord nextRecord = iterator.next();
list.add(getAssociationForRecord(nextRecord)); list.add(getAssociationForRecord(nextRecord));
} }
} }
@ -311,7 +311,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
RecordIterator iterator = RecordIterator iterator =
associationTableAdapter.getRecordsForSourceAddress(addressKey); associationTableAdapter.getRecordsForSourceAddress(addressKey);
while (iterator.hasNext()) { while (iterator.hasNext()) {
Record record = iterator.next(); DBRecord record = iterator.next();
VTAssociationDB associationDB = getAssociationForRecord(record); VTAssociationDB associationDB = getAssociationForRecord(record);
if (associationDB.getDestinationAddress().equals(destinationAddress)) { if (associationDB.getDestinationAddress().equals(destinationAddress)) {
return associationDB; return associationDB;
@ -334,7 +334,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
RecordIterator iterator = RecordIterator iterator =
associationTableAdapter.getRecordsForSourceAddress(addressKey); associationTableAdapter.getRecordsForSourceAddress(addressKey);
while (iterator.hasNext()) { while (iterator.hasNext()) {
Record record = iterator.next(); DBRecord record = iterator.next();
VTAssociationDB associationDB = getAssociationForRecord(record); VTAssociationDB associationDB = getAssociationForRecord(record);
Address dbDestinatonAddress = associationDB.getDestinationAddress(); Address dbDestinatonAddress = associationDB.getDestinationAddress();
if (destinationAddress.equals(dbDestinatonAddress)) { if (destinationAddress.equals(dbDestinatonAddress)) {
@ -349,7 +349,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
return null; return null;
} }
private VTAssociationDB getAssociationForRecord(Record record) { private VTAssociationDB getAssociationForRecord(DBRecord record) {
if (record == null) { if (record == null) {
throw new AssertException("How can we have a null record?!!!"); throw new AssertException("How can we have a null record?!!!");
} }
@ -373,7 +373,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
if (associationDB != null) { if (associationDB != null) {
return associationDB; return associationDB;
} }
Record record = associationTableAdapter.getRecord(associationKey); DBRecord record = associationTableAdapter.getRecord(associationKey);
if (record == null) { if (record == null) {
return null; return null;
} }
@ -397,10 +397,10 @@ public class AssociationDatabaseManager implements VTAssociationManager {
lock.acquire(); lock.acquire();
try { try {
long sourceID = session.getLongFromSourceAddress(sourceAddress); long sourceID = session.getLongFromSourceAddress(sourceAddress);
Set<Record> relatedRecords = Set<DBRecord> relatedRecords =
associationTableAdapter.getRelatedAssociationRecordsBySourceAddress(sourceID); associationTableAdapter.getRelatedAssociationRecordsBySourceAddress(sourceID);
List<VTAssociation> associations = new ArrayList<>(); List<VTAssociation> associations = new ArrayList<>();
for (Record record : relatedRecords) { for (DBRecord record : relatedRecords) {
associations.add(getAssociationForRecord(record)); associations.add(getAssociationForRecord(record));
} }
return associations; return associations;
@ -420,11 +420,11 @@ public class AssociationDatabaseManager implements VTAssociationManager {
lock.acquire(); lock.acquire();
try { try {
long destinationID = session.getLongFromDestinationAddress(destinationAddress); long destinationID = session.getLongFromDestinationAddress(destinationAddress);
Set<Record> relatedRecords = Set<DBRecord> relatedRecords =
associationTableAdapter.getRelatedAssociationRecordsByDestinationAddress( associationTableAdapter.getRelatedAssociationRecordsByDestinationAddress(
destinationID); destinationID);
List<VTAssociation> associations = new ArrayList<>(); List<VTAssociation> associations = new ArrayList<>();
for (Record record : relatedRecords) { for (DBRecord record : relatedRecords) {
associations.add(getAssociationForRecord(record)); associations.add(getAssociationForRecord(record));
} }
return associations; return associations;
@ -445,11 +445,11 @@ public class AssociationDatabaseManager implements VTAssociationManager {
try { try {
long sourceID = session.getLongFromSourceAddress(sourceAddress); long sourceID = session.getLongFromSourceAddress(sourceAddress);
long destinationID = session.getLongFromDestinationAddress(destinationAddress); long destinationID = session.getLongFromDestinationAddress(destinationAddress);
Set<Record> relatedRecords = Set<DBRecord> relatedRecords =
associationTableAdapter.getRelatedAssociationRecordsBySourceAndDestinationAddress( associationTableAdapter.getRelatedAssociationRecordsBySourceAndDestinationAddress(
sourceID, destinationID); sourceID, destinationID);
List<VTAssociation> associations = new ArrayList<>(); List<VTAssociation> associations = new ArrayList<>();
for (Record record : relatedRecords) { for (DBRecord record : relatedRecords) {
associations.add(getAssociationForRecord(record)); associations.add(getAssociationForRecord(record));
} }
return associations; return associations;
@ -572,11 +572,11 @@ public class AssociationDatabaseManager implements VTAssociationManager {
Set<VTAssociationDB> relatedAssociaitons = new HashSet<>(); Set<VTAssociationDB> relatedAssociaitons = new HashSet<>();
try { try {
Set<Record> relatedRecords = Set<DBRecord> relatedRecords =
associationTableAdapter.getRelatedAssociationRecordsBySourceAndDestinationAddress( associationTableAdapter.getRelatedAssociationRecordsBySourceAndDestinationAddress(
sourceID, destinationID); sourceID, destinationID);
relatedRecords.remove(association.getRecord()); // don't change the given association relatedRecords.remove(association.getRecord()); // don't change the given association
for (Record record : relatedRecords) { for (DBRecord record : relatedRecords) {
relatedAssociaitons.add(getAssociationForRecord(record)); relatedAssociaitons.add(getAssociationForRecord(record));
} }
} }
@ -586,7 +586,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
return relatedAssociaitons; return relatedAssociaitons;
} }
void updateAssociationRecord(Record record) { void updateAssociationRecord(DBRecord record) {
try { try {
associationTableAdapter.updateRecord(record); associationTableAdapter.updateRecord(record);
} }
@ -595,7 +595,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
} }
} }
void updateMarkupRecord(Record record) { void updateMarkupRecord(DBRecord record) {
try { try {
markupItemTableAdapter.updateRecord(record); markupItemTableAdapter.updateRecord(record);
} }
@ -617,7 +617,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
associationHooks.remove(hook); associationHooks.remove(hook);
} }
void removeMarkupRecord(Record record) { void removeMarkupRecord(DBRecord record) {
try { try {
markupItemTableAdapter.removeMatchMarkupItemRecord(record.getKey()); markupItemTableAdapter.removeMatchMarkupItemRecord(record.getKey());
} }

View file

@ -17,7 +17,7 @@ package ghidra.feature.vt.api.db;
import static ghidra.feature.vt.api.db.VTMatchMarkupItemTableDBAdapter.MarkupTableDescriptor.*; import static ghidra.feature.vt.api.db.VTMatchMarkupItemTableDBAdapter.MarkupTableDescriptor.*;
import db.Record; import db.DBRecord;
import ghidra.feature.vt.api.impl.MarkupItemStorage; import ghidra.feature.vt.api.impl.MarkupItemStorage;
import ghidra.feature.vt.api.impl.MarkupItemStorageImpl; import ghidra.feature.vt.api.impl.MarkupItemStorageImpl;
import ghidra.feature.vt.api.main.VTAssociation; import ghidra.feature.vt.api.main.VTAssociation;
@ -36,9 +36,9 @@ public class MarkupItemStorageDB extends DatabaseObject implements MarkupItemSto
private final VTAssociation association; private final VTAssociation association;
private final VTSessionDB session; private final VTSessionDB session;
private Record record; private DBRecord record;
MarkupItemStorageDB(Record record, DBObjectCache<MarkupItemStorageDB> cache, MarkupItemStorageDB(DBRecord record, DBObjectCache<MarkupItemStorageDB> cache,
AssociationDatabaseManager associationManager) { AssociationDatabaseManager associationManager) {
super(cache, record.getKey()); super(cache, record.getKey());
this.record = record; this.record = record;
@ -166,7 +166,7 @@ public class MarkupItemStorageDB extends DatabaseObject implements MarkupItemSto
} }
@Override @Override
protected boolean refresh(Record matchRecord) { protected boolean refresh(DBRecord matchRecord) {
if (matchRecord == null) { if (matchRecord == null) {
matchRecord = associationManager.getMarkupItemRecord(key); matchRecord = associationManager.getMarkupItemRecord(key);
} }

View file

@ -49,7 +49,7 @@ public class VTAddressCorrelationAdapterV0 extends VTAddressCorrelatorAdapter {
@Override @Override
void createAddressRecord(long sourceEntryLong, long sourceLong,long destinationLong) throws IOException { void createAddressRecord(long sourceEntryLong, long sourceLong,long destinationLong) throws IOException {
Record record = TABLE_SCHEMA.createRecord(table.getKey()); DBRecord record = TABLE_SCHEMA.createRecord(table.getKey());
record.setLongValue(SOURCE_ENTRY_COL.column(), sourceLong); record.setLongValue(SOURCE_ENTRY_COL.column(), sourceLong);
record.setLongValue(SOURCE_ADDRESS_COL.column(), sourceLong); record.setLongValue(SOURCE_ADDRESS_COL.column(), sourceLong);
@ -59,10 +59,10 @@ public class VTAddressCorrelationAdapterV0 extends VTAddressCorrelatorAdapter {
} }
@Override @Override
List<Record> getAddressRecords(long sourceEntryLong) throws IOException { List<DBRecord> getAddressRecords(long sourceEntryLong) throws IOException {
LongField value = new LongField(sourceEntryLong); LongField value = new LongField(sourceEntryLong);
RecordIterator indexIterator = table.indexIterator(0, value, value, true); RecordIterator indexIterator = table.indexIterator(0, value, value, true);
List<Record>records = new ArrayList<Record>(); List<DBRecord>records = new ArrayList<DBRecord>();
while(indexIterator.hasNext()) { while(indexIterator.hasNext()) {
records.add(indexIterator.next()); records.add(indexIterator.next());
} }

View file

@ -61,7 +61,7 @@ public abstract class VTAddressCorrelatorAdapter {
abstract void createAddressRecord(long sourceEntryLong, long sourceLong, long destinationLong) abstract void createAddressRecord(long sourceEntryLong, long sourceLong, long destinationLong)
throws IOException; throws IOException;
abstract List<Record> getAddressRecords(long sourceEntryLong) throws IOException; abstract List<DBRecord> getAddressRecords(long sourceEntryLong) throws IOException;
void close() { void close() {
dbHandle.close(); dbHandle.close();

View file

@ -19,7 +19,7 @@ import static ghidra.feature.vt.api.db.VTAssociationTableDBAdapter.AssociationTa
import java.util.Collection; import java.util.Collection;
import db.Record; import db.DBRecord;
import ghidra.feature.vt.api.impl.MarkupItemManagerImpl; import ghidra.feature.vt.api.impl.MarkupItemManagerImpl;
import ghidra.feature.vt.api.impl.VTChangeManager; import ghidra.feature.vt.api.impl.VTChangeManager;
import ghidra.feature.vt.api.main.*; import ghidra.feature.vt.api.main.*;
@ -32,12 +32,12 @@ import ghidra.util.task.TaskMonitor;
public class VTAssociationDB extends DatabaseObject implements VTAssociation { public class VTAssociationDB extends DatabaseObject implements VTAssociation {
public Record record; public DBRecord record;
private MarkupItemManagerImpl markupManager; private MarkupItemManagerImpl markupManager;
public final AssociationDatabaseManager associationDBM; public final AssociationDatabaseManager associationDBM;
public VTAssociationDB(AssociationDatabaseManager associationManager, public VTAssociationDB(AssociationDatabaseManager associationManager,
DBObjectCache<VTAssociationDB> cache, Record record) { DBObjectCache<VTAssociationDB> cache, DBRecord record) {
super(cache, record.getKey()); super(cache, record.getKey());
this.associationDBM = associationManager; this.associationDBM = associationManager;
this.record = record; this.record = record;
@ -80,7 +80,7 @@ public class VTAssociationDB extends DatabaseObject implements VTAssociation {
} }
@Override @Override
protected boolean refresh(Record associationRecord) { protected boolean refresh(DBRecord associationRecord) {
if (associationRecord == null) { if (associationRecord == null) {
associationRecord = associationDBM.getAssociationRecord(key); associationRecord = associationDBM.getAssociationRecord(key);
} }
@ -158,7 +158,7 @@ public class VTAssociationDB extends DatabaseObject implements VTAssociation {
} }
} }
Record getRecord() { DBRecord getRecord() {
associationDBM.lock.acquire(); associationDBM.lock.acquire();
try { try {
checkIsValid(); checkIsValid();

View file

@ -56,7 +56,7 @@ public abstract class VTAssociationTableDBAdapter {
return new VTAssociationTableDBAdapterV0(dbHandle, openMode, monitor); return new VTAssociationTableDBAdapterV0(dbHandle, openMode, monitor);
} }
abstract Record insertRecord(long sourceAddressID, long destinationAddressID, abstract DBRecord insertRecord(long sourceAddressID, long destinationAddressID,
VTAssociationType type, VTAssociationStatus status, int voteCount) throws IOException; VTAssociationType type, VTAssociationStatus status, int voteCount) throws IOException;
abstract void deleteRecord(long sourceAddressID) throws IOException; abstract void deleteRecord(long sourceAddressID) throws IOException;
@ -70,18 +70,18 @@ public abstract class VTAssociationTableDBAdapter {
abstract RecordIterator getRecords() throws IOException; abstract RecordIterator getRecords() throws IOException;
abstract Record getRecord(long key) throws IOException; abstract DBRecord getRecord(long key) throws IOException;
abstract Set<Record> getRelatedAssociationRecordsBySourceAndDestinationAddress( abstract Set<DBRecord> getRelatedAssociationRecordsBySourceAndDestinationAddress(
long sourceAddressID, long destinationAddressID) throws IOException; long sourceAddressID, long destinationAddressID) throws IOException;
abstract Set<Record> getRelatedAssociationRecordsBySourceAddress(long sourceAddressID) abstract Set<DBRecord> getRelatedAssociationRecordsBySourceAddress(long sourceAddressID)
throws IOException; throws IOException;
abstract Set<Record> getRelatedAssociationRecordsByDestinationAddress(long destinationAddressID) abstract Set<DBRecord> getRelatedAssociationRecordsByDestinationAddress(long destinationAddressID)
throws IOException; throws IOException;
abstract void updateRecord(Record record) throws IOException; abstract void updateRecord(DBRecord record) throws IOException;
abstract void removeAssociaiton(long id) throws IOException; abstract void removeAssociaiton(long id) throws IOException;
} }

View file

@ -49,9 +49,9 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
} }
@Override @Override
Record insertRecord(long sourceAddressID, long destinationAddressID, VTAssociationType type, DBRecord insertRecord(long sourceAddressID, long destinationAddressID, VTAssociationType type,
VTAssociationStatus lockedStatus, int voteCount) throws IOException { VTAssociationStatus lockedStatus, int voteCount) throws IOException {
Record record = TABLE_SCHEMA.createRecord(table.getKey()); DBRecord record = TABLE_SCHEMA.createRecord(table.getKey());
record.setLongValue(SOURCE_ADDRESS_COL.column(), sourceAddressID); record.setLongValue(SOURCE_ADDRESS_COL.column(), sourceAddressID);
record.setLongValue(DESTINATION_ADDRESS_COL.column(), destinationAddressID); record.setLongValue(DESTINATION_ADDRESS_COL.column(), destinationAddressID);
record.setByteValue(TYPE_COL.column(), (byte) type.ordinal()); record.setByteValue(TYPE_COL.column(), (byte) type.ordinal());
@ -67,7 +67,7 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
} }
@Override @Override
Record getRecord(long key) throws IOException { DBRecord getRecord(long key) throws IOException {
return table.getRecord(key); return table.getRecord(key);
} }
@ -94,9 +94,9 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
} }
@Override @Override
Set<Record> getRelatedAssociationRecordsBySourceAndDestinationAddress(long sourceAddressID, Set<DBRecord> getRelatedAssociationRecordsBySourceAndDestinationAddress(long sourceAddressID,
long destinationAddressID) throws IOException { long destinationAddressID) throws IOException {
Set<Record> recordSet = new HashSet<Record>(); Set<DBRecord> recordSet = new HashSet<DBRecord>();
RecordIterator iterator = getRecordsForSourceAddress(sourceAddressID); RecordIterator iterator = getRecordsForSourceAddress(sourceAddressID);
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -112,9 +112,9 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
} }
@Override @Override
Set<Record> getRelatedAssociationRecordsBySourceAddress(long sourceAddressID) Set<DBRecord> getRelatedAssociationRecordsBySourceAddress(long sourceAddressID)
throws IOException { throws IOException {
Set<Record> recordSet = new HashSet<Record>(); Set<DBRecord> recordSet = new HashSet<DBRecord>();
RecordIterator iterator = getRecordsForSourceAddress(sourceAddressID); RecordIterator iterator = getRecordsForSourceAddress(sourceAddressID);
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -125,9 +125,9 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
} }
@Override @Override
Set<Record> getRelatedAssociationRecordsByDestinationAddress(long destinationAddressID) Set<DBRecord> getRelatedAssociationRecordsByDestinationAddress(long destinationAddressID)
throws IOException { throws IOException {
Set<Record> recordSet = new HashSet<Record>(); Set<DBRecord> recordSet = new HashSet<DBRecord>();
RecordIterator iterator = getRecordsForDestinationAddress(destinationAddressID); RecordIterator iterator = getRecordsForDestinationAddress(destinationAddressID);
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -138,7 +138,7 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
} }
@Override @Override
void updateRecord(Record record) throws IOException { void updateRecord(DBRecord record) throws IOException {
table.putRecord(record); table.putRecord(record);
} }

View file

@ -19,7 +19,7 @@ import static ghidra.feature.vt.api.db.VTMatchTableDBAdapter.ColumnDescription.*
import java.io.IOException; import java.io.IOException;
import db.Record; import db.DBRecord;
import ghidra.feature.vt.api.impl.VTChangeManager; import ghidra.feature.vt.api.impl.VTChangeManager;
import ghidra.feature.vt.api.impl.VTProgramCorrelatorInfo; import ghidra.feature.vt.api.impl.VTProgramCorrelatorInfo;
import ghidra.feature.vt.api.main.*; import ghidra.feature.vt.api.main.*;
@ -32,7 +32,7 @@ import ghidra.util.exception.AssertException;
public class VTMatchDB extends DatabaseObject implements VTMatch { public class VTMatchDB extends DatabaseObject implements VTMatch {
private Record record; private DBRecord record;
private final VTMatchSetDB matchSet; private final VTMatchSetDB matchSet;
private VTSessionDB session; private VTSessionDB session;
private VTAssociation association; private VTAssociation association;
@ -42,7 +42,7 @@ public class VTMatchDB extends DatabaseObject implements VTMatch {
private boolean doCalculateHash = true; private boolean doCalculateHash = true;
private int hash; private int hash;
public VTMatchDB(DBObjectCache<VTMatchDB> cache, Record record, VTMatchSetDB matchSet) { public VTMatchDB(DBObjectCache<VTMatchDB> cache, DBRecord record, VTMatchSetDB matchSet) {
super(cache, record.getKey()); super(cache, record.getKey());
this.record = record; this.record = record;
this.matchSet = matchSet; this.matchSet = matchSet;
@ -56,7 +56,7 @@ public class VTMatchDB extends DatabaseObject implements VTMatch {
} }
@Override @Override
protected boolean refresh(Record matchRecord) { protected boolean refresh(DBRecord matchRecord) {
association = null; association = null;
if (matchRecord == null) { if (matchRecord == null) {
matchRecord = matchSet.getMatchRecord(key); matchRecord = matchSet.getMatchRecord(key);

View file

@ -61,13 +61,13 @@ public abstract class VTMatchMarkupItemTableDBAdapter {
public abstract void removeMatchMarkupItemRecord(long key) throws IOException; public abstract void removeMatchMarkupItemRecord(long key) throws IOException;
public abstract Record getRecord(long key) throws IOException; public abstract DBRecord getRecord(long key) throws IOException;
public abstract RecordIterator getRecords(long AssociationKey) throws IOException; public abstract RecordIterator getRecords(long AssociationKey) throws IOException;
abstract void updateRecord(Record record) throws IOException; abstract void updateRecord(DBRecord record) throws IOException;
public abstract int getRecordCount(); public abstract int getRecordCount();
public abstract Record createMarkupItemRecord(MarkupItemStorage markupItem) throws IOException; public abstract DBRecord createMarkupItemRecord(MarkupItemStorage markupItem) throws IOException;
} }

View file

@ -59,9 +59,9 @@ public class VTMatchMarkupItemTableDBAdapterV0 extends VTMatchMarkupItemTableDBA
} }
@Override @Override
public Record createMarkupItemRecord(MarkupItemStorage markupItem) throws IOException { public DBRecord createMarkupItemRecord(MarkupItemStorage markupItem) throws IOException {
Record record = TABLE_SCHEMA.createRecord(table.getKey()); DBRecord record = TABLE_SCHEMA.createRecord(table.getKey());
VTAssociationDB association = (VTAssociationDB) markupItem.getAssociation(); VTAssociationDB association = (VTAssociationDB) markupItem.getAssociation();
VTSession manager = association.getSession(); VTSession manager = association.getSession();
@ -113,12 +113,12 @@ public class VTMatchMarkupItemTableDBAdapterV0 extends VTMatchMarkupItemTableDBA
} }
@Override @Override
public Record getRecord(long key) throws IOException { public DBRecord getRecord(long key) throws IOException {
return table.getRecord(key); return table.getRecord(key);
} }
@Override @Override
void updateRecord(Record record) throws IOException { void updateRecord(DBRecord record) throws IOException {
table.putRecord(record); table.putRecord(record);
} }

View file

@ -44,7 +44,7 @@ import ghidra.util.xml.XmlUtilities;
public class VTMatchSetDB extends DatabaseObject implements VTMatchSet { public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
private final Record matchSetRecord; private final DBRecord matchSetRecord;
private DBObjectCache<VTMatchDB> matchCache; private DBObjectCache<VTMatchDB> matchCache;
private final VTSessionDB session; private final VTSessionDB session;
@ -56,7 +56,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
private ProgramCorrelatorInfoImpl correlatorInfo; private ProgramCorrelatorInfoImpl correlatorInfo;
private Options options; private Options options;
public static VTMatchSetDB createMatchSetDB(Record record, VTSessionDB session, public static VTMatchSetDB createMatchSetDB(DBRecord record, VTSessionDB session,
DBHandle dbHandle, Lock lock) throws IOException { DBHandle dbHandle, Lock lock) throws IOException {
VTMatchSetDB matchSetDB = new VTMatchSetDB(record, session, dbHandle, lock); VTMatchSetDB matchSetDB = new VTMatchSetDB(record, session, dbHandle, lock);
@ -64,7 +64,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
return matchSetDB; return matchSetDB;
} }
public static VTMatchSetDB getMatchSetDB(Record record, VTSessionDB session, DBHandle dbHandle, public static VTMatchSetDB getMatchSetDB(DBRecord record, VTSessionDB session, DBHandle dbHandle,
OpenMode openMode, TaskMonitor monitor, Lock lock) throws VersionException { OpenMode openMode, TaskMonitor monitor, Lock lock) throws VersionException {
VTMatchSetDB matchSetDB = new VTMatchSetDB(record, session, dbHandle, lock); VTMatchSetDB matchSetDB = new VTMatchSetDB(record, session, dbHandle, lock);
@ -72,7 +72,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
return matchSetDB; return matchSetDB;
} }
private VTMatchSetDB(Record record, VTSessionDB session, DBHandle dbHandle, Lock lock) { private VTMatchSetDB(DBRecord record, VTSessionDB session, DBHandle dbHandle, Lock lock) {
super(null, record.getKey());// cache not supported super(null, record.getKey());// cache not supported
this.matchSetRecord = record; this.matchSetRecord = record;
this.session = session; this.session = session;
@ -166,7 +166,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
try { try {
lock.acquire(); lock.acquire();
VTMatchTagDB tagDB = session.getOrCreateMatchTagDB(tag); VTMatchTagDB tagDB = session.getOrCreateMatchTagDB(tag);
Record matchRecord = DBRecord matchRecord =
matchTableAdapter.insertMatchRecord(info, this, associationDB, tagDB); matchTableAdapter.insertMatchRecord(info, this, associationDB, tagDB);
newMatch = getMatchForRecord(matchRecord); newMatch = getMatchForRecord(matchRecord);
} }
@ -242,7 +242,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
lock.acquire(); lock.acquire();
RecordIterator iterator = matchTableAdapter.getRecords(); RecordIterator iterator = matchTableAdapter.getRecords();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Record nextRecord = iterator.next(); DBRecord nextRecord = iterator.next();
list.add(getMatchForRecord(nextRecord)); list.add(getMatchForRecord(nextRecord));
} }
} }
@ -265,7 +265,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
try { try {
RecordIterator iterator = matchTableAdapter.getRecords(associationDB.getKey()); RecordIterator iterator = matchTableAdapter.getRecords(associationDB.getKey());
while (iterator.hasNext()) { while (iterator.hasNext()) {
Record nextRecord = iterator.next(); DBRecord nextRecord = iterator.next();
VTMatch match = getMatchForRecord(nextRecord); VTMatch match = getMatchForRecord(nextRecord);
list.add(match); list.add(match);
} }
@ -297,7 +297,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
return session.getMatchSetRecord(key) == null; return session.getMatchSetRecord(key) == null;
} }
private VTMatch getMatchForRecord(Record matchRecord) { private VTMatch getMatchForRecord(DBRecord matchRecord) {
try { try {
lock.acquire(); lock.acquire();
VTMatchDB match = matchCache.get(matchRecord); VTMatchDB match = matchCache.get(matchRecord);
@ -311,7 +311,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
} }
} }
Record getMatchRecord(long matchRecordKey) { DBRecord getMatchRecord(long matchRecordKey) {
try { try {
return matchTableAdapter.getMatchRecord(matchRecordKey); return matchTableAdapter.getMatchRecord(matchRecordKey);
} }

View file

@ -80,18 +80,18 @@ public abstract class VTMatchSetTableDBAdapter {
return new VTMatchSetTableDBAdapterV0(dbHandle, openMode); return new VTMatchSetTableDBAdapterV0(dbHandle, openMode);
} }
public abstract Record createMatchSetRecord(long key, VTProgramCorrelator correlator) public abstract DBRecord createMatchSetRecord(long key, VTProgramCorrelator correlator)
throws IOException; throws IOException;
public abstract RecordIterator getRecords() throws IOException; public abstract RecordIterator getRecords() throws IOException;
public abstract AddressSet getSourceAddressSet(Record record, AddressMap addressMap) public abstract AddressSet getSourceAddressSet(DBRecord record, AddressMap addressMap)
throws IOException; throws IOException;
public abstract AddressSet getDestinationAddressSet(Record record, AddressMap addressMap) public abstract AddressSet getDestinationAddressSet(DBRecord record, AddressMap addressMap)
throws IOException; throws IOException;
public abstract long getNextMatchSetID(); public abstract long getNextMatchSetID();
public abstract Record getRecord(long key) throws IOException; public abstract DBRecord getRecord(long key) throws IOException;
} }

View file

@ -60,9 +60,9 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
} }
@Override @Override
public Record createMatchSetRecord(long key, VTProgramCorrelator correlator) public DBRecord createMatchSetRecord(long key, VTProgramCorrelator correlator)
throws IOException { throws IOException {
Record record = TABLE_SCHEMA.createRecord(key); DBRecord record = TABLE_SCHEMA.createRecord(key);
record.setString(CORRELATOR_CLASS_COL.column(), correlator.getClass().getName()); record.setString(CORRELATOR_CLASS_COL.column(), correlator.getClass().getName());
record.setString(CORRELATOR_NAME_COL.column(), correlator.getName()); record.setString(CORRELATOR_NAME_COL.column(), correlator.getName());
@ -91,7 +91,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
return null; return null;
} }
private void createSourceAddressSetTable(VTProgramCorrelator correlator, Record record) private void createSourceAddressSetTable(VTProgramCorrelator correlator, DBRecord record)
throws IOException { throws IOException {
Program program = correlator.getSourceProgram(); Program program = correlator.getSourceProgram();
@ -101,7 +101,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
writeAddressSet(addressSet, tableName, program.getAddressMap()); writeAddressSet(addressSet, tableName, program.getAddressMap());
} }
private void createDestinationAddressSetTable(VTProgramCorrelator correlator, Record record) private void createDestinationAddressSetTable(VTProgramCorrelator correlator, DBRecord record)
throws IOException { throws IOException {
Program program = correlator.getDestinationProgram(); Program program = correlator.getDestinationProgram();
@ -111,11 +111,11 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
writeAddressSet(addressSet, tableName, program.getAddressMap()); writeAddressSet(addressSet, tableName, program.getAddressMap());
} }
private String getSourceTableName(Record record) { private String getSourceTableName(DBRecord record) {
return "Source Address Set " + record.getKey(); return "Source Address Set " + record.getKey();
} }
private String getDestinationTableName(Record record) { private String getDestinationTableName(DBRecord record) {
return "Destination Address Set " + record.getKey(); return "Destination Address Set " + record.getKey();
} }
@ -125,7 +125,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
} }
@Override @Override
public Record getRecord(long key) throws IOException { public DBRecord getRecord(long key) throws IOException {
return table.getRecord(key); return table.getRecord(key);
} }
@ -134,7 +134,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
if (set != null) { if (set != null) {
Table addressSetTable = dbHandle.createTable(tableName, STORED_ADDRESS_RANGE_SCHEMA); Table addressSetTable = dbHandle.createTable(tableName, STORED_ADDRESS_RANGE_SCHEMA);
Record rec = STORED_ADDRESS_RANGE_SCHEMA.createRecord(0); DBRecord rec = STORED_ADDRESS_RANGE_SCHEMA.createRecord(0);
int rangeKey = 1; int rangeKey = 1;
for (KeyRange range : addressMap.getKeyRanges(set, false, false)) { for (KeyRange range : addressMap.getKeyRanges(set, false, false)) {
rec.setKey(rangeKey++); rec.setKey(rangeKey++);
@ -146,17 +146,17 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
} }
@Override @Override
public AddressSet getDestinationAddressSet(Record record, AddressMap addressMap) public AddressSet getDestinationAddressSet(DBRecord record, AddressMap addressMap)
throws IOException { throws IOException {
return readAddressSet(record, getDestinationTableName(record), addressMap); return readAddressSet(record, getDestinationTableName(record), addressMap);
} }
@Override @Override
public AddressSet getSourceAddressSet(Record record, AddressMap addressMap) throws IOException { public AddressSet getSourceAddressSet(DBRecord record, AddressMap addressMap) throws IOException {
return readAddressSet(record, getSourceTableName(record), addressMap); return readAddressSet(record, getSourceTableName(record), addressMap);
} }
private AddressSet readAddressSet(Record record, String tableName, AddressMap addressMap) private AddressSet readAddressSet(DBRecord record, String tableName, AddressMap addressMap)
throws IOException { throws IOException {
Table addressSetTable = dbHandle.getTable(tableName); Table addressSetTable = dbHandle.getTable(tableName);
@ -168,7 +168,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
RecordIterator it = addressSetTable.iterator(); RecordIterator it = addressSetTable.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
Address addr1 = addressMap.decodeAddress(rec.getLongValue(0)); Address addr1 = addressMap.decodeAddress(rec.getLongValue(0));
Address addr2 = addressMap.decodeAddress(rec.getLongValue(1)); Address addr2 = addressMap.decodeAddress(rec.getLongValue(1));
addressSet.addRange(addr1, addr2); addressSet.addRange(addr1, addr2);

View file

@ -82,16 +82,16 @@ public abstract class VTMatchTableDBAdapter {
return new VTMatchTableDBAdapterV0(dbHandle, tableID, openMode, monitor); return new VTMatchTableDBAdapterV0(dbHandle, tableID, openMode, monitor);
} }
public abstract Record insertMatchRecord(VTMatchInfo info, VTMatchSetDB matchSet, public abstract DBRecord insertMatchRecord(VTMatchInfo info, VTMatchSetDB matchSet,
VTAssociationDB associationDB, VTMatchTagDB tag) throws IOException; VTAssociationDB associationDB, VTMatchTagDB tag) throws IOException;
public abstract RecordIterator getRecords() throws IOException; public abstract RecordIterator getRecords() throws IOException;
abstract Record getMatchRecord(long matchRecordKey) throws IOException; abstract DBRecord getMatchRecord(long matchRecordKey) throws IOException;
abstract int getRecordCount(); abstract int getRecordCount();
abstract void updateRecord(Record record) throws IOException; abstract void updateRecord(DBRecord record) throws IOException;
abstract boolean deleteRecord(long matchRecordKey) throws IOException; abstract boolean deleteRecord(long matchRecordKey) throws IOException;

View file

@ -51,10 +51,10 @@ public class VTMatchTableDBAdapterV0 extends VTMatchTableDBAdapter {
} }
@Override @Override
public Record insertMatchRecord(VTMatchInfo info, VTMatchSetDB matchSet, public DBRecord insertMatchRecord(VTMatchInfo info, VTMatchSetDB matchSet,
VTAssociationDB association, VTMatchTagDB tag) throws IOException { VTAssociationDB association, VTMatchTagDB tag) throws IOException {
Record record = TABLE_SCHEMA.createRecord(table.getKey()); DBRecord record = TABLE_SCHEMA.createRecord(table.getKey());
record.setLongValue(TAG_KEY_COL.column(), (tag == null) ? -1 : tag.getKey()); record.setLongValue(TAG_KEY_COL.column(), (tag == null) ? -1 : tag.getKey());
record.setString(SIMILARITY_SCORE_COL.column(), info.getSimilarityScore().toStorageString()); record.setString(SIMILARITY_SCORE_COL.column(), info.getSimilarityScore().toStorageString());
@ -68,7 +68,7 @@ public class VTMatchTableDBAdapterV0 extends VTMatchTableDBAdapter {
} }
@Override @Override
Record getMatchRecord(long matchRecordKey) throws IOException { DBRecord getMatchRecord(long matchRecordKey) throws IOException {
return table.getRecord(matchRecordKey); return table.getRecord(matchRecordKey);
} }
@ -83,7 +83,7 @@ public class VTMatchTableDBAdapterV0 extends VTMatchTableDBAdapter {
} }
@Override @Override
void updateRecord(Record record) throws IOException { void updateRecord(DBRecord record) throws IOException {
table.putRecord(record); table.putRecord(record);
} }

View file

@ -19,7 +19,7 @@ import static ghidra.feature.vt.api.db.VTMatchTagDBAdapter.ColumnDescription.TAG
import java.io.IOException; import java.io.IOException;
import db.Record; import db.DBRecord;
import ghidra.feature.vt.api.main.VTMatchTag; import ghidra.feature.vt.api.main.VTMatchTag;
import ghidra.program.database.DBObjectCache; import ghidra.program.database.DBObjectCache;
import ghidra.program.database.DatabaseObject; import ghidra.program.database.DatabaseObject;
@ -30,9 +30,9 @@ import ghidra.program.database.DatabaseObject;
public class VTMatchTagDB extends DatabaseObject implements VTMatchTag { public class VTMatchTagDB extends DatabaseObject implements VTMatchTag {
private VTSessionDB sessionDB; private VTSessionDB sessionDB;
private Record record; private DBRecord record;
VTMatchTagDB(VTSessionDB sessionDB, DBObjectCache<VTMatchTagDB> cache, Record record) { VTMatchTagDB(VTSessionDB sessionDB, DBObjectCache<VTMatchTagDB> cache, DBRecord record) {
super(cache, record.getKey()); super(cache, record.getKey());
this.sessionDB = sessionDB; this.sessionDB = sessionDB;
this.record = record; this.record = record;
@ -47,7 +47,7 @@ public class VTMatchTagDB extends DatabaseObject implements VTMatchTag {
* Update associated record * Update associated record
* @param rec the new record information * @param rec the new record information
*/ */
void setRecord(Record rec) { void setRecord(DBRecord rec) {
if (rec.getKey() != key) { if (rec.getKey() != key) {
throw new IllegalArgumentException("Key mismatch"); throw new IllegalArgumentException("Key mismatch");
} }
@ -56,7 +56,7 @@ public class VTMatchTagDB extends DatabaseObject implements VTMatchTag {
@Override @Override
protected boolean refresh() { protected boolean refresh() {
Record rec = null; DBRecord rec = null;
try { try {
rec = sessionDB.getTagRecord(key); rec = sessionDB.getTagRecord(key);
} }
@ -74,7 +74,7 @@ public class VTMatchTagDB extends DatabaseObject implements VTMatchTag {
* Returns record associated with this match tag or * Returns record associated with this match tag or
* null if the match tag has been deleted. * null if the match tag has been deleted.
*/ */
Record getRecord() { DBRecord getRecord() {
return checkIsValid() ? record : null; return checkIsValid() ? record : null;
} }

View file

@ -77,15 +77,15 @@ public abstract class VTMatchTagDBAdapter {
return new VTMatchTagDBAdapterV0(dbHandle, openMode, monitor); return new VTMatchTagDBAdapterV0(dbHandle, openMode, monitor);
} }
public abstract Record insertRecord(String tagName) throws IOException; public abstract DBRecord insertRecord(String tagName) throws IOException;
public abstract RecordIterator getRecords() throws IOException; public abstract RecordIterator getRecords() throws IOException;
abstract Record getRecord(long tagRecordKey) throws IOException; abstract DBRecord getRecord(long tagRecordKey) throws IOException;
abstract int getRecordCount(); abstract int getRecordCount();
abstract void updateRecord(Record record) throws IOException; abstract void updateRecord(DBRecord record) throws IOException;
abstract boolean deleteRecord(long tagRecordKey) throws IOException; abstract boolean deleteRecord(long tagRecordKey) throws IOException;
} }

View file

@ -48,7 +48,7 @@ public class VTMatchTagDBAdapterV0 extends VTMatchTagDBAdapter {
} }
@Override @Override
public Record insertRecord(String tagName) throws IOException { public DBRecord insertRecord(String tagName) throws IOException {
if (tagName == null) { if (tagName == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -59,7 +59,7 @@ public class VTMatchTagDBAdapterV0 extends VTMatchTagDBAdapter {
throw new IllegalArgumentException("Cannot create an empty string tag"); throw new IllegalArgumentException("Cannot create an empty string tag");
} }
Record record = TABLE_SCHEMA.createRecord(table.getKey()); DBRecord record = TABLE_SCHEMA.createRecord(table.getKey());
record.setString(TAG_NAME_COL.column(), tagName); record.setString(TAG_NAME_COL.column(), tagName);
table.putRecord(record); table.putRecord(record);
@ -67,7 +67,7 @@ public class VTMatchTagDBAdapterV0 extends VTMatchTagDBAdapter {
} }
@Override @Override
Record getRecord(long tagRecordKey) throws IOException { DBRecord getRecord(long tagRecordKey) throws IOException {
return table.getRecord(tagRecordKey); return table.getRecord(tagRecordKey);
} }
@ -82,7 +82,7 @@ public class VTMatchTagDBAdapterV0 extends VTMatchTagDBAdapter {
} }
@Override @Override
void updateRecord(Record record) throws IOException { void updateRecord(DBRecord record) throws IOException {
table.putRecord(record); table.putRecord(record);
} }

View file

@ -123,7 +123,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
} }
private void updateVersion() throws IOException { private void updateVersion() throws IOException {
Record record = SCHEMA.createRecord(new StringField(DB_VERSION_PROPERTY_NAME)); DBRecord record = SCHEMA.createRecord(new StringField(DB_VERSION_PROPERTY_NAME));
record.setString(0, Integer.toString(DB_VERSION)); record.setString(0, Integer.toString(DB_VERSION));
propertyTable.putRecord(record); propertyTable.putRecord(record);
} }
@ -220,7 +220,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
if (propertyTable == null) { if (propertyTable == null) {
return 0; return 0;
} }
Record record = propertyTable.getRecord(new StringField(DB_VERSION_PROPERTY_NAME)); DBRecord record = propertyTable.getRecord(new StringField(DB_VERSION_PROPERTY_NAME));
if (record != null) { if (record != null) {
String s = record.getString(0); String s = record.getString(0);
@ -365,7 +365,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
throws IOException, VersionException { throws IOException, VersionException {
RecordIterator recordIterator = matchSetTableAdapter.getRecords(); RecordIterator recordIterator = matchSetTableAdapter.getRecords();
while (recordIterator.hasNext()) { while (recordIterator.hasNext()) {
Record record = recordIterator.next(); DBRecord record = recordIterator.next();
matchSets.add( matchSets.add(
VTMatchSetDB.getMatchSetDB(record, this, getDBHandle(), openMode, monitor, lock)); VTMatchSetDB.getMatchSetDB(record, this, getDBHandle(), openMode, monitor, lock));
} }
@ -395,7 +395,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
private VTMatchSet createMatchSet(VTProgramCorrelator correlator, long id) { private VTMatchSet createMatchSet(VTProgramCorrelator correlator, long id) {
try { try {
Record record = matchSetTableAdapter.createMatchSetRecord(id, correlator); DBRecord record = matchSetTableAdapter.createMatchSetRecord(id, correlator);
VTMatchSetDB matchSet = VTMatchSetDB matchSet =
VTMatchSetDB.createMatchSetDB(record, this, getDBHandle(), lock); VTMatchSetDB.createMatchSetDB(record, this, getDBHandle(), lock);
matchSets.add(matchSet); matchSets.add(matchSet);
@ -411,7 +411,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
return null; return null;
} }
Record getMatchSetRecord(long key) { DBRecord getMatchSetRecord(long key) {
try { try {
return matchSetTableAdapter.getRecord(key); return matchSetTableAdapter.getRecord(key);
} }
@ -462,11 +462,11 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
return new ArrayList<>(matchSets); return new ArrayList<>(matchSets);
} }
AddressSet getSourceAddressSet(Record record) throws IOException { AddressSet getSourceAddressSet(DBRecord record) throws IOException {
return matchSetTableAdapter.getSourceAddressSet(record, sourceProgram.getAddressMap()); return matchSetTableAdapter.getSourceAddressSet(record, sourceProgram.getAddressMap());
} }
AddressSet getDestinationAddressSet(Record record) throws IOException { AddressSet getDestinationAddressSet(DBRecord record) throws IOException {
return matchSetTableAdapter.getDestinationAddressSet(record, return matchSetTableAdapter.getDestinationAddressSet(record,
destinationProgram.getAddressMap()); destinationProgram.getAddressMap());
} }
@ -596,7 +596,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
if (matchTag != null) { if (matchTag != null) {
return matchTag; return matchTag;
} }
Record record = matchTagAdapter.insertRecord(tagName); DBRecord record = matchTagAdapter.insertRecord(tagName);
matchTag = new VTMatchTagDB(this, tagCache, record); matchTag = new VTMatchTagDB(this, tagCache, record);
} }
catch (IOException e) { catch (IOException e) {
@ -627,7 +627,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
lock.acquire(); lock.acquire();
RecordIterator records = matchTagAdapter.getRecords(); RecordIterator records = matchTagAdapter.getRecords();
while (records.hasNext()) { while (records.hasNext()) {
Record record = records.next(); DBRecord record = records.next();
tags.add(getMatchTagNew(record)); tags.add(getMatchTagNew(record));
} }
} }
@ -640,7 +640,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
return tags; return tags;
} }
private VTMatchTagDB getMatchTagNew(Record record) { private VTMatchTagDB getMatchTagNew(DBRecord record) {
if (record == null) { if (record == null) {
throw new AssertException("How can we have a null record?!!!"); throw new AssertException("How can we have a null record?!!!");
} }
@ -666,7 +666,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
if (matchTagDB != null) { if (matchTagDB != null) {
return matchTagDB; return matchTagDB;
} }
Record record = matchTagAdapter.getRecord(key); DBRecord record = matchTagAdapter.getRecord(key);
if (record != null) { if (record != null) {
return new VTMatchTagDB(this, tagCache, record); return new VTMatchTagDB(this, tagCache, record);
} }
@ -680,7 +680,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
return VTMatchTag.UNTAGGED; return VTMatchTag.UNTAGGED;
} }
Record getTagRecord(long key) throws IOException { DBRecord getTagRecord(long key) throws IOException {
return matchTagAdapter.getRecord(key); return matchTagAdapter.getRecord(key);
} }

View file

@ -66,14 +66,14 @@ public abstract class ConvertedRecordIterator implements RecordIterator {
/** /**
* @see db.RecordIterator#next() * @see db.RecordIterator#next()
*/ */
public Record next() throws IOException { public DBRecord next() throws IOException {
return convertRecord(originalIterator.next()); return convertRecord(originalIterator.next());
} }
/** /**
* @see db.RecordIterator#previous() * @see db.RecordIterator#previous()
*/ */
public Record previous() throws IOException { public DBRecord previous() throws IOException {
return convertRecord(originalIterator.previous()); return convertRecord(originalIterator.previous());
} }
@ -82,6 +82,6 @@ public abstract class ConvertedRecordIterator implements RecordIterator {
* @param record * @param record
* @return converted record * @return converted record
*/ */
protected abstract Record convertRecord(Record record); protected abstract DBRecord convertRecord(DBRecord record);
} }

View file

@ -25,7 +25,7 @@ import ghidra.util.exception.AssertException;
* associated with a fixed schema. * associated with a fixed schema.
* A record instance contains both a primary key and zero or more data fields. * A record instance contains both a primary key and zero or more data fields.
*/ */
public class Record implements Comparable<Record> { public class DBRecord implements Comparable<DBRecord> {
final Schema schema; final Schema schema;
@ -41,7 +41,7 @@ public class Record implements Comparable<Record> {
* @param schema record schema * @param schema record schema
* @param key record key * @param key record key
*/ */
Record(Schema schema, Field key) { DBRecord(Schema schema, Field key) {
this.schema = schema; this.schema = schema;
this.key = key; this.key = key;
if (!schema.getKeyFieldType().isSameType(key)) { if (!schema.getKeyFieldType().isSameType(key)) {
@ -107,7 +107,7 @@ public class Record implements Comparable<Record> {
* @param otherRec * @param otherRec
* @return true if records schemas are the same * @return true if records schemas are the same
*/ */
public boolean hasSameSchema(Record otherRec) { public boolean hasSameSchema(DBRecord otherRec) {
Field[] otherFieldValues = otherRec.fieldValues; Field[] otherFieldValues = otherRec.fieldValues;
if (fieldValues.length != otherFieldValues.length) { if (fieldValues.length != otherFieldValues.length) {
return false; return false;
@ -219,8 +219,8 @@ public class Record implements Comparable<Record> {
* Obtain a copy of this record object. * Obtain a copy of this record object.
* @return Record * @return Record
*/ */
public Record copy() { public DBRecord copy() {
Record r = schema.createRecord(key.copyField()); DBRecord r = schema.createRecord(key.copyField());
Field[] fields = r.getFields(); Field[] fields = r.getFields();
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {
r.setField(i, fields[i].copyField()); r.setField(i, fields[i].copyField());
@ -449,10 +449,10 @@ public class Record implements Comparable<Record> {
*/ */
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (!(obj instanceof Record)) { if (!(obj instanceof DBRecord)) {
return false; return false;
} }
Record rec = (Record) obj; DBRecord rec = (DBRecord) obj;
return key.equals(rec.key) && Arrays.equals(fieldValues, rec.fieldValues); return key.equals(rec.key) && Arrays.equals(fieldValues, rec.fieldValues);
} }
@ -462,7 +462,7 @@ public class Record implements Comparable<Record> {
* @see java.lang.Comparable#compareTo(java.lang.Object) * @see java.lang.Comparable#compareTo(java.lang.Object)
*/ */
@Override @Override
public int compareTo(Record otherRec) { public int compareTo(DBRecord otherRec) {
return key.compareTo(otherRec.key); return key.compareTo(otherRec.key);
} }

View file

@ -56,7 +56,7 @@ public class DatabaseUtils {
long keyDiff = newStart - oldStart; long keyDiff = newStart - oldStart;
RecordIterator it = table.iterator(oldStart, oldStart+size-1, oldStart); RecordIterator it = table.iterator(oldStart, oldStart+size-1, oldStart);
while(it.hasNext()) { while(it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
rec.setKey(rec.getKey()+keyDiff); rec.setKey(rec.getKey()+keyDiff);
tmpTable.putRecord(rec); tmpTable.putRecord(rec);
} }
@ -66,7 +66,7 @@ public class DatabaseUtils {
it = tmpTable.iterator(newStart, newStart+size-1, newStart); it = tmpTable.iterator(newStart, newStart+size-1, newStart);
while(it.hasNext()) { while(it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
table.putRecord(rec); table.putRecord(rec);
} }

View file

@ -85,7 +85,7 @@ public class FieldIndexTable extends IndexTable {
} }
if (indexField.usesTruncatedFieldValue()) { if (indexField.usesTruncatedFieldValue()) {
// Must check actual record if index value was truncated // Must check actual record if index value was truncated
Record rec = primaryTable.getRecord(f.getPrimaryKey()); DBRecord rec = primaryTable.getRecord(f.getPrimaryKey());
Field val = rec.getField(indexColumn); Field val = rec.getField(indexColumn);
if (!indexValue.equals(val)) { if (!indexValue.equals(val)) {
continue; continue;
@ -107,18 +107,18 @@ public class FieldIndexTable extends IndexTable {
} }
@Override @Override
void addEntry(Record record) throws IOException { void addEntry(DBRecord record) throws IOException {
Field indexedField = record.getField(indexColumn); Field indexedField = record.getField(indexColumn);
if (isSparseIndex && indexedField.isNull()) { if (isSparseIndex && indexedField.isNull()) {
return; return;
} }
IndexField f = indexKeyType.newIndexField(indexedField, record.getKeyField()); IndexField f = indexKeyType.newIndexField(indexedField, record.getKeyField());
Record rec = indexTable.getSchema().createRecord(f); DBRecord rec = indexTable.getSchema().createRecord(f);
indexTable.putRecord(rec); indexTable.putRecord(rec);
} }
@Override @Override
void deleteEntry(Record record) throws IOException { void deleteEntry(DBRecord record) throws IOException {
Field indexedField = record.getField(indexColumn); Field indexedField = record.getField(indexColumn);
if (isSparseIndex && indexedField.isNull()) { if (isSparseIndex && indexedField.isNull()) {
return; return;
@ -364,7 +364,7 @@ public class FieldIndexTable extends IndexTable {
} }
if (indexField.usesTruncatedFieldValue()) { if (indexField.usesTruncatedFieldValue()) {
// Must check actual record if index value was truncated // Must check actual record if index value was truncated
Record rec = primaryTable.getRecord(f.getPrimaryKey()); DBRecord rec = primaryTable.getRecord(f.getPrimaryKey());
Field val = rec.getField(indexColumn); Field val = rec.getField(indexColumn);
if (!field.equals(val)) { if (!field.equals(val)) {
continue; // skip continue; // skip
@ -510,7 +510,7 @@ public class FieldIndexTable extends IndexTable {
private boolean indexValueOutOfRange(IndexField f) throws IOException { private boolean indexValueOutOfRange(IndexField f) throws IOException {
Field val = null; Field val = null;
if (min != null && min.usesTruncatedFieldValue() && min.hasSameIndexValue(f)) { if (min != null && min.usesTruncatedFieldValue() && min.hasSameIndexValue(f)) {
Record rec = primaryTable.getRecord(f.getPrimaryKey()); DBRecord rec = primaryTable.getRecord(f.getPrimaryKey());
val = rec.getField(indexColumn); val = rec.getField(indexColumn);
if (val.compareTo(min.getNonTruncatedIndexField()) < 0) { if (val.compareTo(min.getNonTruncatedIndexField()) < 0) {
return true; return true;
@ -518,7 +518,7 @@ public class FieldIndexTable extends IndexTable {
} }
if (max != null && max.usesTruncatedFieldValue() && max.hasSameIndexValue(f)) { if (max != null && max.usesTruncatedFieldValue() && max.hasSameIndexValue(f)) {
if (val == null) { if (val == null) {
Record rec = primaryTable.getRecord(f.getPrimaryKey()); DBRecord rec = primaryTable.getRecord(f.getPrimaryKey());
val = rec.getField(indexColumn); val = rec.getField(indexColumn);
} }
if (val.compareTo(min.getNonTruncatedIndexField()) > 0) { if (val.compareTo(min.getNonTruncatedIndexField()) > 0) {

View file

@ -30,7 +30,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
* @return Record * @return Record
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecord(Schema schema, int index) throws IOException; DBRecord getRecord(Schema schema, int index) throws IOException;
/** /**
* Insert or Update a record. * Insert or Update a record.
@ -39,7 +39,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
* @return root node which may have changed. * @return root node which may have changed.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
FieldKeyNode putRecord(Record record, Table table) throws IOException; FieldKeyNode putRecord(DBRecord record, Table table) throws IOException;
/** /**
* Remove the record identified by index. * Remove the record identified by index.
@ -101,7 +101,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecordAtOrAfter(Field key, Schema schema) throws IOException; DBRecord getRecordAtOrAfter(Field key, Schema schema) throws IOException;
/** /**
* Get the record with the maximum key value which is less than or equal * Get the record with the maximum key value which is less than or equal
@ -111,7 +111,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecordAtOrBefore(Field key, Schema schema) throws IOException; DBRecord getRecordAtOrBefore(Field key, Schema schema) throws IOException;
/** /**
* Get the record with the minimum key value which is greater than * Get the record with the minimum key value which is greater than
@ -121,7 +121,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecordAfter(Field key, Schema schema) throws IOException; DBRecord getRecordAfter(Field key, Schema schema) throws IOException;
/** /**
* Get the record with the maximum key value which is less than * Get the record with the maximum key value which is less than
@ -131,7 +131,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecordBefore(Field key, Schema schema) throws IOException; DBRecord getRecordBefore(Field key, Schema schema) throws IOException;
/** /**
* Get the record identified by the specified key. * Get the record identified by the specified key.
@ -140,6 +140,6 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecord(Field key, Schema schema) throws IOException; DBRecord getRecord(Field key, Schema schema) throws IOException;
} }

View file

@ -122,7 +122,7 @@ class FixedKeyFixedRecNode extends FixedKeyRecordNode {
} }
@Override @Override
boolean insertRecord(int index, Record record) throws IOException { boolean insertRecord(int index, DBRecord record) throws IOException {
// Check for use of indirect chained record node(s) // Check for use of indirect chained record node(s)
// int len = record.length(); // int len = record.length();
@ -143,26 +143,26 @@ class FixedKeyFixedRecNode extends FixedKeyRecordNode {
} }
@Override @Override
FixedKeyNode updateRecord(int index, Record record) throws IOException { FixedKeyNode updateRecord(int index, DBRecord record) throws IOException {
int offset = getRecordOffset(index) + keySize; int offset = getRecordOffset(index) + keySize;
record.write(buffer, offset); record.write(buffer, offset);
return getRoot(); return getRoot();
} }
@Override @Override
public Record getRecord(Field key, Schema schema) throws IOException { public DBRecord getRecord(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) if (index < 0)
return null; return null;
Record record = schema.createRecord(key); DBRecord record = schema.createRecord(key);
record.read(buffer, getRecordOffset(index) + keySize); record.read(buffer, getRecordOffset(index) + keySize);
return record; return record;
} }
@Override @Override
public Record getRecord(Schema schema, int index) throws IOException { public DBRecord getRecord(Schema schema, int index) throws IOException {
Field key = getKeyField(index); Field key = getKeyField(index);
Record record = schema.createRecord(key); DBRecord record = schema.createRecord(key);
record.read(buffer, getRecordOffset(index) + keySize); record.read(buffer, getRecordOffset(index) + keySize);
return record; return record;
} }

View file

@ -328,7 +328,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
abstract FixedKeyRecordNode createNewLeaf(int prevNodeId, int nextNodeId) throws IOException; abstract FixedKeyRecordNode createNewLeaf(int prevNodeId, int nextNodeId) throws IOException;
@Override @Override
public FixedKeyNode putRecord(Record record, Table table) throws IOException { public FixedKeyNode putRecord(DBRecord record, Table table) throws IOException {
Field key = record.getKeyField(); Field key = record.getKeyField();
int index = getKeyIndex(key); int index = getKeyIndex(key);
@ -374,7 +374,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
* @return root node which may have changed. * @return root node which may have changed.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
FixedKeyNode appendNewLeaf(Record record) throws IOException { FixedKeyNode appendNewLeaf(DBRecord record) throws IOException {
FixedKeyRecordNode newLeaf = createNewLeaf(-1, -1); FixedKeyRecordNode newLeaf = createNewLeaf(-1, -1);
newLeaf.insertRecord(0, record); newLeaf.insertRecord(0, record);
return appendLeaf(newLeaf); return appendLeaf(newLeaf);
@ -418,7 +418,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
* @return true if the record was successfully inserted. * @return true if the record was successfully inserted.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
abstract boolean insertRecord(int index, Record record) throws IOException; abstract boolean insertRecord(int index, DBRecord record) throws IOException;
/** /**
* Updates the record at the given index. * Updates the record at the given index.
@ -427,10 +427,10 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
* @return root node which may have changed. * @return root node which may have changed.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
abstract FixedKeyNode updateRecord(int index, Record record) throws IOException; abstract FixedKeyNode updateRecord(int index, DBRecord record) throws IOException;
@Override @Override
public db.Record getRecordBefore(Field key, Schema schema) throws IOException { public db.DBRecord getRecordBefore(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -index - 2; index = -index - 2;
@ -446,7 +446,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
} }
@Override @Override
public db.Record getRecordAfter(Field key, Schema schema) throws IOException { public db.DBRecord getRecordAfter(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -(index + 1); index = -(index + 1);
@ -462,7 +462,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
} }
@Override @Override
public Record getRecordAtOrBefore(Field key, Schema schema) throws IOException { public DBRecord getRecordAtOrBefore(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -index - 2; index = -index - 2;
@ -475,7 +475,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
} }
@Override @Override
public Record getRecordAtOrAfter(Field key, Schema schema) throws IOException { public DBRecord getRecordAtOrAfter(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -(index + 1); index = -(index + 1);

View file

@ -191,9 +191,9 @@ class FixedKeyVarRecNode extends FixedKeyRecordNode {
} }
@Override @Override
public Record getRecord(Schema schema, int index) throws IOException { public DBRecord getRecord(Schema schema, int index) throws IOException {
Field key = getKeyField(index); Field key = getKeyField(index);
Record record = schema.createRecord(key); DBRecord record = schema.createRecord(key);
if (hasIndirectStorage(index)) { if (hasIndirectStorage(index)) {
int bufId = buffer.getInt(getRecordDataOffset(index)); int bufId = buffer.getInt(getRecordDataOffset(index));
ChainedBuffer chainedBuffer = new ChainedBuffer(nodeMgr.getBufferMgr(), bufId); ChainedBuffer chainedBuffer = new ChainedBuffer(nodeMgr.getBufferMgr(), bufId);
@ -214,7 +214,7 @@ class FixedKeyVarRecNode extends FixedKeyRecordNode {
} }
@Override @Override
public Record getRecord(Field key, Schema schema) throws IOException { public DBRecord getRecord(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
return null; return null;
@ -279,7 +279,7 @@ class FixedKeyVarRecNode extends FixedKeyRecordNode {
} }
@Override @Override
FixedKeyNode updateRecord(int index, Record record) throws IOException { FixedKeyNode updateRecord(int index, DBRecord record) throws IOException {
int offset = getRecordDataOffset(index); int offset = getRecordDataOffset(index);
int oldLen = getRecordLength(index, offset); int oldLen = getRecordLength(index, offset);
@ -341,7 +341,7 @@ class FixedKeyVarRecNode extends FixedKeyRecordNode {
* @throws IOException thrown if an IO error occurs * @throws IOException thrown if an IO error occurs
*/ */
@Override @Override
boolean insertRecord(int index, Record record) throws IOException { boolean insertRecord(int index, DBRecord record) throws IOException {
// Check for use of indirect chained record node(s) // Check for use of indirect chained record node(s)
int len = record.length(); int len = record.length();

View file

@ -130,7 +130,7 @@ class FixedRecNode extends LongKeyRecordNode {
} }
@Override @Override
boolean insertRecord(int index, Record record) throws IOException { boolean insertRecord(int index, DBRecord record) throws IOException {
if (keyCount == ((buffer.length() - HEADER_SIZE) / entrySize)) { if (keyCount == ((buffer.length() - HEADER_SIZE) / entrySize)) {
return false; // insufficient space for record storage return false; // insufficient space for record storage
@ -149,26 +149,26 @@ class FixedRecNode extends LongKeyRecordNode {
} }
@Override @Override
LongKeyNode updateRecord(int index, Record record) throws IOException { LongKeyNode updateRecord(int index, DBRecord record) throws IOException {
int offset = getRecordOffset(index) + KEY_SIZE; int offset = getRecordOffset(index) + KEY_SIZE;
record.write(buffer, offset); record.write(buffer, offset);
return getRoot(); return getRoot();
} }
@Override @Override
Record getRecord(long key, Schema schema) throws IOException { DBRecord getRecord(long key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) if (index < 0)
return null; return null;
Record record = schema.createRecord(key); DBRecord record = schema.createRecord(key);
record.read(buffer, getRecordOffset(index) + KEY_SIZE); record.read(buffer, getRecordOffset(index) + KEY_SIZE);
return record; return record;
} }
@Override @Override
public Record getRecord(Schema schema, int index) throws IOException { public DBRecord getRecord(Schema schema, int index) throws IOException {
long key = getKey(index); long key = getKey(index);
Record record = schema.createRecord(key); DBRecord record = schema.createRecord(key);
record.read(buffer, getRecordOffset(index) + KEY_SIZE); record.read(buffer, getRecordOffset(index) + KEY_SIZE);
return record; return record;
} }

View file

@ -193,14 +193,14 @@ abstract class IndexTable {
* @param record new record * @param record new record
* @throws IOException if IO error occurs * @throws IOException if IO error occurs
*/ */
abstract void addEntry(Record record) throws IOException; abstract void addEntry(DBRecord record) throws IOException;
/** /**
* Delete an entry from this index. * Delete an entry from this index.
* @param oldRecord deleted record * @param oldRecord deleted record
* @throws IOException if IO error occurs * @throws IOException if IO error occurs
*/ */
abstract void deleteEntry(Record oldRecord) throws IOException; abstract void deleteEntry(DBRecord oldRecord) throws IOException;
/** /**
* Delete all records within this index table. * Delete all records within this index table.

View file

@ -61,7 +61,7 @@ public class KeyToRecordIterator implements RecordIterator {
* @see db.RecordIterator#next() * @see db.RecordIterator#next()
*/ */
@Override @Override
public Record next() throws IOException { public DBRecord next() throws IOException {
synchronized (db) { synchronized (db) {
try { try {
return table.getRecord(keyIter.next()); return table.getRecord(keyIter.next());
@ -76,7 +76,7 @@ public class KeyToRecordIterator implements RecordIterator {
* @see db.RecordIterator#previous() * @see db.RecordIterator#previous()
*/ */
@Override @Override
public Record previous() throws IOException { public DBRecord previous() throws IOException {
synchronized (db) { synchronized (db) {
try { try {
return table.getRecord(keyIter.previous()); return table.getRecord(keyIter.previous());

View file

@ -311,7 +311,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return root node which may have changed. * @return root node which may have changed.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
LongKeyNode putRecord(Record record, Table table) throws IOException { LongKeyNode putRecord(DBRecord record, Table table) throws IOException {
long key = record.getKey(); long key = record.getKey();
int index = getKeyIndex(key); int index = getKeyIndex(key);
@ -360,7 +360,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return root node which may have changed. * @return root node which may have changed.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
LongKeyNode appendNewLeaf(Record record) throws IOException { LongKeyNode appendNewLeaf(DBRecord record) throws IOException {
LongKeyRecordNode newLeaf = createNewLeaf(-1, -1); LongKeyRecordNode newLeaf = createNewLeaf(-1, -1);
newLeaf.insertRecord(0, record); newLeaf.insertRecord(0, record);
return appendLeaf(newLeaf); return appendLeaf(newLeaf);
@ -418,7 +418,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return true if the record was successfully inserted. * @return true if the record was successfully inserted.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
abstract boolean insertRecord(int index, Record record) throws IOException; abstract boolean insertRecord(int index, DBRecord record) throws IOException;
/** /**
* Updates the record at the given index. * Updates the record at the given index.
@ -427,7 +427,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return root node which may have changed. * @return root node which may have changed.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
abstract LongKeyNode updateRecord(int index, Record record) throws IOException; abstract LongKeyNode updateRecord(int index, DBRecord record) throws IOException;
/** /**
* Get the record identified by the specified key. * Get the record identified by the specified key.
@ -436,7 +436,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
abstract Record getRecord(long key, Schema schema) throws IOException; abstract DBRecord getRecord(long key, Schema schema) throws IOException;
/** /**
* Get the record located at the specified index. * Get the record located at the specified index.
@ -445,7 +445,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return Record * @return Record
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
abstract Record getRecord(Schema schema, int index) throws IOException; abstract DBRecord getRecord(Schema schema, int index) throws IOException;
/** /**
* Get the first record whoose key is less than the specified key. * Get the first record whoose key is less than the specified key.
@ -454,7 +454,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecordBefore(long key, Schema schema) throws IOException { DBRecord getRecordBefore(long key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -index - 2; index = -index - 2;
@ -476,7 +476,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecordAfter(long key, Schema schema) throws IOException { DBRecord getRecordAfter(long key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -(index + 1); index = -(index + 1);
@ -499,7 +499,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecordAtOrBefore(long key, Schema schema) throws IOException { DBRecord getRecordAtOrBefore(long key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -index - 2; index = -index - 2;
@ -519,7 +519,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
* @return Record requested or null if record not found. * @return Record requested or null if record not found.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
Record getRecordAtOrAfter(long key, Schema schema) throws IOException { DBRecord getRecordAtOrAfter(long key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -(index + 1); index = -(index + 1);

View file

@ -167,7 +167,7 @@ class MasterTable {
int oldTableCnt = tableRecords.length; int oldTableCnt = tableRecords.length;
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
long tablenum = rec.getKey(); long tablenum = rec.getKey();
while (ix < tableRecords.length && tablenum > tableRecords[ix].getTableNum()) { while (ix < tableRecords.length && tablenum > tableRecords[ix].getTableNum()) {
@ -199,7 +199,7 @@ class MasterTable {
*/ */
void flush() throws IOException { void flush() throws IOException {
for (int i = 0; i < tableRecords.length; i++) { for (int i = 0; i < tableRecords.length; i++) {
Record rec = tableRecords[i].getRecord(); DBRecord rec = tableRecords[i].getRecord();
if (rec.isDirty()) { if (rec.isDirty()) {
table.putRecord(rec); table.putRecord(rec);
} }

View file

@ -44,7 +44,7 @@ public class ObjectStorageAdapterDB implements ObjectStorage {
* existing record. * existing record.
* @param rec data record * @param rec data record
*/ */
public ObjectStorageAdapterDB(Record rec) { public ObjectStorageAdapterDB(DBRecord rec) {
readOnly = true; readOnly = true;
Field[] fields = rec.getFields(); Field[] fields = rec.getFields();
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {
@ -335,7 +335,7 @@ public class ObjectStorageAdapterDB implements ObjectStorage {
* Save data into a Record. * Save data into a Record.
* @param rec database record. * @param rec database record.
*/ */
public void save(Record rec) { public void save(DBRecord rec) {
int cnt = fieldList.size(); int cnt = fieldList.size();
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
rec.setField(i, fieldList.get(i)); rec.setField(i, fieldList.get(i));

View file

@ -40,13 +40,13 @@ public interface RecordIterator {
* Return the nexy Record or null if one is not available. * Return the nexy Record or null if one is not available.
* @throws IOException thrown if an IO error occurs * @throws IOException thrown if an IO error occurs
*/ */
public Record next() throws IOException; public DBRecord next() throws IOException;
/** /**
* Return the previous Record or null if one is not available. * Return the previous Record or null if one is not available.
* @throws IOException thrown if an IO error occurs * @throws IOException thrown if an IO error occurs
*/ */
public Record previous() throws IOException; public DBRecord previous() throws IOException;
/** /**
* Delete the last Record read via the next or previous methods. * Delete the last Record read via the next or previous methods.

View file

@ -23,5 +23,5 @@ public interface RecordTranslator {
* @param oldRecord the old database record. * @param oldRecord the old database record.
* @return the new data base record in the form required for the current database version. * @return the new data base record in the form required for the current database version.
*/ */
Record translateRecord(Record oldRecord); DBRecord translateRecord(DBRecord oldRecord);
} }

View file

@ -521,7 +521,7 @@ public class Schema {
* @param key long key * @param key long key
* @return new record * @return new record
*/ */
public Record createRecord(long key) { public DBRecord createRecord(long key) {
return createRecord(new LongField(key)); return createRecord(new LongField(key));
} }
@ -530,8 +530,8 @@ public class Schema {
* @param key record key field * @param key record key field
* @return new record * @return new record
*/ */
public Record createRecord(Field key) { public DBRecord createRecord(Field key) {
return hasSparseColumns() ? new SparseRecord(this, key) : new Record(this, key); return hasSparseColumns() ? new SparseRecord(this, key) : new DBRecord(this, key);
} }
/** /**

View file

@ -18,7 +18,7 @@ package db;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
public class SparseRecord extends Record { public class SparseRecord extends DBRecord {
SparseRecord(Schema schema, Field key) { SparseRecord(Schema schema, Field key) {
super(schema, key); super(schema, key);

View file

@ -239,7 +239,7 @@ public class Table {
* @param record new record which has been added * @param record new record which has been added
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
void insertedRecord(Record record) throws IOException { void insertedRecord(DBRecord record) throws IOException {
// Add secondary index entries for new record // Add secondary index entries for new record
for (int indexedColumn : indexedColumns) { for (int indexedColumn : indexedColumns) {
IndexTable indexTable = secondaryIndexes.get(indexedColumn); IndexTable indexTable = secondaryIndexes.get(indexedColumn);
@ -255,7 +255,7 @@ public class Table {
* @param newRecord new record * @param newRecord new record
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
void updatedRecord(Record oldRecord, Record newRecord) throws IOException { void updatedRecord(DBRecord oldRecord, DBRecord newRecord) throws IOException {
// Update secondary indexes which have been affected // Update secondary indexes which have been affected
for (int colIx : indexedColumns) { for (int colIx : indexedColumns) {
Field oldField = oldRecord.getField(colIx); Field oldField = oldRecord.getField(colIx);
@ -275,7 +275,7 @@ public class Table {
* @param oldRecord record which has been deleted * @param oldRecord record which has been deleted
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
void deletedRecord(Record oldRecord) throws IOException { void deletedRecord(DBRecord oldRecord) throws IOException {
// Delete secondary index entries // Delete secondary index entries
for (int indexedColumn : indexedColumns) { for (int indexedColumn : indexedColumns) {
IndexTable indexTable = secondaryIndexes.get(indexedColumn); IndexTable indexTable = secondaryIndexes.get(indexedColumn);
@ -334,7 +334,7 @@ public class Table {
try { try {
RecordIterator recIter = iterator(); RecordIterator recIter = iterator();
while (recIter.hasNext()) { while (recIter.hasNext()) {
Record rec = recIter.next(); DBRecord rec = recIter.next();
++actualCount; ++actualCount;
Field keyField = rec.getKeyField(); Field keyField = rec.getKeyField();
if ((keyField instanceof LongField) && if ((keyField instanceof LongField) &&
@ -407,7 +407,7 @@ public class Table {
int actualCount = 0; int actualCount = 0;
RecordIterator recIter = iterator(); RecordIterator recIter = iterator();
while (recIter.hasNext()) { while (recIter.hasNext()) {
Record rec = recIter.next(); DBRecord rec = recIter.next();
++actualCount; ++actualCount;
// Check for bad index tables (missing or invalid entries) // Check for bad index tables (missing or invalid entries)
@ -687,7 +687,7 @@ public class Table {
* found. * found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecord(long key) throws IOException { public DBRecord getRecord(long key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -709,7 +709,7 @@ public class Table {
* found. * found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecord(Field key) throws IOException { public DBRecord getRecord(Field key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -740,7 +740,7 @@ public class Table {
* specified key, or null if no record was found. * specified key, or null if no record was found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecordBefore(long key) throws IOException { public DBRecord getRecordBefore(long key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -763,7 +763,7 @@ public class Table {
* specified key, or null if no record was found. * specified key, or null if no record was found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecordBefore(Field key) throws IOException { public DBRecord getRecordBefore(Field key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -789,7 +789,7 @@ public class Table {
* specified key, or null if no record was found. * specified key, or null if no record was found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecordAfter(long key) throws IOException { public DBRecord getRecordAfter(long key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -812,7 +812,7 @@ public class Table {
* specified key, or null if no record was found. * specified key, or null if no record was found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecordAfter(Field key) throws IOException { public DBRecord getRecordAfter(Field key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -838,7 +838,7 @@ public class Table {
* specified key, or null if no record was found. * specified key, or null if no record was found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecordAtOrBefore(long key) throws IOException { public DBRecord getRecordAtOrBefore(long key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -861,7 +861,7 @@ public class Table {
* specified key, or null if no record was found. * specified key, or null if no record was found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecordAtOrBefore(Field key) throws IOException { public DBRecord getRecordAtOrBefore(Field key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -887,7 +887,7 @@ public class Table {
* specified key, or null if no record was found. * specified key, or null if no record was found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecordAtOrAfter(long key) throws IOException { public DBRecord getRecordAtOrAfter(long key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -910,7 +910,7 @@ public class Table {
* specified key, or null if no record was found. * specified key, or null if no record was found.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public Record getRecordAtOrAfter(Field key) throws IOException { public DBRecord getRecordAtOrAfter(Field key) throws IOException {
synchronized (db) { synchronized (db) {
if (rootBufferId < 0) { if (rootBufferId < 0) {
return null; return null;
@ -933,7 +933,7 @@ public class Table {
* @param record the record to be stored. * @param record the record to be stored.
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
public void putRecord(Record record) throws IOException { public void putRecord(DBRecord record) throws IOException {
synchronized (db) { synchronized (db) {
db.checkTransaction(); db.checkTransaction();
if (schema.useLongKeyNodes()) { if (schema.useLongKeyNodes()) {
@ -951,7 +951,7 @@ public class Table {
* @param record recore to be inserted or updated * @param record recore to be inserted or updated
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
private void putLongKeyRecord(Record record) throws IOException { private void putLongKeyRecord(DBRecord record) throws IOException {
// boolean inserted = false; // boolean inserted = false;
try { try {
@ -1000,7 +1000,7 @@ public class Table {
* @param record record to be inserted or updated * @param record record to be inserted or updated
* @throws IOException throw if an IO Error occurs * @throws IOException throw if an IO Error occurs
*/ */
private void putFieldKeyRecord(Record record) throws IOException { private void putFieldKeyRecord(DBRecord record) throws IOException {
// boolean inserted = false; // boolean inserted = false;
try { try {
@ -2031,9 +2031,9 @@ public class Table {
private boolean isNext; // recover position is next record private boolean isNext; // recover position is next record
private boolean isPrev; // recover position is previous record private boolean isPrev; // recover position is previous record
private Record record; // current record private DBRecord record; // current record
private long curKey; // copy of record key (record may get changed by consumer) private long curKey; // copy of record key (record may get changed by consumer)
private Record lastRecord; private DBRecord lastRecord;
private boolean hasPrev; // current record is previous private boolean hasPrev; // current record is previous
private boolean hasNext; // current record is next private boolean hasNext; // current record is next
@ -2224,7 +2224,7 @@ public class Table {
} }
// Load next record // Load next record
Record nextRecord = leaf.getRecord(schema, nextIndex); DBRecord nextRecord = leaf.getRecord(schema, nextIndex);
hasNext = nextRecord.getKey() <= maxKey; hasNext = nextRecord.getKey() <= maxKey;
if (hasNext) { if (hasNext) {
bufferId = nextBufferId; bufferId = nextBufferId;
@ -2271,7 +2271,7 @@ public class Table {
} }
// Load previous record // Load previous record
Record prevRecord = leaf.getRecord(schema, prevIndex); DBRecord prevRecord = leaf.getRecord(schema, prevIndex);
hasPrev = prevRecord.getKey() >= minKey; hasPrev = prevRecord.getKey() >= minKey;
if (hasPrev) { if (hasPrev) {
bufferId = prevBufferId; bufferId = prevBufferId;
@ -2290,7 +2290,7 @@ public class Table {
} }
@Override @Override
public Record next() throws IOException { public DBRecord next() throws IOException {
if (hasNext || hasNext()) { if (hasNext || hasNext()) {
hasNext = false; hasNext = false;
hasPrev = true; hasPrev = true;
@ -2301,7 +2301,7 @@ public class Table {
} }
@Override @Override
public Record previous() throws IOException { public DBRecord previous() throws IOException {
if (hasPrev || hasPrevious()) { if (hasPrev || hasPrevious()) {
hasNext = true; hasNext = true;
hasPrev = false; hasPrev = false;
@ -2333,9 +2333,9 @@ public class Table {
private boolean isNext; // recover position is next record private boolean isNext; // recover position is next record
private boolean isPrev; // recover position is previous record private boolean isPrev; // recover position is previous record
private Record record; // current record private DBRecord record; // current record
// private Field curKey; // copy of record key (record may get changed by consumer) // private Field curKey; // copy of record key (record may get changed by consumer)
private Record lastRecord; private DBRecord lastRecord;
private boolean hasPrev; // current record is previous private boolean hasPrev; // current record is previous
private boolean hasNext; // current record is next private boolean hasNext; // current record is next
@ -2549,7 +2549,7 @@ public class Table {
} }
// Load next record // Load next record
Record nextRecord = leaf.getRecord(schema, nextIndex); DBRecord nextRecord = leaf.getRecord(schema, nextIndex);
hasNext = maxKey == null ? true hasNext = maxKey == null ? true
: (nextRecord.getKeyField().compareTo(maxKey) <= 0); : (nextRecord.getKeyField().compareTo(maxKey) <= 0);
if (hasNext) { if (hasNext) {
@ -2597,7 +2597,7 @@ public class Table {
} }
// Load previous record // Load previous record
Record prevRecord = leaf.getRecord(schema, prevIndex); DBRecord prevRecord = leaf.getRecord(schema, prevIndex);
hasPrev = minKey == null ? true hasPrev = minKey == null ? true
: (prevRecord.getKeyField().compareTo(minKey) >= 0); : (prevRecord.getKeyField().compareTo(minKey) >= 0);
if (hasPrev) { if (hasPrev) {
@ -2617,7 +2617,7 @@ public class Table {
} }
@Override @Override
public Record next() throws IOException { public DBRecord next() throws IOException {
if (hasNext || hasNext()) { if (hasNext || hasNext()) {
hasNext = false; hasNext = false;
hasPrev = true; hasPrev = true;
@ -2628,7 +2628,7 @@ public class Table {
} }
@Override @Override
public Record previous() throws IOException { public DBRecord previous() throws IOException {
if (hasPrev || hasPrevious()) { if (hasPrev || hasPrevious()) {
hasNext = true; hasNext = true;
hasPrev = false; hasPrev = false;

View file

@ -54,7 +54,7 @@ class TableRecord implements Comparable<TableRecord> {
private static Schema schema = new Schema(0, "TableNum", fields, tableRecordFieldNames); private static Schema schema = new Schema(0, "TableNum", fields, tableRecordFieldNames);
private Record record; private DBRecord record;
private Schema tableSchema; private Schema tableSchema;
private Table table; private Table table;
@ -86,7 +86,7 @@ class TableRecord implements Comparable<TableRecord> {
* @throws UnsupportedFieldException stored schema contains unsupported field * @throws UnsupportedFieldException stored schema contains unsupported field
* @throws IOException if IO error occurs * @throws IOException if IO error occurs
*/ */
TableRecord(DBHandle dbh, Record record) throws IOException { TableRecord(DBHandle dbh, DBRecord record) throws IOException {
this.tableSchema = parseSchema(dbh, record); this.tableSchema = parseSchema(dbh, record);
this.record = record; this.record = record;
} }
@ -95,7 +95,7 @@ class TableRecord implements Comparable<TableRecord> {
* Get the underlying storage record for this instance. * Get the underlying storage record for this instance.
* @return master table storage record. * @return master table storage record.
*/ */
Record getRecord() { DBRecord getRecord() {
return record; return record;
} }
@ -115,7 +115,7 @@ class TableRecord implements Comparable<TableRecord> {
* @throws UnsupportedFieldException stored schema contains unsupported field * @throws UnsupportedFieldException stored schema contains unsupported field
* @throws IOException if IO error occurs * @throws IOException if IO error occurs
*/ */
void setRecord(DBHandle dbh, Record record) throws IOException { void setRecord(DBHandle dbh, DBRecord record) throws IOException {
this.tableSchema = parseSchema(dbh, record); this.tableSchema = parseSchema(dbh, record);
this.record = record; this.record = record;
if (table != null) { if (table != null) {
@ -169,7 +169,7 @@ class TableRecord implements Comparable<TableRecord> {
* @throws UnsupportedFieldException stored schema contains unsupported field * @throws UnsupportedFieldException stored schema contains unsupported field
* @throws IOException if IO error occurs * @throws IOException if IO error occurs
*/ */
private static Schema parseSchema(DBHandle dbh, Record record) throws IOException { private static Schema parseSchema(DBHandle dbh, DBRecord record) throws IOException {
Schema tableSchema = Schema tableSchema =
new Schema(record.getIntValue(VERSION_COLUMN), record.getByteValue(KEY_TYPE_COLUMN), new Schema(record.getIntValue(VERSION_COLUMN), record.getByteValue(KEY_TYPE_COLUMN),
record.getBinaryData(FIELD_TYPES_COLUMN), record.getString(FIELD_NAMES_COLUMN)); record.getBinaryData(FIELD_TYPES_COLUMN), record.getString(FIELD_NAMES_COLUMN));

View file

@ -37,12 +37,12 @@ public class TranslatedRecordIterator implements RecordIterator {
} }
@Override @Override
public Record next() throws IOException { public DBRecord next() throws IOException {
return translator.translateRecord(it.next()); return translator.translateRecord(it.next());
} }
@Override @Override
public Record previous() throws IOException { public DBRecord previous() throws IOException {
return translator.translateRecord(it.previous()); return translator.translateRecord(it.previous());
} }

View file

@ -296,7 +296,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
} }
@Override @Override
public VarKeyNode putRecord(Record record, Table table) throws IOException { public VarKeyNode putRecord(DBRecord record, Table table) throws IOException {
Field key = record.getKeyField(); Field key = record.getKeyField();
int index = getKeyIndex(key); int index = getKeyIndex(key);
@ -342,7 +342,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
* @return root node which may have changed. * @return root node which may have changed.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
VarKeyNode appendNewLeaf(Record record) throws IOException { VarKeyNode appendNewLeaf(DBRecord record) throws IOException {
VarKeyRecordNode newLeaf = createNewLeaf(-1, -1); VarKeyRecordNode newLeaf = createNewLeaf(-1, -1);
newLeaf.insertRecord(0, record); newLeaf.insertRecord(0, record);
return appendLeaf(newLeaf); return appendLeaf(newLeaf);
@ -386,7 +386,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
} }
@Override @Override
public Record getRecordBefore(Field key, Schema schema) throws IOException { public DBRecord getRecordBefore(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -index - 2; index = -index - 2;
@ -402,7 +402,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
} }
@Override @Override
public Record getRecordAfter(Field key, Schema schema) throws IOException { public DBRecord getRecordAfter(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -(index + 1); index = -(index + 1);
@ -418,7 +418,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
} }
@Override @Override
public Record getRecordAtOrBefore(Field key, Schema schema) throws IOException { public DBRecord getRecordAtOrBefore(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -index - 2; index = -index - 2;
@ -431,7 +431,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
} }
@Override @Override
public Record getRecordAtOrAfter(Field key, Schema schema) throws IOException { public DBRecord getRecordAtOrAfter(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
index = -(index + 1); index = -(index + 1);
@ -574,9 +574,9 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
* @return Record * @return Record
*/ */
@Override @Override
public Record getRecord(Schema schema, int index) throws IOException { public DBRecord getRecord(Schema schema, int index) throws IOException {
Field key = getKeyField(index); Field key = getKeyField(index);
Record record = schema.createRecord(key); DBRecord record = schema.createRecord(key);
if (hasIndirectStorage(index)) { if (hasIndirectStorage(index)) {
int bufId = buffer.getInt(getRecordDataOffset(index)); int bufId = buffer.getInt(getRecordDataOffset(index));
ChainedBuffer chainedBuffer = new ChainedBuffer(nodeMgr.getBufferMgr(), bufId); ChainedBuffer chainedBuffer = new ChainedBuffer(nodeMgr.getBufferMgr(), bufId);
@ -597,7 +597,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
} }
@Override @Override
public Record getRecord(Field key, Schema schema) throws IOException { public DBRecord getRecord(Field key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) if (index < 0)
return null; return null;
@ -669,7 +669,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
* @return root node which may have changed. * @return root node which may have changed.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
private VarKeyNode updateRecord(int index, Record record) throws IOException { private VarKeyNode updateRecord(int index, DBRecord record) throws IOException {
Field key = record.getKeyField(); Field key = record.getKeyField();
int keyLen = key.length(); int keyLen = key.length();
@ -733,7 +733,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
* @return true if the record was successfully inserted. * @return true if the record was successfully inserted.
* @throws IOException thrown if IO error occurs * @throws IOException thrown if IO error occurs
*/ */
private boolean insertRecord(int index, Record record) throws IOException { private boolean insertRecord(int index, DBRecord record) throws IOException {
Field key = record.getKeyField(); Field key = record.getKeyField();
int keyLen = key.length(); int keyLen = key.length();

View file

@ -189,9 +189,9 @@ class VarRecNode extends LongKeyRecordNode {
} }
@Override @Override
public Record getRecord(Schema schema, int index) throws IOException { public DBRecord getRecord(Schema schema, int index) throws IOException {
long key = getKey(index); long key = getKey(index);
Record record = schema.createRecord(key); DBRecord record = schema.createRecord(key);
if (hasIndirectStorage(index)) { if (hasIndirectStorage(index)) {
int bufId = buffer.getInt(getRecordDataOffset(index)); int bufId = buffer.getInt(getRecordDataOffset(index));
ChainedBuffer chainedBuffer = new ChainedBuffer(nodeMgr.getBufferMgr(), bufId); ChainedBuffer chainedBuffer = new ChainedBuffer(nodeMgr.getBufferMgr(), bufId);
@ -212,7 +212,7 @@ class VarRecNode extends LongKeyRecordNode {
} }
@Override @Override
Record getRecord(long key, Schema schema) throws IOException { DBRecord getRecord(long key, Schema schema) throws IOException {
int index = getKeyIndex(key); int index = getKeyIndex(key);
if (index < 0) { if (index < 0) {
return null; return null;
@ -277,7 +277,7 @@ class VarRecNode extends LongKeyRecordNode {
} }
@Override @Override
LongKeyNode updateRecord(int index, Record record) throws IOException { LongKeyNode updateRecord(int index, DBRecord record) throws IOException {
int offset = getRecordDataOffset(index); int offset = getRecordDataOffset(index);
int oldLen = getRecordLength(index, offset); int oldLen = getRecordLength(index, offset);
@ -330,7 +330,7 @@ class VarRecNode extends LongKeyRecordNode {
} }
@Override @Override
boolean insertRecord(int index, Record record) throws IOException { boolean insertRecord(int index, DBRecord record) throws IOException {
// Check for use of indirect chained record node(s) // Check for use of indirect chained record node(s)
int len = record.length(); int len = record.length();

View file

@ -86,11 +86,11 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createRandomTableRecords(int schemaType, int recordCnt, int varDataSize) private DBRecord[] createRandomTableRecords(int schemaType, int recordCnt, int varDataSize)
throws IOException { throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = DBTestUtils.createFixedKeyTable(dbh, table1Name, schemaType, true, false); Table table = DBTestUtils.createFixedKeyTable(dbh, table1Name, schemaType, true, false);
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
recs[i] = DBTestUtils.createFixedKeyRecord(table, varDataSize, true); recs[i] = DBTestUtils.createFixedKeyRecord(table, varDataSize, true);
@ -110,13 +110,13 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createOrderedTableRecords(int schemaType, int recordCnt, long keyIncrement, private DBRecord[] createOrderedTableRecords(int schemaType, int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = DBTestUtils.createFixedKeyTable(dbh, table1Name, schemaType, true, false); Table table = DBTestUtils.createFixedKeyTable(dbh, table1Name, schemaType, true, false);
FixedField key = new FixedField10(new byte[] { 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff, FixedField key = new FixedField10(new byte[] { 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff }); (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff });
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true); recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true);
@ -130,19 +130,19 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
return recs; return recs;
} }
private Field[] matchingKeys(Record[] recs, int columnIx, Record matchRec) { private Field[] matchingKeys(DBRecord[] recs, int columnIx, DBRecord matchRec) {
ArrayList<Record> recList = new ArrayList<>(); ArrayList<DBRecord> recList = new ArrayList<>();
Field f = matchRec.getField(columnIx); Field f = matchRec.getField(columnIx);
for (Record rec : recs) { for (DBRecord rec : recs) {
if (f.equals(rec.getField(columnIx))) { if (f.equals(rec.getField(columnIx))) {
recList.add(rec); recList.add(rec);
} }
} }
Field[] keys = new FixedField[recList.size()]; Field[] keys = new FixedField[recList.size()];
Iterator<Record> iter = recList.iterator(); Iterator<DBRecord> iter = recList.iterator();
int i = 0; int i = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
keys[i++] = rec.getKeyField(); keys[i++] = rec.getKeyField();
} }
Arrays.sort(keys); Arrays.sort(keys);
@ -151,7 +151,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
private void findRecords(boolean testStoredDB, int recordCnt, int findCnt, int varDataSize) private void findRecords(boolean testStoredDB, int recordCnt, int findCnt, int varDataSize)
throws IOException { throws IOException {
Record[] recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);// short var-len fields DBRecord[] recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);// short var-len fields
if (testStoredDB) { if (testStoredDB) {
saveAsAndReopen(dbName); saveAsAndReopen(dbName);
} }
@ -239,7 +239,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
private void updateRecordsIterator(boolean testStoredDB, int schemaType, int recordCnt, private void updateRecordsIterator(boolean testStoredDB, int schemaType, int recordCnt,
long keyIncrement, int varDataSize) throws IOException { long keyIncrement, int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomTableRecords(schemaType, recordCnt, varDataSize); recs = createRandomTableRecords(schemaType, recordCnt, varDataSize);
} }
@ -305,7 +305,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
int recIx = 0; int recIx = 0;
RecordIterator iter = table.indexIterator(colIx); RecordIterator iter = table.indexIterator(colIx);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -315,7 +315,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -325,7 +325,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -335,7 +335,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -344,7 +344,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = findStart(recs, recordCnt / 2, colIx); recIx = findStart(recs, recordCnt / 2, colIx);
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -353,7 +353,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = recordCnt - 1; recIx = recordCnt - 1;
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -362,7 +362,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = findEnd(recs, recordCnt / 2, colIx); recIx = findEnd(recs, recordCnt / 2, colIx);
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -375,7 +375,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1); startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1);
iter = table.indexIteratorAfter(colIx, startValue); iter = table.indexIteratorAfter(colIx, startValue);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -385,7 +385,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1); startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1);
iter = table.indexIteratorBefore(colIx, startValue); iter = table.indexIteratorBefore(colIx, startValue);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -409,7 +409,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
private void iterateRecords(boolean testStoredDB, int schemaType, int recordCnt, private void iterateRecords(boolean testStoredDB, int schemaType, int recordCnt,
long keyIncrement, int varDataSize, boolean doUndoRedo) throws IOException { long keyIncrement, int varDataSize, boolean doUndoRedo) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomTableRecords(schemaType, recordCnt, varDataSize); recs = createRandomTableRecords(schemaType, recordCnt, varDataSize);
} }
@ -443,7 +443,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = 0; recIx = 0;
iter = table.indexIterator(colIx); iter = table.indexIterator(colIx);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx], rec); assertEquals(recs[recIx], rec);
Field indexField = recs[recIx].getField(colIx); Field indexField = recs[recIx].getField(colIx);
if (lastIndex == null || !lastIndex.equals(indexField)) { if (lastIndex == null || !lastIndex.equals(indexField)) {
@ -473,7 +473,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = findEnd(recs, startIx, colIx); recIx = findEnd(recs, startIx, colIx);
iter = table.indexIteratorAfter(colIx, recs[startIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[startIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -485,7 +485,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[startIx].getField(colIx), iter = table.indexIteratorBefore(colIx, recs[startIx].getField(colIx),
recs[startIx].getKeyField()); recs[startIx].getKeyField());
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -501,7 +501,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = 0; recIx = 0;
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -522,7 +522,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -536,7 +536,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = recordCnt - 1; recIx = recordCnt - 1;
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -546,7 +546,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -556,7 +556,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -565,7 +565,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = findStart(recs, recordCnt / 2, colIx); recIx = findStart(recs, recordCnt / 2, colIx);
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -574,7 +574,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = findStart(recs, recordCnt / 2, colIx); recIx = findStart(recs, recordCnt / 2, colIx);
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[--recIx], rec); assertEquals(recs[--recIx], rec);
} }
assertEquals(0, recIx); assertEquals(0, recIx);
@ -583,7 +583,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = findEnd(recs, recordCnt / 2, colIx); recIx = findEnd(recs, recordCnt / 2, colIx);
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[++recIx], rec); assertEquals(recs[++recIx], rec);
} }
assertEquals(recordCnt - 1, recIx); assertEquals(recordCnt - 1, recIx);
@ -592,7 +592,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = findEnd(recs, recordCnt / 2, colIx); recIx = findEnd(recs, recordCnt / 2, colIx);
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -604,7 +604,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIterator(colIx, recs[minIx].getField(colIx), iter = table.indexIterator(colIx, recs[minIx].getField(colIx),
recs[maxIx].getField(colIx), true); recs[maxIx].getField(colIx), true);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(maxIx + 1, recIx); assertEquals(maxIx + 1, recIx);
@ -613,7 +613,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = 0; recIx = 0;
iter = table.indexIterator(colIx, null, null, true); iter = table.indexIterator(colIx, null, null, true);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -625,7 +625,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIterator(colIx, recs[minIx].getField(colIx), iter = table.indexIterator(colIx, recs[minIx].getField(colIx),
recs[maxIx].getField(colIx), false); recs[maxIx].getField(colIx), false);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(minIx - 1, recIx); assertEquals(minIx - 1, recIx);
@ -634,7 +634,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
recIx = recordCnt - 1; recIx = recordCnt - 1;
iter = table.indexIterator(colIx, null, null, false); iter = table.indexIterator(colIx, null, null, false);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -652,7 +652,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1); startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1);
iter = table.indexIteratorAfter(colIx, startValue); iter = table.indexIteratorAfter(colIx, startValue);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -662,7 +662,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1); startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1);
iter = table.indexIteratorBefore(colIx, startValue); iter = table.indexIteratorBefore(colIx, startValue);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -675,26 +675,26 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasNext()) { if (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
} }
--recIx; --recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasPrevious()) { if (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
} }
++recIx; ++recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasNext()) { if (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
} }
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -705,26 +705,26 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
--recIx; --recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasPrevious()) { if (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
} }
++recIx; ++recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasNext()) { if (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
} }
--recIx; --recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasPrevious()) { if (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
} }
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -734,13 +734,13 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (iter.hasNext()) { if (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
} }
assertEquals(recordCnt - 1, recIx); assertEquals(recordCnt - 1, recIx);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -750,13 +750,13 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (iter.hasPrevious()) { if (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[--recIx], rec); assertEquals(recs[--recIx], rec);
} }
} }
assertEquals(0, recIx); assertEquals(0, recIx);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -862,7 +862,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
private void deleteIteratedRecords(int recordCnt, int testColIx, long keyIncrement, private void deleteIteratedRecords(int recordCnt, int testColIx, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize); recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);
} }
@ -930,7 +930,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
private void deleteIteratedIndexFields(int recordCnt, int testColIx, long keyIncrement, private void deleteIteratedIndexFields(int recordCnt, int testColIx, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize); recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);
} }
@ -948,7 +948,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
int fieldCnt = 0; int fieldCnt = 0;
Field lastField = null; Field lastField = null;
ArrayList<Field> fieldList = new ArrayList<>(); ArrayList<Field> fieldList = new ArrayList<>();
for (Record rec : recs) { for (DBRecord rec : recs) {
Field f = rec.getField(testColIx); Field f = rec.getField(testColIx);
if (lastField == null || !lastField.equals(f)) { if (lastField == null || !lastField.equals(f)) {
lastField = f; lastField = f;
@ -997,7 +997,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
int fieldCnt = 0; int fieldCnt = 0;
Field lastField = null; Field lastField = null;
ArrayList<Field> fieldList = new ArrayList<>(); ArrayList<Field> fieldList = new ArrayList<>();
for (Record rec : recs) { for (DBRecord rec : recs) {
Field f = rec.getField(testColIx); Field f = rec.getField(testColIx);
if (lastField == null || !lastField.equals(f)) { if (lastField == null || !lastField.equals(f)) {
lastField = f; lastField = f;
@ -1025,7 +1025,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
} }
} }
private int findStart(Record[] recs, int startIx, int colIx) { private int findStart(DBRecord[] recs, int startIx, int colIx) {
Field f = recs[startIx].getField(colIx); Field f = recs[startIx].getField(colIx);
--startIx; --startIx;
while (startIx >= 0 && f.equals(recs[startIx].getField(colIx))) { while (startIx >= 0 && f.equals(recs[startIx].getField(colIx))) {
@ -1037,7 +1037,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
return ++startIx; return ++startIx;
} }
private int findEnd(Record[] recs, int startIx, int colIx) { private int findEnd(DBRecord[] recs, int startIx, int colIx) {
Field f = recs[startIx].getField(colIx); Field f = recs[startIx].getField(colIx);
++startIx; ++startIx;
while (startIx < recs.length && f.equals(recs[startIx].getField(colIx))) { while (startIx < recs.length && f.equals(recs[startIx].getField(colIx))) {
@ -1049,7 +1049,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
return --startIx; return --startIx;
} }
private class RecColumnComparator implements Comparator<Record> { private class RecColumnComparator implements Comparator<DBRecord> {
int columnIx; int columnIx;
@ -1058,7 +1058,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
} }
@Override @Override
public int compare(Record rec1, Record rec2) { public int compare(DBRecord rec1, DBRecord rec2) {
int r = rec1.getField(columnIx).compareTo(rec2.getField(columnIx)); int r = rec1.getField(columnIx).compareTo(rec2.getField(columnIx));
if (r == 0) { if (r == 0) {
return rec1.getKeyField().compareTo(rec2.getKeyField()); return rec1.getKeyField().compareTo(rec2.getKeyField());
@ -1135,7 +1135,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
@Test @Test
public void testRecordIteratorExtents() throws IOException { public void testRecordIteratorExtents() throws IOException {
Record[] recs = null; DBRecord[] recs = null;
recs = createOrderedTableRecords(DBTestUtils.SINGLE_SHORT, 30, 2, 1); recs = createOrderedTableRecords(DBTestUtils.SINGLE_SHORT, 30, 2, 1);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
assertEquals(recs.length, table.getRecordCount()); assertEquals(recs.length, table.getRecordCount());
@ -1148,7 +1148,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
Field maxField = new ShortField(Short.MAX_VALUE); Field maxField = new ShortField(Short.MAX_VALUE);
RecordIterator iter = table.indexIterator(colIx, minField, maxField, false); RecordIterator iter = table.indexIterator(colIx, minField, maxField, false);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(recIx, -1); assertEquals(recIx, -1);

View file

@ -139,7 +139,7 @@ public class DBFixedKeySparseIndexedTableTest extends AbstractGenericTest {
int cnt = schema.getFieldCount(); int cnt = schema.getFieldCount();
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
Field key = new FixedField10(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, (byte) i }); Field key = new FixedField10(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, (byte) i });
Record r = schema.createRecord(key); DBRecord r = schema.createRecord(key);
Field f = schema.getField(i); Field f = schema.getField(i);
if (f.isVariableLength()) { if (f.isVariableLength()) {

View file

@ -91,7 +91,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = Table table =
DBTestUtils.createFixedKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false); DBTestUtils.createFixedKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false);
Record rec = null; DBRecord rec = null;
try { try {
rec = DBTestUtils.createFixedKeyRecord(table, varDataSize, true); rec = DBTestUtils.createFixedKeyRecord(table, varDataSize, true);
} }
@ -276,14 +276,14 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createRandomFixedKeyTableRecords(Table table, int recordCnt, int varDataSize) private DBRecord[] createRandomFixedKeyTableRecords(Table table, int recordCnt, int varDataSize)
throws IOException { throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
if (table == null) { if (table == null) {
table = DBTestUtils.createFixedKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, table = DBTestUtils.createFixedKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false,
false); false);
} }
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
recs[i] = DBTestUtils.createFixedKeyRecord(table, varDataSize, true); recs[i] = DBTestUtils.createFixedKeyRecord(table, varDataSize, true);
@ -302,13 +302,13 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createOrderedFixedKeyTableRecords(int recordCnt, long keyIncrement, private DBRecord[] createOrderedFixedKeyTableRecords(int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = Table table =
DBTestUtils.createFixedKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false); DBTestUtils.createFixedKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false);
FixedField10 key = new FixedField10(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }); FixedField10 key = new FixedField10(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true); recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true);
@ -332,7 +332,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
*/ */
private void iterateFixedKeyRecords(boolean testStoredDB, int recordCnt, long keyIncrement, private void iterateFixedKeyRecords(boolean testStoredDB, int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomFixedKeyTableRecords(null, recordCnt, varDataSize); recs = createRandomFixedKeyTableRecords(null, recordCnt, varDataSize);
} }
@ -567,7 +567,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
*/ */
private void iterateFixedKeys(boolean testStoredDB, int recordCnt, long keyIncrement, private void iterateFixedKeys(boolean testStoredDB, int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomFixedKeyTableRecords(null, recordCnt, varDataSize); recs = createRandomFixedKeyTableRecords(null, recordCnt, varDataSize);
} }
@ -742,7 +742,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testForwardDeleteIterator() throws IOException { public void testForwardDeleteIterator() throws IOException {
Record[] recs = createOrderedFixedKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1); DBRecord[] recs = createOrderedFixedKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount()); assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
@ -761,7 +761,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testReverseDeleteIterator() throws IOException { public void testReverseDeleteIterator() throws IOException {
Record[] recs = createOrderedFixedKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1); DBRecord[] recs = createOrderedFixedKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount()); assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
@ -779,22 +779,22 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testGetFixedKeyRecordAfter() throws IOException { public void testGetFixedKeyRecordAfter() throws IOException {
Record[] recs = createRandomFixedKeyTableRecords(null, 16000, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, 16000, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
// After test // After test
for (int i = 1000; i < 16000; i += 1000) { for (int i = 1000; i < 16000; i += 1000) {
Record rec = table.getRecordAfter(recs[i].getKeyField()); DBRecord rec = table.getRecordAfter(recs[i].getKeyField());
assertEquals(rec.getKeyField(), recs[i + 1].getKeyField()); assertEquals(rec.getKeyField(), recs[i + 1].getKeyField());
} }
// End test // End test
Record rec = table.getRecordAfter(recs[15999].getKeyField()); DBRecord rec = table.getRecordAfter(recs[15999].getKeyField());
assertNull(rec); assertNull(rec);
} }
private int findHoleAfterFixedKey(Record[] recs, int startIx) { private int findHoleAfterFixedKey(DBRecord[] recs, int startIx) {
for (int i = startIx; i < recs.length - 1; i++) { for (int i = startIx; i < recs.length - 1; i++) {
FixedField f = DBTestUtils.addToFixedField(recs[i].getKeyField(), 1); FixedField f = DBTestUtils.addToFixedField(recs[i].getKeyField(), 1);
if (f.compareTo(recs[i + 1].getKeyField()) < 0) { if (f.compareTo(recs[i + 1].getKeyField()) < 0) {
@ -804,7 +804,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
return -1; return -1;
} }
private int findHoleBeforeFixedKey(Record[] recs, int startIx) { private int findHoleBeforeFixedKey(DBRecord[] recs, int startIx) {
for (int i = startIx; i < recs.length; i++) { for (int i = startIx; i < recs.length; i++) {
FixedField f = DBTestUtils.addToFixedField(recs[i - 1].getKeyField(), 1); FixedField f = DBTestUtils.addToFixedField(recs[i - 1].getKeyField(), 1);
if (f.compareTo(recs[i].getKeyField()) < 0) { if (f.compareTo(recs[i].getKeyField()) < 0) {
@ -816,13 +816,13 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testGetFixedKeyRecordAtOrAfter() throws IOException { public void testGetFixedKeyRecordAtOrAfter() throws IOException {
Record[] recs = createRandomFixedKeyTableRecords(null, 16000, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, 16000, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
// At and After tests // At and After tests
for (int i = 1000; i < 16000; i += 1000) { for (int i = 1000; i < 16000; i += 1000) {
Record rec = table.getRecordAtOrAfter(recs[i].getKeyField()); DBRecord rec = table.getRecordAtOrAfter(recs[i].getKeyField());
assertEquals(rec.getKeyField(), recs[i].getKeyField()); assertEquals(rec.getKeyField(), recs[i].getKeyField());
int ix = findHoleAfterFixedKey(recs, i + 500); int ix = findHoleAfterFixedKey(recs, i + 500);
if (ix < 0) { if (ix < 0) {
@ -837,7 +837,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
if (lastKey == MAX_VALUE) { if (lastKey == MAX_VALUE) {
Assert.fail("Bad test data"); Assert.fail("Bad test data");
} }
Record rec = table.getRecordAtOrAfter(lastKey); DBRecord rec = table.getRecordAtOrAfter(lastKey);
assertEquals(rec.getKeyField(), lastKey); assertEquals(rec.getKeyField(), lastKey);
rec = table.getRecordAtOrAfter(DBTestUtils.addToFixedField(lastKey, 1)); rec = table.getRecordAtOrAfter(DBTestUtils.addToFixedField(lastKey, 1));
assertNull(rec); assertNull(rec);
@ -845,13 +845,13 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testGetFixedKeyRecordAtOrBefore() throws IOException { public void testGetFixedKeyRecordAtOrBefore() throws IOException {
Record[] recs = createRandomFixedKeyTableRecords(null, 16000, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, 16000, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
// At and Before tests // At and Before tests
for (int i = 1000; i < 16000; i += 1000) { for (int i = 1000; i < 16000; i += 1000) {
Record rec = table.getRecordAtOrBefore(recs[i].getKeyField()); DBRecord rec = table.getRecordAtOrBefore(recs[i].getKeyField());
assertEquals(rec.getKeyField(), recs[i].getKeyField()); assertEquals(rec.getKeyField(), recs[i].getKeyField());
int ix = findHoleBeforeFixedKey(recs, i + 500); int ix = findHoleBeforeFixedKey(recs, i + 500);
if (ix < 0) { if (ix < 0) {
@ -867,7 +867,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
if (firstKey.equals(MIN_VALUE)) { if (firstKey.equals(MIN_VALUE)) {
Assert.fail("Bad test data"); Assert.fail("Bad test data");
} }
Record rec = table.getRecordAtOrBefore(firstKey); DBRecord rec = table.getRecordAtOrBefore(firstKey);
assertEquals(rec.getKeyField(), firstKey); assertEquals(rec.getKeyField(), firstKey);
rec = table.getRecordAtOrBefore(DBTestUtils.addToFixedField(firstKey, -1)); rec = table.getRecordAtOrBefore(DBTestUtils.addToFixedField(firstKey, -1));
assertNull(rec); assertNull(rec);
@ -876,7 +876,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testDeleteFixedKeyRecord() throws IOException { public void testDeleteFixedKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -890,7 +890,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 1; int recIx = 1;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
if ((recIx % 1000) == 0) { if ((recIx % 1000) == 0) {
++recIx; ++recIx;
@ -902,7 +902,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testForwardDeleteFixedKeyRecord() throws IOException { public void testForwardDeleteFixedKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -918,7 +918,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testReverseDeleteFixedKeyRecord() throws IOException { public void testReverseDeleteFixedKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -934,7 +934,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
public void testDeleteAllFixedKeyRecords() throws IOException { public void testDeleteAllFixedKeyRecords() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
@ -954,7 +954,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -962,7 +962,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
private void deleteFixedKeyRangeRecords(int count, int startIx, int endIx) throws IOException { private void deleteFixedKeyRangeRecords(int count, int startIx, int endIx) throws IOException {
Record[] recs = createRandomFixedKeyTableRecords(null, count, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, count, 1);
Arrays.sort(recs); Arrays.sort(recs);
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
@ -973,7 +973,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = startIx != 0 ? 0 : (endIx + 1); int recIx = startIx != 0 ? 0 : (endIx + 1);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
if (recIx == startIx) { if (recIx == startIx) {
recIx = endIx + 1; recIx = endIx + 1;
@ -1002,7 +1002,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testUpdateFixedKeyRecord() throws IOException { public void testUpdateFixedKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -1016,7 +1016,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1025,7 +1025,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testUpdateBigFixedKeyRecord() throws IOException { public void testUpdateBigFixedKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -1039,7 +1039,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1054,7 +1054,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
recIx = 0; recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1066,7 +1066,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
assertTrue(!dbh.canUndo()); assertTrue(!dbh.canUndo());
assertTrue(!dbh.canRedo()); assertTrue(!dbh.canRedo());
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -1077,7 +1077,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
// Update records // Update records
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
for (int i = 0; i < cnt; i += 100) { for (int i = 0; i < cnt; i += 100) {
Record rec = table.getSchema().createRecord(recs[i].getKeyField()); DBRecord rec = table.getSchema().createRecord(recs[i].getKeyField());
DBTestUtils.fillRecord(rec, (BUFFER_SIZE / 8) * BUFFER_SIZE); DBTestUtils.fillRecord(rec, (BUFFER_SIZE / 8) * BUFFER_SIZE);
table.putRecord(rec); table.putRecord(rec);
} }
@ -1093,7 +1093,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1115,7 +1115,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
recIx = 0; recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1128,7 +1128,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
assertTrue(!dbh.canUndo()); assertTrue(!dbh.canUndo());
assertTrue(!dbh.canRedo()); assertTrue(!dbh.canRedo());
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
assertTrue(dbh.canUndo()); assertTrue(dbh.canUndo());
assertTrue(!dbh.canRedo()); assertTrue(!dbh.canRedo());
@ -1163,13 +1163,13 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
// Add records // Add records
Record[] newRecs = new Record[recs.length + 100]; DBRecord[] newRecs = new DBRecord[recs.length + 100];
System.arraycopy(recs, 0, newRecs, 0, recs.length); System.arraycopy(recs, 0, newRecs, 0, recs.length);
txId = dbh.startTransaction(); txId = dbh.startTransaction();
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
@ -1193,7 +1193,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
recIx = 0; recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recs.length, recIx); assertEquals(recs.length, recIx);

View file

@ -87,11 +87,11 @@ public class DBIndexedTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createRandomTableRecords(int schemaType, int recordCnt, int varDataSize) private DBRecord[] createRandomTableRecords(int schemaType, int recordCnt, int varDataSize)
throws IOException { throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = DBTestUtils.createLongKeyTable(dbh, table1Name, schemaType, true, false); Table table = DBTestUtils.createLongKeyTable(dbh, table1Name, schemaType, true, false);
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
recs[i] = DBTestUtils.createLongKeyRecord(table, true, varDataSize, true); recs[i] = DBTestUtils.createLongKeyRecord(table, true, varDataSize, true);
@ -111,12 +111,12 @@ public class DBIndexedTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createOrderedTableRecords(int schemaType, int recordCnt, long keyIncrement, private DBRecord[] createOrderedTableRecords(int schemaType, int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = DBTestUtils.createLongKeyTable(dbh, table1Name, schemaType, true, false); Table table = DBTestUtils.createLongKeyTable(dbh, table1Name, schemaType, true, false);
long key = 0; long key = 0;
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true); recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true);
@ -130,19 +130,19 @@ public class DBIndexedTableTest extends AbstractGenericTest {
return recs; return recs;
} }
private Field[] matchingKeys(Record[] recs, int columnIx, Record matchRec) { private Field[] matchingKeys(DBRecord[] recs, int columnIx, DBRecord matchRec) {
ArrayList<Record> recList = new ArrayList<>(); ArrayList<DBRecord> recList = new ArrayList<>();
Field f = matchRec.getField(columnIx); Field f = matchRec.getField(columnIx);
for (Record rec : recs) { for (DBRecord rec : recs) {
if (f.equals(rec.getField(columnIx))) { if (f.equals(rec.getField(columnIx))) {
recList.add(rec); recList.add(rec);
} }
} }
Field[] keys = new Field[recList.size()]; Field[] keys = new Field[recList.size()];
Iterator<Record> iter = recList.iterator(); Iterator<DBRecord> iter = recList.iterator();
int i = 0; int i = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
keys[i++] = rec.getKeyField(); keys[i++] = rec.getKeyField();
} }
Arrays.sort(keys); Arrays.sort(keys);
@ -151,7 +151,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
private void findRecords(boolean testStoredDB, int recordCnt, int findCnt, int varDataSize) private void findRecords(boolean testStoredDB, int recordCnt, int findCnt, int varDataSize)
throws IOException { throws IOException {
Record[] recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);// short var-len fields DBRecord[] recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);// short var-len fields
if (testStoredDB) { if (testStoredDB) {
saveAsAndReopen(dbName); saveAsAndReopen(dbName);
} }
@ -239,7 +239,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
private void updateRecordsIterator(boolean testStoredDB, int schemaType, int recordCnt, private void updateRecordsIterator(boolean testStoredDB, int schemaType, int recordCnt,
long keyIncrement, int varDataSize) throws IOException { long keyIncrement, int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomTableRecords(schemaType, recordCnt, varDataSize); recs = createRandomTableRecords(schemaType, recordCnt, varDataSize);
} }
@ -307,7 +307,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
int recIx = 0; int recIx = 0;
RecordIterator iter = table.indexIterator(colIx); RecordIterator iter = table.indexIterator(colIx);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -317,7 +317,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -327,7 +327,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -337,7 +337,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -346,7 +346,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = findStart(recs, recordCnt / 2, colIx); recIx = findStart(recs, recordCnt / 2, colIx);
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -355,7 +355,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = recordCnt - 1; recIx = recordCnt - 1;
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -364,7 +364,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = findEnd(recs, recordCnt / 2, colIx); recIx = findEnd(recs, recordCnt / 2, colIx);
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -377,7 +377,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1); startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1);
iter = table.indexIteratorAfter(colIx, startValue); iter = table.indexIteratorAfter(colIx, startValue);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -387,7 +387,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1); startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1);
iter = table.indexIteratorBefore(colIx, startValue); iter = table.indexIteratorBefore(colIx, startValue);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -411,7 +411,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
private void iterateRecords(boolean testStoredDB, int schemaType, int recordCnt, private void iterateRecords(boolean testStoredDB, int schemaType, int recordCnt,
long keyIncrement, int varDataSize, boolean doUndoRedo) throws IOException { long keyIncrement, int varDataSize, boolean doUndoRedo) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomTableRecords(schemaType, recordCnt, varDataSize); recs = createRandomTableRecords(schemaType, recordCnt, varDataSize);
} }
@ -444,7 +444,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = 0; recIx = 0;
iter = table.indexIterator(colIx); iter = table.indexIterator(colIx);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx], rec); assertEquals(recs[recIx], rec);
Field indexField = recs[recIx].getField(colIx); Field indexField = recs[recIx].getField(colIx);
if (lastIndex == null || !lastIndex.equals(indexField)) { if (lastIndex == null || !lastIndex.equals(indexField)) {
@ -474,7 +474,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = findEnd(recs, startIx, colIx); recIx = findEnd(recs, startIx, colIx);
iter = table.indexIteratorAfter(colIx, recs[startIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[startIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -486,7 +486,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[startIx].getField(colIx), iter = table.indexIteratorBefore(colIx, recs[startIx].getField(colIx),
recs[startIx].getKeyField()); recs[startIx].getKeyField());
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -502,7 +502,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = 0; recIx = 0;
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -523,7 +523,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -537,7 +537,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = recordCnt - 1; recIx = recordCnt - 1;
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -547,7 +547,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -557,7 +557,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx), iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
recs[recIx].getKeyField()); recs[recIx].getKeyField());
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -566,7 +566,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = findStart(recs, recordCnt / 2, colIx); recIx = findStart(recs, recordCnt / 2, colIx);
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -575,7 +575,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = findStart(recs, recordCnt / 2, colIx); recIx = findStart(recs, recordCnt / 2, colIx);
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[--recIx], rec); assertEquals(recs[--recIx], rec);
} }
assertEquals(0, recIx); assertEquals(0, recIx);
@ -584,7 +584,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = findEnd(recs, recordCnt / 2, colIx); recIx = findEnd(recs, recordCnt / 2, colIx);
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[++recIx], rec); assertEquals(recs[++recIx], rec);
} }
assertEquals(recordCnt - 1, recIx); assertEquals(recordCnt - 1, recIx);
@ -593,7 +593,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = findEnd(recs, recordCnt / 2, colIx); recIx = findEnd(recs, recordCnt / 2, colIx);
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -605,7 +605,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIterator(colIx, recs[minIx].getField(colIx), iter = table.indexIterator(colIx, recs[minIx].getField(colIx),
recs[maxIx].getField(colIx), true); recs[maxIx].getField(colIx), true);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(maxIx + 1, recIx); assertEquals(maxIx + 1, recIx);
@ -614,7 +614,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = 0; recIx = 0;
iter = table.indexIterator(colIx, null, null, true); iter = table.indexIterator(colIx, null, null, true);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -626,7 +626,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIterator(colIx, recs[minIx].getField(colIx), iter = table.indexIterator(colIx, recs[minIx].getField(colIx),
recs[maxIx].getField(colIx), false); recs[maxIx].getField(colIx), false);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(minIx - 1, recIx); assertEquals(minIx - 1, recIx);
@ -635,7 +635,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
recIx = recordCnt - 1; recIx = recordCnt - 1;
iter = table.indexIterator(colIx, null, null, false); iter = table.indexIterator(colIx, null, null, false);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -653,7 +653,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1); startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1);
iter = table.indexIteratorAfter(colIx, startValue); iter = table.indexIteratorAfter(colIx, startValue);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -663,7 +663,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1); startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1);
iter = table.indexIteratorBefore(colIx, startValue); iter = table.indexIteratorBefore(colIx, startValue);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -676,26 +676,26 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasNext()) { if (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
} }
--recIx; --recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasPrevious()) { if (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
} }
++recIx; ++recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasNext()) { if (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
} }
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -706,26 +706,26 @@ public class DBIndexedTableTest extends AbstractGenericTest {
--recIx; --recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasPrevious()) { if (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
} }
++recIx; ++recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasNext()) { if (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
} }
--recIx; --recIx;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (iter.hasPrevious()) { if (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
} }
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -735,13 +735,13 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (iter.hasNext()) { if (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
} }
assertEquals(recordCnt - 1, recIx); assertEquals(recordCnt - 1, recIx);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -751,13 +751,13 @@ public class DBIndexedTableTest extends AbstractGenericTest {
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx)); iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (iter.hasPrevious()) { if (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[--recIx], rec); assertEquals(recs[--recIx], rec);
} }
} }
assertEquals(0, recIx); assertEquals(0, recIx);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -870,7 +870,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
private void deleteIteratedRecords(int recordCnt, int testColIx, long keyIncrement, private void deleteIteratedRecords(int recordCnt, int testColIx, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize); recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);
} }
@ -938,7 +938,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
private void deleteIteratedIndexFields(int recordCnt, int testColIx, long keyIncrement, private void deleteIteratedIndexFields(int recordCnt, int testColIx, long keyIncrement,
int varDataSize) throws Exception { int varDataSize) throws Exception {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize); recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);
} }
@ -956,7 +956,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
int fieldCnt = 0; int fieldCnt = 0;
Field lastField = null; Field lastField = null;
ArrayList<Field> fieldList = new ArrayList<>(); ArrayList<Field> fieldList = new ArrayList<>();
for (Record rec : recs) { for (DBRecord rec : recs) {
Field f = rec.getField(testColIx); Field f = rec.getField(testColIx);
if (lastField == null || !lastField.equals(f)) { if (lastField == null || !lastField.equals(f)) {
lastField = f; lastField = f;
@ -1009,7 +1009,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
int fieldCnt = 0; int fieldCnt = 0;
Field lastField = null; Field lastField = null;
ArrayList<Field> fieldList = new ArrayList<>(); ArrayList<Field> fieldList = new ArrayList<>();
for (Record rec : recs) { for (DBRecord rec : recs) {
Field f = rec.getField(testColIx); Field f = rec.getField(testColIx);
if (lastField == null || !lastField.equals(f)) { if (lastField == null || !lastField.equals(f)) {
lastField = f; lastField = f;
@ -1037,7 +1037,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
} }
} }
private int findStart(Record[] recs, int startIx, int colIx) { private int findStart(DBRecord[] recs, int startIx, int colIx) {
Field f = recs[startIx].getField(colIx); Field f = recs[startIx].getField(colIx);
--startIx; --startIx;
while (startIx >= 0 && f.equals(recs[startIx].getField(colIx))) { while (startIx >= 0 && f.equals(recs[startIx].getField(colIx))) {
@ -1049,7 +1049,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
return ++startIx; return ++startIx;
} }
private int findEnd(Record[] recs, int startIx, int colIx) { private int findEnd(DBRecord[] recs, int startIx, int colIx) {
Field f = recs[startIx].getField(colIx); Field f = recs[startIx].getField(colIx);
++startIx; ++startIx;
while (startIx < recs.length && f.equals(recs[startIx].getField(colIx))) { while (startIx < recs.length && f.equals(recs[startIx].getField(colIx))) {
@ -1061,7 +1061,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
return --startIx; return --startIx;
} }
private class RecColumnComparator implements Comparator<Record> { private class RecColumnComparator implements Comparator<DBRecord> {
final int columnIx; final int columnIx;
@ -1073,7 +1073,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/ */
@Override @Override
public int compare(Record rec1, Record rec2) { public int compare(DBRecord rec1, DBRecord rec2) {
int r = rec1.getField(columnIx).compareTo(rec2.getField(columnIx)); int r = rec1.getField(columnIx).compareTo(rec2.getField(columnIx));
if (r == 0) { if (r == 0) {
if (rec1.getKey() == rec2.getKey()) { if (rec1.getKey() == rec2.getKey()) {
@ -1156,7 +1156,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
@Test @Test
public void testRecordIteratorExtents() throws IOException { public void testRecordIteratorExtents() throws IOException {
Record[] recs = null; DBRecord[] recs = null;
recs = createOrderedRecordRange(DBTestUtils.SINGLE_SHORT, 30, 2, 1); recs = createOrderedRecordRange(DBTestUtils.SINGLE_SHORT, 30, 2, 1);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
assertEquals(recs.length, table.getRecordCount()); assertEquals(recs.length, table.getRecordCount());
@ -1174,17 +1174,17 @@ public class DBIndexedTableTest extends AbstractGenericTest {
Field maxField = new ShortField(Short.MAX_VALUE); Field maxField = new ShortField(Short.MAX_VALUE);
RecordIterator iter = table.indexIterator(colIx, minField, maxField, false); RecordIterator iter = table.indexIterator(colIx, minField, maxField, false);
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(recIx, -1); assertEquals(recIx, -1);
} }
private Record[] createOrderedRecordRange(int schemaType, int recordCnt, long keyIncrement, private DBRecord[] createOrderedRecordRange(int schemaType, int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = DBTestUtils.createLongKeyTable(dbh, table1Name, schemaType, true, false); Table table = DBTestUtils.createLongKeyTable(dbh, table1Name, schemaType, true, false);
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int key = 0; key < recordCnt; key++) { for (int key = 0; key < recordCnt; key++) {
try { try {
recs[key] = DBTestUtils.createMidRangeRecord(table, key, varDataSize, true); recs[key] = DBTestUtils.createMidRangeRecord(table, key, varDataSize, true);
@ -1220,7 +1220,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
@Test @Test
public void testConsistencyAndIndexRebuild() throws IOException { public void testConsistencyAndIndexRebuild() throws IOException {
Record[] recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, ITER_REC_CNT, 10); DBRecord[] recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, ITER_REC_CNT, 10);
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
try { try {
@ -1240,7 +1240,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
int recIx = 0; int recIx = 0;
RecordIterator iter = table.indexIterator(colIx); RecordIterator iter = table.indexIterator(colIx);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(ITER_REC_CNT, recIx); assertEquals(ITER_REC_CNT, recIx);
@ -1254,7 +1254,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
int recIx = 0; int recIx = 0;
RecordIterator iter = table.indexIterator(colIx); RecordIterator iter = table.indexIterator(colIx);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(ITER_REC_CNT, recIx); assertEquals(ITER_REC_CNT, recIx);

View file

@ -77,7 +77,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
// Add even keys // Add even keys
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = schema.createRecord(k); DBRecord rec = schema.createRecord(k);
rec.setString(0, getBigString("a", k)); rec.setString(0, getBigString("a", k));
rec.setString(1, getSmallString("b", k)); rec.setString(1, getSmallString("b", k));
rec.setLongValue(2, 0x2222222222222222L); rec.setLongValue(2, 0x2222222222222222L);
@ -89,7 +89,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
// Add odd keys // Add odd keys
for (int k = 1; k < 256; k += 2) { for (int k = 1; k < 256; k += 2) {
Record rec = schema.createRecord(k); DBRecord rec = schema.createRecord(k);
rec.setString(0, getBigString("a", k)); rec.setString(0, getBigString("a", k));
rec.setString(1, getSmallString("b", k)); rec.setString(1, getSmallString("b", k));
rec.setLongValue(2, 0x2222222222222222L); rec.setLongValue(2, 0x2222222222222222L);
@ -116,7 +116,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
// Add even keys // Add even keys
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = schema.createRecord(k); DBRecord rec = schema.createRecord(k);
rec.setString(0, getSmallString("a", k)); rec.setString(0, getSmallString("a", k));
rec.setString(1, getSmallString("b", k)); rec.setString(1, getSmallString("b", k));
rec.setLongValue(2, 0x2222222222222222L); rec.setLongValue(2, 0x2222222222222222L);
@ -128,7 +128,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
// Add odd keys // Add odd keys
for (int k = 1; k < 256; k += 2) { for (int k = 1; k < 256; k += 2) {
Record rec = schema.createRecord(k); DBRecord rec = schema.createRecord(k);
rec.setString(0, getSmallString("a", k)); rec.setString(0, getSmallString("a", k));
rec.setString(1, getSmallString("b", k)); rec.setString(1, getSmallString("b", k));
rec.setLongValue(2, 0x2222222222222222L); rec.setLongValue(2, 0x2222222222222222L);
@ -143,7 +143,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
return table; return table;
} }
private void assertPrimitiveColumns(Record rec) { private void assertPrimitiveColumns(DBRecord rec) {
Assert.assertEquals(0x2222222222222222L, rec.getLongValue(2)); Assert.assertEquals(0x2222222222222222L, rec.getLongValue(2));
Assert.assertEquals((byte) 0x33, rec.getByteValue(3)); Assert.assertEquals((byte) 0x33, rec.getByteValue(3));
Assert.assertEquals((short) 0x4444, rec.getShortValue(4)); Assert.assertEquals((short) 0x4444, rec.getShortValue(4));
@ -156,7 +156,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
Table table = fillTableBigRecs(256); Table table = fillTableBigRecs(256);
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
Assert.assertEquals(getBigString("a", k), rec.getString(0)); Assert.assertEquals(getBigString("a", k), rec.getString(0));
Assert.assertEquals(getSmallString("b", k), rec.getString(1)); Assert.assertEquals(getSmallString("b", k), rec.getString(1));
assertPrimitiveColumns(rec); assertPrimitiveColumns(rec);
@ -170,7 +170,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
Table table = fillTableSmallRecs(256); Table table = fillTableSmallRecs(256);
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
Assert.assertEquals(rec.getString(0), getSmallString("a", k)); Assert.assertEquals(rec.getString(0), getSmallString("a", k));
Assert.assertEquals(rec.getString(1), getSmallString("b", k)); Assert.assertEquals(rec.getString(1), getSmallString("b", k));
assertPrimitiveColumns(rec); assertPrimitiveColumns(rec);
@ -187,14 +187,14 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
// Update even keys // Update even keys
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
rec.setString(0, getSmallString("a", k)); rec.setString(0, getSmallString("a", k));
table.putRecord(rec); table.putRecord(rec);
} }
// Update odd keys // Update odd keys
for (int k = 1; k < 256; k += 2) { for (int k = 1; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
rec.setString(0, getSmallString("a", k)); rec.setString(0, getSmallString("a", k));
table.putRecord(rec); table.putRecord(rec);
} }
@ -202,7 +202,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
dbh.endTransaction(txId, true); dbh.endTransaction(txId, true);
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
Assert.assertEquals(rec.getString(0), getSmallString("a", k)); Assert.assertEquals(rec.getString(0), getSmallString("a", k));
Assert.assertEquals(rec.getString(1), getSmallString("b", k)); Assert.assertEquals(rec.getString(1), getSmallString("b", k));
assertPrimitiveColumns(rec); assertPrimitiveColumns(rec);
@ -219,14 +219,14 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
// Update even keys // Update even keys
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
rec.setString(1, getBigString("b", k, 3)); rec.setString(1, getBigString("b", k, 3));
table.putRecord(rec); table.putRecord(rec);
} }
// Update odd keys // Update odd keys
for (int k = 1; k < 256; k += 2) { for (int k = 1; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
rec.setString(1, getBigString("b", k, 3)); rec.setString(1, getBigString("b", k, 3));
table.putRecord(rec); table.putRecord(rec);
} }
@ -234,7 +234,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
dbh.endTransaction(txId, true); dbh.endTransaction(txId, true);
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
Assert.assertEquals(rec.getString(0), getBigString("a", k)); Assert.assertEquals(rec.getString(0), getBigString("a", k));
Assert.assertEquals(rec.getString(1), getBigString("b", k, 3)); Assert.assertEquals(rec.getString(1), getBigString("b", k, 3));
assertPrimitiveColumns(rec); assertPrimitiveColumns(rec);
@ -253,14 +253,14 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
// Update even keys // Update even keys
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
rec.setString(1, getBigString("b", k, 4)); rec.setString(1, getBigString("b", k, 4));
table.putRecord(rec); table.putRecord(rec);
} }
// Update odd keys // Update odd keys
for (int k = 1; k < 256; k += 2) { for (int k = 1; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
rec.setString(1, getBigString("b", k, 4)); rec.setString(1, getBigString("b", k, 4));
table.putRecord(rec); table.putRecord(rec);
} }
@ -268,7 +268,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
dbh.endTransaction(txId, true); dbh.endTransaction(txId, true);
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
Assert.assertEquals(rec.getString(0), getBigString("a", k)); Assert.assertEquals(rec.getString(0), getBigString("a", k));
Assert.assertEquals(rec.getString(1), getBigString("b", k, 4)); Assert.assertEquals(rec.getString(1), getBigString("b", k, 4));
assertPrimitiveColumns(rec); assertPrimitiveColumns(rec);
@ -285,14 +285,14 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
// Update even keys // Update even keys
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
rec.setString(1, getBigString("b", k)); rec.setString(1, getBigString("b", k));
table.putRecord(rec); table.putRecord(rec);
} }
// Update odd keys // Update odd keys
for (int k = 1; k < 256; k += 2) { for (int k = 1; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
rec.setString(1, getBigString("b", k)); rec.setString(1, getBigString("b", k));
table.putRecord(rec); table.putRecord(rec);
} }
@ -300,7 +300,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
dbh.endTransaction(txId, true); dbh.endTransaction(txId, true);
for (int k = 0; k < 256; k += 2) { for (int k = 0; k < 256; k += 2) {
Record rec = table.getRecord(k); DBRecord rec = table.getRecord(k);
Assert.assertEquals(rec.getString(0), getSmallString("a", k)); Assert.assertEquals(rec.getString(0), getSmallString("a", k));
Assert.assertEquals(rec.getString(1), getBigString("b", k)); Assert.assertEquals(rec.getString(1), getBigString("b", k));
assertPrimitiveColumns(rec); assertPrimitiveColumns(rec);

View file

@ -83,7 +83,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = Table table =
DBTestUtils.createLongKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false); DBTestUtils.createLongKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false);
Record rec = null; DBRecord rec = null;
try { try {
rec = DBTestUtils.createLongKeyRecord(table, true, varDataSize, true); rec = DBTestUtils.createLongKeyRecord(table, true, varDataSize, true);
} }
@ -262,14 +262,14 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createRandomLongKeyTableRecords(Table table, int recordCnt, int varDataSize) private DBRecord[] createRandomLongKeyTableRecords(Table table, int recordCnt, int varDataSize)
throws IOException { throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
if (table == null) { if (table == null) {
table = DBTestUtils.createLongKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, table = DBTestUtils.createLongKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false,
false); false);
} }
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
recs[i] = DBTestUtils.createLongKeyRecord(table, true, varDataSize, true); recs[i] = DBTestUtils.createLongKeyRecord(table, true, varDataSize, true);
@ -288,13 +288,13 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createOrderedLongKeyTableRecords(int recordCnt, long keyIncrement, private DBRecord[] createOrderedLongKeyTableRecords(int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = Table table =
DBTestUtils.createLongKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false); DBTestUtils.createLongKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false);
long key = 0; long key = 0;
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true); recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true);
@ -318,7 +318,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
*/ */
private void iterateLongKeyRecords(boolean testStoredDB, int recordCnt, long keyIncrement, private void iterateLongKeyRecords(boolean testStoredDB, int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomLongKeyTableRecords(null, recordCnt, varDataSize); recs = createRandomLongKeyTableRecords(null, recordCnt, varDataSize);
} }
@ -547,7 +547,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
*/ */
private void iterateLongKeys(boolean testStoredDB, int recordCnt, long keyIncrement, private void iterateLongKeys(boolean testStoredDB, int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomLongKeyTableRecords(null, recordCnt, varDataSize); recs = createRandomLongKeyTableRecords(null, recordCnt, varDataSize);
} }
@ -723,7 +723,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testForwardDeleteIterator() throws IOException { public void testForwardDeleteIterator() throws IOException {
Record[] recs = createOrderedLongKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1); DBRecord[] recs = createOrderedLongKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount()); assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
@ -743,7 +743,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testReverseDeleteIterator() throws IOException { public void testReverseDeleteIterator() throws IOException {
Record[] recs = createOrderedLongKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1); DBRecord[] recs = createOrderedLongKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount()); assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
@ -762,22 +762,22 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testGetLongKeyRecordAfter() throws IOException { public void testGetLongKeyRecordAfter() throws IOException {
Record[] recs = createRandomLongKeyTableRecords(null, 16000, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, 16000, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
// After test // After test
for (int i = 1000; i < 16000; i += 1000) { for (int i = 1000; i < 16000; i += 1000) {
Record rec = table.getRecordAfter(recs[i].getKey()); DBRecord rec = table.getRecordAfter(recs[i].getKey());
assertEquals(rec.getKey(), recs[i + 1].getKey()); assertEquals(rec.getKey(), recs[i + 1].getKey());
} }
// End test // End test
Record rec = table.getRecordAfter(recs[15999].getKey()); DBRecord rec = table.getRecordAfter(recs[15999].getKey());
assertNull(rec); assertNull(rec);
} }
private int findHoleAfterLongKey(Record[] recs, int startIx) { private int findHoleAfterLongKey(DBRecord[] recs, int startIx) {
for (int i = startIx; i < recs.length - 1; i++) { for (int i = startIx; i < recs.length - 1; i++) {
if ((recs[i].getKey() + 1) < recs[i + 1].getKey()) { if ((recs[i].getKey() + 1) < recs[i + 1].getKey()) {
return i; return i;
@ -786,7 +786,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
return -1; return -1;
} }
private int findHoleBeforeLongKey(Record[] recs, int startIx) { private int findHoleBeforeLongKey(DBRecord[] recs, int startIx) {
for (int i = startIx; i < recs.length; i++) { for (int i = startIx; i < recs.length; i++) {
if ((recs[i - 1].getKey() + 1) < recs[i].getKey()) { if ((recs[i - 1].getKey() + 1) < recs[i].getKey()) {
return i; return i;
@ -797,13 +797,13 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testGetLongKeyRecordAtOrAfter() throws IOException { public void testGetLongKeyRecordAtOrAfter() throws IOException {
Record[] recs = createRandomLongKeyTableRecords(null, 16000, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, 16000, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
// At and After tests // At and After tests
for (int i = 1000; i < 16000; i += 1000) { for (int i = 1000; i < 16000; i += 1000) {
Record rec = table.getRecordAtOrAfter(recs[i].getKey()); DBRecord rec = table.getRecordAtOrAfter(recs[i].getKey());
assertEquals(rec.getKey(), recs[i].getKey()); assertEquals(rec.getKey(), recs[i].getKey());
int ix = findHoleAfterLongKey(recs, i + 500); int ix = findHoleAfterLongKey(recs, i + 500);
if (ix < 0) { if (ix < 0) {
@ -818,7 +818,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
if (lastKey == Long.MAX_VALUE) { if (lastKey == Long.MAX_VALUE) {
Assert.fail("Bad test data"); Assert.fail("Bad test data");
} }
Record rec = table.getRecordAtOrAfter(lastKey); DBRecord rec = table.getRecordAtOrAfter(lastKey);
assertEquals(rec.getKey(), lastKey); assertEquals(rec.getKey(), lastKey);
rec = table.getRecordAtOrAfter(lastKey + 1); rec = table.getRecordAtOrAfter(lastKey + 1);
assertNull(rec); assertNull(rec);
@ -826,13 +826,13 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testGetLongKeyRecordAtOrBefore() throws IOException { public void testGetLongKeyRecordAtOrBefore() throws IOException {
Record[] recs = createRandomLongKeyTableRecords(null, 16000, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, 16000, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
// At and Before tests // At and Before tests
for (int i = 1000; i < 16000; i += 1000) { for (int i = 1000; i < 16000; i += 1000) {
Record rec = table.getRecordAtOrBefore(recs[i].getKey()); DBRecord rec = table.getRecordAtOrBefore(recs[i].getKey());
assertEquals(rec.getKey(), recs[i].getKey()); assertEquals(rec.getKey(), recs[i].getKey());
int ix = findHoleBeforeLongKey(recs, i + 500); int ix = findHoleBeforeLongKey(recs, i + 500);
if (ix < 0) { if (ix < 0) {
@ -847,7 +847,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
if (firstKey == Long.MIN_VALUE) { if (firstKey == Long.MIN_VALUE) {
Assert.fail("Bad test data"); Assert.fail("Bad test data");
} }
Record rec = table.getRecordAtOrBefore(firstKey); DBRecord rec = table.getRecordAtOrBefore(firstKey);
assertEquals(rec.getKey(), firstKey); assertEquals(rec.getKey(), firstKey);
rec = table.getRecordAtOrBefore(firstKey - 1); rec = table.getRecordAtOrBefore(firstKey - 1);
assertNull(rec); assertNull(rec);
@ -856,7 +856,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testDeleteLongKeyRecord() throws IOException { public void testDeleteLongKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -870,7 +870,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 1; int recIx = 1;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
if ((recIx % 1000) == 0) { if ((recIx % 1000) == 0) {
++recIx; ++recIx;
@ -882,7 +882,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testForwardDeleteLongKeyRecord() throws IOException { public void testForwardDeleteLongKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -898,7 +898,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testReverseDeleteLongKeyRecord() throws IOException { public void testReverseDeleteLongKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -914,7 +914,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
public void testDeleteAllLongKeyRecords() throws IOException { public void testDeleteAllLongKeyRecords() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
@ -934,7 +934,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -942,7 +942,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
private void deleteLongKeyRangeRecords(int count, int startIx, int endIx) throws IOException { private void deleteLongKeyRangeRecords(int count, int startIx, int endIx) throws IOException {
Record[] recs = createRandomLongKeyTableRecords(null, count, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, count, 1);
Arrays.sort(recs); Arrays.sort(recs);
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
@ -953,7 +953,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = startIx != 0 ? 0 : (endIx + 1); int recIx = startIx != 0 ? 0 : (endIx + 1);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
if (recIx == startIx) { if (recIx == startIx) {
recIx = endIx + 1; recIx = endIx + 1;
@ -982,7 +982,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testUpdateLongKeyRecord() throws IOException { public void testUpdateLongKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -996,7 +996,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1005,7 +1005,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testUpdateBigLongKeyRecord() throws IOException { public void testUpdateBigLongKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -1019,7 +1019,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1034,7 +1034,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
recIx = 0; recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1047,7 +1047,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
assertTrue(!dbh.canUndo()); assertTrue(!dbh.canUndo());
assertTrue(!dbh.canRedo()); assertTrue(!dbh.canRedo());
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -1058,7 +1058,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
// Update records // Update records
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
for (int i = 0; i < cnt; i += 100) { for (int i = 0; i < cnt; i += 100) {
Record rec = table.getSchema().createRecord(recs[i].getKey()); DBRecord rec = table.getSchema().createRecord(recs[i].getKey());
DBTestUtils.fillRecord(rec, (BUFFER_SIZE / 8) * BUFFER_SIZE); DBTestUtils.fillRecord(rec, (BUFFER_SIZE / 8) * BUFFER_SIZE);
table.putRecord(rec); table.putRecord(rec);
} }
@ -1074,7 +1074,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1096,7 +1096,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
recIx = 0; recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -1109,7 +1109,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
assertTrue(!dbh.canUndo()); assertTrue(!dbh.canUndo());
assertTrue(!dbh.canRedo()); assertTrue(!dbh.canRedo());
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
assertTrue(dbh.canUndo()); assertTrue(dbh.canUndo());
assertTrue(!dbh.canRedo()); assertTrue(!dbh.canRedo());
@ -1144,13 +1144,13 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
// Add records // Add records
Record[] newRecs = new Record[recs.length + 100]; DBRecord[] newRecs = new DBRecord[recs.length + 100];
System.arraycopy(recs, 0, newRecs, 0, recs.length); System.arraycopy(recs, 0, newRecs, 0, recs.length);
txId = dbh.startTransaction(); txId = dbh.startTransaction();
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
@ -1174,7 +1174,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
recIx = 0; recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recs.length, recIx); assertEquals(recs.length, recIx);

View file

@ -464,7 +464,7 @@ public class DBTest extends AbstractGenericTest {
} }
Schema s = tables[1].getSchema(); Schema s = tables[1].getSchema();
Record rec = s.createRecord(1); DBRecord rec = s.createRecord(1);
txId = dbh.startTransaction(); txId = dbh.startTransaction();
try { try {

View file

@ -271,7 +271,7 @@ public class DBTestUtils {
* @param doInsert insert record into table if true * @param doInsert insert record into table if true
* @return Record new record * @return Record new record
*/ */
static Record createLongKeyRecord(Table table, boolean randomKey, int varDataSize, static DBRecord createLongKeyRecord(Table table, boolean randomKey, int varDataSize,
boolean doInsert) throws IOException, DuplicateKeyException { boolean doInsert) throws IOException, DuplicateKeyException {
long key; long key;
if (randomKey) { if (randomKey) {
@ -281,7 +281,7 @@ public class DBTestUtils {
key = table.getMaxKey() + 1; key = table.getMaxKey() + 1;
} }
try { try {
Record rec = createRecord(table, key, varDataSize, doInsert); DBRecord rec = createRecord(table, key, varDataSize, doInsert);
if (!randomKey) { if (!randomKey) {
Assert.assertEquals(rec.getKey(), table.getMaxKey()); Assert.assertEquals(rec.getKey(), table.getMaxKey());
} }
@ -304,7 +304,7 @@ public class DBTestUtils {
* @throws IOException * @throws IOException
* @throws DuplicateKeyException * @throws DuplicateKeyException
*/ */
static Record createFixedKeyRecord(Table table, int varDataSize, boolean doInsert) static DBRecord createFixedKeyRecord(Table table, int varDataSize, boolean doInsert)
throws IOException, DuplicateKeyException { throws IOException, DuplicateKeyException {
int keyLength = 10; int keyLength = 10;
byte[] bytes = new byte[keyLength]; byte[] bytes = new byte[keyLength];
@ -313,7 +313,7 @@ public class DBTestUtils {
key.setBinaryData(bytes); key.setBinaryData(bytes);
try { try {
Record rec = createRecord(table, key, varDataSize, doInsert); DBRecord rec = createRecord(table, key, varDataSize, doInsert);
Assert.assertEquals(key, rec.getKeyField()); Assert.assertEquals(key, rec.getKeyField());
return rec; return rec;
} }
@ -332,7 +332,7 @@ public class DBTestUtils {
* @throws IOException * @throws IOException
* @throws DuplicateKeyException * @throws DuplicateKeyException
*/ */
static Record createBinaryKeyRecord(Table table, int maxKeyLength, int varDataSize, static DBRecord createBinaryKeyRecord(Table table, int maxKeyLength, int varDataSize,
boolean doInsert) throws IOException, DuplicateKeyException { boolean doInsert) throws IOException, DuplicateKeyException {
int keyLength = int keyLength =
(maxKeyLength < 0) ? -maxKeyLength : DBTestUtils.getRandomKeyLength(maxKeyLength); (maxKeyLength < 0) ? -maxKeyLength : DBTestUtils.getRandomKeyLength(maxKeyLength);
@ -342,7 +342,7 @@ public class DBTestUtils {
key.setBinaryData(bytes); key.setBinaryData(bytes);
try { try {
Record rec = createRecord(table, key, varDataSize, doInsert); DBRecord rec = createRecord(table, key, varDataSize, doInsert);
Assert.assertEquals(key, rec.getKeyField()); Assert.assertEquals(key, rec.getKeyField());
return rec; return rec;
} }
@ -361,18 +361,18 @@ public class DBTestUtils {
* @throws IOException * @throws IOException
* @throws DuplicateKeyException record with assigned key already exists in table. * @throws DuplicateKeyException record with assigned key already exists in table.
*/ */
static Record createRecord(Table table, long key, int varDataSize, boolean doInsert) static DBRecord createRecord(Table table, long key, int varDataSize, boolean doInsert)
throws IOException, DuplicateKeyException { throws IOException, DuplicateKeyException {
// Check for duplicate key // Check for duplicate key
if (doInsert) { if (doInsert) {
Record oldRec = table.getRecord(key); DBRecord oldRec = table.getRecord(key);
if (oldRec != null) { if (oldRec != null) {
throw new DuplicateKeyException(); throw new DuplicateKeyException();
} }
} }
// Create record and fill with data // Create record and fill with data
Record rec = table.getSchema().createRecord(key); DBRecord rec = table.getSchema().createRecord(key);
fillRecord(rec, varDataSize); fillRecord(rec, varDataSize);
// Insert record if requested // Insert record if requested
@ -395,18 +395,18 @@ public class DBTestUtils {
* @throws IOException * @throws IOException
* @throws DuplicateKeyException record with assigned key already exists in table. * @throws DuplicateKeyException record with assigned key already exists in table.
*/ */
static Record createRecord(Table table, Field key, int varDataSize, boolean doInsert) static DBRecord createRecord(Table table, Field key, int varDataSize, boolean doInsert)
throws IOException, DuplicateKeyException { throws IOException, DuplicateKeyException {
// Check for duplicate key // Check for duplicate key
if (doInsert) { if (doInsert) {
Record oldRec = table.getRecord(key); DBRecord oldRec = table.getRecord(key);
if (oldRec != null) { if (oldRec != null) {
throw new DuplicateKeyException(); throw new DuplicateKeyException();
} }
} }
// Create record and fill with data // Create record and fill with data
Record rec = table.getSchema().createRecord(key); DBRecord rec = table.getSchema().createRecord(key);
fillRecord(rec, varDataSize); fillRecord(rec, varDataSize);
// Insert record if requested // Insert record if requested
@ -455,18 +455,18 @@ public class DBTestUtils {
* @throws IOException * @throws IOException
* @throws DuplicateKeyException record with assigned key already exists in table. * @throws DuplicateKeyException record with assigned key already exists in table.
*/ */
static Record createMidRangeRecord(Table table, long key, int varDataSize, boolean doInsert) static DBRecord createMidRangeRecord(Table table, long key, int varDataSize, boolean doInsert)
throws IOException, DuplicateKeyException { throws IOException, DuplicateKeyException {
// Check for duplicate key // Check for duplicate key
if (doInsert) { if (doInsert) {
Record oldRec = table.getRecord(key); DBRecord oldRec = table.getRecord(key);
if (oldRec != null) { if (oldRec != null) {
throw new DuplicateKeyException(); throw new DuplicateKeyException();
} }
} }
// Create record and fill with data // Create record and fill with data
Record rec = table.getSchema().createRecord(key); DBRecord rec = table.getSchema().createRecord(key);
fillMidRangeRecord(rec, varDataSize); fillMidRangeRecord(rec, varDataSize);
// Insert record if requested // Insert record if requested
@ -490,18 +490,18 @@ public class DBTestUtils {
* @throws IOException * @throws IOException
* @throws DuplicateKeyException record with assigned key already exists in table. * @throws DuplicateKeyException record with assigned key already exists in table.
*/ */
static Record createMidRangeRecord(Table table, Field key, int varDataSize, boolean doInsert) static DBRecord createMidRangeRecord(Table table, Field key, int varDataSize, boolean doInsert)
throws IOException, DuplicateKeyException { throws IOException, DuplicateKeyException {
// Check for duplicate key // Check for duplicate key
if (doInsert) { if (doInsert) {
Record oldRec = table.getRecord(key); DBRecord oldRec = table.getRecord(key);
if (oldRec != null) { if (oldRec != null) {
throw new DuplicateKeyException(); throw new DuplicateKeyException();
} }
} }
// Create record and fill with data // Create record and fill with data
Record rec = table.getSchema().createRecord(key); DBRecord rec = table.getSchema().createRecord(key);
fillMidRangeRecord(rec, varDataSize); fillMidRangeRecord(rec, varDataSize);
// Insert record if requested // Insert record if requested
@ -521,7 +521,7 @@ public class DBTestUtils {
* NOTE: The StringField does not strictly follow the varDataSize paramter. * NOTE: The StringField does not strictly follow the varDataSize paramter.
* A value less than 0 results in a null assignment to those fields. * A value less than 0 results in a null assignment to those fields.
*/ */
static void fillRecord(Record rec, int varDataSize) { static void fillRecord(DBRecord rec, int varDataSize) {
Field[] fields = rec.getFields(); Field[] fields = rec.getFields();
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {
@ -586,7 +586,7 @@ public class DBTestUtils {
* @param varDataSize number of bytes to fill into all variable length fields. * @param varDataSize number of bytes to fill into all variable length fields.
* A value less than 0 results in a null assignment to those fields. * A value less than 0 results in a null assignment to those fields.
*/ */
static void fillMidRangeRecord(Record rec, int varDataSize) { static void fillMidRangeRecord(DBRecord rec, int varDataSize) {
Field[] fields = rec.getFields(); Field[] fields = rec.getFields();
for (int i = 0; i < fields.length; i++) { for (int i = 0; i < fields.length; i++) {

View file

@ -86,7 +86,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = Table table =
DBTestUtils.createBinaryKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false); DBTestUtils.createBinaryKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false);
Record rec = null; DBRecord rec = null;
try { try {
rec = DBTestUtils.createBinaryKeyRecord(table, -MAX_VAR_KEY_LENGTH, varDataSize, true); rec = DBTestUtils.createBinaryKeyRecord(table, -MAX_VAR_KEY_LENGTH, varDataSize, true);
} }
@ -271,13 +271,13 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createRandomVarKeyTableRecords(Table table, int recordCnt, int varDataSize) private DBRecord[] createRandomVarKeyTableRecords(Table table, int recordCnt, int varDataSize)
throws IOException { throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
if (table == null) { if (table == null) {
table = DBTestUtils.createBinaryKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false); table = DBTestUtils.createBinaryKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false);
} }
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
recs[i] = recs[i] =
@ -297,7 +297,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
* @param varDataSize size of variable length data fields. * @param varDataSize size of variable length data fields.
* @return Record[] records which were inserted. * @return Record[] records which were inserted.
*/ */
private Record[] createOrderedVarKeyTableRecords(int recordCnt, long keyIncrement, private DBRecord[] createOrderedVarKeyTableRecords(int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = Table table =
@ -305,7 +305,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
long key = 0; long key = 0;
Field keyField = new LongField(); Field keyField = new LongField();
Record[] recs = new Record[recordCnt]; DBRecord[] recs = new DBRecord[recordCnt];
for (int i = 0; i < recordCnt; i++) { for (int i = 0; i < recordCnt; i++) {
try { try {
keyField.setLongValue(key); keyField.setLongValue(key);
@ -331,7 +331,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
*/ */
private void iterateVarKeyRecords(boolean testStoredDB, int recordCnt, long keyIncrement, private void iterateVarKeyRecords(boolean testStoredDB, int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomVarKeyTableRecords(null, recordCnt, varDataSize); recs = createRandomVarKeyTableRecords(null, recordCnt, varDataSize);
} }
@ -349,7 +349,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
int recIx = 0; int recIx = 0;
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -358,7 +358,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
recIx = recordCnt / 2; recIx = recordCnt / 2;
iter = table.iterator(recs[recIx].getKeyField()); iter = table.iterator(recs[recIx].getKeyField());
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recordCnt, recIx); assertEquals(recordCnt, recIx);
@ -367,7 +367,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
recIx = recordCnt - 1; recIx = recordCnt - 1;
iter = table.iterator(DBTestUtils.getMaxValue(MAX_VAR_KEY_LENGTH)); iter = table.iterator(DBTestUtils.getMaxValue(MAX_VAR_KEY_LENGTH));
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -376,7 +376,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
recIx = recordCnt / 2; recIx = recordCnt / 2;
iter = table.iterator(recs[recIx].getKeyField()); iter = table.iterator(recs[recIx].getKeyField());
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(-1, recIx); assertEquals(-1, recIx);
@ -388,7 +388,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
recs[minIx].getKeyField()); recs[minIx].getKeyField());
recIx = minIx; recIx = minIx;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(recIx, maxIx + 1); assertEquals(recIx, maxIx + 1);
@ -398,7 +398,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
recs[maxIx].getKeyField()); recs[maxIx].getKeyField());
recIx = maxIx; recIx = maxIx;
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(recs[recIx--], rec); assertEquals(recs[recIx--], rec);
} }
assertEquals(recIx, minIx - 1); assertEquals(recIx, minIx - 1);
@ -515,7 +515,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
*/ */
private void iterateVarKeys(boolean testStoredDB, int recordCnt, long keyIncrement, private void iterateVarKeys(boolean testStoredDB, int recordCnt, long keyIncrement,
int varDataSize) throws IOException { int varDataSize) throws IOException {
Record[] recs = null; DBRecord[] recs = null;
if (keyIncrement == 0) { if (keyIncrement == 0) {
recs = createRandomVarKeyTableRecords(null, recordCnt, varDataSize); recs = createRandomVarKeyTableRecords(null, recordCnt, varDataSize);
} }
@ -692,7 +692,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testForwardDeleteIterator() throws IOException { public void testForwardDeleteIterator() throws IOException {
Record[] recs = createOrderedVarKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1); DBRecord[] recs = createOrderedVarKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount()); assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
@ -711,7 +711,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testReverseDeleteIterator() throws IOException { public void testReverseDeleteIterator() throws IOException {
Record[] recs = createOrderedVarKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1); DBRecord[] recs = createOrderedVarKeyTableRecords(SMALL_ITER_REC_CNT, 2, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount()); assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
@ -729,22 +729,22 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testGetVarKeyRecordAfter() throws IOException { public void testGetVarKeyRecordAfter() throws IOException {
Record[] recs = createRandomVarKeyTableRecords(null, 16000, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, 16000, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
// After test // After test
for (int i = 1000; i < 16000; i += 1000) { for (int i = 1000; i < 16000; i += 1000) {
Record rec = table.getRecordAfter(recs[i].getKeyField()); DBRecord rec = table.getRecordAfter(recs[i].getKeyField());
assertEquals(rec.getKeyField(), recs[i + 1].getKeyField()); assertEquals(rec.getKeyField(), recs[i + 1].getKeyField());
} }
// End test // End test
Record rec = table.getRecordAfter(recs[15999].getKeyField()); DBRecord rec = table.getRecordAfter(recs[15999].getKeyField());
assertNull(rec); assertNull(rec);
} }
private int findHoleAfterVarKey(Record[] recs, int startIx) { private int findHoleAfterVarKey(DBRecord[] recs, int startIx) {
for (int i = startIx; i < recs.length - 1; i++) { for (int i = startIx; i < recs.length - 1; i++) {
if (DBTestUtils.increment((BinaryField) recs[i].getKeyField(), if (DBTestUtils.increment((BinaryField) recs[i].getKeyField(),
MAX_VAR_KEY_LENGTH).compareTo(recs[i + 1].getKeyField()) < 0) { MAX_VAR_KEY_LENGTH).compareTo(recs[i + 1].getKeyField()) < 0) {
@ -754,7 +754,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
return -1; return -1;
} }
private int findHoleBeforeVarKey(Record[] recs, int startIx) { private int findHoleBeforeVarKey(DBRecord[] recs, int startIx) {
for (int i = startIx; i < recs.length; i++) { for (int i = startIx; i < recs.length; i++) {
if (DBTestUtils.increment((BinaryField) recs[i - 1].getKeyField(), if (DBTestUtils.increment((BinaryField) recs[i - 1].getKeyField(),
MAX_VAR_KEY_LENGTH).compareTo(recs[i].getKeyField()) < 0) { MAX_VAR_KEY_LENGTH).compareTo(recs[i].getKeyField()) < 0) {
@ -766,13 +766,13 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testGetVarKeyRecordAtOrAfter() throws IOException { public void testGetVarKeyRecordAtOrAfter() throws IOException {
Record[] recs = createRandomVarKeyTableRecords(null, 16000, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, 16000, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
// At and After tests // At and After tests
for (int i = 1000; i < 16000; i += 1000) { for (int i = 1000; i < 16000; i += 1000) {
Record rec = table.getRecordAtOrAfter(recs[i].getKeyField()); DBRecord rec = table.getRecordAtOrAfter(recs[i].getKeyField());
assertEquals(rec.getKeyField(), recs[i].getKeyField()); assertEquals(rec.getKeyField(), recs[i].getKeyField());
int ix = findHoleAfterVarKey(recs, i + 500); int ix = findHoleAfterVarKey(recs, i + 500);
if (ix < 0) { if (ix < 0) {
@ -785,7 +785,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
// End tests // End tests
Field lastKey = recs[15999].getKeyField(); Field lastKey = recs[15999].getKeyField();
Record rec = table.getRecordAtOrAfter(lastKey); DBRecord rec = table.getRecordAtOrAfter(lastKey);
assertEquals(rec.getKeyField(), lastKey); assertEquals(rec.getKeyField(), lastKey);
rec = table.getRecordAtOrAfter( rec = table.getRecordAtOrAfter(
DBTestUtils.increment((BinaryField) lastKey, MAX_VAR_KEY_LENGTH)); DBTestUtils.increment((BinaryField) lastKey, MAX_VAR_KEY_LENGTH));
@ -794,13 +794,13 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testGetVarKeyRecordAtOrBefore() throws IOException { public void testGetVarKeyRecordAtOrBefore() throws IOException {
Record[] recs = createRandomVarKeyTableRecords(null, 16000, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, 16000, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
// At and Before tests // At and Before tests
for (int i = 1000; i < 16000; i += 1000) { for (int i = 1000; i < 16000; i += 1000) {
Record rec = table.getRecordAtOrBefore(recs[i].getKeyField()); DBRecord rec = table.getRecordAtOrBefore(recs[i].getKeyField());
assertEquals(rec.getKeyField(), recs[i].getKeyField()); assertEquals(rec.getKeyField(), recs[i].getKeyField());
int ix = findHoleBeforeVarKey(recs, i + 500); int ix = findHoleBeforeVarKey(recs, i + 500);
if (ix < 0) { if (ix < 0) {
@ -813,7 +813,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
// End tests // End tests
Field firstKey = recs[0].getKeyField(); Field firstKey = recs[0].getKeyField();
Record rec = table.getRecordAtOrBefore(firstKey); DBRecord rec = table.getRecordAtOrBefore(firstKey);
assertEquals(rec.getKeyField(), firstKey); assertEquals(rec.getKeyField(), firstKey);
rec = table.getRecordAtOrBefore( rec = table.getRecordAtOrBefore(
DBTestUtils.decrement((BinaryField) firstKey, MAX_VAR_KEY_LENGTH)); DBTestUtils.decrement((BinaryField) firstKey, MAX_VAR_KEY_LENGTH));
@ -823,7 +823,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testDeleteVarKeyRecord() throws IOException { public void testDeleteVarKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -837,7 +837,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 1; int recIx = 1;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
if ((recIx % 1000) == 0) { if ((recIx % 1000) == 0) {
++recIx; ++recIx;
@ -849,7 +849,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testForwardDeleteVarKeyRecord() throws IOException { public void testForwardDeleteVarKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -865,7 +865,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testReverseDeleteVarKeyRecord() throws IOException { public void testReverseDeleteVarKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -881,7 +881,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
public void testDeleteAllVarKeyRecords() throws IOException { public void testDeleteAllVarKeyRecords() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -901,7 +901,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -909,7 +909,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
private void deleteVarKeyRangeRecords(int count, int startIx, int endIx) throws IOException { private void deleteVarKeyRangeRecords(int count, int startIx, int endIx) throws IOException {
Record[] recs = createRandomVarKeyTableRecords(null, count, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, count, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -920,7 +920,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = startIx != 0 ? 0 : (endIx + 1); int recIx = startIx != 0 ? 0 : (endIx + 1);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
if (recIx == startIx) { if (recIx == startIx) {
recIx = endIx + 1; recIx = endIx + 1;
@ -943,7 +943,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testUpdateVarKeyRecord() throws IOException { public void testUpdateVarKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
//Record[] recs = createOrderedVarKeyTableRecords(cnt, 1, 1); //Record[] recs = createOrderedVarKeyTableRecords(cnt, 1, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -958,7 +958,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -967,7 +967,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
@Test @Test
public void testUpdateBigVarKeyRecord() throws IOException { public void testUpdateBigVarKeyRecord() throws IOException {
int cnt = SMALL_ITER_REC_CNT; int cnt = SMALL_ITER_REC_CNT;
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1); DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
Arrays.sort(recs); Arrays.sort(recs);
Table table = dbh.getTable(table1Name); Table table = dbh.getTable(table1Name);
@ -981,7 +981,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
int recIx = 0; int recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);
@ -996,7 +996,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
iter = table.iterator(); iter = table.iterator();
recIx = 0; recIx = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(recs[recIx++], rec); assertEquals(recs[recIx++], rec);
} }
assertEquals(cnt, recIx); assertEquals(cnt, recIx);

View file

@ -53,7 +53,7 @@ public class TableConcurrencyTest extends AbstractGenericTest {
schema2 = table2.getSchema(); schema2 = table2.getSchema();
for (byte i = 0; i < 100; i++) { for (byte i = 0; i < 100; i++) {
Record rec = schema1.createRecord(i); DBRecord rec = schema1.createRecord(i);
rec.setLongValue(0, i); rec.setLongValue(0, i);
table1.putRecord(rec); table1.putRecord(rec);
@ -226,7 +226,7 @@ public class TableConcurrencyTest extends AbstractGenericTest {
table1.deleteRecord(10);// iterator already primed table1.deleteRecord(10);// iterator already primed
assertTrue(iter.hasNext()); assertTrue(iter.hasNext());
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(10, rec.getKey()); assertEquals(10, rec.getKey());
assertTrue(iter.hasNext()); assertTrue(iter.hasNext());
@ -271,7 +271,7 @@ public class TableConcurrencyTest extends AbstractGenericTest {
table1.deleteRecord(10);// iterator already primed table1.deleteRecord(10);// iterator already primed
assertTrue(iter.hasPrevious()); assertTrue(iter.hasPrevious());
Record rec = iter.previous(); DBRecord rec = iter.previous();
assertEquals(10, rec.getKey()); assertEquals(10, rec.getKey());
assertTrue(iter.hasPrevious()); assertTrue(iter.hasPrevious());
@ -458,7 +458,7 @@ public class TableConcurrencyTest extends AbstractGenericTest {
table2.deleteRecord(getField((byte) 10));// iterator already primed table2.deleteRecord(getField((byte) 10));// iterator already primed
assertTrue(iter.hasNext()); assertTrue(iter.hasNext());
Record rec = iter.next(); DBRecord rec = iter.next();
assertEquals(getField((byte) 10), rec.getKeyField()); assertEquals(getField((byte) 10), rec.getKeyField());
assertTrue(iter.hasNext()); assertTrue(iter.hasNext());

View file

@ -227,10 +227,10 @@ public class TableTest extends AbstractGenericTest {
// //
// } // }
// } // }
private Record generateRandomStringRecord(Schema schema, List<Long> keyList) { private DBRecord generateRandomStringRecord(Schema schema, List<Long> keyList) {
long key = (long) (Math.random() * 1000000000F); long key = (long) (Math.random() * 1000000000F);
keyList.add(key); keyList.add(key);
Record record = schema.createRecord(key); DBRecord record = schema.createRecord(key);
record.setString(0, getRandomSizeString(200));// this size string causes 10 records per buffer record.setString(0, getRandomSizeString(200));// this size string causes 10 records per buffer
return record; return record;
} }
@ -270,7 +270,7 @@ public class TableTest extends AbstractGenericTest {
int n = bufferCount * RECORD_KEY_SPACING; int n = bufferCount * RECORD_KEY_SPACING;
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Record rec = schema.createRecord(i * RECORD_KEY_SPACING); DBRecord rec = schema.createRecord(i * RECORD_KEY_SPACING);
if (fixedSize) { if (fixedSize) {
rec.setLongValue(0, i); rec.setLongValue(0, i);
rec.setIntValue(1, i); rec.setIntValue(1, i);

View file

@ -124,7 +124,7 @@ public class RecoveryDBTest extends AbstractGenericTest {
private void tableFill(Table table, int recCnt, String baseName) throws Exception { private void tableFill(Table table, int recCnt, String baseName) throws Exception {
for (int i = 0; i < recCnt; i++) { for (int i = 0; i < recCnt; i++) {
Record rec = SCHEMA.createRecord(i); DBRecord rec = SCHEMA.createRecord(i);
rec.setString(0, baseName + i); rec.setString(0, baseName + i);
table.putRecord(rec); table.putRecord(rec);
} }
@ -152,12 +152,12 @@ public class RecoveryDBTest extends AbstractGenericTest {
assertEquals(RECORD_COUNT / 2, table1.getRecordCount()); assertEquals(RECORD_COUNT / 2, table1.getRecordCount());
for (int i = 0; i < RECORD_COUNT; i += 2) { for (int i = 0; i < RECORD_COUNT; i += 2) {
Record rec = table1.getRecord(i); DBRecord rec = table1.getRecord(i);
assertNull(rec); assertNull(rec);
} }
for (int i = 1; i < RECORD_COUNT; i += 2) { for (int i = 1; i < RECORD_COUNT; i += 2) {
Record rec = table1.getRecord(i); DBRecord rec = table1.getRecord(i);
assertNotNull(rec); assertNotNull(rec);
assertEquals("initTable1_" + i, rec.getString(0)); assertEquals("initTable1_" + i, rec.getString(0));
} }
@ -171,7 +171,7 @@ public class RecoveryDBTest extends AbstractGenericTest {
} }
for (int i = 1; i < RECORD_COUNT; i += 2) { for (int i = 1; i < RECORD_COUNT; i += 2) {
Record rec = table2.getRecord(i); DBRecord rec = table2.getRecord(i);
assertNotNull(rec); assertNotNull(rec);
assertEquals("initTable2_" + i, rec.getString(0)); assertEquals("initTable2_" + i, rec.getString(0));
} }
@ -207,12 +207,12 @@ public class RecoveryDBTest extends AbstractGenericTest {
assertEquals(RECORD_COUNT / 2, table1.getRecordCount()); assertEquals(RECORD_COUNT / 2, table1.getRecordCount());
for (int i = 0; i < RECORD_COUNT; i += 2) { for (int i = 0; i < RECORD_COUNT; i += 2) {
Record rec = table1.getRecord(i); DBRecord rec = table1.getRecord(i);
assertNull(rec); assertNull(rec);
} }
for (int i = 1; i < RECORD_COUNT; i += 2) { for (int i = 1; i < RECORD_COUNT; i += 2) {
Record rec = table1.getRecord(i); DBRecord rec = table1.getRecord(i);
assertNotNull(rec); assertNotNull(rec);
assertEquals("initTable1_" + i, rec.getString(0)); assertEquals("initTable1_" + i, rec.getString(0));
} }
@ -259,12 +259,12 @@ public class RecoveryDBTest extends AbstractGenericTest {
assertEquals(RECORD_COUNT / 2, table1.getRecordCount()); assertEquals(RECORD_COUNT / 2, table1.getRecordCount());
for (int i = 0; i < RECORD_COUNT; i += 2) { for (int i = 0; i < RECORD_COUNT; i += 2) {
Record rec = table1.getRecord(i); DBRecord rec = table1.getRecord(i);
assertNull(rec); assertNull(rec);
} }
for (int i = 1; i < RECORD_COUNT; i += 2) { for (int i = 1; i < RECORD_COUNT; i += 2) {
Record rec = table1.getRecord(i); DBRecord rec = table1.getRecord(i);
assertNotNull(rec); assertNotNull(rec);
assertEquals("initTable1_" + i, rec.getString(0)); assertEquals("initTable1_" + i, rec.getString(0));
} }
@ -278,7 +278,7 @@ public class RecoveryDBTest extends AbstractGenericTest {
} }
for (int i = 1; i < RECORD_COUNT; i += 2) { for (int i = 1; i < RECORD_COUNT; i += 2) {
Record rec = table2.getRecord(i); DBRecord rec = table2.getRecord(i);
assertNotNull(rec); assertNotNull(rec);
assertEquals("initTable2_" + i, rec.getString(0)); assertEquals("initTable2_" + i, rec.getString(0));
} }
@ -315,12 +315,12 @@ public class RecoveryDBTest extends AbstractGenericTest {
assertEquals(RECORD_COUNT / 2, table1.getRecordCount()); assertEquals(RECORD_COUNT / 2, table1.getRecordCount());
for (int i = 0; i < RECORD_COUNT; i += 2) { for (int i = 0; i < RECORD_COUNT; i += 2) {
Record rec = table1.getRecord(i); DBRecord rec = table1.getRecord(i);
assertNull(rec); assertNull(rec);
} }
for (int i = 1; i < RECORD_COUNT; i += 2) { for (int i = 1; i < RECORD_COUNT; i += 2) {
Record rec = table1.getRecord(i); DBRecord rec = table1.getRecord(i);
assertNotNull(rec); assertNotNull(rec);
assertEquals("initTable1_" + i, rec.getString(0)); assertEquals("initTable1_" + i, rec.getString(0));
} }
@ -334,7 +334,7 @@ public class RecoveryDBTest extends AbstractGenericTest {
} }
for (int i = 1; i < RECORD_COUNT; i += 2) { for (int i = 1; i < RECORD_COUNT; i += 2) {
Record rec = table2.getRecord(i); DBRecord rec = table2.getRecord(i);
assertNotNull(rec); assertNotNull(rec);
assertEquals("initTable2_" + i, rec.getString(0)); assertEquals("initTable2_" + i, rec.getString(0));
} }

View file

@ -84,7 +84,7 @@ public class PackedDatabaseTest extends AbstractGenericTest {
dbh = new PackedDBHandle("MyContent"); dbh = new PackedDBHandle("MyContent");
long txId = dbh.startTransaction(); long txId = dbh.startTransaction();
Table table = dbh.createTable("MyTable", TEST_SCHEMA); Table table = dbh.createTable("MyTable", TEST_SCHEMA);
Record rec = TEST_SCHEMA.createRecord(1); DBRecord rec = TEST_SCHEMA.createRecord(1);
rec.setString(0, "String1"); rec.setString(0, "String1");
table.putRecord(rec); table.putRecord(rec);
dbh.endTransaction(txId, true); dbh.endTransaction(txId, true);
@ -115,7 +115,7 @@ public class PackedDatabaseTest extends AbstractGenericTest {
assertNotNull(table); assertNotNull(table);
assertEquals(1, table.getRecordCount()); assertEquals(1, table.getRecordCount());
Record rec = table.getRecord(1); DBRecord rec = table.getRecord(1);
assertNotNull(rec); assertNotNull(rec);
assertEquals("String1", rec.getString(0)); assertEquals("String1", rec.getString(0));

View file

@ -35,7 +35,7 @@ class MetadataManager {
if (table != null) { if (table != null) {
RecordIterator iterator = table.iterator(); RecordIterator iterator = table.iterator();
while(iterator.hasNext()) { while(iterator.hasNext()) {
Record record = iterator.next(); DBRecord record = iterator.next();
String key = record.getString(0); String key = record.getString(0);
String value = record.getString(1); String value = record.getString(1);
metadata.put(key, value); metadata.put(key, value);
@ -58,7 +58,7 @@ class MetadataManager {
while(keyIterator.hasNext()) { while(keyIterator.hasNext()) {
String key = keyIterator.next(); String key = keyIterator.next();
String value = metadata.get(key); String value = metadata.get(key);
Record record = SCHEMA.createRecord(id++); DBRecord record = SCHEMA.createRecord(id++);
record.setString(0, key); record.setString(0, key);
record.setString(1, value); record.setString(1, value);
table.putRecord(record); table.putRecord(record);

View file

@ -97,7 +97,7 @@ class OptionsDB extends AbstractOptions {
return false; return false;
} }
RecordIterator iterator = propertyTable.iterator(new StringField(newSubListPath)); RecordIterator iterator = propertyTable.iterator(new StringField(newSubListPath));
Record rec = iterator.next(); DBRecord rec = iterator.next();
if (rec != null) { if (rec != null) {
String keyName = ((StringField) rec.getKeyField()).getString(); String keyName = ((StringField) rec.getKeyField()).getString();
if (keyName.startsWith(newSubListPath)) { if (keyName.startsWith(newSubListPath)) {
@ -106,7 +106,7 @@ class OptionsDB extends AbstractOptions {
} }
// move records // move records
ArrayList<Record> list = new ArrayList<>(); ArrayList<DBRecord> list = new ArrayList<>();
rec = propertyTable.getRecord(new StringField(oldPath)); rec = propertyTable.getRecord(new StringField(oldPath));
if (rec != null) { if (rec != null) {
propertyTable.deleteRecord(new StringField(oldPath)); propertyTable.deleteRecord(new StringField(oldPath));
@ -127,7 +127,7 @@ class OptionsDB extends AbstractOptions {
break; break;
} }
} }
for (Record updatedRec : list) { for (DBRecord updatedRec : list) {
propertyTable.putRecord(updatedRec); propertyTable.putRecord(updatedRec);
} }
@ -141,7 +141,7 @@ class OptionsDB extends AbstractOptions {
// remove records // remove records
RecordIterator iterator = propertyTable.iterator(new StringField(path)); RecordIterator iterator = propertyTable.iterator(new StringField(path));
while (iterator.hasNext()) { while (iterator.hasNext()) {
Record rec = iterator.next(); DBRecord rec = iterator.next();
String keyName = ((StringField) rec.getKeyField()).getString(); String keyName = ((StringField) rec.getKeyField()).getString();
if (keyName.equals(path)) { if (keyName.equals(path)) {
iterator.delete(); iterator.delete();
@ -186,7 +186,7 @@ class OptionsDB extends AbstractOptions {
if (propertyTable != null) { if (propertyTable != null) {
RecordIterator recIt = propertyTable.iterator(); RecordIterator recIt = propertyTable.iterator();
while (recIt.hasNext()) { while (recIt.hasNext()) {
Record rec = recIt.next(); DBRecord rec = recIt.next();
names.add(rec.getKeyField().getString()); names.add(rec.getKeyField().getString());
} }
} }
@ -208,7 +208,7 @@ class OptionsDB extends AbstractOptions {
if (propertyTable != null) { if (propertyTable != null) {
RecordIterator recIt = propertyTable.iterator(); RecordIterator recIt = propertyTable.iterator();
while (recIt.hasNext()) { while (recIt.hasNext()) {
Record rec = recIt.next(); DBRecord rec = recIt.next();
String key = rec.getKeyField().getString(); String key = rec.getKeyField().getString();
if (optionName.equals(key)) { if (optionName.equals(key)) {
return true; return true;
@ -222,7 +222,7 @@ class OptionsDB extends AbstractOptions {
return false; return false;
} }
private Record getPropertyRecord(String propertyName) { private DBRecord getPropertyRecord(String propertyName) {
if (propertyTable == null) { if (propertyTable == null) {
return null; return null;
} }
@ -238,7 +238,7 @@ class OptionsDB extends AbstractOptions {
return null; return null;
} }
private void putRecord(Record rec) { private void putRecord(DBRecord rec) {
try { try {
if (propertyTable == null) { if (propertyTable == null) {
propertyTable = propertyTable =
@ -265,7 +265,7 @@ class OptionsDB extends AbstractOptions {
@Override @Override
public Object getCurrentValue() { public Object getCurrentValue() {
if (!isCached) { if (!isCached) {
Record rec = getPropertyRecord(getName()); DBRecord rec = getPropertyRecord(getName());
if (rec == null) { if (rec == null) {
value = getDefaultValue(); value = getDefaultValue();
} }
@ -295,7 +295,7 @@ class OptionsDB extends AbstractOptions {
removePropertyFromDB(getName()); removePropertyFromDB(getName());
} }
else { else {
Record rec = PROPERTY_SCHEMA.createRecord(new StringField(getName())); DBRecord rec = PROPERTY_SCHEMA.createRecord(new StringField(getName()));
OptionType optionType = getOptionType(); OptionType optionType = getOptionType();
rec.setByteValue(TYPE_COL, (byte) (optionType.ordinal())); rec.setByteValue(TYPE_COL, (byte) (optionType.ordinal()));
rec.setString(VALUE_COL, optionType.convertObjectToString(newValue)); rec.setString(VALUE_COL, optionType.convertObjectToString(newValue));
@ -321,7 +321,7 @@ class OptionsDB extends AbstractOptions {
Object defaultValue) { Object defaultValue) {
if (type == OptionType.NO_TYPE) { if (type == OptionType.NO_TYPE) {
Record record = getPropertyRecord(optionName); DBRecord record = getPropertyRecord(optionName);
if (record != null) { if (record != null) {
type = OptionType.values()[record.getByteValue(TYPE_COL)]; type = OptionType.values()[record.getByteValue(TYPE_COL)];
} }

View file

@ -22,7 +22,7 @@ import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.*; import java.util.*;
import db.Record; import db.DBRecord;
import ghidra.program.model.address.KeyRange; import ghidra.program.model.address.KeyRange;
/** /**
@ -81,13 +81,13 @@ public class DBObjectCache<T extends DatabaseObject> {
* Retrieves the database object with the given record and associated key from the cache. * Retrieves the database object with the given record and associated key from the cache.
* This form should be used in conjunction with record iterators to avoid unnecessary * This form should be used in conjunction with record iterators to avoid unnecessary
* record query during a possible object refresh. To benefit from the record the cached * record query during a possible object refresh. To benefit from the record the cached
* object must implement the {@link DatabaseObject#refresh(Record)} method which by default * object must implement the {@link DatabaseObject#refresh(DBRecord)} method which by default
* ignores the record and simply calls {@link DatabaseObject#refresh()}. * ignores the record and simply calls {@link DatabaseObject#refresh()}.
* @param objectRecord the valid record corresponding to the object to be retrieved and possibly * @param objectRecord the valid record corresponding to the object to be retrieved and possibly
* used to refresh the associated object if found in cache * used to refresh the associated object if found in cache
* @return the cached object or null if the object with that key is not currently cached. * @return the cached object or null if the object with that key is not currently cached.
*/ */
public synchronized T get(Record objectRecord) { public synchronized T get(DBRecord objectRecord) {
long key = objectRecord.getKey(); long key = objectRecord.getKey();
KeyedSoftReference ref = map.get(key); KeyedSoftReference ref = map.get(key);
if (ref != null) { if (ref != null) {

View file

@ -384,7 +384,7 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB
private void createDatabase() throws IOException { private void createDatabase() throws IOException {
table = dbh.createTable(TABLE_NAME, SCHEMA); table = dbh.createTable(TABLE_NAME, SCHEMA);
Record record = SCHEMA.createRecord(new StringField(ARCHIVE_DB_VERSION)); DBRecord record = SCHEMA.createRecord(new StringField(ARCHIVE_DB_VERSION));
record.setString(0, Integer.toString(DB_VERSION)); record.setString(0, Integer.toString(DB_VERSION));
table.putRecord(record); table.putRecord(record);
} }
@ -430,13 +430,13 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB
private void upgradeDatabase() throws IOException { private void upgradeDatabase() throws IOException {
table = dbh.getTable(TABLE_NAME); table = dbh.getTable(TABLE_NAME);
Record record = SCHEMA.createRecord(new StringField(ARCHIVE_DB_VERSION)); DBRecord record = SCHEMA.createRecord(new StringField(ARCHIVE_DB_VERSION));
record.setString(0, Integer.toString(DB_VERSION)); record.setString(0, Integer.toString(DB_VERSION));
table.putRecord(record); table.putRecord(record);
} }
private int getStoredVersion() throws IOException { private int getStoredVersion() throws IOException {
Record record = table.getRecord(new StringField(ARCHIVE_DB_VERSION)); DBRecord record = table.getRecord(new StringField(ARCHIVE_DB_VERSION));
// DB Version // DB Version
// if record does not exist return 1; // if record does not exist return 1;

View file

@ -291,7 +291,7 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
} }
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
ids.add(rec.getLongValue(0)); ids.add(rec.getLongValue(0));
} }
} }
@ -321,7 +321,7 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
private void writeIdRecords(DBHandle dbh, String tableName, Set<Long> ids) throws IOException { private void writeIdRecords(DBHandle dbh, String tableName, Set<Long> ids) throws IOException {
if (ids.size() > 0) { if (ids.size() > 0) {
Table table = dbh.createTable(tableName, STORED_ID_SCHEMA); Table table = dbh.createTable(tableName, STORED_ID_SCHEMA);
Record rec = STORED_ID_SCHEMA.createRecord(0); DBRecord rec = STORED_ID_SCHEMA.createRecord(0);
int key = 1; int key = 1;
for (long id : ids) { for (long id : ids) {
rec.setKey(key++); rec.setKey(key++);

View file

@ -17,7 +17,7 @@ package ghidra.program.database;
import java.util.ConcurrentModificationException; import java.util.ConcurrentModificationException;
import db.Record; import db.DBRecord;
import ghidra.util.Lock; import ghidra.util.Lock;
/** /**
@ -140,7 +140,7 @@ abstract public class DatabaseObject {
* @param record optional record which may be used to refresh invalid object * @param record optional record which may be used to refresh invalid object
* @return true if the object is valid. * @return true if the object is valid.
*/ */
public boolean checkIsValid(Record record) { public boolean checkIsValid(DBRecord record) {
if (deleted) { if (deleted) {
return false; return false;
} }
@ -199,7 +199,7 @@ abstract public class DatabaseObject {
* object was deleted. Objects that extend this class must implement a refresh method. * object was deleted. Objects that extend this class must implement a refresh method.
* If an object can never refresh itself, then it should always return false. * If an object can never refresh itself, then it should always return false.
*/ */
protected boolean refresh(Record record) { protected boolean refresh(DBRecord record) {
return refresh(); return refresh();
} }
} }

View file

@ -54,7 +54,7 @@ class OverlaySpaceAdapterDB {
if (table != null) { if (table != null) {
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
String spaceName = rec.getString(OV_SPACE_NAME_COL); String spaceName = rec.getString(OV_SPACE_NAME_COL);
String templateSpaceName = rec.getString(OV_SPACE_BASE_COL); String templateSpaceName = rec.getString(OV_SPACE_BASE_COL);
long minOffset = rec.getLongValue(OV_MIN_OFFSET_COL); long minOffset = rec.getLongValue(OV_MIN_OFFSET_COL);
@ -86,7 +86,7 @@ class OverlaySpaceAdapterDB {
if (table == null) { if (table == null) {
table = db.createTable(TABLE_NAME, SCHEMA); table = db.createTable(TABLE_NAME, SCHEMA);
} }
Record rec = SCHEMA.createRecord(table.getKey()); DBRecord rec = SCHEMA.createRecord(table.getKey());
rec.setString(0, ovSpace.getName()); rec.setString(0, ovSpace.getName());
rec.setString(1, ovSpace.getOverlayedSpace().getName()); rec.setString(1, ovSpace.getOverlayedSpace().getName());
rec.setLongValue(OV_MIN_OFFSET_COL, ovSpace.getMinOffset()); rec.setLongValue(OV_MIN_OFFSET_COL, ovSpace.getMinOffset());
@ -105,7 +105,7 @@ class OverlaySpaceAdapterDB {
if (table != null) { if (table != null) {
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
String spaceName = rec.getString(0); String spaceName = rec.getString(0);
if (name.equals(spaceName)) { if (name.equals(spaceName)) {
it.delete(); it.delete();
@ -127,7 +127,7 @@ class OverlaySpaceAdapterDB {
if (table != null) { if (table != null) {
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
OverlayAddressSpace space = map.remove(rec.getKey()); OverlayAddressSpace space = map.remove(rec.getKey());
if (space != null) { if (space != null) {
//maxId = Math.max(maxId, space.getUnique()); //maxId = Math.max(maxId, space.getUnique());
@ -173,7 +173,7 @@ class OverlaySpaceAdapterDB {
if (table != null) { if (table != null) {
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
String spaceName = rec.getString(0); String spaceName = rec.getString(0);
if (oldName.equals(spaceName)) { if (oldName.equals(spaceName)) {
it.delete(); it.delete();
@ -202,7 +202,7 @@ class OverlaySpaceAdapterDB {
if (table != null) { if (table != null) {
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
String oldUnderlyingSpaceName = rec.getString(OV_SPACE_BASE_COL); String oldUnderlyingSpaceName = rec.getString(OV_SPACE_BASE_COL);
AddressSpace space = addrFactory.getAddressSpace(oldUnderlyingSpaceName); AddressSpace space = addrFactory.getAddressSpace(oldUnderlyingSpaceName);
if (space != null && space.isNonLoadedMemorySpace()) { if (space != null && space.isNonLoadedMemorySpace()) {

View file

@ -1155,7 +1155,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
if (name.equals(newName)) { if (name.equals(newName)) {
return; return;
} }
Record record = table.getRecord(new StringField(PROGRAM_NAME)); DBRecord record = table.getRecord(new StringField(PROGRAM_NAME));
record.setString(0, newName); record.setString(0, newName);
table.putRecord(record); table.putRecord(record);
getTreeManager().setProgramName(name, newName); getTreeManager().setProgramName(name, newName);
@ -1170,7 +1170,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
} }
private void refreshName() throws IOException { private void refreshName() throws IOException {
Record record = table.getRecord(new StringField(PROGRAM_NAME)); DBRecord record = table.getRecord(new StringField(PROGRAM_NAME));
name = record.getString(0); name = record.getString(0);
} }
@ -1265,7 +1265,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
} }
private long getStoredBaseImageOffset() throws IOException { private long getStoredBaseImageOffset() throws IOException {
Record rec = table.getRecord(new StringField(IMAGE_OFFSET)); DBRecord rec = table.getRecord(new StringField(IMAGE_OFFSET));
if (rec != null) { if (rec != null) {
return (new BigInteger(rec.getString(0), 16)).longValue(); return (new BigInteger(rec.getString(0), 16)).longValue();
} }
@ -1325,7 +1325,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
if (commit) { if (commit) {
try { try {
Record record = SCHEMA.createRecord(new StringField(IMAGE_OFFSET)); DBRecord record = SCHEMA.createRecord(new StringField(IMAGE_OFFSET));
record.setString(0, Long.toHexString(base.getOffset())); record.setString(0, Long.toHexString(base.getOffset()));
table.putRecord(record); table.putRecord(record);
@ -1384,7 +1384,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
private void createDatabase() throws IOException { private void createDatabase() throws IOException {
table = dbh.createTable(TABLE_NAME, SCHEMA); table = dbh.createTable(TABLE_NAME, SCHEMA);
Record record = SCHEMA.createRecord(new StringField(PROGRAM_NAME)); DBRecord record = SCHEMA.createRecord(new StringField(PROGRAM_NAME));
record.setString(0, name); record.setString(0, name);
table.putRecord(record); table.putRecord(record);
@ -1432,7 +1432,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
if (table == null) { if (table == null) {
throw new IOException("Unsupported File Content"); throw new IOException("Unsupported File Content");
} }
Record record = table.getRecord(new StringField(PROGRAM_NAME)); DBRecord record = table.getRecord(new StringField(PROGRAM_NAME));
name = record.getString(0); name = record.getString(0);
record = table.getRecord(new StringField(LANGUAGE_ID)); record = table.getRecord(new StringField(LANGUAGE_ID));
@ -1501,7 +1501,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
table = dbh.getTable(TABLE_NAME); table = dbh.getTable(TABLE_NAME);
Field key = new StringField(PROGRAM_DB_VERSION); Field key = new StringField(PROGRAM_DB_VERSION);
String versionStr = Integer.toString(DB_VERSION); String versionStr = Integer.toString(DB_VERSION);
Record record = table.getRecord(key); DBRecord record = table.getRecord(key);
if (record != null && versionStr.equals(record.getString(0))) { if (record != null && versionStr.equals(record.getString(0))) {
return; // already has correct version return; // already has correct version
} }
@ -1534,7 +1534,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
} }
public int getStoredVersion() throws IOException { public int getStoredVersion() throws IOException {
Record record = table.getRecord(new StringField(PROGRAM_DB_VERSION)); DBRecord record = table.getRecord(new StringField(PROGRAM_DB_VERSION));
if (record != null) { if (record != null) {
String s = record.getString(0); String s = record.getString(0);
try { try {
@ -1549,7 +1549,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
private void checkOldProperties(int openMode, TaskMonitor monitor) private void checkOldProperties(int openMode, TaskMonitor monitor)
throws IOException, VersionException { throws IOException, VersionException {
Record record = table.getRecord(new StringField(EXECUTE_PATH)); DBRecord record = table.getRecord(new StringField(EXECUTE_PATH));
if (record != null) { if (record != null) {
if (openMode == READ_ONLY) { if (openMode == READ_ONLY) {
return; // not important, get on path or format will return "unknown" return; // not important, get on path or format will return "unknown"
@ -2098,7 +2098,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
translator.fixupInstructions(this, translator.getOldLanguage(), monitor); translator.fixupInstructions(this, translator.getOldLanguage(), monitor);
} }
Record record = SCHEMA.createRecord(new StringField(LANGUAGE_ID)); DBRecord record = SCHEMA.createRecord(new StringField(LANGUAGE_ID));
record.setString(0, languageID.getIdAsString()); record.setString(0, languageID.getIdAsString());
table.putRecord(record); table.putRecord(record);
record = SCHEMA.createRecord(new StringField(COMPILER_SPEC_ID)); record = SCHEMA.createRecord(new StringField(COMPILER_SPEC_ID));

View file

@ -542,7 +542,7 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
ids.add(rec.getLongValue(0)); ids.add(rec.getLongValue(0));
} }
} }
@ -557,7 +557,7 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
} }
RecordIterator it = table.iterator(); RecordIterator it = table.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
Address addr1 = addrMap.decodeAddress(rec.getLongValue(0)); Address addr1 = addrMap.decodeAddress(rec.getLongValue(0));
Address addr2 = addrMap.decodeAddress(rec.getLongValue(1)); Address addr2 = addrMap.decodeAddress(rec.getLongValue(1));
// Memory addresses or external addresses are the only ones that should be in here. // Memory addresses or external addresses are the only ones that should be in here.
@ -611,7 +611,7 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
private void writeIdRecords(DBHandle dbh, String tableName, Set<Long> ids) throws IOException { private void writeIdRecords(DBHandle dbh, String tableName, Set<Long> ids) throws IOException {
if (ids.size() > 0) { if (ids.size() > 0) {
Table table = dbh.createTable(tableName, STORED_ID_SCHEMA); Table table = dbh.createTable(tableName, STORED_ID_SCHEMA);
Record rec = STORED_ID_SCHEMA.createRecord(0); DBRecord rec = STORED_ID_SCHEMA.createRecord(0);
int key = 1; int key = 1;
for (long id : ids) { for (long id : ids) {
rec.setKey(key++); rec.setKey(key++);
@ -625,7 +625,7 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
throws IOException { throws IOException {
if (!set.isEmpty()) { if (!set.isEmpty()) {
Table table = dbh.createTable(tableName, STORED_ADDRESS_RANGE_SCHEMA); Table table = dbh.createTable(tableName, STORED_ADDRESS_RANGE_SCHEMA);
Record rec = STORED_ADDRESS_RANGE_SCHEMA.createRecord(0); DBRecord rec = STORED_ADDRESS_RANGE_SCHEMA.createRecord(0);
int key = 1; int key = 1;
for (KeyRange range : addrMap.getKeyRanges(set, false, false)) { for (KeyRange range : addrMap.getKeyRanges(set, false, false)) {
rec.setKey(key++); rec.setKey(key++);

View file

@ -324,7 +324,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
registryTable = registryTable =
dbh.createTable(REGISTRY_TABLE_NAME, REGISTRY_SCHEMA, new int[] { PROPERTY_OWNER_COL }); dbh.createTable(REGISTRY_TABLE_NAME, REGISTRY_SCHEMA, new int[] { PROPERTY_OWNER_COL });
Record record = SCHEMA.createRecord(new StringField(LANGUAGE_ID)); DBRecord record = SCHEMA.createRecord(new StringField(LANGUAGE_ID));
record.setString(VALUE_COL, languageID.getIdAsString()); record.setString(VALUE_COL, languageID.getIdAsString());
table.putRecord(record); table.putRecord(record);
@ -347,7 +347,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
throw new IOException("Unsupported User Data File Content"); throw new IOException("Unsupported User Data File Content");
} }
Record record = table.getRecord(new StringField(LANGUAGE_ID)); DBRecord record = table.getRecord(new StringField(LANGUAGE_ID));
languageID = new LanguageID(record.getString(VALUE_COL)); languageID = new LanguageID(record.getString(VALUE_COL));
record = table.getRecord(new StringField(LANGUAGE_VERSION)); record = table.getRecord(new StringField(LANGUAGE_VERSION));
@ -377,7 +377,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
private void upgradeDatabase() throws IOException { private void upgradeDatabase() throws IOException {
table = dbh.getTable(TABLE_NAME); table = dbh.getTable(TABLE_NAME);
Record record = SCHEMA.createRecord(new StringField(STORED_DB_VERSION)); DBRecord record = SCHEMA.createRecord(new StringField(STORED_DB_VERSION));
record.setString(VALUE_COL, Integer.toString(DB_VERSION)); record.setString(VALUE_COL, Integer.toString(DB_VERSION));
table.putRecord(record); table.putRecord(record);
} }
@ -438,7 +438,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
clearCache(true); clearCache(true);
Record record = SCHEMA.createRecord(new StringField(LANGUAGE_ID)); DBRecord record = SCHEMA.createRecord(new StringField(LANGUAGE_ID));
record.setString(VALUE_COL, languageID.getIdAsString()); record.setString(VALUE_COL, languageID.getIdAsString());
table.putRecord(record); table.putRecord(record);
@ -472,7 +472,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
try { try {
for (Field key : registryTable.findRecords(new StringField(owner), for (Field key : registryTable.findRecords(new StringField(owner),
PROPERTY_OWNER_COL)) { PROPERTY_OWNER_COL)) {
Record rec = registryTable.getRecord(key); DBRecord rec = registryTable.getRecord(key);
if (propertyName.equals(rec.getString(PROPERTY_NAME_COL))) { if (propertyName.equals(rec.getString(PROPERTY_NAME_COL))) {
int type = rec.getIntValue(PROPERTY_TYPE_COL); int type = rec.getIntValue(PROPERTY_TYPE_COL);
if (propertyType != type) { if (propertyType != type) {
@ -495,7 +495,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
} }
long key = registryTable.getKey(); long key = registryTable.getKey();
Record rec = REGISTRY_SCHEMA.createRecord(key); DBRecord rec = REGISTRY_SCHEMA.createRecord(key);
rec.setString(PROPERTY_OWNER_COL, owner); rec.setString(PROPERTY_OWNER_COL, owner);
rec.setString(PROPERTY_NAME_COL, propertyName); rec.setString(PROPERTY_NAME_COL, propertyName);
rec.setIntValue(PROPERTY_TYPE_COL, propertyType); rec.setIntValue(PROPERTY_TYPE_COL, propertyType);
@ -526,7 +526,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
return null; return null;
} }
private PropertyMap getPropertyMap(Record rec) throws IOException { private PropertyMap getPropertyMap(DBRecord rec) throws IOException {
try { try {
PropertyMap map; PropertyMap map;
int type = rec.getIntValue(PROPERTY_TYPE_COL); int type = rec.getIntValue(PROPERTY_TYPE_COL);
@ -579,7 +579,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
try { try {
for (Field key : registryTable.findRecords(new StringField(owner), for (Field key : registryTable.findRecords(new StringField(owner),
PROPERTY_OWNER_COL)) { PROPERTY_OWNER_COL)) {
Record rec = registryTable.getRecord(key); DBRecord rec = registryTable.getRecord(key);
list.add(getPropertyMap(rec)); list.add(getPropertyMap(rec));
} }
} }
@ -596,7 +596,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
propertyMapOwners = new HashSet<String>(); propertyMapOwners = new HashSet<String>();
RecordIterator recIter = registryTable.iterator(); RecordIterator recIter = registryTable.iterator();
while (recIter.hasNext()) { while (recIter.hasNext()) {
Record rec = recIter.next(); DBRecord rec = recIter.next();
propertyMapOwners.add(rec.getString(PROPERTY_OWNER_COL)); propertyMapOwners.add(rec.getString(PROPERTY_OWNER_COL));
} }
} }

View file

@ -15,7 +15,7 @@
*/ */
package ghidra.program.database.bookmark; package ghidra.program.database.bookmark;
import db.Record; import db.DBRecord;
import ghidra.program.database.DBObjectCache; import ghidra.program.database.DBObjectCache;
import ghidra.program.database.DatabaseObject; import ghidra.program.database.DatabaseObject;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
@ -28,9 +28,9 @@ import ghidra.program.model.listing.BookmarkType;
public class BookmarkDB extends DatabaseObject implements Bookmark { public class BookmarkDB extends DatabaseObject implements Bookmark {
private BookmarkDBManager mgr; private BookmarkDBManager mgr;
private Record record; private DBRecord record;
BookmarkDB(BookmarkDBManager mgr, DBObjectCache<BookmarkDB> cache, Record record) { BookmarkDB(BookmarkDBManager mgr, DBObjectCache<BookmarkDB> cache, DBRecord record) {
super(cache, record.getKey()); super(cache, record.getKey());
this.mgr = mgr; this.mgr = mgr;
this.record = record; this.record = record;
@ -46,7 +46,7 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
* Update associated record * Update associated record
* @param rec * @param rec
*/ */
void setRecord(Record rec) { void setRecord(DBRecord rec) {
if (rec.getKey() != key) { if (rec.getKey() != key) {
throw new IllegalArgumentException("Key mismatch"); throw new IllegalArgumentException("Key mismatch");
} }
@ -121,7 +121,7 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
} }
@Override @Override
protected boolean refresh(Record rec) { protected boolean refresh(DBRecord rec) {
if (rec == null) { if (rec == null) {
rec = mgr.getRecord(key); rec = mgr.getRecord(key);
} }
@ -136,7 +136,7 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
* Returns record associated with this bookmark or * Returns record associated with this bookmark or
* null if bookmark has been deleted. * null if bookmark has been deleted.
*/ */
Record getRecord() { DBRecord getRecord() {
return checkIsValid() ? record : null; return checkIsValid() ? record : null;
} }

View file

@ -117,7 +117,7 @@ abstract class BookmarkDBAdapter {
if (monitor.isCancelled()) { if (monitor.isCancelled()) {
throw new IOException("Upgrade Cancelled"); throw new IOException("Upgrade Cancelled");
} }
Record rec = it.next(); DBRecord rec = it.next();
int typeId = getTypeId(rec); int typeId = getTypeId(rec);
tmpAdapter.addType(typeId); tmpAdapter.addType(typeId);
Address addr = oldAddrMap.decodeAddress(rec.getLongValue(ADDRESS_COL)); Address addr = oldAddrMap.decodeAddress(rec.getLongValue(ADDRESS_COL));
@ -138,7 +138,7 @@ abstract class BookmarkDBAdapter {
if (monitor.isCancelled()) { if (monitor.isCancelled()) {
throw new IOException("Upgrade Cancelled"); throw new IOException("Upgrade Cancelled");
} }
Record rec = it.next(); DBRecord rec = it.next();
newAdapter.updateRecord(rec); newAdapter.updateRecord(rec);
monitor.setProgress(++cnt); monitor.setProgress(++cnt);
} }
@ -151,7 +151,7 @@ abstract class BookmarkDBAdapter {
} }
} }
static int getTypeId(Record rec) { static int getTypeId(DBRecord rec) {
long key = rec.getKey(); long key = rec.getKey();
return (int) (key >> 48); return (int) (key >> 48);
} }
@ -181,7 +181,7 @@ abstract class BookmarkDBAdapter {
* @return * @return
* @throws IOException * @throws IOException
*/ */
Record createBookmark(int typeId, String category, long index, String comment) DBRecord createBookmark(int typeId, String category, long index, String comment)
throws IOException { throws IOException {
throw new UnsupportedOperationException("Bookmarks are read-only and may not be created"); throw new UnsupportedOperationException("Bookmarks are read-only and may not be created");
} }
@ -191,7 +191,7 @@ abstract class BookmarkDBAdapter {
* @param rec modified bookmark record * @param rec modified bookmark record
* @throws IOException * @throws IOException
*/ */
void updateRecord(Record rec) throws IOException { void updateRecord(DBRecord rec) throws IOException {
throw new UnsupportedOperationException("Bookmarks are read-only and may not be modified"); throw new UnsupportedOperationException("Bookmarks are read-only and may not be modified");
} }
@ -209,7 +209,7 @@ abstract class BookmarkDBAdapter {
* @param id bookmark ID * @param id bookmark ID
* @return bookmark record or null if not found. * @return bookmark record or null if not found.
*/ */
abstract Record getRecord(long id) throws IOException; abstract DBRecord getRecord(long id) throws IOException;
/** /**
* Get all bookmark records associated with a specific type and address. * Get all bookmark records associated with a specific type and address.

View file

@ -55,7 +55,7 @@ class BookmarkDBAdapterV0 extends BookmarkDBAdapter {
catch (VersionException e) { catch (VersionException e) {
throw new AssertException(); throw new AssertException();
} }
Record[] oldTypes = oldMgr.getTypeRecords(); DBRecord[] oldTypes = oldMgr.getTypeRecords();
if (oldTypes.length == 0) { if (oldTypes.length == 0) {
return; return;
} }
@ -88,7 +88,7 @@ class BookmarkDBAdapterV0 extends BookmarkDBAdapter {
} }
@Override @Override
Record getRecord(long id) throws IOException { DBRecord getRecord(long id) throws IOException {
return conversionAdapter.getRecord(id); return conversionAdapter.getRecord(id);
} }

View file

@ -75,7 +75,7 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
AddressSet set = new AddressSet(); AddressSet set = new AddressSet();
RecordIterator recordIter = getRecordsByType(typeId); RecordIterator recordIter = getRecordsByType(typeId);
while (recordIter.hasNext()) { while (recordIter.hasNext()) {
Record rec = recordIter.next(); DBRecord rec = recordIter.next();
Address addr = addrMap.decodeAddress(rec.getLongValue(V1_ADDRESS_COL)); Address addr = addrMap.decodeAddress(rec.getLongValue(V1_ADDRESS_COL));
set.addRange(addr, addr); set.addRange(addr, addr);
} }
@ -88,7 +88,7 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
Field fv = new LongField(typeId); Field fv = new LongField(typeId);
RecordIterator recordIter = table.indexIterator(V1_TYPE_ID_COL, fv, fv, true); RecordIterator recordIter = table.indexIterator(V1_TYPE_ID_COL, fv, fv, true);
while (recordIter.hasNext()) { while (recordIter.hasNext()) {
Record rec = recordIter.next(); DBRecord rec = recordIter.next();
String cat = demangleTypeCategory(rec.getString(V1_TYPE_CATEGORY_COL)); String cat = demangleTypeCategory(rec.getString(V1_TYPE_CATEGORY_COL));
set.add(cat); set.add(cat);
} }
@ -99,13 +99,13 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
} }
@Override @Override
Record getRecord(long id) throws IOException { DBRecord getRecord(long id) throws IOException {
return convertV1Record(table.getRecord(id)); return convertV1Record(table.getRecord(id));
} }
private static Record convertV1Record(Record record) { private static DBRecord convertV1Record(DBRecord record) {
long key = record.getLongValue(V1_TYPE_ID_COL) << 48 | (record.getKey() & 0xffffffffL); long key = record.getLongValue(V1_TYPE_ID_COL) << 48 | (record.getKey() & 0xffffffffL);
Record rec = BookmarkDBAdapter.SCHEMA.createRecord(key); DBRecord rec = BookmarkDBAdapter.SCHEMA.createRecord(key);
rec.setLongValue(BookmarkDBAdapter.ADDRESS_COL, record.getLongValue(V1_ADDRESS_COL)); rec.setLongValue(BookmarkDBAdapter.ADDRESS_COL, record.getLongValue(V1_ADDRESS_COL));
rec.setString(BookmarkDBAdapter.CATEGORY_COL, rec.setString(BookmarkDBAdapter.CATEGORY_COL,
demangleTypeCategory(record.getString(V1_TYPE_CATEGORY_COL))); demangleTypeCategory(record.getString(V1_TYPE_CATEGORY_COL)));
@ -177,10 +177,10 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
//================================================================================================== //==================================================================================================
private class BatchRecordIterator implements RecordIterator { private class BatchRecordIterator implements RecordIterator {
private ListIterator<Record> iter; private ListIterator<DBRecord> iter;
BatchRecordIterator(int typeId, long start, long end) throws IOException { BatchRecordIterator(int typeId, long start, long end) throws IOException {
ArrayList<Record> list = new ArrayList<Record>(); ArrayList<DBRecord> list = new ArrayList<DBRecord>();
Field sf = new LongField(start); Field sf = new LongField(start);
Field ef = new LongField(end); Field ef = new LongField(end);
RecordIterator recIter = table.indexIterator(V1_ADDRESS_COL, sf, ef, true); RecordIterator recIter = table.indexIterator(V1_ADDRESS_COL, sf, ef, true);
@ -201,12 +201,12 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
} }
@Override @Override
public Record next() throws IOException { public DBRecord next() throws IOException {
return iter.next(); return iter.next();
} }
@Override @Override
public Record previous() throws IOException { public DBRecord previous() throws IOException {
return iter.previous(); return iter.previous();
} }
@ -223,7 +223,7 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
} }
@Override @Override
protected Record convertRecord(Record record) { protected DBRecord convertRecord(DBRecord record) {
return convertV1Record(record); return convertV1Record(record);
} }
} }

View file

@ -107,7 +107,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
} }
@Override @Override
Record getRecord(long id) throws IOException { DBRecord getRecord(long id) throws IOException {
Table table = getTable(id); Table table = getTable(id);
if (table == null) { if (table == null) {
return null; return null;
@ -160,7 +160,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
// TODO: This is very inefficient but is just as fast as using the index iterator // TODO: This is very inefficient but is just as fast as using the index iterator
// Employing a separate category table would be faster // Employing a separate category table would be faster
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
String cat = rec.getString(V3_CATEGORY_COL); String cat = rec.getString(V3_CATEGORY_COL);
if (cat != null && cat.length() != 0) { if (cat != null && cat.length() != 0) {
set.add(cat); set.add(cat);
@ -175,7 +175,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
AddressSet set = new AddressSet(); AddressSet set = new AddressSet();
RecordIterator recordIter = getRecordsByType(typeID); RecordIterator recordIter = getRecordsByType(typeID);
while (recordIter.hasNext()) { while (recordIter.hasNext()) {
Record rec = recordIter.next(); DBRecord rec = recordIter.next();
Address addr = addressMap.decodeAddress(rec.getLongValue(V3_ADDRESS_COL)); Address addr = addressMap.decodeAddress(rec.getLongValue(V3_ADDRESS_COL));
set.addRange(addr, addr); set.addRange(addr, addr);
} }
@ -200,7 +200,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
} }
@Override @Override
Record createBookmark(int typeID, String category, long index, String comment) DBRecord createBookmark(int typeID, String category, long index, String comment)
throws IOException { throws IOException {
if (!hasTable(typeID)) { if (!hasTable(typeID)) {
return null; return null;
@ -210,7 +210,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
long nextId = table.getKey() + 1; long nextId = table.getKey() + 1;
long id = ((long) typeID << TYPE_ID_OFFSET) | nextId; long id = ((long) typeID << TYPE_ID_OFFSET) | nextId;
Record rec = V3_SCHEMA.createRecord(id); DBRecord rec = V3_SCHEMA.createRecord(id);
rec.setLongValue(V3_ADDRESS_COL, index); rec.setLongValue(V3_ADDRESS_COL, index);
rec.setString(V3_CATEGORY_COL, category); rec.setString(V3_CATEGORY_COL, category);
rec.setString(V3_COMMENT_COL, comment); rec.setString(V3_COMMENT_COL, comment);
@ -225,7 +225,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
} }
@Override @Override
void updateRecord(Record rec) throws IOException { void updateRecord(DBRecord rec) throws IOException {
Table table = getTable(rec.getKey()); Table table = getTable(rec.getKey());
table.putRecord(rec); table.putRecord(rec);
} }

View file

@ -96,8 +96,8 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
TaskMonitor.DUMMY); TaskMonitor.DUMMY);
} }
Record[] typeRecords = bookmarkTypeAdapter.getRecords(); DBRecord[] typeRecords = bookmarkTypeAdapter.getRecords();
for (Record rec : typeRecords) { for (DBRecord rec : typeRecords) {
int typeId = (int) rec.getKey(); int typeId = (int) rec.getKey();
BookmarkTypeDB type = BookmarkTypeDB type =
new BookmarkTypeDB(typeId, rec.getString(BookmarkTypeDBAdapter.TYPE_NAME_COL)); new BookmarkTypeDB(typeId, rec.getString(BookmarkTypeDBAdapter.TYPE_NAME_COL));
@ -157,7 +157,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
void bookmarkChanged(BookmarkDB bm) { void bookmarkChanged(BookmarkDB bm) {
lock.acquire(); lock.acquire();
try { try {
Record rec = bm.getRecord(); DBRecord rec = bm.getRecord();
if (rec != null) { if (rec != null) {
bookmarkAdapter.updateRecord(rec); bookmarkAdapter.updateRecord(rec);
Address addr = bm.getAddress(); Address addr = bm.getAddress();
@ -179,11 +179,11 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
private void upgradeOldBookmarks(ProgramDB programDB) { private void upgradeOldBookmarks(ProgramDB programDB) {
OldBookmarkManager oldMgr = new OldBookmarkManager(programDB); OldBookmarkManager oldMgr = new OldBookmarkManager(programDB);
Record[] oldTypes = oldMgr.getTypeRecords(); DBRecord[] oldTypes = oldMgr.getTypeRecords();
if (oldTypes.length == 0) { if (oldTypes.length == 0) {
return; return;
} }
for (Record oldType : oldTypes) { for (DBRecord oldType : oldTypes) {
String type = oldType.getString(BookmarkTypeDBAdapter.TYPE_NAME_COL); String type = oldType.getString(BookmarkTypeDBAdapter.TYPE_NAME_COL);
AddressIterator iter = oldMgr.getBookmarkAddresses(type); AddressIterator iter = oldMgr.getBookmarkAddresses(type);
while (iter.hasNext()) { while (iter.hasNext()) {
@ -296,7 +296,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
bm.setComment(comment); bm.setComment(comment);
} }
else { else {
Record rec = bookmarkAdapter.createBookmark(typeId, category, DBRecord rec = bookmarkAdapter.createBookmark(typeId, category,
addrMap.getKey(addr, true), comment); addrMap.getKey(addr, true), comment);
bm = new BookmarkDB(this, cache, rec); bm = new BookmarkDB(this, cache, rec);
@ -315,7 +315,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
return null; return null;
} }
private BookmarkDB getBookmark(Record bookmarkRecord) { private BookmarkDB getBookmark(DBRecord bookmarkRecord) {
BookmarkDB bm = cache.get(bookmarkRecord); BookmarkDB bm = cache.get(bookmarkRecord);
if (bm == null) { if (bm == null) {
bm = new BookmarkDB(this, cache, bookmarkRecord); bm = new BookmarkDB(this, cache, bookmarkRecord);
@ -333,7 +333,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
RecordIterator iter = RecordIterator iter =
bookmarkAdapter.getRecordsByTypeAtAddress(typeId, addrMap.getKey(addr, false)); bookmarkAdapter.getRecordsByTypeAtAddress(typeId, addrMap.getKey(addr, false));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
String cat = rec.getString(BookmarkDBAdapter.CATEGORY_COL); String cat = rec.getString(BookmarkDBAdapter.CATEGORY_COL);
if (category.equals(cat)) { if (category.equals(cat)) {
return getBookmark(rec); return getBookmark(rec);
@ -430,7 +430,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
RecordIterator iter = RecordIterator iter =
bookmarkAdapter.getRecordsByTypeAndCategory(bmt.getTypeId(), category); bookmarkAdapter.getRecordsByTypeAndCategory(bmt.getTypeId(), category);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
BookmarkDB bm = getBookmark(rec); BookmarkDB bm = getBookmark(rec);
removeBookmark(bm); removeBookmark(bm);
monitor.checkCanceled(); monitor.checkCanceled();
@ -458,8 +458,8 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
* @param id bookmark ID * @param id bookmark ID
* @return bookmark record * @return bookmark record
*/ */
Record getRecord(long id) { DBRecord getRecord(long id) {
Record rec = null; DBRecord rec = null;
try { try {
rec = bookmarkAdapter.getRecord(id); rec = bookmarkAdapter.getRecord(id);
} }
@ -498,7 +498,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
RecordIterator iter = RecordIterator iter =
bookmarkAdapter.getRecordsByTypeAtAddress(typeId, addrMap.getKey(addr, false)); bookmarkAdapter.getRecordsByTypeAtAddress(typeId, addrMap.getKey(addr, false));
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
list.add(getBookmark(rec)); list.add(getBookmark(rec));
} }
} }
@ -626,7 +626,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
try { try {
BookmarkDB bm = cache.get(id); BookmarkDB bm = cache.get(id);
if (bm == null) { if (bm == null) {
Record record = bookmarkAdapter.getRecord(id); DBRecord record = bookmarkAdapter.getRecord(id);
if (record == null) { if (record == null) {
return null; return null;
} }
@ -847,7 +847,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
lock.acquire(); lock.acquire();
try { try {
while (nextBookmark == null && (forward ? it.hasNext() : it.hasPrevious())) { while (nextBookmark == null && (forward ? it.hasNext() : it.hasPrevious())) {
Record record = forward ? it.next() : it.previous(); DBRecord record = forward ? it.next() : it.previous();
nextBookmark = getBookmark(record); nextBookmark = getBookmark(record);
} }
} }

View file

@ -85,13 +85,13 @@ abstract class BookmarkTypeDBAdapter {
* @return array of records * @return array of records
* @throws IOException * @throws IOException
*/ */
abstract Record[] getRecords() throws IOException; abstract DBRecord[] getRecords() throws IOException;
public int[] getTypeIds() throws IOException { public int[] getTypeIds() throws IOException {
Record[] typeRecords = getRecords(); DBRecord[] typeRecords = getRecords();
int[] ids = new int[typeRecords.length]; int[] ids = new int[typeRecords.length];
for (int i = 0; i < typeRecords.length; i++) { for (int i = 0; i < typeRecords.length; i++) {
Record rec = typeRecords[i]; DBRecord rec = typeRecords[i];
ids[i] = (int) rec.getKey(); ids[i] = (int) rec.getKey();
} }
return ids; return ids;

View file

@ -18,14 +18,14 @@ package ghidra.program.database.bookmark;
import java.io.IOException; import java.io.IOException;
import db.DBHandle; import db.DBHandle;
import db.Record; import db.DBRecord;
/** /**
* *
*/ */
public class BookmarkTypeDBAdapterNoTable extends BookmarkTypeDBAdapter { public class BookmarkTypeDBAdapterNoTable extends BookmarkTypeDBAdapter {
private Record[] records = new Record[0]; private DBRecord[] records = new DBRecord[0];
/** /**
* @param dbHandle the database handle * @param dbHandle the database handle
@ -44,7 +44,7 @@ public class BookmarkTypeDBAdapterNoTable extends BookmarkTypeDBAdapter {
} }
@Override @Override
Record[] getRecords() throws IOException { DBRecord[] getRecords() throws IOException {
return records; return records;
} }

View file

@ -44,13 +44,13 @@ public class BookmarkTypeDBAdapterV0 extends BookmarkTypeDBAdapter {
} }
@Override @Override
Record[] getRecords() throws IOException { DBRecord[] getRecords() throws IOException {
ArrayList<Record> list = new ArrayList<Record>(); ArrayList<DBRecord> list = new ArrayList<DBRecord>();
RecordIterator iter = table.iterator(); RecordIterator iter = table.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
list.add(iter.next()); list.add(iter.next());
} }
Record[] recs = new Record[list.size()]; DBRecord[] recs = new DBRecord[list.size()];
list.toArray(recs); list.toArray(recs);
return recs; return recs;
} }
@ -58,7 +58,7 @@ public class BookmarkTypeDBAdapterV0 extends BookmarkTypeDBAdapter {
@Override @Override
void addType(int typeId, String type) throws IOException { void addType(int typeId, String type) throws IOException {
Record rec = SCHEMA.createRecord(typeId); DBRecord rec = SCHEMA.createRecord(typeId);
rec.setString(TYPE_NAME_COL, type); rec.setString(TYPE_NAME_COL, type);
table.putRecord(rec); table.putRecord(rec);
} }

View file

@ -26,7 +26,7 @@ import ghidra.util.exception.DuplicateNameException;
import java.util.*; import java.util.*;
import db.Record; import db.DBRecord;
/** /**
* Interface to manage bookmarks on a program. * Interface to manage bookmarks on a program.
@ -41,7 +41,7 @@ class OldBookmarkManager {
private Program program; private Program program;
private PropertyMapManager propertyMgr; private PropertyMapManager propertyMgr;
private HashMap<String, Record> bookmarkTypes = new HashMap<String, Record>(); // maps type to record private HashMap<String, DBRecord> bookmarkTypes = new HashMap<String, DBRecord>(); // maps type to record
// private ArrayList bookmarks = new ArrayList(); // private ArrayList bookmarks = new ArrayList();
// private LongIntHashedList bookmarkAddrIndex = new LongIntHashedList(); // private LongIntHashedList bookmarkAddrIndex = new LongIntHashedList();
@ -56,7 +56,7 @@ class OldBookmarkManager {
// Create type records // Create type records
String[] types = getTypes(); String[] types = getTypes();
for (int i = 0; i < types.length; i++) { for (int i = 0; i < types.length; i++) {
Record rec = BookmarkTypeDBAdapter.SCHEMA.createRecord(i); DBRecord rec = BookmarkTypeDBAdapter.SCHEMA.createRecord(i);
rec.setString(BookmarkTypeDBAdapter.TYPE_NAME_COL, types[i]); rec.setString(BookmarkTypeDBAdapter.TYPE_NAME_COL, types[i]);
bookmarkTypes.put(types[i], rec); bookmarkTypes.put(types[i], rec);
} }
@ -189,9 +189,9 @@ class OldBookmarkManager {
/** /**
* Returns array of bookmark type records * Returns array of bookmark type records
*/ */
public Record[] getTypeRecords() { public DBRecord[] getTypeRecords() {
Collection<Record> c = bookmarkTypes.values(); Collection<DBRecord> c = bookmarkTypes.values();
Record[] recs = new Record[c.size()]; DBRecord[] recs = new DBRecord[c.size()];
c.toArray(recs); c.toArray(recs);
return recs; return recs;
} }

View file

@ -260,12 +260,12 @@ public class CodeManager implements ErrorHandler, ManagerDB {
Instruction inst = null; Instruction inst = null;
RecordIterator recIt = instAdapter.getRecords(firstInstrStart, true); RecordIterator recIt = instAdapter.getRecords(firstInstrStart, true);
if (recIt.hasNext()) { if (recIt.hasNext()) {
Record rec = recIt.next(); DBRecord rec = recIt.next();
inst = getInstructionDB(rec); inst = getInstructionDB(rec);
recIt.previous(); recIt.previous();
} }
if (recIt.hasPrevious()) { if (recIt.hasPrevious()) {
Record rec = recIt.previous(); DBRecord rec = recIt.previous();
Instruction prevInst = getInstructionDB(rec); Instruction prevInst = getInstructionDB(rec);
if (prevInst.getMaxAddress().compareTo(firstInstrStart) >= 0) { if (prevInst.getMaxAddress().compareTo(firstInstrStart) >= 0) {
return prevInst; return prevInst;
@ -275,12 +275,12 @@ public class CodeManager implements ErrorHandler, ManagerDB {
Data data = null; Data data = null;
recIt = dataAdapter.getRecords(firstInstrStart, true); recIt = dataAdapter.getRecords(firstInstrStart, true);
if (recIt.hasNext()) { if (recIt.hasNext()) {
Record rec = recIt.next(); DBRecord rec = recIt.next();
data = getDataDB(rec); data = getDataDB(rec);
recIt.previous(); recIt.previous();
} }
if (recIt.hasPrevious()) { if (recIt.hasPrevious()) {
Record rec = recIt.previous(); DBRecord rec = recIt.previous();
Data prevData = getDataDB(rec); Data prevData = getDataDB(rec);
if (prevData.getMaxAddress().compareTo(firstInstrStart) >= 0) { if (prevData.getMaxAddress().compareTo(firstInstrStart) >= 0) {
return prevData; return prevData;
@ -930,8 +930,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
} }
private CodeUnit getDefinedBefore(Address address) throws IOException { private CodeUnit getDefinedBefore(Address address) throws IOException {
Record dataRec = dataAdapter.getRecordBefore(address); DBRecord dataRec = dataAdapter.getRecordBefore(address);
Record instRec = instAdapter.getRecordBefore(address); DBRecord instRec = instAdapter.getRecordBefore(address);
if (dataRec == null && instRec == null) { if (dataRec == null && instRec == null) {
return null; return null;
@ -1010,8 +1010,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
return cu; return cu;
} }
try { try {
Record dataRec = dataAdapter.getRecordBefore(address); DBRecord dataRec = dataAdapter.getRecordBefore(address);
Record instRec = instAdapter.getRecordBefore(address); DBRecord instRec = instAdapter.getRecordBefore(address);
CodeUnit cuFirst = null, cuSecond = null; CodeUnit cuFirst = null, cuSecond = null;
@ -1320,7 +1320,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
try { try {
CodeUnit cu = cache.get(addr); CodeUnit cu = cache.get(addr);
if (cu == null) { if (cu == null) {
Record rec = dataAdapter.getRecord(addr); DBRecord rec = dataAdapter.getRecord(addr);
return getDataDB(rec); return getDataDB(rec);
} }
else if (cu instanceof Data) { else if (cu instanceof Data) {
@ -1350,7 +1350,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
public Instruction getInstructionBefore(Address addr) { public Instruction getInstructionBefore(Address addr) {
lock.acquire(); lock.acquire();
try { try {
Record rec = instAdapter.getRecordBefore(addr); DBRecord rec = instAdapter.getRecordBefore(addr);
return getInstructionDB(rec); return getInstructionDB(rec);
} }
catch (IOException e) { catch (IOException e) {
@ -1374,7 +1374,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
public Instruction getInstructionAfter(Address addr) { public Instruction getInstructionAfter(Address addr) {
lock.acquire(); lock.acquire();
try { try {
Record rec = instAdapter.getRecordAfter(addr); DBRecord rec = instAdapter.getRecordAfter(addr);
return getInstructionDB(rec); return getInstructionDB(rec);
} }
catch (IOException e) { catch (IOException e) {
@ -1548,7 +1548,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
public Data getDefinedDataAfter(Address addr) { public Data getDefinedDataAfter(Address addr) {
lock.acquire(); lock.acquire();
try { try {
Record rec = dataAdapter.getRecordAfter(addr); DBRecord rec = dataAdapter.getRecordAfter(addr);
return getDataDB(rec); return getDataDB(rec);
} }
catch (IOException e) { catch (IOException e) {
@ -1573,7 +1573,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
public Data getDefinedDataBefore(Address addr) { public Data getDefinedDataBefore(Address addr) {
lock.acquire(); lock.acquire();
try { try {
Record rec = dataAdapter.getRecordBefore(addr); DBRecord rec = dataAdapter.getRecordBefore(addr);
return getDataDB(rec); return getDataDB(rec);
} }
catch (IOException e) { catch (IOException e) {
@ -1682,7 +1682,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
while (true) { while (true) {
if (nextInstAddr == null && instIter.hasNext()) { if (nextInstAddr == null && instIter.hasNext()) {
Record nextInstRec = instIter.next(); DBRecord nextInstRec = instIter.next();
nextInstAddr = addrMap.decodeAddress(nextInstRec.getKey()); nextInstAddr = addrMap.decodeAddress(nextInstRec.getKey());
nextInstEndAddr = nextInstAddr; nextInstEndAddr = nextInstAddr;
int protoID = nextInstRec.getIntValue(InstDBAdapter.PROTO_ID_COL); int protoID = nextInstRec.getIntValue(InstDBAdapter.PROTO_ID_COL);
@ -1700,7 +1700,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
} }
if (nextDataAddr == null && dataIter.hasNext()) { if (nextDataAddr == null && dataIter.hasNext()) {
Record nextDataRec = dataIter.next(); DBRecord nextDataRec = dataIter.next();
nextDataAddr = addrMap.decodeAddress(nextDataRec.getKey()); nextDataAddr = addrMap.decodeAddress(nextDataRec.getKey());
nextDataEndAddr = nextDataAddr; nextDataEndAddr = nextDataAddr;
DataDB data = getDataDB(nextDataRec); DataDB data = getDataDB(nextDataRec);
@ -1919,7 +1919,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
RecordIterator recIt = instAdapter.getRecords(startAddr, true); RecordIterator recIt = instAdapter.getRecords(startAddr, true);
if (recIt.hasNext()) { if (recIt.hasNext()) {
Record rec = recIt.next(); DBRecord rec = recIt.next();
Instruction inst = getInstructionDB(rec); Instruction inst = getInstructionDB(rec);
if (inst.getMinAddress().compareTo(endAddr) <= 0) { if (inst.getMinAddress().compareTo(endAddr) <= 0) {
throw new CodeUnitInsertionException("Conflicting instruction exists at address " + throw new CodeUnitInsertionException("Conflicting instruction exists at address " +
@ -1928,7 +1928,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
recIt.previous(); recIt.previous();
} }
if (recIt.hasPrevious()) { if (recIt.hasPrevious()) {
Record rec = recIt.previous(); DBRecord rec = recIt.previous();
Instruction inst = getInstructionDB(rec); Instruction inst = getInstructionDB(rec);
if (inst.getMaxAddress().compareTo(startAddr) >= 0) { if (inst.getMaxAddress().compareTo(startAddr) >= 0) {
throw new CodeUnitInsertionException("Conflicting instruction exists at address " + throw new CodeUnitInsertionException("Conflicting instruction exists at address " +
@ -1938,7 +1938,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
recIt = dataAdapter.getRecords(startAddr, true); recIt = dataAdapter.getRecords(startAddr, true);
if (recIt.hasNext()) { if (recIt.hasNext()) {
Record rec = recIt.next(); DBRecord rec = recIt.next();
Data data = getDataDB(rec); Data data = getDataDB(rec);
if (data.getMinAddress().compareTo(endAddr) <= 0) { if (data.getMinAddress().compareTo(endAddr) <= 0) {
throw new CodeUnitInsertionException("Conflicting data exists at address " + throw new CodeUnitInsertionException("Conflicting data exists at address " +
@ -1947,7 +1947,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
recIt.previous(); recIt.previous();
} }
if (recIt.hasPrevious()) { if (recIt.hasPrevious()) {
Record rec = recIt.previous(); DBRecord rec = recIt.previous();
Data data = getDataDB(rec); Data data = getDataDB(rec);
if (data.getMaxAddress().compareTo(startAddr) >= 0) { if (data.getMaxAddress().compareTo(startAddr) >= 0) {
throw new CodeUnitInsertionException("Conflicting data exists at address " + throw new CodeUnitInsertionException("Conflicting data exists at address " +
@ -2033,7 +2033,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
return getUndefinedDataDB(addr, addrMap.getKey(addr, false)); return getUndefinedDataDB(addr, addrMap.getKey(addr, false));
} }
Record record = dataAdapter.createData(addr, dataManager.getResolvedID(dataType)); DBRecord record = dataAdapter.createData(addr, dataManager.getResolvedID(dataType));
DataType baseDt = dataType; DataType baseDt = dataType;
if (baseDt instanceof TypeDef) { if (baseDt instanceof TypeDef) {
@ -2635,7 +2635,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
protected boolean isUndefined(Address address, long addr) { protected boolean isUndefined(Address address, long addr) {
if (program.getMemory().contains(address)) { if (program.getMemory().contains(address)) {
try { try {
Record rec = dataAdapter.getRecord(addr); DBRecord rec = dataAdapter.getRecord(addr);
if (rec == null) { if (rec == null) {
rec = instAdapter.getRecord(addr); rec = instAdapter.getRecord(addr);
} }
@ -2668,7 +2668,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
RecordIterator it = dataAdapter.getRecords(); RecordIterator it = dataAdapter.getRecords();
while (it.hasNext()) { while (it.hasNext()) {
monitor.checkCanceled(); monitor.checkCanceled();
Record rec = it.next(); DBRecord rec = it.next();
long id = rec.getLongValue(DataDBAdapter.DATA_TYPE_ID_COL); long id = rec.getLongValue(DataDBAdapter.DATA_TYPE_ID_COL);
for (long dataTypeID : dataTypeIDs) { for (long dataTypeID : dataTypeIDs) {
if (id == dataTypeID) { if (id == dataTypeID) {
@ -2726,7 +2726,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
* the cache, create a new DB object and add it. * the cache, create a new DB object and add it.
* @param rec record for the instruction * @param rec record for the instruction
*/ */
InstructionDB getInstructionDB(Record rec) { InstructionDB getInstructionDB(DBRecord rec) {
lock.acquire(); lock.acquire();
try { try {
if (rec != null) { if (rec != null) {
@ -2754,7 +2754,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
* create a new DB object and add it. * create a new DB object and add it.
* @param rec data record * @param rec data record
*/ */
DataDB getDataDB(Record rec) { DataDB getDataDB(DBRecord rec) {
lock.acquire(); lock.acquire();
try { try {
if (rec != null) { if (rec != null) {
@ -2792,8 +2792,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
} }
Address getDefinedAddressAfter(Address address) { Address getDefinedAddressAfter(Address address) {
Record dataRec = null; DBRecord dataRec = null;
Record instRec = null; DBRecord instRec = null;
try { try {
dataRec = dataAdapter.getRecordAfter(address); dataRec = dataAdapter.getRecordAfter(address);
instRec = instAdapter.getRecordAfter(address); instRec = instAdapter.getRecordAfter(address);
@ -2876,7 +2876,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
RecordIterator iter = dataAdapter.getRecords(start, end, true); RecordIterator iter = dataAdapter.getRecords(start, end, true);
while (iter.hasNext()) { while (iter.hasNext()) {
monitor.checkCanceled(); monitor.checkCanceled();
Record rec = iter.next(); DBRecord rec = iter.next();
Data data = getDataDB(rec); Data data = getDataDB(rec);
addDataReferences(data, new ArrayList<Address>()); addDataReferences(data, new ArrayList<Address>());
} }
@ -3091,11 +3091,11 @@ public class CodeManager implements ErrorHandler, ManagerDB {
} }
private InstructionDB getInstructionDB(long addr) throws IOException { private InstructionDB getInstructionDB(long addr) throws IOException {
Record rec = instAdapter.getRecord(addr); DBRecord rec = instAdapter.getRecord(addr);
return getInstructionDB(rec); return getInstructionDB(rec);
} }
protected Record getInstructionRecord(long addr) { protected DBRecord getInstructionRecord(long addr) {
try { try {
return instAdapter.getRecord(addr); return instAdapter.getRecord(addr);
} }
@ -3115,7 +3115,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
return null; return null;
} }
DataType getDataType(Record dataRecord) { DataType getDataType(DBRecord dataRecord) {
if (dataRecord != null) { if (dataRecord != null) {
long datatypeID = dataRecord.getLongValue(DataDBAdapter.DATA_TYPE_ID_COL); long datatypeID = dataRecord.getLongValue(DataDBAdapter.DATA_TYPE_ID_COL);
DataType dt = dataManager.getDataType(datatypeID); DataType dt = dataManager.getDataType(datatypeID);
@ -3323,7 +3323,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
public String getComment(int commentType, Address address) { public String getComment(int commentType, Address address) {
try { try {
long addr = addrMap.getKey(address, false); long addr = addrMap.getKey(address, false);
Record commentRec = getCommentAdapter().getRecord(addr); DBRecord commentRec = getCommentAdapter().getRecord(addr);
if (commentRec != null) { if (commentRec != null) {
return commentRec.getString(commentType); return commentRec.getString(commentType);
} }
@ -3353,7 +3353,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
lock.acquire(); lock.acquire();
try { try {
long addr = addrMap.getKey(address, true); long addr = addrMap.getKey(address, true);
Record commentRec = getCommentAdapter().getRecord(addr); DBRecord commentRec = getCommentAdapter().getRecord(addr);
if (commentRec == null) { if (commentRec == null) {
if (comment == null) { if (comment == null) {
return; return;
@ -3444,20 +3444,20 @@ public class CodeManager implements ErrorHandler, ManagerDB {
try { try {
// records are sorted by date ascending // records are sorted by date ascending
List<Record> allRecords = getHistoryRecords(addr, commentType); List<DBRecord> allRecords = getHistoryRecords(addr, commentType);
List<CommentHistory> results = new ArrayList<>(); List<CommentHistory> results = new ArrayList<>();
String comment = getComment(addr, commentType); String comment = getComment(addr, commentType);
while (!allRecords.isEmpty()) { while (!allRecords.isEmpty()) {
Record rec = allRecords.get(allRecords.size() - 1); DBRecord rec = allRecords.get(allRecords.size() - 1);
long date = rec.getLongValue(CommentHistoryAdapter.HISTORY_DATE_COL); long date = rec.getLongValue(CommentHistoryAdapter.HISTORY_DATE_COL);
List<Record> records = subListByDate(allRecords, date); List<DBRecord> records = subListByDate(allRecords, date);
List<StringDiff> diffs = new ArrayList<>(records.size()); List<StringDiff> diffs = new ArrayList<>(records.size());
String user = null; String user = null;
for (Record r : records) { for (DBRecord r : records) {
user = r.getString(CommentHistoryAdapter.HISTORY_USER_COL); user = r.getString(CommentHistoryAdapter.HISTORY_USER_COL);
int pos1 = r.getIntValue(CommentHistoryAdapter.HISTORY_POS1_COL); int pos1 = r.getIntValue(CommentHistoryAdapter.HISTORY_POS1_COL);
int pos2 = r.getIntValue(CommentHistoryAdapter.HISTORY_POS2_COL); int pos2 = r.getIntValue(CommentHistoryAdapter.HISTORY_POS2_COL);
@ -3484,11 +3484,11 @@ public class CodeManager implements ErrorHandler, ManagerDB {
} }
// note: you must have the lock when calling this method // note: you must have the lock when calling this method
private List<Record> getHistoryRecords(Address addr, int commentType) throws IOException { private List<DBRecord> getHistoryRecords(Address addr, int commentType) throws IOException {
RecordIterator it = historyAdapter.getRecordsByAddress(addr); RecordIterator it = historyAdapter.getRecordsByAddress(addr);
List<Record> list = new ArrayList<>(); List<DBRecord> list = new ArrayList<>();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
if (rec.getByteValue(CommentHistoryAdapter.HISTORY_TYPE_COL) == commentType) { if (rec.getByteValue(CommentHistoryAdapter.HISTORY_TYPE_COL) == commentType) {
list.add(rec); list.add(rec);
} }
@ -3497,10 +3497,10 @@ public class CodeManager implements ErrorHandler, ManagerDB {
} }
// note: records are sorted by date; assume that the date we seek is at the end // note: records are sorted by date; assume that the date we seek is at the end
private List<Record> subListByDate(List<Record> records, long date) { private List<DBRecord> subListByDate(List<DBRecord> records, long date) {
for (int i = records.size() - 1; i >= 0; i--) { for (int i = records.size() - 1; i >= 0; i--) {
Record rec = records.get(i); DBRecord rec = records.get(i);
if (date != rec.getLongValue(CommentHistoryAdapter.HISTORY_DATE_COL)) { if (date != rec.getLongValue(CommentHistoryAdapter.HISTORY_DATE_COL)) {
return records.subList(i + 1, records.size()); return records.subList(i + 1, records.size());
} }
@ -3511,7 +3511,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
} }
private String getComment(Address addr, int commentType) throws IOException { private String getComment(Address addr, int commentType) throws IOException {
Record record = commentAdapter.getRecord(addrMap.getKey(addr, false)); DBRecord record = commentAdapter.getRecord(addrMap.getKey(addr, false));
if (record != null) { if (record != null) {
return record.getString(commentType); return record.getString(commentType);
} }
@ -3523,7 +3523,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
try { try {
RecordIterator it = dataAdapter.getRecords(); RecordIterator it = dataAdapter.getRecords();
while (it.hasNext()) { while (it.hasNext()) {
Record rec = it.next(); DBRecord rec = it.next();
long id = rec.getLongValue(DataDBAdapter.DATA_TYPE_ID_COL); long id = rec.getLongValue(DataDBAdapter.DATA_TYPE_ID_COL);
if (id == oldDataTypeID) { if (id == oldDataTypeID) {
rec.setLongValue(DataDBAdapter.DATA_TYPE_ID_COL, newDataTypeID); rec.setLongValue(DataDBAdapter.DATA_TYPE_ID_COL, newDataTypeID);
@ -3551,7 +3551,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
private void addCommentHistoryRecords(Address start, Address end) throws IOException { private void addCommentHistoryRecords(Address start, Address end) throws IOException {
RecordIterator iter = commentAdapter.getRecords(start, end, true); RecordIterator iter = commentAdapter.getRecords(start, end, true);
while (iter.hasNext()) { while (iter.hasNext()) {
Record rec = iter.next(); DBRecord rec = iter.next();
addCommentHistoryRecord(rec, CodeUnit.PRE_COMMENT); addCommentHistoryRecord(rec, CodeUnit.PRE_COMMENT);
addCommentHistoryRecord(rec, CodeUnit.POST_COMMENT); addCommentHistoryRecord(rec, CodeUnit.POST_COMMENT);
addCommentHistoryRecord(rec, CodeUnit.EOL_COMMENT); addCommentHistoryRecord(rec, CodeUnit.EOL_COMMENT);
@ -3560,7 +3560,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
} }
} }
private void addCommentHistoryRecord(Record commentRec, int commentType) { private void addCommentHistoryRecord(DBRecord commentRec, int commentType) {
String comment = commentRec.getString(commentType); String comment = commentRec.getString(commentType);
if (comment != null) { if (comment != null) {
createCommentHistoryRecord(addrMap.decodeAddress(commentRec.getKey()), commentType, createCommentHistoryRecord(addrMap.decodeAddress(commentRec.getKey()), commentType,
@ -3608,7 +3608,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
int count = 0; int count = 0;
RecordIterator recIter = instAdapter.getRecords(); RecordIterator recIter = instAdapter.getRecords();
while (recIter.hasNext()) { while (recIter.hasNext()) {
Record rec = recIter.next(); DBRecord rec = recIter.next();
Address addr = addrMap.decodeAddress(rec.getKey()); Address addr = addrMap.decodeAddress(rec.getKey());
if (minAddr == null) { if (minAddr == null) {

Some files were not shown because too many files have changed in this diff Show more