mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-24 21:21:56 +00:00
Renamed Record class to DBRecord
This commit is contained in:
parent
04276e9522
commit
db1e3d1b62
@ -93,7 +93,7 @@ public class FixLangId extends GhidraScript {
|
||||
Msg.showError(getClass(), null, "Script Error", "Bad program database!!");
|
||||
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
|
||||
Msg.showError(getClass(), null, "Script Error",
|
||||
"Old program file! Language fix is not appropriate.");
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,15 +15,15 @@
|
||||
*/
|
||||
package ghidra.app.plugin.debug.dbtable;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
abstract class AbstractColumnAdapter {
|
||||
|
||||
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) {
|
||||
String str = Integer.toHexString(b);
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,7 +16,7 @@
|
||||
package ghidra.app.plugin.debug.dbtable;
|
||||
|
||||
import db.BinaryField;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
public class BinaryColumnAdapter extends AbstractColumnAdapter {
|
||||
|
||||
@ -27,7 +26,7 @@ public class BinaryColumnAdapter extends AbstractColumnAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getKeyValue(Record rec) {
|
||||
Object getKeyValue(DBRecord rec) {
|
||||
byte[] bytes = ((BinaryField) rec.getKeyField()).getBinaryData();
|
||||
StringBuffer buf = new StringBuffer(" byte[" + bytes.length + "] = ");
|
||||
if (bytes.length > 0) {
|
||||
@ -45,7 +44,7 @@ public class BinaryColumnAdapter extends AbstractColumnAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getValue(Record rec, int col) {
|
||||
Object getValue(DBRecord rec, int col) {
|
||||
byte[] bytes = rec.getBinaryData(col);
|
||||
if (bytes == null) {
|
||||
return "null";
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,7 +16,7 @@
|
||||
package ghidra.app.plugin.debug.dbtable;
|
||||
|
||||
import db.BooleanField;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
public class BooleanColumnAdapter extends AbstractColumnAdapter {
|
||||
|
||||
@ -27,12 +26,12 @@ public class BooleanColumnAdapter extends AbstractColumnAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getKeyValue(Record rec) {
|
||||
Object getKeyValue(DBRecord rec) {
|
||||
return new Boolean(((BooleanField) rec.getKeyField()).getBooleanValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getValue(Record rec, int col) {
|
||||
Object getValue(DBRecord rec, int col) {
|
||||
return Boolean.valueOf(rec.getBooleanValue(col));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,7 +16,7 @@
|
||||
package ghidra.app.plugin.debug.dbtable;
|
||||
|
||||
import db.ByteField;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
public class ByteColumnAdapter extends AbstractColumnAdapter {
|
||||
|
||||
@ -27,12 +26,12 @@ public class ByteColumnAdapter extends AbstractColumnAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getKeyValue(Record rec) {
|
||||
Object getKeyValue(DBRecord rec) {
|
||||
return new Byte(((ByteField) rec.getKeyField()).getByteValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getValue(Record rec, int col) {
|
||||
Object getValue(DBRecord rec, int col) {
|
||||
return new Byte(rec.getByteValue(col));
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class DbLargeTableModel implements TableModel {
|
||||
private Schema schema;
|
||||
private List<AbstractColumnAdapter> columns = new ArrayList<AbstractColumnAdapter>();
|
||||
private RecordIterator recIt;
|
||||
private Record lastRecord;
|
||||
private DBRecord lastRecord;
|
||||
private int lastIndex;
|
||||
private Field minKey;
|
||||
private Field maxKey;
|
||||
@ -94,7 +94,7 @@ public class DbLargeTableModel implements TableModel {
|
||||
|
||||
private void findMinKey() throws IOException {
|
||||
RecordIterator iter = table.iterator();
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
minKey = rec.getKeyField();
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public class DbLargeTableModel implements TableModel {
|
||||
max.setBinaryData(maxBytes);
|
||||
}
|
||||
RecordIterator iter = table.iterator(max);
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
maxKey = rec.getKeyField();
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ public class DbLargeTableModel implements TableModel {
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
Record rec = getRecord(rowIndex);
|
||||
DBRecord rec = getRecord(rowIndex);
|
||||
if (columnIndex == 0) { // key column
|
||||
return columns.get(columnIndex).getKeyValue(rec);
|
||||
}
|
||||
@ -177,7 +177,7 @@ public class DbLargeTableModel implements TableModel {
|
||||
// no!
|
||||
}
|
||||
|
||||
private Record getRecord(int index) {
|
||||
private DBRecord getRecord(int index) {
|
||||
try {
|
||||
if (index == lastIndex + 1) {
|
||||
if (recIt.hasNext()) {
|
||||
@ -196,7 +196,7 @@ public class DbLargeTableModel implements TableModel {
|
||||
recIt.previous();
|
||||
}
|
||||
}
|
||||
Record rec = recIt.next();
|
||||
DBRecord rec = recIt.next();
|
||||
if (rec != null) {
|
||||
lastRecord = rec;
|
||||
lastIndex = index;
|
||||
|
@ -24,11 +24,11 @@ import docking.widgets.table.AbstractSortedTableModel;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.AssertException;
|
||||
|
||||
public class DbSmallTableModel extends AbstractSortedTableModel<Record> {
|
||||
public class DbSmallTableModel extends AbstractSortedTableModel<DBRecord> {
|
||||
private Table table;
|
||||
private Schema schema;
|
||||
private List<AbstractColumnAdapter> columns = new ArrayList<>();
|
||||
private List<Record> records;
|
||||
private List<DBRecord> records;
|
||||
|
||||
public DbSmallTableModel(Table table) {
|
||||
this.table = table;
|
||||
@ -124,7 +124,7 @@ public class DbSmallTableModel extends AbstractSortedTableModel<Record> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getColumnValueForRow(Record rec, int columnIndex) {
|
||||
public Object getColumnValueForRow(DBRecord rec, int columnIndex) {
|
||||
if (columnIndex == 0) { // key column
|
||||
return columns.get(columnIndex).getKeyValue(rec);
|
||||
}
|
||||
@ -134,7 +134,7 @@ public class DbSmallTableModel extends AbstractSortedTableModel<Record> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Record> getModelData() {
|
||||
public List<DBRecord> getModelData() {
|
||||
return records;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,7 +16,7 @@
|
||||
package ghidra.app.plugin.debug.dbtable;
|
||||
|
||||
import db.IntField;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
public class IntegerColumnAdapter extends AbstractColumnAdapter {
|
||||
|
||||
@ -27,12 +26,12 @@ public class IntegerColumnAdapter extends AbstractColumnAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getKeyValue(Record rec) {
|
||||
Object getKeyValue(DBRecord rec) {
|
||||
return new Integer(((IntField) rec.getKeyField()).getIntValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getValue(Record rec, int col) {
|
||||
Object getValue(DBRecord rec, int col) {
|
||||
return new Integer(rec.getIntValue(col));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,7 +15,7 @@
|
||||
*/
|
||||
package ghidra.app.plugin.debug.dbtable;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
public class LongColumnAdapter extends AbstractColumnAdapter {
|
||||
|
||||
@ -26,12 +25,12 @@ public class LongColumnAdapter extends AbstractColumnAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getKeyValue(Record rec) {
|
||||
Object getKeyValue(DBRecord rec) {
|
||||
return new Long(rec.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getValue(Record rec, int col) {
|
||||
Object getValue(DBRecord rec, int col) {
|
||||
return new Long(rec.getLongValue(col));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,7 +15,7 @@
|
||||
*/
|
||||
package ghidra.app.plugin.debug.dbtable;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import db.ShortField;
|
||||
|
||||
public class ShortColumnAdapter extends AbstractColumnAdapter {
|
||||
@ -27,12 +26,12 @@ public class ShortColumnAdapter extends AbstractColumnAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getKeyValue(Record rec) {
|
||||
Object getKeyValue(DBRecord rec) {
|
||||
return new Short(((ShortField) rec.getKeyField()).getShortValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getValue(Record rec, int col) {
|
||||
Object getValue(DBRecord rec, int col) {
|
||||
return new Short(rec.getShortValue(col));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,7 +15,7 @@
|
||||
*/
|
||||
package ghidra.app.plugin.debug.dbtable;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import db.StringField;
|
||||
|
||||
public class StringColumnAdapter extends AbstractColumnAdapter {
|
||||
@ -27,12 +26,12 @@ public class StringColumnAdapter extends AbstractColumnAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getKeyValue(Record rec) {
|
||||
Object getKeyValue(DBRecord rec) {
|
||||
return ((StringField) rec.getKeyField()).getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
Object getValue(Record rec, int col) {
|
||||
Object getValue(DBRecord rec, int col) {
|
||||
return " " + rec.getString(col);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class AddressIndexPrimaryKeyIteratorTest extends AbstractGhidraHeadedInte
|
||||
Address maxAddr = r.getMaxAddress();
|
||||
while (a.compareTo(maxAddr) <= 0) {
|
||||
long addrKey = addrMap.getKey(a, true);
|
||||
Record rec = schema.createRecord(myTable.getKey());
|
||||
DBRecord rec = schema.createRecord(myTable.getKey());
|
||||
rec.setLongValue(0, addrKey);
|
||||
myTable.putRecord(rec);
|
||||
a = a.add(1);
|
||||
|
@ -97,7 +97,7 @@ public class AddressKeyIteratorTest extends AbstractGhidraHeadedIntegrationTest
|
||||
|
||||
private long addRecord(Address a) throws Exception {
|
||||
long key = addrMap.getKey(a, true);
|
||||
Record rec = SCHEMA.createRecord(key);
|
||||
DBRecord rec = SCHEMA.createRecord(key);
|
||||
rec.setString(0, a.toString());
|
||||
myTable.putRecord(rec);
|
||||
return key;
|
||||
|
@ -95,7 +95,7 @@ public class SharedRangeMapDBTest extends AbstractGhidraHeadedIntegrationTest
|
||||
int cnt = 0;
|
||||
while (iter.hasNext()) {
|
||||
++cnt;
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
IndexRange range =
|
||||
new IndexRange(rec.getKey(), rec.getLongValue(SharedRangeMapDB.RANGE_TO_COL));
|
||||
if (indexOf(ranges, range) < 0) {
|
||||
@ -108,7 +108,7 @@ public class SharedRangeMapDBTest extends AbstractGhidraHeadedIntegrationTest
|
||||
cnt = 0;
|
||||
while (iter.hasNext()) {
|
||||
++cnt;
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
IndexRange entry = new IndexRange(rec.getLongValue(SharedRangeMapDB.MAP_RANGE_KEY_COL),
|
||||
rec.getLongValue(SharedRangeMapDB.MAP_VALUE_COL));
|
||||
if (indexOf(mapRangeToValue, entry) < 0) {
|
||||
|
@ -59,7 +59,7 @@ public class DatabaseBenchMarks {
|
||||
Schema schema =
|
||||
new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" });
|
||||
Table table = dbh.createTable("Test", schema);
|
||||
Record record = schema.createRecord(0);
|
||||
DBRecord record = schema.createRecord(0);
|
||||
timer.start(
|
||||
"Inserting " + numInsertions + " sorted records with long keys and integer values");
|
||||
for (int i = 0; i < numInsertions; i++) {
|
||||
@ -83,7 +83,7 @@ public class DatabaseBenchMarks {
|
||||
Schema schema = new Schema(1, "Key", new Field[] { StringField.INSTANCE },
|
||||
new String[] { "Value" });
|
||||
Table table = dbh.createTable("Test", schema);
|
||||
Record record = schema.createRecord(0);
|
||||
DBRecord record = schema.createRecord(0);
|
||||
timer.start("Inserting " + numInsertions +
|
||||
" sorted records with long keys and String (length = 8) values");
|
||||
for (int i = 0; i < numInsertions; i++) {
|
||||
@ -108,7 +108,7 @@ public class DatabaseBenchMarks {
|
||||
Schema schema =
|
||||
new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" });
|
||||
Table table = dbh.createTable("Test", schema);
|
||||
Record record = schema.createRecord(0);
|
||||
DBRecord record = schema.createRecord(0);
|
||||
timer.start(
|
||||
"Inserting " + numInsertions + " random records with long keys and integer values");
|
||||
for (int i = 0; i < numInsertions; i++) {
|
||||
@ -132,7 +132,7 @@ public class DatabaseBenchMarks {
|
||||
Schema schema =
|
||||
new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" });
|
||||
Table table = dbh.createTable("Test", schema);
|
||||
Record record = schema.createRecord(0);
|
||||
DBRecord record = schema.createRecord(0);
|
||||
System.out.print("building database...");
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
record.setKey(i);
|
||||
@ -161,7 +161,7 @@ public class DatabaseBenchMarks {
|
||||
Schema schema =
|
||||
new Schema(1, "Key", new Field[] { IntField.INSTANCE }, new String[] { "Value" });
|
||||
Table table = dbh.createTable("Test", schema);
|
||||
Record record = schema.createRecord(0);
|
||||
DBRecord record = schema.createRecord(0);
|
||||
System.out.print("building database...");
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
record.setKey(i);
|
||||
|
@ -19,7 +19,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import db.DBHandle;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import db.RecordIterator;
|
||||
import db.Schema;
|
||||
import db.Table;
|
||||
@ -50,7 +50,7 @@ public class RepackFid extends GhidraScript {
|
||||
monitor.setProgress(0);
|
||||
RecordIterator iterator = oldTable.iterator();
|
||||
while(iterator.hasNext()) { // Iterate through old records
|
||||
Record record = iterator.next();
|
||||
DBRecord record = iterator.next();
|
||||
newTable.putRecord(record); // Copy as is into new table
|
||||
monitor.checkCanceled();
|
||||
monitor.incrementProgress(1);
|
||||
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import db.DBHandle;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import ghidra.feature.fid.hash.FidHashQuad;
|
||||
import ghidra.framework.store.db.PackedDBHandle;
|
||||
import ghidra.framework.store.db.PackedDatabase;
|
||||
@ -384,7 +384,7 @@ public class FidDB implements Closeable {
|
||||
public boolean getSuperiorFullRelation(FunctionRecord superiorFunction,
|
||||
FidHashQuad inferiorFunction) {
|
||||
try {
|
||||
Record libraryByID = librariesTable.getLibraryByID(superiorFunction.getLibraryID());
|
||||
DBRecord libraryByID = librariesTable.getLibraryByID(superiorFunction.getLibraryID());
|
||||
if (libraryByID != null) {
|
||||
return relationsTable.getSuperiorFullRelation(superiorFunction, inferiorFunction);
|
||||
}
|
||||
@ -405,7 +405,7 @@ public class FidDB implements Closeable {
|
||||
public boolean getInferiorFullRelation(FidHashQuad superiorFunction,
|
||||
FunctionRecord inferiorFunction) {
|
||||
try {
|
||||
Record libraryByID = librariesTable.getLibraryByID(inferiorFunction.getLibraryID());
|
||||
DBRecord libraryByID = librariesTable.getLibraryByID(inferiorFunction.getLibraryID());
|
||||
if (libraryByID != null) {
|
||||
return relationsTable.getInferiorFullRelation(superiorFunction, inferiorFunction);
|
||||
}
|
||||
@ -439,7 +439,7 @@ public class FidDB implements Closeable {
|
||||
*/
|
||||
public LibraryRecord getLibraryForFunction(FunctionRecord functionRecord) {
|
||||
try {
|
||||
Record record = librariesTable.getLibraryByID(functionRecord.getLibraryID());
|
||||
DBRecord record = librariesTable.getLibraryByID(functionRecord.getLibraryID());
|
||||
if (record == null) {
|
||||
return null;
|
||||
}
|
||||
@ -473,7 +473,7 @@ public class FidDB implements Closeable {
|
||||
|
||||
try {
|
||||
checkUpdateAllowed();
|
||||
Record record = librariesTable.createLibrary(libraryFamilyName, libraryVersion,
|
||||
DBRecord record = librariesTable.createLibrary(libraryFamilyName, libraryVersion,
|
||||
libraryVariant, ghidraVersion, languageID, languageVersion, languageMinorVersion,
|
||||
compilerSpecID);
|
||||
return new LibraryRecord(record);
|
||||
|
@ -17,7 +17,7 @@ package ghidra.feature.fid.db;
|
||||
|
||||
import static ghidra.feature.fid.db.FunctionsTable.*;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import ghidra.feature.fid.hash.FidHashQuad;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
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.
|
||||
*/
|
||||
final Record record;
|
||||
final DBRecord record;
|
||||
/**
|
||||
* Need a reference to the FidDb because all strings are stored
|
||||
* 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 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());
|
||||
this.record = record;
|
||||
this.fidDb = fid;
|
||||
|
@ -112,7 +112,7 @@ public class FunctionsTable {
|
||||
RecordIterator iterator = table.iterator();
|
||||
List<FunctionRecord> list = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
Record record = iterator.next();
|
||||
DBRecord record = iterator.next();
|
||||
if (record.getLongValue(SPECIFIC_HASH_COL) != hash) {
|
||||
continue;
|
||||
}
|
||||
@ -143,7 +143,7 @@ public class FunctionsTable {
|
||||
Field key = iterator.next();
|
||||
FunctionRecord functionRecord = functionCache.get(key.getLongValue());
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
functionRecord = new FunctionRecord(fidDb, functionCache, record);
|
||||
}
|
||||
list.add(functionRecord);
|
||||
@ -164,7 +164,7 @@ public class FunctionsTable {
|
||||
*/
|
||||
public FunctionRecord createFunctionRecord(long libraryID, FidHashQuad hashQuad, String name,
|
||||
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.setLongValue(FULL_HASH_COL, hashQuad.getFullHash());
|
||||
record.setByteValue(SPECIFIC_HASH_ADDITIONAL_SIZE_COL,
|
||||
@ -191,7 +191,7 @@ public class FunctionsTable {
|
||||
* @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) {
|
||||
throw new IOException("Function record does not exist");
|
||||
}
|
||||
@ -227,7 +227,7 @@ public class FunctionsTable {
|
||||
Field key = iterator.next();
|
||||
FunctionRecord functionRecord = functionCache.get(key.getLongValue());
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
long nameID = record.getLongValue(NAME_ID_COL);
|
||||
StringRecord nameRecord = stringsTable.lookupString(nameID);
|
||||
String name = nameRecord.getValue();
|
||||
@ -266,7 +266,7 @@ public class FunctionsTable {
|
||||
Field key = iterator.next();
|
||||
FunctionRecord functionRecord = functionCache.get(key.getLongValue());
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
long nameID = record.getLongValue(NAME_ID_COL);
|
||||
StringRecord nameRecord = stringsTable.lookupString(nameID);
|
||||
String name = nameRecord.getValue();
|
||||
@ -297,7 +297,7 @@ public class FunctionsTable {
|
||||
public FunctionRecord getFunctionByID(long functionID) throws IOException {
|
||||
FunctionRecord functionRecord = functionCache.get(functionID);
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(functionID);
|
||||
DBRecord record = table.getRecord(functionID);
|
||||
if (record != null) {
|
||||
functionRecord = new FunctionRecord(fidDb, functionCache, record);
|
||||
}
|
||||
@ -318,7 +318,7 @@ public class FunctionsTable {
|
||||
RecordIterator iterator = table.iterator();
|
||||
List<FunctionRecord> list = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
Record record = iterator.next();
|
||||
DBRecord record = iterator.next();
|
||||
long domainPathID = record.getLongValue(DOMAIN_PATH_ID_COL);
|
||||
StringRecord domainPathRecord = stringsTable.lookupString(domainPathID);
|
||||
String domainPath = domainPathRecord.getValue();
|
||||
@ -358,7 +358,7 @@ public class FunctionsTable {
|
||||
Field key = iterator.next();
|
||||
FunctionRecord functionRecord = functionCache.get(key.getLongValue());
|
||||
if (functionRecord == null) {
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
if (record.getLongValue(LIBRARY_ID_COL) == libraryKey) {
|
||||
functionRecord = new FunctionRecord(fidDb, functionCache, record);
|
||||
list.add(functionRecord);
|
||||
|
@ -110,10 +110,10 @@ public class LibrariesTable {
|
||||
* @return the new library record
|
||||
* @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,
|
||||
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_VERSION_COL, libraryVersion);
|
||||
record.setString(LIBRARY_VARIANT_COL, libraryVariant);
|
||||
@ -164,7 +164,7 @@ public class LibrariesTable {
|
||||
List<LibraryRecord> list = new ArrayList<LibraryRecord>();
|
||||
while (iterator.hasNext()) {
|
||||
Field key = iterator.next();
|
||||
Record record = table.getRecord(key);
|
||||
DBRecord record = table.getRecord(key);
|
||||
LibraryRecord libraryRecord = new LibraryRecord(record);
|
||||
if (version != null) {
|
||||
if (!libraryRecord.getLibraryVersion().equals(version)) {
|
||||
@ -187,8 +187,8 @@ public class LibrariesTable {
|
||||
* @return the library or null if not found
|
||||
* @throws IOException if database seek encounters an error
|
||||
*/
|
||||
public Record getLibraryByID(long id) throws IOException {
|
||||
Record record = table.getRecord(id);
|
||||
public DBRecord getLibraryByID(long id) throws IOException {
|
||||
DBRecord record = table.getRecord(id);
|
||||
return record;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ package ghidra.feature.fid.db;
|
||||
import static ghidra.feature.fid.db.LibrariesTable.*;
|
||||
import ghidra.program.model.lang.CompilerSpecID;
|
||||
import ghidra.program.model.lang.LanguageID;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
/**
|
||||
* Represents a library record in the FID database.
|
||||
@ -27,13 +27,13 @@ public class LibraryRecord {
|
||||
/**
|
||||
* The record is stored, no memoization is performed.
|
||||
*/
|
||||
final Record record;
|
||||
final DBRecord record;
|
||||
|
||||
/**
|
||||
* Creates a new library record.
|
||||
* @param record the database record on which to base this library
|
||||
*/
|
||||
public LibraryRecord(Record record) {
|
||||
public LibraryRecord(DBRecord record) {
|
||||
if (record == null) {
|
||||
throw new IllegalArgumentException("null record");
|
||||
}
|
||||
|
@ -63,12 +63,12 @@ public class RelationsTable {
|
||||
RelationType relationType) throws IOException {
|
||||
long superiorKey =
|
||||
FidDBUtils.generateSuperiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record superiorRecord = SCHEMA.createRecord(superiorKey);
|
||||
DBRecord superiorRecord = SCHEMA.createRecord(superiorKey);
|
||||
superiorTable.putRecord(superiorRecord);
|
||||
if (relationType != RelationType.INTER_LIBRARY_CALL) {
|
||||
long inferiorKey =
|
||||
FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record inferiorRecord = SCHEMA.createRecord(inferiorKey);
|
||||
DBRecord inferiorRecord = SCHEMA.createRecord(inferiorKey);
|
||||
inferiorTable.putRecord(inferiorRecord);
|
||||
}
|
||||
}
|
||||
@ -84,7 +84,7 @@ public class RelationsTable {
|
||||
FunctionRecord inferiorFunction) throws IOException {
|
||||
long inferiorKey =
|
||||
FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record inferiorRecord = SCHEMA.createRecord(inferiorKey);
|
||||
DBRecord inferiorRecord = SCHEMA.createRecord(inferiorKey);
|
||||
inferiorTable.putRecord(inferiorRecord);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public class RelationsTable {
|
||||
FidHashQuad inferiorFunction) throws IOException {
|
||||
long superiorKey =
|
||||
FidDBUtils.generateSuperiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record record = superiorTable.getRecord(superiorKey);
|
||||
DBRecord record = superiorTable.getRecord(superiorKey);
|
||||
return (record != null);
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class RelationsTable {
|
||||
FunctionRecord inferiorFunction) throws IOException {
|
||||
long inferiorKey =
|
||||
FidDBUtils.generateInferiorFullHashSmash(superiorFunction, inferiorFunction);
|
||||
Record record = inferiorTable.getRecord(inferiorKey);
|
||||
DBRecord record = inferiorTable.getRecord(inferiorKey);
|
||||
return (record != null);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class StringsTable {
|
||||
if (records == null || records.length == 0) {
|
||||
// create
|
||||
long key = UniversalIdGenerator.nextID().getValue();
|
||||
Record record = SCHEMA.createRecord(key);
|
||||
DBRecord record = SCHEMA.createRecord(key);
|
||||
record.setString(STRING_VALUE_COL, value);
|
||||
table.putRecord(record);
|
||||
return key;
|
||||
@ -101,7 +101,7 @@ public class StringsTable {
|
||||
StringRecord lookupString(long stringID) {
|
||||
StringRecord stringRecord = stringCache.get(stringID);
|
||||
if (stringRecord == null) {
|
||||
Record record;
|
||||
DBRecord record;
|
||||
try {
|
||||
record = table.getRecord(stringID);
|
||||
if (record != null) {
|
||||
|
@ -24,7 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import db.DBHandle;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import generic.stl.Pair;
|
||||
import ghidra.program.database.map.AddressMap;
|
||||
import ghidra.program.model.address.Address;
|
||||
@ -87,8 +87,8 @@ public class AddressCorrelatorDB {
|
||||
public List<Pair<Address, Address>> getAddressCorrelations(Address sourceEntryPoint) throws IOException {
|
||||
long sourceEntryLong = getLongFromSourceAddress(sourceEntryPoint);
|
||||
List<Pair<Address, Address>> addressList = new ArrayList<Pair<Address,Address>>();
|
||||
List<Record> addressRecords = adapter.getAddressRecords(sourceEntryLong);
|
||||
for (Record record : addressRecords) {
|
||||
List<DBRecord> addressRecords = adapter.getAddressRecords(sourceEntryLong);
|
||||
for (DBRecord record : addressRecords) {
|
||||
long sourceLong = record.getLongValue(SOURCE_ADDRESS_COL.column());
|
||||
long destinationLong = record.getLongValue(DESTINATION_ADDRESS_COL.column());
|
||||
Address sourceAddress = getSourceAddressFromLong(sourceLong);
|
||||
|
@ -84,7 +84,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
RecordIterator records = markupItemTableAdapter.getRecords(associationDB.getKey());
|
||||
while (records.hasNext()) {
|
||||
monitor.checkCanceled();
|
||||
Record record = records.next();
|
||||
DBRecord record = records.next();
|
||||
items.add(getMarkupItemForRecord(record));
|
||||
monitor.incrementProgress(1);
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
return items;
|
||||
}
|
||||
|
||||
Record getMarkupItemRecord(long key) {
|
||||
DBRecord getMarkupItemRecord(long key) {
|
||||
try {
|
||||
return markupItemTableAdapter.getRecord(key);
|
||||
}
|
||||
@ -155,7 +155,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
}
|
||||
}
|
||||
|
||||
private MarkupItemStorageDB getMarkupItemForRecord(Record markupItemRecord) {
|
||||
private MarkupItemStorageDB getMarkupItemForRecord(DBRecord markupItemRecord) {
|
||||
try {
|
||||
lock.acquire();
|
||||
MarkupItemStorageDB markupItem = markupItemCache.get(markupItemRecord);
|
||||
@ -181,7 +181,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
return session.getSourceAddressFromLong(longValue);
|
||||
}
|
||||
|
||||
Record getAssociationRecord(long key) {
|
||||
DBRecord getAssociationRecord(long key) {
|
||||
try {
|
||||
return associationTableAdapter.getRecord(key);
|
||||
}
|
||||
@ -194,7 +194,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
private MarkupItemStorageDB createMarkupItemDB(MarkupItemStorage markupItem) {
|
||||
|
||||
try {
|
||||
Record record = markupItemTableAdapter.createMarkupItemRecord(markupItem);
|
||||
DBRecord record = markupItemTableAdapter.createMarkupItemRecord(markupItem);
|
||||
MarkupItemStorageDB appliedMarkupItem = getMarkupItemForRecord(record);
|
||||
return appliedMarkupItem;
|
||||
}
|
||||
@ -222,7 +222,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
VTAssociationDB newAssociation = null;
|
||||
try {
|
||||
lock.acquire();
|
||||
Record record = associationTableAdapter.insertRecord(sourceLong, destinationLong, type,
|
||||
DBRecord record = associationTableAdapter.insertRecord(sourceLong, destinationLong, type,
|
||||
isBlocked ? BLOCKED : AVAILABLE, 0);
|
||||
newAssociation = new VTAssociationDB(this, associationCache, record);
|
||||
}
|
||||
@ -260,10 +260,10 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
long sourceID = session.getLongFromSourceAddress(sourceAddress);
|
||||
long destinationID = session.getLongFromDestinationAddress(destinationAddress);
|
||||
try {
|
||||
Set<Record> relatedRecords =
|
||||
Set<DBRecord> relatedRecords =
|
||||
associationTableAdapter.getRelatedAssociationRecordsBySourceAndDestinationAddress(
|
||||
sourceID, destinationID);
|
||||
for (Record record : relatedRecords) {
|
||||
for (DBRecord record : relatedRecords) {
|
||||
VTAssociationDB associationDB = getAssociationForRecord(record);
|
||||
VTAssociationStatus status = associationDB.getStatus();
|
||||
if (status == ACCEPTED) {
|
||||
@ -290,7 +290,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
try {
|
||||
RecordIterator iterator = associationTableAdapter.getRecords();
|
||||
for (; iterator.hasNext();) {
|
||||
Record nextRecord = iterator.next();
|
||||
DBRecord nextRecord = iterator.next();
|
||||
list.add(getAssociationForRecord(nextRecord));
|
||||
}
|
||||
}
|
||||
@ -311,7 +311,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
RecordIterator iterator =
|
||||
associationTableAdapter.getRecordsForSourceAddress(addressKey);
|
||||
while (iterator.hasNext()) {
|
||||
Record record = iterator.next();
|
||||
DBRecord record = iterator.next();
|
||||
VTAssociationDB associationDB = getAssociationForRecord(record);
|
||||
if (associationDB.getDestinationAddress().equals(destinationAddress)) {
|
||||
return associationDB;
|
||||
@ -334,7 +334,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
RecordIterator iterator =
|
||||
associationTableAdapter.getRecordsForSourceAddress(addressKey);
|
||||
while (iterator.hasNext()) {
|
||||
Record record = iterator.next();
|
||||
DBRecord record = iterator.next();
|
||||
VTAssociationDB associationDB = getAssociationForRecord(record);
|
||||
Address dbDestinatonAddress = associationDB.getDestinationAddress();
|
||||
if (destinationAddress.equals(dbDestinatonAddress)) {
|
||||
@ -349,7 +349,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
private VTAssociationDB getAssociationForRecord(Record record) {
|
||||
private VTAssociationDB getAssociationForRecord(DBRecord record) {
|
||||
if (record == null) {
|
||||
throw new AssertException("How can we have a null record?!!!");
|
||||
}
|
||||
@ -373,7 +373,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
if (associationDB != null) {
|
||||
return associationDB;
|
||||
}
|
||||
Record record = associationTableAdapter.getRecord(associationKey);
|
||||
DBRecord record = associationTableAdapter.getRecord(associationKey);
|
||||
if (record == null) {
|
||||
return null;
|
||||
}
|
||||
@ -397,10 +397,10 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
lock.acquire();
|
||||
try {
|
||||
long sourceID = session.getLongFromSourceAddress(sourceAddress);
|
||||
Set<Record> relatedRecords =
|
||||
Set<DBRecord> relatedRecords =
|
||||
associationTableAdapter.getRelatedAssociationRecordsBySourceAddress(sourceID);
|
||||
List<VTAssociation> associations = new ArrayList<>();
|
||||
for (Record record : relatedRecords) {
|
||||
for (DBRecord record : relatedRecords) {
|
||||
associations.add(getAssociationForRecord(record));
|
||||
}
|
||||
return associations;
|
||||
@ -420,11 +420,11 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
lock.acquire();
|
||||
try {
|
||||
long destinationID = session.getLongFromDestinationAddress(destinationAddress);
|
||||
Set<Record> relatedRecords =
|
||||
Set<DBRecord> relatedRecords =
|
||||
associationTableAdapter.getRelatedAssociationRecordsByDestinationAddress(
|
||||
destinationID);
|
||||
List<VTAssociation> associations = new ArrayList<>();
|
||||
for (Record record : relatedRecords) {
|
||||
for (DBRecord record : relatedRecords) {
|
||||
associations.add(getAssociationForRecord(record));
|
||||
}
|
||||
return associations;
|
||||
@ -445,11 +445,11 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
try {
|
||||
long sourceID = session.getLongFromSourceAddress(sourceAddress);
|
||||
long destinationID = session.getLongFromDestinationAddress(destinationAddress);
|
||||
Set<Record> relatedRecords =
|
||||
Set<DBRecord> relatedRecords =
|
||||
associationTableAdapter.getRelatedAssociationRecordsBySourceAndDestinationAddress(
|
||||
sourceID, destinationID);
|
||||
List<VTAssociation> associations = new ArrayList<>();
|
||||
for (Record record : relatedRecords) {
|
||||
for (DBRecord record : relatedRecords) {
|
||||
associations.add(getAssociationForRecord(record));
|
||||
}
|
||||
return associations;
|
||||
@ -572,11 +572,11 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
|
||||
Set<VTAssociationDB> relatedAssociaitons = new HashSet<>();
|
||||
try {
|
||||
Set<Record> relatedRecords =
|
||||
Set<DBRecord> relatedRecords =
|
||||
associationTableAdapter.getRelatedAssociationRecordsBySourceAndDestinationAddress(
|
||||
sourceID, destinationID);
|
||||
relatedRecords.remove(association.getRecord()); // don't change the given association
|
||||
for (Record record : relatedRecords) {
|
||||
for (DBRecord record : relatedRecords) {
|
||||
relatedAssociaitons.add(getAssociationForRecord(record));
|
||||
}
|
||||
}
|
||||
@ -586,7 +586,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
return relatedAssociaitons;
|
||||
}
|
||||
|
||||
void updateAssociationRecord(Record record) {
|
||||
void updateAssociationRecord(DBRecord record) {
|
||||
try {
|
||||
associationTableAdapter.updateRecord(record);
|
||||
}
|
||||
@ -595,7 +595,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
}
|
||||
}
|
||||
|
||||
void updateMarkupRecord(Record record) {
|
||||
void updateMarkupRecord(DBRecord record) {
|
||||
try {
|
||||
markupItemTableAdapter.updateRecord(record);
|
||||
}
|
||||
@ -617,7 +617,7 @@ public class AssociationDatabaseManager implements VTAssociationManager {
|
||||
associationHooks.remove(hook);
|
||||
}
|
||||
|
||||
void removeMarkupRecord(Record record) {
|
||||
void removeMarkupRecord(DBRecord record) {
|
||||
try {
|
||||
markupItemTableAdapter.removeMatchMarkupItemRecord(record.getKey());
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ package ghidra.feature.vt.api.db;
|
||||
|
||||
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.MarkupItemStorageImpl;
|
||||
import ghidra.feature.vt.api.main.VTAssociation;
|
||||
@ -36,9 +36,9 @@ public class MarkupItemStorageDB extends DatabaseObject implements MarkupItemSto
|
||||
private final VTAssociation association;
|
||||
private final VTSessionDB session;
|
||||
|
||||
private Record record;
|
||||
private DBRecord record;
|
||||
|
||||
MarkupItemStorageDB(Record record, DBObjectCache<MarkupItemStorageDB> cache,
|
||||
MarkupItemStorageDB(DBRecord record, DBObjectCache<MarkupItemStorageDB> cache,
|
||||
AssociationDatabaseManager associationManager) {
|
||||
super(cache, record.getKey());
|
||||
this.record = record;
|
||||
@ -166,7 +166,7 @@ public class MarkupItemStorageDB extends DatabaseObject implements MarkupItemSto
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean refresh(Record matchRecord) {
|
||||
protected boolean refresh(DBRecord matchRecord) {
|
||||
if (matchRecord == null) {
|
||||
matchRecord = associationManager.getMarkupItemRecord(key);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -49,7 +48,7 @@ public class VTAddressCorrelationAdapterV0 extends VTAddressCorrelatorAdapter {
|
||||
|
||||
@Override
|
||||
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_ADDRESS_COL.column(), sourceLong);
|
||||
@ -59,10 +58,10 @@ public class VTAddressCorrelationAdapterV0 extends VTAddressCorrelatorAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
List<Record> getAddressRecords(long sourceEntryLong) throws IOException {
|
||||
List<DBRecord> getAddressRecords(long sourceEntryLong) throws IOException {
|
||||
LongField value = new LongField(sourceEntryLong);
|
||||
RecordIterator indexIterator = table.indexIterator(0, value, value, true);
|
||||
List<Record>records = new ArrayList<Record>();
|
||||
List<DBRecord>records = new ArrayList<DBRecord>();
|
||||
while(indexIterator.hasNext()) {
|
||||
records.add(indexIterator.next());
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public abstract class VTAddressCorrelatorAdapter {
|
||||
abstract void createAddressRecord(long sourceEntryLong, long sourceLong, long destinationLong)
|
||||
throws IOException;
|
||||
|
||||
abstract List<Record> getAddressRecords(long sourceEntryLong) throws IOException;
|
||||
abstract List<DBRecord> getAddressRecords(long sourceEntryLong) throws IOException;
|
||||
|
||||
void close() {
|
||||
dbHandle.close();
|
||||
|
@ -19,7 +19,7 @@ import static ghidra.feature.vt.api.db.VTAssociationTableDBAdapter.AssociationTa
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import ghidra.feature.vt.api.impl.MarkupItemManagerImpl;
|
||||
import ghidra.feature.vt.api.impl.VTChangeManager;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
@ -32,12 +32,12 @@ import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class VTAssociationDB extends DatabaseObject implements VTAssociation {
|
||||
|
||||
public Record record;
|
||||
public DBRecord record;
|
||||
private MarkupItemManagerImpl markupManager;
|
||||
public final AssociationDatabaseManager associationDBM;
|
||||
|
||||
public VTAssociationDB(AssociationDatabaseManager associationManager,
|
||||
DBObjectCache<VTAssociationDB> cache, Record record) {
|
||||
DBObjectCache<VTAssociationDB> cache, DBRecord record) {
|
||||
super(cache, record.getKey());
|
||||
this.associationDBM = associationManager;
|
||||
this.record = record;
|
||||
@ -80,7 +80,7 @@ public class VTAssociationDB extends DatabaseObject implements VTAssociation {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean refresh(Record associationRecord) {
|
||||
protected boolean refresh(DBRecord associationRecord) {
|
||||
if (associationRecord == null) {
|
||||
associationRecord = associationDBM.getAssociationRecord(key);
|
||||
}
|
||||
@ -158,7 +158,7 @@ public class VTAssociationDB extends DatabaseObject implements VTAssociation {
|
||||
}
|
||||
}
|
||||
|
||||
Record getRecord() {
|
||||
DBRecord getRecord() {
|
||||
associationDBM.lock.acquire();
|
||||
try {
|
||||
checkIsValid();
|
||||
|
@ -56,7 +56,7 @@ public abstract class VTAssociationTableDBAdapter {
|
||||
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;
|
||||
|
||||
abstract void deleteRecord(long sourceAddressID) throws IOException;
|
||||
@ -70,18 +70,18 @@ public abstract class VTAssociationTableDBAdapter {
|
||||
|
||||
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;
|
||||
|
||||
abstract Set<Record> getRelatedAssociationRecordsBySourceAddress(long sourceAddressID)
|
||||
abstract Set<DBRecord> getRelatedAssociationRecordsBySourceAddress(long sourceAddressID)
|
||||
throws IOException;
|
||||
|
||||
abstract Set<Record> getRelatedAssociationRecordsByDestinationAddress(long destinationAddressID)
|
||||
abstract Set<DBRecord> getRelatedAssociationRecordsByDestinationAddress(long destinationAddressID)
|
||||
throws IOException;
|
||||
|
||||
abstract void updateRecord(Record record) throws IOException;
|
||||
abstract void updateRecord(DBRecord record) throws IOException;
|
||||
|
||||
abstract void removeAssociaiton(long id) throws IOException;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -49,9 +48,9 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record insertRecord(long sourceAddressID, long destinationAddressID, VTAssociationType type,
|
||||
DBRecord insertRecord(long sourceAddressID, long destinationAddressID, VTAssociationType type,
|
||||
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(DESTINATION_ADDRESS_COL.column(), destinationAddressID);
|
||||
record.setByteValue(TYPE_COL.column(), (byte) type.ordinal());
|
||||
@ -67,7 +66,7 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecord(long key) throws IOException {
|
||||
DBRecord getRecord(long key) throws IOException {
|
||||
return table.getRecord(key);
|
||||
}
|
||||
|
||||
@ -94,9 +93,9 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Set<Record> getRelatedAssociationRecordsBySourceAndDestinationAddress(long sourceAddressID,
|
||||
Set<DBRecord> getRelatedAssociationRecordsBySourceAndDestinationAddress(long sourceAddressID,
|
||||
long destinationAddressID) throws IOException {
|
||||
Set<Record> recordSet = new HashSet<Record>();
|
||||
Set<DBRecord> recordSet = new HashSet<DBRecord>();
|
||||
|
||||
RecordIterator iterator = getRecordsForSourceAddress(sourceAddressID);
|
||||
while (iterator.hasNext()) {
|
||||
@ -112,9 +111,9 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Set<Record> getRelatedAssociationRecordsBySourceAddress(long sourceAddressID)
|
||||
Set<DBRecord> getRelatedAssociationRecordsBySourceAddress(long sourceAddressID)
|
||||
throws IOException {
|
||||
Set<Record> recordSet = new HashSet<Record>();
|
||||
Set<DBRecord> recordSet = new HashSet<DBRecord>();
|
||||
|
||||
RecordIterator iterator = getRecordsForSourceAddress(sourceAddressID);
|
||||
while (iterator.hasNext()) {
|
||||
@ -125,9 +124,9 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Set<Record> getRelatedAssociationRecordsByDestinationAddress(long destinationAddressID)
|
||||
Set<DBRecord> getRelatedAssociationRecordsByDestinationAddress(long destinationAddressID)
|
||||
throws IOException {
|
||||
Set<Record> recordSet = new HashSet<Record>();
|
||||
Set<DBRecord> recordSet = new HashSet<DBRecord>();
|
||||
|
||||
RecordIterator iterator = getRecordsForDestinationAddress(destinationAddressID);
|
||||
while (iterator.hasNext()) {
|
||||
@ -138,7 +137,7 @@ public class VTAssociationTableDBAdapterV0 extends VTAssociationTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
void updateRecord(Record record) throws IOException {
|
||||
void updateRecord(DBRecord record) throws IOException {
|
||||
table.putRecord(record);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import static ghidra.feature.vt.api.db.VTMatchTableDBAdapter.ColumnDescription.*
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import ghidra.feature.vt.api.impl.VTChangeManager;
|
||||
import ghidra.feature.vt.api.impl.VTProgramCorrelatorInfo;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
@ -32,7 +32,7 @@ import ghidra.util.exception.AssertException;
|
||||
|
||||
public class VTMatchDB extends DatabaseObject implements VTMatch {
|
||||
|
||||
private Record record;
|
||||
private DBRecord record;
|
||||
private final VTMatchSetDB matchSet;
|
||||
private VTSessionDB session;
|
||||
private VTAssociation association;
|
||||
@ -42,7 +42,7 @@ public class VTMatchDB extends DatabaseObject implements VTMatch {
|
||||
private boolean doCalculateHash = true;
|
||||
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());
|
||||
this.record = record;
|
||||
this.matchSet = matchSet;
|
||||
@ -56,7 +56,7 @@ public class VTMatchDB extends DatabaseObject implements VTMatch {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean refresh(Record matchRecord) {
|
||||
protected boolean refresh(DBRecord matchRecord) {
|
||||
association = null;
|
||||
if (matchRecord == null) {
|
||||
matchRecord = matchSet.getMatchRecord(key);
|
||||
|
@ -61,13 +61,13 @@ public abstract class VTMatchMarkupItemTableDBAdapter {
|
||||
|
||||
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;
|
||||
|
||||
abstract void updateRecord(Record record) throws IOException;
|
||||
abstract void updateRecord(DBRecord record) throws IOException;
|
||||
|
||||
public abstract int getRecordCount();
|
||||
|
||||
public abstract Record createMarkupItemRecord(MarkupItemStorage markupItem) throws IOException;
|
||||
public abstract DBRecord createMarkupItemRecord(MarkupItemStorage markupItem) throws IOException;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -59,9 +58,9 @@ public class VTMatchMarkupItemTableDBAdapterV0 extends VTMatchMarkupItemTableDBA
|
||||
}
|
||||
|
||||
@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();
|
||||
VTSession manager = association.getSession();
|
||||
@ -113,12 +112,12 @@ public class VTMatchMarkupItemTableDBAdapterV0 extends VTMatchMarkupItemTableDBA
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(long key) throws IOException {
|
||||
public DBRecord getRecord(long key) throws IOException {
|
||||
return table.getRecord(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
void updateRecord(Record record) throws IOException {
|
||||
void updateRecord(DBRecord record) throws IOException {
|
||||
table.putRecord(record);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ import ghidra.util.xml.XmlUtilities;
|
||||
|
||||
public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
|
||||
|
||||
private final Record matchSetRecord;
|
||||
private final DBRecord matchSetRecord;
|
||||
|
||||
private DBObjectCache<VTMatchDB> matchCache;
|
||||
private final VTSessionDB session;
|
||||
@ -56,7 +56,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
|
||||
private ProgramCorrelatorInfoImpl correlatorInfo;
|
||||
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 {
|
||||
|
||||
VTMatchSetDB matchSetDB = new VTMatchSetDB(record, session, dbHandle, lock);
|
||||
@ -64,7 +64,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
|
||||
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 {
|
||||
|
||||
VTMatchSetDB matchSetDB = new VTMatchSetDB(record, session, dbHandle, lock);
|
||||
@ -72,7 +72,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
|
||||
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
|
||||
this.matchSetRecord = record;
|
||||
this.session = session;
|
||||
@ -166,7 +166,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
|
||||
try {
|
||||
lock.acquire();
|
||||
VTMatchTagDB tagDB = session.getOrCreateMatchTagDB(tag);
|
||||
Record matchRecord =
|
||||
DBRecord matchRecord =
|
||||
matchTableAdapter.insertMatchRecord(info, this, associationDB, tagDB);
|
||||
newMatch = getMatchForRecord(matchRecord);
|
||||
}
|
||||
@ -242,7 +242,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
|
||||
lock.acquire();
|
||||
RecordIterator iterator = matchTableAdapter.getRecords();
|
||||
while (iterator.hasNext()) {
|
||||
Record nextRecord = iterator.next();
|
||||
DBRecord nextRecord = iterator.next();
|
||||
list.add(getMatchForRecord(nextRecord));
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
|
||||
try {
|
||||
RecordIterator iterator = matchTableAdapter.getRecords(associationDB.getKey());
|
||||
while (iterator.hasNext()) {
|
||||
Record nextRecord = iterator.next();
|
||||
DBRecord nextRecord = iterator.next();
|
||||
VTMatch match = getMatchForRecord(nextRecord);
|
||||
list.add(match);
|
||||
}
|
||||
@ -297,7 +297,7 @@ public class VTMatchSetDB extends DatabaseObject implements VTMatchSet {
|
||||
return session.getMatchSetRecord(key) == null;
|
||||
}
|
||||
|
||||
private VTMatch getMatchForRecord(Record matchRecord) {
|
||||
private VTMatch getMatchForRecord(DBRecord matchRecord) {
|
||||
try {
|
||||
lock.acquire();
|
||||
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 {
|
||||
return matchTableAdapter.getMatchRecord(matchRecordKey);
|
||||
}
|
||||
|
@ -80,18 +80,18 @@ public abstract class VTMatchSetTableDBAdapter {
|
||||
return new VTMatchSetTableDBAdapterV0(dbHandle, openMode);
|
||||
}
|
||||
|
||||
public abstract Record createMatchSetRecord(long key, VTProgramCorrelator correlator)
|
||||
public abstract DBRecord createMatchSetRecord(long key, VTProgramCorrelator correlator)
|
||||
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;
|
||||
|
||||
public abstract AddressSet getDestinationAddressSet(Record record, AddressMap addressMap)
|
||||
public abstract AddressSet getDestinationAddressSet(DBRecord record, AddressMap addressMap)
|
||||
throws IOException;
|
||||
|
||||
public abstract long getNextMatchSetID();
|
||||
|
||||
public abstract Record getRecord(long key) throws IOException;
|
||||
public abstract DBRecord getRecord(long key) throws IOException;
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record createMatchSetRecord(long key, VTProgramCorrelator correlator)
|
||||
public DBRecord createMatchSetRecord(long key, VTProgramCorrelator correlator)
|
||||
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_NAME_COL.column(), correlator.getName());
|
||||
@ -91,7 +91,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createSourceAddressSetTable(VTProgramCorrelator correlator, Record record)
|
||||
private void createSourceAddressSetTable(VTProgramCorrelator correlator, DBRecord record)
|
||||
throws IOException {
|
||||
|
||||
Program program = correlator.getSourceProgram();
|
||||
@ -101,7 +101,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
|
||||
writeAddressSet(addressSet, tableName, program.getAddressMap());
|
||||
}
|
||||
|
||||
private void createDestinationAddressSetTable(VTProgramCorrelator correlator, Record record)
|
||||
private void createDestinationAddressSetTable(VTProgramCorrelator correlator, DBRecord record)
|
||||
throws IOException {
|
||||
|
||||
Program program = correlator.getDestinationProgram();
|
||||
@ -111,11 +111,11 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
|
||||
writeAddressSet(addressSet, tableName, program.getAddressMap());
|
||||
}
|
||||
|
||||
private String getSourceTableName(Record record) {
|
||||
private String getSourceTableName(DBRecord record) {
|
||||
return "Source Address Set " + record.getKey();
|
||||
}
|
||||
|
||||
private String getDestinationTableName(Record record) {
|
||||
private String getDestinationTableName(DBRecord record) {
|
||||
return "Destination Address Set " + record.getKey();
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(long key) throws IOException {
|
||||
public DBRecord getRecord(long key) throws IOException {
|
||||
return table.getRecord(key);
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
|
||||
|
||||
if (set != null) {
|
||||
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;
|
||||
for (KeyRange range : addressMap.getKeyRanges(set, false, false)) {
|
||||
rec.setKey(rangeKey++);
|
||||
@ -146,17 +146,17 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressSet getDestinationAddressSet(Record record, AddressMap addressMap)
|
||||
public AddressSet getDestinationAddressSet(DBRecord record, AddressMap addressMap)
|
||||
throws IOException {
|
||||
return readAddressSet(record, getDestinationTableName(record), addressMap);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
private AddressSet readAddressSet(Record record, String tableName, AddressMap addressMap)
|
||||
private AddressSet readAddressSet(DBRecord record, String tableName, AddressMap addressMap)
|
||||
throws IOException {
|
||||
|
||||
Table addressSetTable = dbHandle.getTable(tableName);
|
||||
@ -168,7 +168,7 @@ public class VTMatchSetTableDBAdapterV0 extends VTMatchSetTableDBAdapter {
|
||||
|
||||
RecordIterator it = addressSetTable.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
Address addr1 = addressMap.decodeAddress(rec.getLongValue(0));
|
||||
Address addr2 = addressMap.decodeAddress(rec.getLongValue(1));
|
||||
addressSet.addRange(addr1, addr2);
|
||||
|
@ -82,16 +82,16 @@ public abstract class VTMatchTableDBAdapter {
|
||||
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;
|
||||
|
||||
public abstract RecordIterator getRecords() throws IOException;
|
||||
|
||||
abstract Record getMatchRecord(long matchRecordKey) throws IOException;
|
||||
abstract DBRecord getMatchRecord(long matchRecordKey) throws IOException;
|
||||
|
||||
abstract int getRecordCount();
|
||||
|
||||
abstract void updateRecord(Record record) throws IOException;
|
||||
abstract void updateRecord(DBRecord record) throws IOException;
|
||||
|
||||
abstract boolean deleteRecord(long matchRecordKey) throws IOException;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -51,10 +50,10 @@ public class VTMatchTableDBAdapterV0 extends VTMatchTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record insertMatchRecord(VTMatchInfo info, VTMatchSetDB matchSet,
|
||||
public DBRecord insertMatchRecord(VTMatchInfo info, VTMatchSetDB matchSet,
|
||||
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.setString(SIMILARITY_SCORE_COL.column(), info.getSimilarityScore().toStorageString());
|
||||
@ -68,7 +67,7 @@ public class VTMatchTableDBAdapterV0 extends VTMatchTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getMatchRecord(long matchRecordKey) throws IOException {
|
||||
DBRecord getMatchRecord(long matchRecordKey) throws IOException {
|
||||
return table.getRecord(matchRecordKey);
|
||||
}
|
||||
|
||||
@ -83,7 +82,7 @@ public class VTMatchTableDBAdapterV0 extends VTMatchTableDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
void updateRecord(Record record) throws IOException {
|
||||
void updateRecord(DBRecord record) throws IOException {
|
||||
table.putRecord(record);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import static ghidra.feature.vt.api.db.VTMatchTagDBAdapter.ColumnDescription.TAG
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import ghidra.feature.vt.api.main.VTMatchTag;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.DatabaseObject;
|
||||
@ -30,9 +30,9 @@ import ghidra.program.database.DatabaseObject;
|
||||
public class VTMatchTagDB extends DatabaseObject implements VTMatchTag {
|
||||
|
||||
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());
|
||||
this.sessionDB = sessionDB;
|
||||
this.record = record;
|
||||
@ -47,7 +47,7 @@ public class VTMatchTagDB extends DatabaseObject implements VTMatchTag {
|
||||
* Update associated record
|
||||
* @param rec the new record information
|
||||
*/
|
||||
void setRecord(Record rec) {
|
||||
void setRecord(DBRecord rec) {
|
||||
if (rec.getKey() != key) {
|
||||
throw new IllegalArgumentException("Key mismatch");
|
||||
}
|
||||
@ -56,7 +56,7 @@ public class VTMatchTagDB extends DatabaseObject implements VTMatchTag {
|
||||
|
||||
@Override
|
||||
protected boolean refresh() {
|
||||
Record rec = null;
|
||||
DBRecord rec = null;
|
||||
try {
|
||||
rec = sessionDB.getTagRecord(key);
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class VTMatchTagDB extends DatabaseObject implements VTMatchTag {
|
||||
* Returns record associated with this match tag or
|
||||
* null if the match tag has been deleted.
|
||||
*/
|
||||
Record getRecord() {
|
||||
DBRecord getRecord() {
|
||||
return checkIsValid() ? record : null;
|
||||
}
|
||||
|
||||
|
@ -77,15 +77,15 @@ public abstract class VTMatchTagDBAdapter {
|
||||
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;
|
||||
|
||||
abstract Record getRecord(long tagRecordKey) throws IOException;
|
||||
abstract DBRecord getRecord(long tagRecordKey) throws IOException;
|
||||
|
||||
abstract int getRecordCount();
|
||||
|
||||
abstract void updateRecord(Record record) throws IOException;
|
||||
abstract void updateRecord(DBRecord record) throws IOException;
|
||||
|
||||
abstract boolean deleteRecord(long tagRecordKey) throws IOException;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -48,7 +47,7 @@ public class VTMatchTagDBAdapterV0 extends VTMatchTagDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record insertRecord(String tagName) throws IOException {
|
||||
public DBRecord insertRecord(String tagName) throws IOException {
|
||||
|
||||
if (tagName == null) {
|
||||
throw new IllegalArgumentException(
|
||||
@ -59,7 +58,7 @@ public class VTMatchTagDBAdapterV0 extends VTMatchTagDBAdapter {
|
||||
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);
|
||||
|
||||
table.putRecord(record);
|
||||
@ -67,7 +66,7 @@ public class VTMatchTagDBAdapterV0 extends VTMatchTagDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecord(long tagRecordKey) throws IOException {
|
||||
DBRecord getRecord(long tagRecordKey) throws IOException {
|
||||
return table.getRecord(tagRecordKey);
|
||||
}
|
||||
|
||||
@ -82,7 +81,7 @@ public class VTMatchTagDBAdapterV0 extends VTMatchTagDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
void updateRecord(Record record) throws IOException {
|
||||
void updateRecord(DBRecord record) throws IOException {
|
||||
table.putRecord(record);
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
|
||||
}
|
||||
|
||||
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));
|
||||
propertyTable.putRecord(record);
|
||||
}
|
||||
@ -220,7 +220,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
|
||||
if (propertyTable == null) {
|
||||
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) {
|
||||
String s = record.getString(0);
|
||||
@ -365,7 +365,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
|
||||
throws IOException, VersionException {
|
||||
RecordIterator recordIterator = matchSetTableAdapter.getRecords();
|
||||
while (recordIterator.hasNext()) {
|
||||
Record record = recordIterator.next();
|
||||
DBRecord record = recordIterator.next();
|
||||
matchSets.add(
|
||||
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) {
|
||||
try {
|
||||
Record record = matchSetTableAdapter.createMatchSetRecord(id, correlator);
|
||||
DBRecord record = matchSetTableAdapter.createMatchSetRecord(id, correlator);
|
||||
VTMatchSetDB matchSet =
|
||||
VTMatchSetDB.createMatchSetDB(record, this, getDBHandle(), lock);
|
||||
matchSets.add(matchSet);
|
||||
@ -411,7 +411,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
|
||||
return null;
|
||||
}
|
||||
|
||||
Record getMatchSetRecord(long key) {
|
||||
DBRecord getMatchSetRecord(long key) {
|
||||
try {
|
||||
return matchSetTableAdapter.getRecord(key);
|
||||
}
|
||||
@ -462,11 +462,11 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
|
||||
return new ArrayList<>(matchSets);
|
||||
}
|
||||
|
||||
AddressSet getSourceAddressSet(Record record) throws IOException {
|
||||
AddressSet getSourceAddressSet(DBRecord record) throws IOException {
|
||||
return matchSetTableAdapter.getSourceAddressSet(record, sourceProgram.getAddressMap());
|
||||
}
|
||||
|
||||
AddressSet getDestinationAddressSet(Record record) throws IOException {
|
||||
AddressSet getDestinationAddressSet(DBRecord record) throws IOException {
|
||||
return matchSetTableAdapter.getDestinationAddressSet(record,
|
||||
destinationProgram.getAddressMap());
|
||||
}
|
||||
@ -596,7 +596,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
|
||||
if (matchTag != null) {
|
||||
return matchTag;
|
||||
}
|
||||
Record record = matchTagAdapter.insertRecord(tagName);
|
||||
DBRecord record = matchTagAdapter.insertRecord(tagName);
|
||||
matchTag = new VTMatchTagDB(this, tagCache, record);
|
||||
}
|
||||
catch (IOException e) {
|
||||
@ -627,7 +627,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
|
||||
lock.acquire();
|
||||
RecordIterator records = matchTagAdapter.getRecords();
|
||||
while (records.hasNext()) {
|
||||
Record record = records.next();
|
||||
DBRecord record = records.next();
|
||||
tags.add(getMatchTagNew(record));
|
||||
}
|
||||
}
|
||||
@ -640,7 +640,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
|
||||
return tags;
|
||||
}
|
||||
|
||||
private VTMatchTagDB getMatchTagNew(Record record) {
|
||||
private VTMatchTagDB getMatchTagNew(DBRecord record) {
|
||||
if (record == null) {
|
||||
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) {
|
||||
return matchTagDB;
|
||||
}
|
||||
Record record = matchTagAdapter.getRecord(key);
|
||||
DBRecord record = matchTagAdapter.getRecord(key);
|
||||
if (record != null) {
|
||||
return new VTMatchTagDB(this, tagCache, record);
|
||||
}
|
||||
@ -680,7 +680,7 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
|
||||
return VTMatchTag.UNTAGGED;
|
||||
}
|
||||
|
||||
Record getTagRecord(long key) throws IOException {
|
||||
DBRecord getTagRecord(long key) throws IOException {
|
||||
return matchTagAdapter.getRecord(key);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -66,14 +65,14 @@ public abstract class ConvertedRecordIterator implements RecordIterator {
|
||||
/**
|
||||
* @see db.RecordIterator#next()
|
||||
*/
|
||||
public Record next() throws IOException {
|
||||
public DBRecord next() throws IOException {
|
||||
return convertRecord(originalIterator.next());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see db.RecordIterator#previous()
|
||||
*/
|
||||
public Record previous() throws IOException {
|
||||
public DBRecord previous() throws IOException {
|
||||
return convertRecord(originalIterator.previous());
|
||||
}
|
||||
|
||||
@ -82,6 +81,6 @@ public abstract class ConvertedRecordIterator implements RecordIterator {
|
||||
* @param record
|
||||
* @return converted record
|
||||
*/
|
||||
protected abstract Record convertRecord(Record record);
|
||||
protected abstract DBRecord convertRecord(DBRecord record);
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import ghidra.util.exception.AssertException;
|
||||
* associated with a fixed schema.
|
||||
* 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;
|
||||
|
||||
@ -41,7 +41,7 @@ public class Record implements Comparable<Record> {
|
||||
* @param schema record schema
|
||||
* @param key record key
|
||||
*/
|
||||
Record(Schema schema, Field key) {
|
||||
DBRecord(Schema schema, Field key) {
|
||||
this.schema = schema;
|
||||
this.key = key;
|
||||
if (!schema.getKeyFieldType().isSameType(key)) {
|
||||
@ -107,7 +107,7 @@ public class Record implements Comparable<Record> {
|
||||
* @param otherRec
|
||||
* @return true if records schemas are the same
|
||||
*/
|
||||
public boolean hasSameSchema(Record otherRec) {
|
||||
public boolean hasSameSchema(DBRecord otherRec) {
|
||||
Field[] otherFieldValues = otherRec.fieldValues;
|
||||
if (fieldValues.length != otherFieldValues.length) {
|
||||
return false;
|
||||
@ -219,8 +219,8 @@ public class Record implements Comparable<Record> {
|
||||
* Obtain a copy of this record object.
|
||||
* @return Record
|
||||
*/
|
||||
public Record copy() {
|
||||
Record r = schema.createRecord(key.copyField());
|
||||
public DBRecord copy() {
|
||||
DBRecord r = schema.createRecord(key.copyField());
|
||||
for (int i = 0; i < fieldValues.length; i++) {
|
||||
r.setField(i, fieldValues[i].copyField());
|
||||
}
|
||||
@ -448,10 +448,10 @@ public class Record implements Comparable<Record> {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Record)) {
|
||||
if (!(obj instanceof DBRecord)) {
|
||||
return false;
|
||||
}
|
||||
Record rec = (Record) obj;
|
||||
DBRecord rec = (DBRecord) obj;
|
||||
return key.equals(rec.key) && Arrays.equals(fieldValues, rec.fieldValues);
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ public class Record implements Comparable<Record> {
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Record otherRec) {
|
||||
public int compareTo(DBRecord otherRec) {
|
||||
return key.compareTo(otherRec.key);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -56,7 +55,7 @@ public class DatabaseUtils {
|
||||
long keyDiff = newStart - oldStart;
|
||||
RecordIterator it = table.iterator(oldStart, oldStart+size-1, oldStart);
|
||||
while(it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
rec.setKey(rec.getKey()+keyDiff);
|
||||
tmpTable.putRecord(rec);
|
||||
}
|
||||
@ -66,7 +65,7 @@ public class DatabaseUtils {
|
||||
|
||||
it = tmpTable.iterator(newStart, newStart+size-1, newStart);
|
||||
while(it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
table.putRecord(rec);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class FieldIndexTable extends IndexTable {
|
||||
}
|
||||
if (indexField.usesTruncatedFieldValue()) {
|
||||
// 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);
|
||||
if (!indexValue.equals(val)) {
|
||||
continue;
|
||||
@ -107,18 +107,18 @@ public class FieldIndexTable extends IndexTable {
|
||||
}
|
||||
|
||||
@Override
|
||||
void addEntry(Record record) throws IOException {
|
||||
void addEntry(DBRecord record) throws IOException {
|
||||
Field indexedField = record.getField(indexColumn);
|
||||
if (isSparseIndex && indexedField.isNull()) {
|
||||
return;
|
||||
}
|
||||
IndexField f = indexKeyType.newIndexField(indexedField, record.getKeyField());
|
||||
Record rec = indexTable.getSchema().createRecord(f);
|
||||
DBRecord rec = indexTable.getSchema().createRecord(f);
|
||||
indexTable.putRecord(rec);
|
||||
}
|
||||
|
||||
@Override
|
||||
void deleteEntry(Record record) throws IOException {
|
||||
void deleteEntry(DBRecord record) throws IOException {
|
||||
Field indexedField = record.getField(indexColumn);
|
||||
if (isSparseIndex && indexedField.isNull()) {
|
||||
return;
|
||||
@ -364,7 +364,7 @@ public class FieldIndexTable extends IndexTable {
|
||||
}
|
||||
if (indexField.usesTruncatedFieldValue()) {
|
||||
// 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);
|
||||
if (!field.equals(val)) {
|
||||
continue; // skip
|
||||
@ -510,7 +510,7 @@ public class FieldIndexTable extends IndexTable {
|
||||
private boolean indexValueOutOfRange(IndexField f) throws IOException {
|
||||
Field val = null;
|
||||
if (min != null && min.usesTruncatedFieldValue() && min.hasSameIndexValue(f)) {
|
||||
Record rec = primaryTable.getRecord(f.getPrimaryKey());
|
||||
DBRecord rec = primaryTable.getRecord(f.getPrimaryKey());
|
||||
val = rec.getField(indexColumn);
|
||||
if (val.compareTo(min.getNonTruncatedIndexField()) < 0) {
|
||||
return true;
|
||||
@ -518,7 +518,7 @@ public class FieldIndexTable extends IndexTable {
|
||||
}
|
||||
if (max != null && max.usesTruncatedFieldValue() && max.hasSameIndexValue(f)) {
|
||||
if (val == null) {
|
||||
Record rec = primaryTable.getRecord(f.getPrimaryKey());
|
||||
DBRecord rec = primaryTable.getRecord(f.getPrimaryKey());
|
||||
val = rec.getField(indexColumn);
|
||||
}
|
||||
if (val.compareTo(min.getNonTruncatedIndexField()) > 0) {
|
||||
|
@ -30,7 +30,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
|
||||
* @return Record
|
||||
* @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.
|
||||
@ -39,7 +39,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
|
||||
* @return root node which may have changed.
|
||||
* @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.
|
||||
@ -101,7 +101,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @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
|
||||
@ -111,7 +111,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @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
|
||||
@ -121,7 +121,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @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
|
||||
@ -131,7 +131,7 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @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.
|
||||
@ -140,6 +140,6 @@ interface FieldKeyRecordNode extends RecordNode, FieldKeyNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @throws IOException thrown if IO error occurs
|
||||
*/
|
||||
Record getRecord(Field key, Schema schema) throws IOException;
|
||||
DBRecord getRecord(Field key, Schema schema) throws IOException;
|
||||
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class FixedKeyFixedRecNode extends FixedKeyRecordNode {
|
||||
}
|
||||
|
||||
@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)
|
||||
// int len = record.length();
|
||||
@ -143,26 +143,26 @@ class FixedKeyFixedRecNode extends FixedKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
FixedKeyNode updateRecord(int index, Record record) throws IOException {
|
||||
FixedKeyNode updateRecord(int index, DBRecord record) throws IOException {
|
||||
int offset = getRecordOffset(index) + keySize;
|
||||
record.write(buffer, offset);
|
||||
return getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(Field key, Schema schema) throws IOException {
|
||||
public DBRecord getRecord(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0)
|
||||
return null;
|
||||
Record record = schema.createRecord(key);
|
||||
DBRecord record = schema.createRecord(key);
|
||||
record.read(buffer, getRecordOffset(index) + keySize);
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(Schema schema, int index) throws IOException {
|
||||
public DBRecord getRecord(Schema schema, int index) throws IOException {
|
||||
Field key = getKeyField(index);
|
||||
Record record = schema.createRecord(key);
|
||||
DBRecord record = schema.createRecord(key);
|
||||
record.read(buffer, getRecordOffset(index) + keySize);
|
||||
return record;
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
|
||||
abstract FixedKeyRecordNode createNewLeaf(int prevNodeId, int nextNodeId) throws IOException;
|
||||
|
||||
@Override
|
||||
public FixedKeyNode putRecord(Record record, Table table) throws IOException {
|
||||
public FixedKeyNode putRecord(DBRecord record, Table table) throws IOException {
|
||||
|
||||
Field key = record.getKeyField();
|
||||
int index = getKeyIndex(key);
|
||||
@ -374,7 +374,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
|
||||
* @return root node which may have changed.
|
||||
* @throws IOException thrown if IO error occurs
|
||||
*/
|
||||
FixedKeyNode appendNewLeaf(Record record) throws IOException {
|
||||
FixedKeyNode appendNewLeaf(DBRecord record) throws IOException {
|
||||
FixedKeyRecordNode newLeaf = createNewLeaf(-1, -1);
|
||||
newLeaf.insertRecord(0, record);
|
||||
return appendLeaf(newLeaf);
|
||||
@ -418,7 +418,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
|
||||
* @return true if the record was successfully inserted.
|
||||
* @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.
|
||||
@ -427,10 +427,10 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
|
||||
* @return root node which may have changed.
|
||||
* @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
|
||||
public db.Record getRecordBefore(Field key, Schema schema) throws IOException {
|
||||
public db.DBRecord getRecordBefore(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0) {
|
||||
index = -index - 2;
|
||||
@ -446,7 +446,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
|
||||
}
|
||||
|
||||
@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);
|
||||
if (index < 0) {
|
||||
index = -(index + 1);
|
||||
@ -462,7 +462,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecordAtOrBefore(Field key, Schema schema) throws IOException {
|
||||
public DBRecord getRecordAtOrBefore(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0) {
|
||||
index = -index - 2;
|
||||
@ -475,7 +475,7 @@ abstract class FixedKeyRecordNode extends FixedKeyNode implements FieldKeyRecord
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecordAtOrAfter(Field key, Schema schema) throws IOException {
|
||||
public DBRecord getRecordAtOrAfter(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0) {
|
||||
index = -(index + 1);
|
||||
|
@ -191,9 +191,9 @@ class FixedKeyVarRecNode extends FixedKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(Schema schema, int index) throws IOException {
|
||||
public DBRecord getRecord(Schema schema, int index) throws IOException {
|
||||
Field key = getKeyField(index);
|
||||
Record record = schema.createRecord(key);
|
||||
DBRecord record = schema.createRecord(key);
|
||||
if (hasIndirectStorage(index)) {
|
||||
int bufId = buffer.getInt(getRecordDataOffset(index));
|
||||
ChainedBuffer chainedBuffer = new ChainedBuffer(nodeMgr.getBufferMgr(), bufId);
|
||||
@ -214,7 +214,7 @@ class FixedKeyVarRecNode extends FixedKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(Field key, Schema schema) throws IOException {
|
||||
public DBRecord getRecord(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0) {
|
||||
return null;
|
||||
@ -279,7 +279,7 @@ class FixedKeyVarRecNode extends FixedKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
FixedKeyNode updateRecord(int index, Record record) throws IOException {
|
||||
FixedKeyNode updateRecord(int index, DBRecord record) throws IOException {
|
||||
|
||||
int offset = getRecordDataOffset(index);
|
||||
int oldLen = getRecordLength(index, offset);
|
||||
@ -341,7 +341,7 @@ class FixedKeyVarRecNode extends FixedKeyRecordNode {
|
||||
* @throws IOException thrown if an IO error occurs
|
||||
*/
|
||||
@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)
|
||||
int len = record.length();
|
||||
|
@ -130,7 +130,7 @@ class FixedRecNode extends LongKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean insertRecord(int index, Record record) throws IOException {
|
||||
boolean insertRecord(int index, DBRecord record) throws IOException {
|
||||
|
||||
if (keyCount == ((buffer.length() - HEADER_SIZE) / entrySize)) {
|
||||
return false; // insufficient space for record storage
|
||||
@ -149,26 +149,26 @@ class FixedRecNode extends LongKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
LongKeyNode updateRecord(int index, Record record) throws IOException {
|
||||
LongKeyNode updateRecord(int index, DBRecord record) throws IOException {
|
||||
int offset = getRecordOffset(index) + KEY_SIZE;
|
||||
record.write(buffer, offset);
|
||||
return getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecord(long key, Schema schema) throws IOException {
|
||||
DBRecord getRecord(long key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0)
|
||||
return null;
|
||||
Record record = schema.createRecord(key);
|
||||
DBRecord record = schema.createRecord(key);
|
||||
record.read(buffer, getRecordOffset(index) + KEY_SIZE);
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(Schema schema, int index) throws IOException {
|
||||
public DBRecord getRecord(Schema schema, int index) throws IOException {
|
||||
long key = getKey(index);
|
||||
Record record = schema.createRecord(key);
|
||||
DBRecord record = schema.createRecord(key);
|
||||
record.read(buffer, getRecordOffset(index) + KEY_SIZE);
|
||||
return record;
|
||||
}
|
||||
|
@ -193,14 +193,14 @@ abstract class IndexTable {
|
||||
* @param record new record
|
||||
* @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.
|
||||
* @param oldRecord deleted record
|
||||
* @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.
|
||||
|
@ -61,7 +61,7 @@ public class KeyToRecordIterator implements RecordIterator {
|
||||
* @see db.RecordIterator#next()
|
||||
*/
|
||||
@Override
|
||||
public Record next() throws IOException {
|
||||
public DBRecord next() throws IOException {
|
||||
synchronized (db) {
|
||||
try {
|
||||
return table.getRecord(keyIter.next());
|
||||
@ -76,7 +76,7 @@ public class KeyToRecordIterator implements RecordIterator {
|
||||
* @see db.RecordIterator#previous()
|
||||
*/
|
||||
@Override
|
||||
public Record previous() throws IOException {
|
||||
public DBRecord previous() throws IOException {
|
||||
synchronized (db) {
|
||||
try {
|
||||
return table.getRecord(keyIter.previous());
|
||||
|
@ -311,7 +311,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return root node which may have changed.
|
||||
* @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();
|
||||
int index = getKeyIndex(key);
|
||||
@ -360,7 +360,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return root node which may have changed.
|
||||
* @throws IOException thrown if IO error occurs
|
||||
*/
|
||||
LongKeyNode appendNewLeaf(Record record) throws IOException {
|
||||
LongKeyNode appendNewLeaf(DBRecord record) throws IOException {
|
||||
LongKeyRecordNode newLeaf = createNewLeaf(-1, -1);
|
||||
newLeaf.insertRecord(0, record);
|
||||
return appendLeaf(newLeaf);
|
||||
@ -418,7 +418,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return true if the record was successfully inserted.
|
||||
* @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.
|
||||
@ -427,7 +427,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return root node which may have changed.
|
||||
* @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.
|
||||
@ -436,7 +436,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @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.
|
||||
@ -445,7 +445,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return Record
|
||||
* @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.
|
||||
@ -454,7 +454,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @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);
|
||||
if (index < 0) {
|
||||
index = -index - 2;
|
||||
@ -476,7 +476,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @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);
|
||||
if (index < 0) {
|
||||
index = -(index + 1);
|
||||
@ -499,7 +499,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @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);
|
||||
if (index < 0) {
|
||||
index = -index - 2;
|
||||
@ -519,7 +519,7 @@ abstract class LongKeyRecordNode extends LongKeyNode implements RecordNode {
|
||||
* @return Record requested or null if record not found.
|
||||
* @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);
|
||||
if (index < 0) {
|
||||
index = -(index + 1);
|
||||
|
@ -167,7 +167,7 @@ class MasterTable {
|
||||
int oldTableCnt = tableRecords.length;
|
||||
RecordIterator it = table.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
long tablenum = rec.getKey();
|
||||
|
||||
while (ix < tableRecords.length && tablenum > tableRecords[ix].getTableNum()) {
|
||||
@ -199,7 +199,7 @@ class MasterTable {
|
||||
*/
|
||||
void flush() throws IOException {
|
||||
for (int i = 0; i < tableRecords.length; i++) {
|
||||
Record rec = tableRecords[i].getRecord();
|
||||
DBRecord rec = tableRecords[i].getRecord();
|
||||
if (rec.isDirty()) {
|
||||
table.putRecord(rec);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class ObjectStorageAdapterDB implements ObjectStorage {
|
||||
* existing record.
|
||||
* @param rec data record
|
||||
*/
|
||||
public ObjectStorageAdapterDB(Record rec) {
|
||||
public ObjectStorageAdapterDB(DBRecord rec) {
|
||||
readOnly = true;
|
||||
Field[] fields = rec.getFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
@ -335,7 +335,7 @@ public class ObjectStorageAdapterDB implements ObjectStorage {
|
||||
* Save data into a Record.
|
||||
* @param rec database record.
|
||||
*/
|
||||
public void save(Record rec) {
|
||||
public void save(DBRecord rec) {
|
||||
int cnt = fieldList.size();
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
rec.setField(i, fieldList.get(i));
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -40,13 +39,13 @@ public interface RecordIterator {
|
||||
* Return the nexy Record or null if one is not available.
|
||||
* @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.
|
||||
* @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.
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -23,5 +22,5 @@ public interface RecordTranslator {
|
||||
* @param oldRecord the old database record.
|
||||
* @return the new data base record in the form required for the current database version.
|
||||
*/
|
||||
Record translateRecord(Record oldRecord);
|
||||
DBRecord translateRecord(DBRecord oldRecord);
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ public class Schema {
|
||||
* @param key long key
|
||||
* @return new record
|
||||
*/
|
||||
public Record createRecord(long key) {
|
||||
public DBRecord createRecord(long key) {
|
||||
return createRecord(new LongField(key));
|
||||
}
|
||||
|
||||
@ -530,8 +530,8 @@ public class Schema {
|
||||
* @param key record key field
|
||||
* @return new record
|
||||
*/
|
||||
public Record createRecord(Field key) {
|
||||
return hasSparseColumns() ? new SparseRecord(this, key) : new Record(this, key);
|
||||
public DBRecord createRecord(Field key) {
|
||||
return hasSparseColumns() ? new SparseRecord(this, key) : new DBRecord(this, key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@ package db;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SparseRecord extends Record {
|
||||
public class SparseRecord extends DBRecord {
|
||||
|
||||
SparseRecord(Schema schema, Field key) {
|
||||
super(schema, key);
|
||||
|
@ -239,7 +239,7 @@ public class Table {
|
||||
* @param record new record which has been added
|
||||
* @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
|
||||
for (int indexedColumn : indexedColumns) {
|
||||
IndexTable indexTable = secondaryIndexes.get(indexedColumn);
|
||||
@ -255,7 +255,7 @@ public class Table {
|
||||
* @param newRecord new record
|
||||
* @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
|
||||
for (int colIx : indexedColumns) {
|
||||
Field oldField = oldRecord.getField(colIx);
|
||||
@ -275,7 +275,7 @@ public class Table {
|
||||
* @param oldRecord record which has been deleted
|
||||
* @throws IOException thrown if IO error occurs
|
||||
*/
|
||||
void deletedRecord(Record oldRecord) throws IOException {
|
||||
void deletedRecord(DBRecord oldRecord) throws IOException {
|
||||
// Delete secondary index entries
|
||||
for (int indexedColumn : indexedColumns) {
|
||||
IndexTable indexTable = secondaryIndexes.get(indexedColumn);
|
||||
@ -334,7 +334,7 @@ public class Table {
|
||||
try {
|
||||
RecordIterator recIter = iterator();
|
||||
while (recIter.hasNext()) {
|
||||
Record rec = recIter.next();
|
||||
DBRecord rec = recIter.next();
|
||||
++actualCount;
|
||||
Field keyField = rec.getKeyField();
|
||||
if ((keyField instanceof LongField) &&
|
||||
@ -407,7 +407,7 @@ public class Table {
|
||||
int actualCount = 0;
|
||||
RecordIterator recIter = iterator();
|
||||
while (recIter.hasNext()) {
|
||||
Record rec = recIter.next();
|
||||
DBRecord rec = recIter.next();
|
||||
++actualCount;
|
||||
|
||||
// Check for bad index tables (missing or invalid entries)
|
||||
@ -687,7 +687,7 @@ public class Table {
|
||||
* found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecord(long key) throws IOException {
|
||||
public DBRecord getRecord(long key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -709,7 +709,7 @@ public class Table {
|
||||
* found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecord(Field key) throws IOException {
|
||||
public DBRecord getRecord(Field key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -740,7 +740,7 @@ public class Table {
|
||||
* specified key, or null if no record was found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecordBefore(long key) throws IOException {
|
||||
public DBRecord getRecordBefore(long key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -763,7 +763,7 @@ public class Table {
|
||||
* specified key, or null if no record was found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecordBefore(Field key) throws IOException {
|
||||
public DBRecord getRecordBefore(Field key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -789,7 +789,7 @@ public class Table {
|
||||
* specified key, or null if no record was found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecordAfter(long key) throws IOException {
|
||||
public DBRecord getRecordAfter(long key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -812,7 +812,7 @@ public class Table {
|
||||
* specified key, or null if no record was found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecordAfter(Field key) throws IOException {
|
||||
public DBRecord getRecordAfter(Field key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -838,7 +838,7 @@ public class Table {
|
||||
* specified key, or null if no record was found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecordAtOrBefore(long key) throws IOException {
|
||||
public DBRecord getRecordAtOrBefore(long key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -861,7 +861,7 @@ public class Table {
|
||||
* specified key, or null if no record was found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecordAtOrBefore(Field key) throws IOException {
|
||||
public DBRecord getRecordAtOrBefore(Field key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -887,7 +887,7 @@ public class Table {
|
||||
* specified key, or null if no record was found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecordAtOrAfter(long key) throws IOException {
|
||||
public DBRecord getRecordAtOrAfter(long key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -910,7 +910,7 @@ public class Table {
|
||||
* specified key, or null if no record was found.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public Record getRecordAtOrAfter(Field key) throws IOException {
|
||||
public DBRecord getRecordAtOrAfter(Field key) throws IOException {
|
||||
synchronized (db) {
|
||||
if (rootBufferId < 0) {
|
||||
return null;
|
||||
@ -933,7 +933,7 @@ public class Table {
|
||||
* @param record the record to be stored.
|
||||
* @throws IOException throw if an IO Error occurs
|
||||
*/
|
||||
public void putRecord(Record record) throws IOException {
|
||||
public void putRecord(DBRecord record) throws IOException {
|
||||
synchronized (db) {
|
||||
db.checkTransaction();
|
||||
if (schema.useLongKeyNodes()) {
|
||||
@ -951,7 +951,7 @@ public class Table {
|
||||
* @param record recore to be inserted or updated
|
||||
* @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;
|
||||
try {
|
||||
@ -1000,7 +1000,7 @@ public class Table {
|
||||
* @param record record to be inserted or updated
|
||||
* @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;
|
||||
try {
|
||||
@ -2031,9 +2031,9 @@ public class Table {
|
||||
private boolean isNext; // recover position is next 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 Record lastRecord;
|
||||
private DBRecord lastRecord;
|
||||
|
||||
private boolean hasPrev; // current record is previous
|
||||
private boolean hasNext; // current record is next
|
||||
@ -2224,7 +2224,7 @@ public class Table {
|
||||
}
|
||||
|
||||
// Load next record
|
||||
Record nextRecord = leaf.getRecord(schema, nextIndex);
|
||||
DBRecord nextRecord = leaf.getRecord(schema, nextIndex);
|
||||
hasNext = nextRecord.getKey() <= maxKey;
|
||||
if (hasNext) {
|
||||
bufferId = nextBufferId;
|
||||
@ -2271,7 +2271,7 @@ public class Table {
|
||||
}
|
||||
|
||||
// Load previous record
|
||||
Record prevRecord = leaf.getRecord(schema, prevIndex);
|
||||
DBRecord prevRecord = leaf.getRecord(schema, prevIndex);
|
||||
hasPrev = prevRecord.getKey() >= minKey;
|
||||
if (hasPrev) {
|
||||
bufferId = prevBufferId;
|
||||
@ -2290,7 +2290,7 @@ public class Table {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record next() throws IOException {
|
||||
public DBRecord next() throws IOException {
|
||||
if (hasNext || hasNext()) {
|
||||
hasNext = false;
|
||||
hasPrev = true;
|
||||
@ -2301,7 +2301,7 @@ public class Table {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record previous() throws IOException {
|
||||
public DBRecord previous() throws IOException {
|
||||
if (hasPrev || hasPrevious()) {
|
||||
hasNext = true;
|
||||
hasPrev = false;
|
||||
@ -2333,9 +2333,9 @@ public class Table {
|
||||
private boolean isNext; // recover position is next 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 Record lastRecord;
|
||||
private DBRecord lastRecord;
|
||||
|
||||
private boolean hasPrev; // current record is previous
|
||||
private boolean hasNext; // current record is next
|
||||
@ -2549,7 +2549,7 @@ public class Table {
|
||||
}
|
||||
|
||||
// Load next record
|
||||
Record nextRecord = leaf.getRecord(schema, nextIndex);
|
||||
DBRecord nextRecord = leaf.getRecord(schema, nextIndex);
|
||||
hasNext = maxKey == null ? true
|
||||
: (nextRecord.getKeyField().compareTo(maxKey) <= 0);
|
||||
if (hasNext) {
|
||||
@ -2597,7 +2597,7 @@ public class Table {
|
||||
}
|
||||
|
||||
// Load previous record
|
||||
Record prevRecord = leaf.getRecord(schema, prevIndex);
|
||||
DBRecord prevRecord = leaf.getRecord(schema, prevIndex);
|
||||
hasPrev = minKey == null ? true
|
||||
: (prevRecord.getKeyField().compareTo(minKey) >= 0);
|
||||
if (hasPrev) {
|
||||
@ -2617,7 +2617,7 @@ public class Table {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record next() throws IOException {
|
||||
public DBRecord next() throws IOException {
|
||||
if (hasNext || hasNext()) {
|
||||
hasNext = false;
|
||||
hasPrev = true;
|
||||
@ -2628,7 +2628,7 @@ public class Table {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record previous() throws IOException {
|
||||
public DBRecord previous() throws IOException {
|
||||
if (hasPrev || hasPrevious()) {
|
||||
hasNext = true;
|
||||
hasPrev = false;
|
||||
|
@ -54,7 +54,7 @@ class TableRecord implements Comparable<TableRecord> {
|
||||
|
||||
private static Schema schema = new Schema(0, "TableNum", fields, tableRecordFieldNames);
|
||||
|
||||
private Record record;
|
||||
private DBRecord record;
|
||||
private Schema tableSchema;
|
||||
private Table table;
|
||||
|
||||
@ -86,7 +86,7 @@ class TableRecord implements Comparable<TableRecord> {
|
||||
* @throws UnsupportedFieldException stored schema contains unsupported field
|
||||
* @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.record = record;
|
||||
}
|
||||
@ -95,7 +95,7 @@ class TableRecord implements Comparable<TableRecord> {
|
||||
* Get the underlying storage record for this instance.
|
||||
* @return master table storage record.
|
||||
*/
|
||||
Record getRecord() {
|
||||
DBRecord getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ class TableRecord implements Comparable<TableRecord> {
|
||||
* @throws UnsupportedFieldException stored schema contains unsupported field
|
||||
* @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.record = record;
|
||||
if (table != null) {
|
||||
@ -169,7 +169,7 @@ class TableRecord implements Comparable<TableRecord> {
|
||||
* @throws UnsupportedFieldException stored schema contains unsupported field
|
||||
* @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 =
|
||||
new Schema(record.getIntValue(VERSION_COLUMN), record.getByteValue(KEY_TYPE_COLUMN),
|
||||
record.getBinaryData(FIELD_TYPES_COLUMN), record.getString(FIELD_NAMES_COLUMN));
|
||||
|
@ -37,12 +37,12 @@ public class TranslatedRecordIterator implements RecordIterator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record next() throws IOException {
|
||||
public DBRecord next() throws IOException {
|
||||
return translator.translateRecord(it.next());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record previous() throws IOException {
|
||||
public DBRecord previous() throws IOException {
|
||||
return translator.translateRecord(it.previous());
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VarKeyNode putRecord(Record record, Table table) throws IOException {
|
||||
public VarKeyNode putRecord(DBRecord record, Table table) throws IOException {
|
||||
|
||||
Field key = record.getKeyField();
|
||||
int index = getKeyIndex(key);
|
||||
@ -342,7 +342,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
* @return root node which may have changed.
|
||||
* @throws IOException thrown if IO error occurs
|
||||
*/
|
||||
VarKeyNode appendNewLeaf(Record record) throws IOException {
|
||||
VarKeyNode appendNewLeaf(DBRecord record) throws IOException {
|
||||
VarKeyRecordNode newLeaf = createNewLeaf(-1, -1);
|
||||
newLeaf.insertRecord(0, record);
|
||||
return appendLeaf(newLeaf);
|
||||
@ -386,7 +386,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecordBefore(Field key, Schema schema) throws IOException {
|
||||
public DBRecord getRecordBefore(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0) {
|
||||
index = -index - 2;
|
||||
@ -402,7 +402,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecordAfter(Field key, Schema schema) throws IOException {
|
||||
public DBRecord getRecordAfter(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0) {
|
||||
index = -(index + 1);
|
||||
@ -418,7 +418,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecordAtOrBefore(Field key, Schema schema) throws IOException {
|
||||
public DBRecord getRecordAtOrBefore(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0) {
|
||||
index = -index - 2;
|
||||
@ -431,7 +431,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecordAtOrAfter(Field key, Schema schema) throws IOException {
|
||||
public DBRecord getRecordAtOrAfter(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0) {
|
||||
index = -(index + 1);
|
||||
@ -574,9 +574,9 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
* @return Record
|
||||
*/
|
||||
@Override
|
||||
public Record getRecord(Schema schema, int index) throws IOException {
|
||||
public DBRecord getRecord(Schema schema, int index) throws IOException {
|
||||
Field key = getKeyField(index);
|
||||
Record record = schema.createRecord(key);
|
||||
DBRecord record = schema.createRecord(key);
|
||||
if (hasIndirectStorage(index)) {
|
||||
int bufId = buffer.getInt(getRecordDataOffset(index));
|
||||
ChainedBuffer chainedBuffer = new ChainedBuffer(nodeMgr.getBufferMgr(), bufId);
|
||||
@ -597,7 +597,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(Field key, Schema schema) throws IOException {
|
||||
public DBRecord getRecord(Field key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0)
|
||||
return null;
|
||||
@ -669,7 +669,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
* @return root node which may have changed.
|
||||
* @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();
|
||||
int keyLen = key.length();
|
||||
@ -733,7 +733,7 @@ class VarKeyRecordNode extends VarKeyNode implements FieldKeyRecordNode {
|
||||
* @return true if the record was successfully inserted.
|
||||
* @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();
|
||||
int keyLen = key.length();
|
||||
|
@ -189,9 +189,9 @@ class VarRecNode extends LongKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record getRecord(Schema schema, int index) throws IOException {
|
||||
public DBRecord getRecord(Schema schema, int index) throws IOException {
|
||||
long key = getKey(index);
|
||||
Record record = schema.createRecord(key);
|
||||
DBRecord record = schema.createRecord(key);
|
||||
if (hasIndirectStorage(index)) {
|
||||
int bufId = buffer.getInt(getRecordDataOffset(index));
|
||||
ChainedBuffer chainedBuffer = new ChainedBuffer(nodeMgr.getBufferMgr(), bufId);
|
||||
@ -212,7 +212,7 @@ class VarRecNode extends LongKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecord(long key, Schema schema) throws IOException {
|
||||
DBRecord getRecord(long key, Schema schema) throws IOException {
|
||||
int index = getKeyIndex(key);
|
||||
if (index < 0) {
|
||||
return null;
|
||||
@ -277,7 +277,7 @@ class VarRecNode extends LongKeyRecordNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
LongKeyNode updateRecord(int index, Record record) throws IOException {
|
||||
LongKeyNode updateRecord(int index, DBRecord record) throws IOException {
|
||||
|
||||
int offset = getRecordDataOffset(index);
|
||||
int oldLen = getRecordLength(index, offset);
|
||||
@ -330,7 +330,7 @@ class VarRecNode extends LongKeyRecordNode {
|
||||
}
|
||||
|
||||
@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)
|
||||
int len = record.length();
|
||||
|
@ -86,11 +86,11 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
* @param varDataSize size of variable length data fields.
|
||||
* @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 {
|
||||
long txId = dbh.startTransaction();
|
||||
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++) {
|
||||
try {
|
||||
recs[i] = DBTestUtils.createFixedKeyRecord(table, varDataSize, true);
|
||||
@ -110,13 +110,13 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
* @param varDataSize size of variable length data fields.
|
||||
* @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 {
|
||||
long txId = dbh.startTransaction();
|
||||
Table table = DBTestUtils.createFixedKeyTable(dbh, table1Name, schemaType, true, false);
|
||||
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 });
|
||||
Record[] recs = new Record[recordCnt];
|
||||
DBRecord[] recs = new DBRecord[recordCnt];
|
||||
for (int i = 0; i < recordCnt; i++) {
|
||||
try {
|
||||
recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true);
|
||||
@ -130,19 +130,19 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
return recs;
|
||||
}
|
||||
|
||||
private Field[] matchingKeys(Record[] recs, int columnIx, Record matchRec) {
|
||||
ArrayList<Record> recList = new ArrayList<>();
|
||||
private Field[] matchingKeys(DBRecord[] recs, int columnIx, DBRecord matchRec) {
|
||||
ArrayList<DBRecord> recList = new ArrayList<>();
|
||||
Field f = matchRec.getField(columnIx);
|
||||
for (Record rec : recs) {
|
||||
for (DBRecord rec : recs) {
|
||||
if (f.equals(rec.getField(columnIx))) {
|
||||
recList.add(rec);
|
||||
}
|
||||
}
|
||||
Field[] keys = new FixedField[recList.size()];
|
||||
Iterator<Record> iter = recList.iterator();
|
||||
Iterator<DBRecord> iter = recList.iterator();
|
||||
int i = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
keys[i++] = rec.getKeyField();
|
||||
}
|
||||
Arrays.sort(keys);
|
||||
@ -151,7 +151,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
|
||||
private void findRecords(boolean testStoredDB, int recordCnt, int findCnt, int varDataSize)
|
||||
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) {
|
||||
saveAsAndReopen(dbName);
|
||||
}
|
||||
@ -239,7 +239,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
|
||||
private void updateRecordsIterator(boolean testStoredDB, int schemaType, int recordCnt,
|
||||
long keyIncrement, int varDataSize) throws IOException {
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomTableRecords(schemaType, recordCnt, varDataSize);
|
||||
}
|
||||
@ -305,7 +305,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
int recIx = 0;
|
||||
RecordIterator iter = table.indexIterator(colIx);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -315,7 +315,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -325,7 +325,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -335,7 +335,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -344,7 +344,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findStart(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -353,7 +353,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = recordCnt - 1;
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -362,7 +362,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findEnd(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -375,7 +375,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1);
|
||||
iter = table.indexIteratorAfter(colIx, startValue);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -385,7 +385,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1);
|
||||
iter = table.indexIteratorBefore(colIx, startValue);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -409,7 +409,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
private void iterateRecords(boolean testStoredDB, int schemaType, int recordCnt,
|
||||
long keyIncrement, int varDataSize, boolean doUndoRedo) throws IOException {
|
||||
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomTableRecords(schemaType, recordCnt, varDataSize);
|
||||
}
|
||||
@ -443,7 +443,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = 0;
|
||||
iter = table.indexIterator(colIx);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx], rec);
|
||||
Field indexField = recs[recIx].getField(colIx);
|
||||
if (lastIndex == null || !lastIndex.equals(indexField)) {
|
||||
@ -473,7 +473,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findEnd(recs, startIx, colIx);
|
||||
iter = table.indexIteratorAfter(colIx, recs[startIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -485,7 +485,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[startIx].getField(colIx),
|
||||
recs[startIx].getKeyField());
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -501,7 +501,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = 0;
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -522,7 +522,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -536,7 +536,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = recordCnt - 1;
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -546,7 +546,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -556,7 +556,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -565,7 +565,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findStart(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -574,7 +574,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findStart(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[--recIx], rec);
|
||||
}
|
||||
assertEquals(0, recIx);
|
||||
@ -583,7 +583,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findEnd(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[++recIx], rec);
|
||||
}
|
||||
assertEquals(recordCnt - 1, recIx);
|
||||
@ -592,7 +592,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findEnd(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -604,7 +604,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIterator(colIx, recs[minIx].getField(colIx),
|
||||
recs[maxIx].getField(colIx), true);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(maxIx + 1, recIx);
|
||||
@ -613,7 +613,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = 0;
|
||||
iter = table.indexIterator(colIx, null, null, true);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -625,7 +625,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIterator(colIx, recs[minIx].getField(colIx),
|
||||
recs[maxIx].getField(colIx), false);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(minIx - 1, recIx);
|
||||
@ -634,7 +634,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = recordCnt - 1;
|
||||
iter = table.indexIterator(colIx, null, null, false);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -652,7 +652,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1);
|
||||
iter = table.indexIteratorAfter(colIx, startValue);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -662,7 +662,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1);
|
||||
iter = table.indexIteratorBefore(colIx, startValue);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -675,26 +675,26 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
}
|
||||
--recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
}
|
||||
++recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
}
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -705,26 +705,26 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
--recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
}
|
||||
++recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
}
|
||||
--recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
}
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -734,13 +734,13 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
}
|
||||
assertEquals(recordCnt - 1, recIx);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -750,13 +750,13 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[--recIx], rec);
|
||||
}
|
||||
}
|
||||
assertEquals(0, recIx);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -862,7 +862,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
private void deleteIteratedRecords(int recordCnt, int testColIx, long keyIncrement,
|
||||
int varDataSize) throws IOException {
|
||||
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
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,
|
||||
int varDataSize) throws IOException {
|
||||
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);
|
||||
}
|
||||
@ -948,7 +948,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
int fieldCnt = 0;
|
||||
Field lastField = null;
|
||||
ArrayList<Field> fieldList = new ArrayList<>();
|
||||
for (Record rec : recs) {
|
||||
for (DBRecord rec : recs) {
|
||||
Field f = rec.getField(testColIx);
|
||||
if (lastField == null || !lastField.equals(f)) {
|
||||
lastField = f;
|
||||
@ -997,7 +997,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
int fieldCnt = 0;
|
||||
Field lastField = null;
|
||||
ArrayList<Field> fieldList = new ArrayList<>();
|
||||
for (Record rec : recs) {
|
||||
for (DBRecord rec : recs) {
|
||||
Field f = rec.getField(testColIx);
|
||||
if (lastField == null || !lastField.equals(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);
|
||||
--startIx;
|
||||
while (startIx >= 0 && f.equals(recs[startIx].getField(colIx))) {
|
||||
@ -1037,7 +1037,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
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);
|
||||
++startIx;
|
||||
while (startIx < recs.length && f.equals(recs[startIx].getField(colIx))) {
|
||||
@ -1049,7 +1049,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
return --startIx;
|
||||
}
|
||||
|
||||
private class RecColumnComparator implements Comparator<Record> {
|
||||
private class RecColumnComparator implements Comparator<DBRecord> {
|
||||
|
||||
int columnIx;
|
||||
|
||||
@ -1058,7 +1058,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Record rec1, Record rec2) {
|
||||
public int compare(DBRecord rec1, DBRecord rec2) {
|
||||
int r = rec1.getField(columnIx).compareTo(rec2.getField(columnIx));
|
||||
if (r == 0) {
|
||||
return rec1.getKeyField().compareTo(rec2.getKeyField());
|
||||
@ -1135,7 +1135,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testRecordIteratorExtents() throws IOException {
|
||||
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
recs = createOrderedTableRecords(DBTestUtils.SINGLE_SHORT, 30, 2, 1);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
assertEquals(recs.length, table.getRecordCount());
|
||||
@ -1148,7 +1148,7 @@ public class DBFixedKeyIndexedTableTest extends AbstractGenericTest {
|
||||
Field maxField = new ShortField(Short.MAX_VALUE);
|
||||
RecordIterator iter = table.indexIterator(colIx, minField, maxField, false);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(recIx, -1);
|
||||
|
@ -139,7 +139,7 @@ public class DBFixedKeySparseIndexedTableTest extends AbstractGenericTest {
|
||||
int cnt = schema.getFieldCount();
|
||||
for (int i = 0; i < cnt; 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);
|
||||
if (f.isVariableLength()) {
|
||||
|
@ -91,7 +91,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
long txId = dbh.startTransaction();
|
||||
Table table =
|
||||
DBTestUtils.createFixedKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false);
|
||||
Record rec = null;
|
||||
DBRecord rec = null;
|
||||
try {
|
||||
rec = DBTestUtils.createFixedKeyRecord(table, varDataSize, true);
|
||||
}
|
||||
@ -276,14 +276,14 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
* @param varDataSize size of variable length data fields.
|
||||
* @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 {
|
||||
long txId = dbh.startTransaction();
|
||||
if (table == null) {
|
||||
table = DBTestUtils.createFixedKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false,
|
||||
false);
|
||||
}
|
||||
Record[] recs = new Record[recordCnt];
|
||||
DBRecord[] recs = new DBRecord[recordCnt];
|
||||
for (int i = 0; i < recordCnt; i++) {
|
||||
try {
|
||||
recs[i] = DBTestUtils.createFixedKeyRecord(table, varDataSize, true);
|
||||
@ -302,13 +302,13 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
* @param varDataSize size of variable length data fields.
|
||||
* @return Record[] records which were inserted.
|
||||
*/
|
||||
private Record[] createOrderedFixedKeyTableRecords(int recordCnt, long keyIncrement,
|
||||
private DBRecord[] createOrderedFixedKeyTableRecords(int recordCnt, long keyIncrement,
|
||||
int varDataSize) throws IOException {
|
||||
long txId = dbh.startTransaction();
|
||||
Table table =
|
||||
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 });
|
||||
Record[] recs = new Record[recordCnt];
|
||||
DBRecord[] recs = new DBRecord[recordCnt];
|
||||
for (int i = 0; i < recordCnt; i++) {
|
||||
try {
|
||||
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,
|
||||
int varDataSize) throws IOException {
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomFixedKeyTableRecords(null, recordCnt, varDataSize);
|
||||
}
|
||||
@ -567,7 +567,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
*/
|
||||
private void iterateFixedKeys(boolean testStoredDB, int recordCnt, long keyIncrement,
|
||||
int varDataSize) throws IOException {
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomFixedKeyTableRecords(null, recordCnt, varDataSize);
|
||||
}
|
||||
@ -742,7 +742,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
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);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
|
||||
@ -761,7 +761,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
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);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
|
||||
@ -779,22 +779,22 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
@Test
|
||||
public void testGetFixedKeyRecordAfter() throws IOException {
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, 16000, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, 16000, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
// After test
|
||||
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());
|
||||
}
|
||||
|
||||
// End test
|
||||
Record rec = table.getRecordAfter(recs[15999].getKeyField());
|
||||
DBRecord rec = table.getRecordAfter(recs[15999].getKeyField());
|
||||
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++) {
|
||||
FixedField f = DBTestUtils.addToFixedField(recs[i].getKeyField(), 1);
|
||||
if (f.compareTo(recs[i + 1].getKeyField()) < 0) {
|
||||
@ -804,7 +804,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int findHoleBeforeFixedKey(Record[] recs, int startIx) {
|
||||
private int findHoleBeforeFixedKey(DBRecord[] recs, int startIx) {
|
||||
for (int i = startIx; i < recs.length; i++) {
|
||||
FixedField f = DBTestUtils.addToFixedField(recs[i - 1].getKeyField(), 1);
|
||||
if (f.compareTo(recs[i].getKeyField()) < 0) {
|
||||
@ -816,13 +816,13 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
@Test
|
||||
public void testGetFixedKeyRecordAtOrAfter() throws IOException {
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, 16000, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, 16000, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
// At and After tests
|
||||
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());
|
||||
int ix = findHoleAfterFixedKey(recs, i + 500);
|
||||
if (ix < 0) {
|
||||
@ -837,7 +837,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
if (lastKey == MAX_VALUE) {
|
||||
Assert.fail("Bad test data");
|
||||
}
|
||||
Record rec = table.getRecordAtOrAfter(lastKey);
|
||||
DBRecord rec = table.getRecordAtOrAfter(lastKey);
|
||||
assertEquals(rec.getKeyField(), lastKey);
|
||||
rec = table.getRecordAtOrAfter(DBTestUtils.addToFixedField(lastKey, 1));
|
||||
assertNull(rec);
|
||||
@ -845,13 +845,13 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
@Test
|
||||
public void testGetFixedKeyRecordAtOrBefore() throws IOException {
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, 16000, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, 16000, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
// At and Before tests
|
||||
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());
|
||||
int ix = findHoleBeforeFixedKey(recs, i + 500);
|
||||
if (ix < 0) {
|
||||
@ -867,7 +867,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
if (firstKey.equals(MIN_VALUE)) {
|
||||
Assert.fail("Bad test data");
|
||||
}
|
||||
Record rec = table.getRecordAtOrBefore(firstKey);
|
||||
DBRecord rec = table.getRecordAtOrBefore(firstKey);
|
||||
assertEquals(rec.getKeyField(), firstKey);
|
||||
rec = table.getRecordAtOrBefore(DBTestUtils.addToFixedField(firstKey, -1));
|
||||
assertNull(rec);
|
||||
@ -876,7 +876,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testDeleteFixedKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -890,7 +890,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 1;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
if ((recIx % 1000) == 0) {
|
||||
++recIx;
|
||||
@ -902,7 +902,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testForwardDeleteFixedKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -918,7 +918,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testReverseDeleteFixedKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -934,7 +934,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
public void testDeleteAllFixedKeyRecords() throws IOException {
|
||||
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
|
||||
long txId = dbh.startTransaction();
|
||||
@ -954,7 +954,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -962,7 +962,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
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);
|
||||
|
||||
long txId = dbh.startTransaction();
|
||||
@ -973,7 +973,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = startIx != 0 ? 0 : (endIx + 1);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
if (recIx == startIx) {
|
||||
recIx = endIx + 1;
|
||||
@ -1002,7 +1002,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testUpdateFixedKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -1016,7 +1016,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1025,7 +1025,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testUpdateBigFixedKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -1039,7 +1039,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1054,7 +1054,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1066,7 +1066,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
assertTrue(!dbh.canUndo());
|
||||
assertTrue(!dbh.canRedo());
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
@ -1077,7 +1077,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
// Update records
|
||||
long txId = dbh.startTransaction();
|
||||
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);
|
||||
table.putRecord(rec);
|
||||
}
|
||||
@ -1093,7 +1093,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1115,7 +1115,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1128,7 +1128,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
assertTrue(!dbh.canUndo());
|
||||
assertTrue(!dbh.canRedo());
|
||||
|
||||
Record[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomFixedKeyTableRecords(null, cnt, 1);
|
||||
|
||||
assertTrue(dbh.canUndo());
|
||||
assertTrue(!dbh.canRedo());
|
||||
@ -1163,13 +1163,13 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
|
||||
// Add records
|
||||
Record[] newRecs = new Record[recs.length + 100];
|
||||
DBRecord[] newRecs = new DBRecord[recs.length + 100];
|
||||
System.arraycopy(recs, 0, newRecs, 0, recs.length);
|
||||
txId = dbh.startTransaction();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
@ -1193,7 +1193,7 @@ public class DBFixedKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recs.length, recIx);
|
||||
|
@ -87,11 +87,11 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
* @param varDataSize size of variable length data fields.
|
||||
* @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 {
|
||||
long txId = dbh.startTransaction();
|
||||
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++) {
|
||||
try {
|
||||
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.
|
||||
* @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 {
|
||||
long txId = dbh.startTransaction();
|
||||
Table table = DBTestUtils.createLongKeyTable(dbh, table1Name, schemaType, true, false);
|
||||
long key = 0;
|
||||
Record[] recs = new Record[recordCnt];
|
||||
DBRecord[] recs = new DBRecord[recordCnt];
|
||||
for (int i = 0; i < recordCnt; i++) {
|
||||
try {
|
||||
recs[i] = DBTestUtils.createRecord(table, key, varDataSize, true);
|
||||
@ -130,19 +130,19 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
return recs;
|
||||
}
|
||||
|
||||
private Field[] matchingKeys(Record[] recs, int columnIx, Record matchRec) {
|
||||
ArrayList<Record> recList = new ArrayList<>();
|
||||
private Field[] matchingKeys(DBRecord[] recs, int columnIx, DBRecord matchRec) {
|
||||
ArrayList<DBRecord> recList = new ArrayList<>();
|
||||
Field f = matchRec.getField(columnIx);
|
||||
for (Record rec : recs) {
|
||||
for (DBRecord rec : recs) {
|
||||
if (f.equals(rec.getField(columnIx))) {
|
||||
recList.add(rec);
|
||||
}
|
||||
}
|
||||
Field[] keys = new Field[recList.size()];
|
||||
Iterator<Record> iter = recList.iterator();
|
||||
Iterator<DBRecord> iter = recList.iterator();
|
||||
int i = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
keys[i++] = rec.getKeyField();
|
||||
}
|
||||
Arrays.sort(keys);
|
||||
@ -151,7 +151,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
|
||||
private void findRecords(boolean testStoredDB, int recordCnt, int findCnt, int varDataSize)
|
||||
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) {
|
||||
saveAsAndReopen(dbName);
|
||||
}
|
||||
@ -239,7 +239,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
|
||||
private void updateRecordsIterator(boolean testStoredDB, int schemaType, int recordCnt,
|
||||
long keyIncrement, int varDataSize) throws IOException {
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomTableRecords(schemaType, recordCnt, varDataSize);
|
||||
}
|
||||
@ -307,7 +307,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
int recIx = 0;
|
||||
RecordIterator iter = table.indexIterator(colIx);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -317,7 +317,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -327,7 +327,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -337,7 +337,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -346,7 +346,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findStart(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -355,7 +355,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = recordCnt - 1;
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -364,7 +364,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findEnd(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -377,7 +377,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1);
|
||||
iter = table.indexIteratorAfter(colIx, startValue);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -387,7 +387,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1);
|
||||
iter = table.indexIteratorBefore(colIx, startValue);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -411,7 +411,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
private void iterateRecords(boolean testStoredDB, int schemaType, int recordCnt,
|
||||
long keyIncrement, int varDataSize, boolean doUndoRedo) throws IOException {
|
||||
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomTableRecords(schemaType, recordCnt, varDataSize);
|
||||
}
|
||||
@ -444,7 +444,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = 0;
|
||||
iter = table.indexIterator(colIx);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx], rec);
|
||||
Field indexField = recs[recIx].getField(colIx);
|
||||
if (lastIndex == null || !lastIndex.equals(indexField)) {
|
||||
@ -474,7 +474,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findEnd(recs, startIx, colIx);
|
||||
iter = table.indexIteratorAfter(colIx, recs[startIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -486,7 +486,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[startIx].getField(colIx),
|
||||
recs[startIx].getKeyField());
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -502,7 +502,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = 0;
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -523,7 +523,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -537,7 +537,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = recordCnt - 1;
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -547,7 +547,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -557,7 +557,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx),
|
||||
recs[recIx].getKeyField());
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -566,7 +566,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findStart(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -575,7 +575,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findStart(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[--recIx], rec);
|
||||
}
|
||||
assertEquals(0, recIx);
|
||||
@ -584,7 +584,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findEnd(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[++recIx], rec);
|
||||
}
|
||||
assertEquals(recordCnt - 1, recIx);
|
||||
@ -593,7 +593,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = findEnd(recs, recordCnt / 2, colIx);
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -605,7 +605,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIterator(colIx, recs[minIx].getField(colIx),
|
||||
recs[maxIx].getField(colIx), true);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(maxIx + 1, recIx);
|
||||
@ -614,7 +614,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = 0;
|
||||
iter = table.indexIterator(colIx, null, null, true);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -626,7 +626,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIterator(colIx, recs[minIx].getField(colIx),
|
||||
recs[maxIx].getField(colIx), false);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(minIx - 1, recIx);
|
||||
@ -635,7 +635,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
recIx = recordCnt - 1;
|
||||
iter = table.indexIterator(colIx, null, null, false);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -653,7 +653,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() - 1);
|
||||
iter = table.indexIteratorAfter(colIx, startValue);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -663,7 +663,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
startValue.setLongValue(recs[recIx].getField(colIx).getLongValue() + 1);
|
||||
iter = table.indexIteratorBefore(colIx, startValue);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -676,26 +676,26 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
}
|
||||
--recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
}
|
||||
++recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
}
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -706,26 +706,26 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
--recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
}
|
||||
++recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
}
|
||||
--recIx;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
}
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -735,13 +735,13 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorAfter(colIx, recs[recIx].getField(colIx));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
}
|
||||
assertEquals(recordCnt - 1, recIx);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -751,13 +751,13 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
iter = table.indexIteratorBefore(colIx, recs[recIx].getField(colIx));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[--recIx], rec);
|
||||
}
|
||||
}
|
||||
assertEquals(0, recIx);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -870,7 +870,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
private void deleteIteratedRecords(int recordCnt, int testColIx, long keyIncrement,
|
||||
int varDataSize) throws IOException {
|
||||
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
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,
|
||||
int varDataSize) throws Exception {
|
||||
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomTableRecords(DBTestUtils.ALL_TYPES, recordCnt, varDataSize);
|
||||
}
|
||||
@ -956,7 +956,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
int fieldCnt = 0;
|
||||
Field lastField = null;
|
||||
ArrayList<Field> fieldList = new ArrayList<>();
|
||||
for (Record rec : recs) {
|
||||
for (DBRecord rec : recs) {
|
||||
Field f = rec.getField(testColIx);
|
||||
if (lastField == null || !lastField.equals(f)) {
|
||||
lastField = f;
|
||||
@ -1009,7 +1009,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
int fieldCnt = 0;
|
||||
Field lastField = null;
|
||||
ArrayList<Field> fieldList = new ArrayList<>();
|
||||
for (Record rec : recs) {
|
||||
for (DBRecord rec : recs) {
|
||||
Field f = rec.getField(testColIx);
|
||||
if (lastField == null || !lastField.equals(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);
|
||||
--startIx;
|
||||
while (startIx >= 0 && f.equals(recs[startIx].getField(colIx))) {
|
||||
@ -1049,7 +1049,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
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);
|
||||
++startIx;
|
||||
while (startIx < recs.length && f.equals(recs[startIx].getField(colIx))) {
|
||||
@ -1061,7 +1061,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
return --startIx;
|
||||
}
|
||||
|
||||
private class RecColumnComparator implements Comparator<Record> {
|
||||
private class RecColumnComparator implements Comparator<DBRecord> {
|
||||
|
||||
final int columnIx;
|
||||
|
||||
@ -1073,7 +1073,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compare(Record rec1, Record rec2) {
|
||||
public int compare(DBRecord rec1, DBRecord rec2) {
|
||||
int r = rec1.getField(columnIx).compareTo(rec2.getField(columnIx));
|
||||
if (r == 0) {
|
||||
if (rec1.getKey() == rec2.getKey()) {
|
||||
@ -1156,7 +1156,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testRecordIteratorExtents() throws IOException {
|
||||
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
recs = createOrderedRecordRange(DBTestUtils.SINGLE_SHORT, 30, 2, 1);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
assertEquals(recs.length, table.getRecordCount());
|
||||
@ -1174,17 +1174,17 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
Field maxField = new ShortField(Short.MAX_VALUE);
|
||||
RecordIterator iter = table.indexIterator(colIx, minField, maxField, false);
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
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 {
|
||||
long txId = dbh.startTransaction();
|
||||
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++) {
|
||||
try {
|
||||
recs[key] = DBTestUtils.createMidRangeRecord(table, key, varDataSize, true);
|
||||
@ -1220,7 +1220,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
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();
|
||||
try {
|
||||
@ -1240,7 +1240,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
int recIx = 0;
|
||||
RecordIterator iter = table.indexIterator(colIx);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(ITER_REC_CNT, recIx);
|
||||
@ -1254,7 +1254,7 @@ public class DBIndexedTableTest extends AbstractGenericTest {
|
||||
int recIx = 0;
|
||||
RecordIterator iter = table.indexIterator(colIx);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(ITER_REC_CNT, recIx);
|
||||
|
@ -77,7 +77,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
|
||||
// Add even keys
|
||||
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(1, getSmallString("b", k));
|
||||
rec.setLongValue(2, 0x2222222222222222L);
|
||||
@ -89,7 +89,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
|
||||
// Add odd keys
|
||||
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(1, getSmallString("b", k));
|
||||
rec.setLongValue(2, 0x2222222222222222L);
|
||||
@ -116,7 +116,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
|
||||
// Add even keys
|
||||
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(1, getSmallString("b", k));
|
||||
rec.setLongValue(2, 0x2222222222222222L);
|
||||
@ -128,7 +128,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
|
||||
// Add odd keys
|
||||
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(1, getSmallString("b", k));
|
||||
rec.setLongValue(2, 0x2222222222222222L);
|
||||
@ -143,7 +143,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
return table;
|
||||
}
|
||||
|
||||
private void assertPrimitiveColumns(Record rec) {
|
||||
private void assertPrimitiveColumns(DBRecord rec) {
|
||||
Assert.assertEquals(0x2222222222222222L, rec.getLongValue(2));
|
||||
Assert.assertEquals((byte) 0x33, rec.getByteValue(3));
|
||||
Assert.assertEquals((short) 0x4444, rec.getShortValue(4));
|
||||
@ -156,7 +156,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
Table table = fillTableBigRecs(256);
|
||||
|
||||
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(getSmallString("b", k), rec.getString(1));
|
||||
assertPrimitiveColumns(rec);
|
||||
@ -170,7 +170,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
Table table = fillTableSmallRecs(256);
|
||||
|
||||
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(1), getSmallString("b", k));
|
||||
assertPrimitiveColumns(rec);
|
||||
@ -187,14 +187,14 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
|
||||
// Update even keys
|
||||
for (int k = 0; k < 256; k += 2) {
|
||||
Record rec = table.getRecord(k);
|
||||
DBRecord rec = table.getRecord(k);
|
||||
rec.setString(0, getSmallString("a", k));
|
||||
table.putRecord(rec);
|
||||
}
|
||||
|
||||
// Update odd keys
|
||||
for (int k = 1; k < 256; k += 2) {
|
||||
Record rec = table.getRecord(k);
|
||||
DBRecord rec = table.getRecord(k);
|
||||
rec.setString(0, getSmallString("a", k));
|
||||
table.putRecord(rec);
|
||||
}
|
||||
@ -202,7 +202,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
dbh.endTransaction(txId, true);
|
||||
|
||||
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(1), getSmallString("b", k));
|
||||
assertPrimitiveColumns(rec);
|
||||
@ -219,14 +219,14 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
|
||||
// Update even keys
|
||||
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));
|
||||
table.putRecord(rec);
|
||||
}
|
||||
|
||||
// Update odd keys
|
||||
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));
|
||||
table.putRecord(rec);
|
||||
}
|
||||
@ -234,7 +234,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
dbh.endTransaction(txId, true);
|
||||
|
||||
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(1), getBigString("b", k, 3));
|
||||
assertPrimitiveColumns(rec);
|
||||
@ -253,14 +253,14 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
|
||||
// Update even keys
|
||||
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));
|
||||
table.putRecord(rec);
|
||||
}
|
||||
|
||||
// Update odd keys
|
||||
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));
|
||||
table.putRecord(rec);
|
||||
}
|
||||
@ -268,7 +268,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
dbh.endTransaction(txId, true);
|
||||
|
||||
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(1), getBigString("b", k, 4));
|
||||
assertPrimitiveColumns(rec);
|
||||
@ -285,14 +285,14 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
|
||||
// Update even keys
|
||||
for (int k = 0; k < 256; k += 2) {
|
||||
Record rec = table.getRecord(k);
|
||||
DBRecord rec = table.getRecord(k);
|
||||
rec.setString(1, getBigString("b", k));
|
||||
table.putRecord(rec);
|
||||
}
|
||||
|
||||
// Update odd keys
|
||||
for (int k = 1; k < 256; k += 2) {
|
||||
Record rec = table.getRecord(k);
|
||||
DBRecord rec = table.getRecord(k);
|
||||
rec.setString(1, getBigString("b", k));
|
||||
table.putRecord(rec);
|
||||
}
|
||||
@ -300,7 +300,7 @@ public class DBLongKeyChainedBufferUseTest extends AbstractGenericTest {
|
||||
dbh.endTransaction(txId, true);
|
||||
|
||||
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(1), getBigString("b", k));
|
||||
assertPrimitiveColumns(rec);
|
||||
|
@ -83,7 +83,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
long txId = dbh.startTransaction();
|
||||
Table table =
|
||||
DBTestUtils.createLongKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false);
|
||||
Record rec = null;
|
||||
DBRecord rec = null;
|
||||
try {
|
||||
rec = DBTestUtils.createLongKeyRecord(table, true, varDataSize, true);
|
||||
}
|
||||
@ -262,14 +262,14 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
* @param varDataSize size of variable length data fields.
|
||||
* @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 {
|
||||
long txId = dbh.startTransaction();
|
||||
if (table == null) {
|
||||
table = DBTestUtils.createLongKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false,
|
||||
false);
|
||||
}
|
||||
Record[] recs = new Record[recordCnt];
|
||||
DBRecord[] recs = new DBRecord[recordCnt];
|
||||
for (int i = 0; i < recordCnt; i++) {
|
||||
try {
|
||||
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.
|
||||
* @return Record[] records which were inserted.
|
||||
*/
|
||||
private Record[] createOrderedLongKeyTableRecords(int recordCnt, long keyIncrement,
|
||||
private DBRecord[] createOrderedLongKeyTableRecords(int recordCnt, long keyIncrement,
|
||||
int varDataSize) throws IOException {
|
||||
long txId = dbh.startTransaction();
|
||||
Table table =
|
||||
DBTestUtils.createLongKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false, false);
|
||||
long key = 0;
|
||||
Record[] recs = new Record[recordCnt];
|
||||
DBRecord[] recs = new DBRecord[recordCnt];
|
||||
for (int i = 0; i < recordCnt; i++) {
|
||||
try {
|
||||
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,
|
||||
int varDataSize) throws IOException {
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomLongKeyTableRecords(null, recordCnt, varDataSize);
|
||||
}
|
||||
@ -547,7 +547,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
*/
|
||||
private void iterateLongKeys(boolean testStoredDB, int recordCnt, long keyIncrement,
|
||||
int varDataSize) throws IOException {
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomLongKeyTableRecords(null, recordCnt, varDataSize);
|
||||
}
|
||||
@ -723,7 +723,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
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);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
|
||||
@ -743,7 +743,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
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);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
|
||||
@ -762,22 +762,22 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
@Test
|
||||
public void testGetLongKeyRecordAfter() throws IOException {
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, 16000, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, 16000, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
// After test
|
||||
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());
|
||||
}
|
||||
|
||||
// End test
|
||||
Record rec = table.getRecordAfter(recs[15999].getKey());
|
||||
DBRecord rec = table.getRecordAfter(recs[15999].getKey());
|
||||
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++) {
|
||||
if ((recs[i].getKey() + 1) < recs[i + 1].getKey()) {
|
||||
return i;
|
||||
@ -786,7 +786,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int findHoleBeforeLongKey(Record[] recs, int startIx) {
|
||||
private int findHoleBeforeLongKey(DBRecord[] recs, int startIx) {
|
||||
for (int i = startIx; i < recs.length; i++) {
|
||||
if ((recs[i - 1].getKey() + 1) < recs[i].getKey()) {
|
||||
return i;
|
||||
@ -797,13 +797,13 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
@Test
|
||||
public void testGetLongKeyRecordAtOrAfter() throws IOException {
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, 16000, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, 16000, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
// At and After tests
|
||||
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());
|
||||
int ix = findHoleAfterLongKey(recs, i + 500);
|
||||
if (ix < 0) {
|
||||
@ -818,7 +818,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
if (lastKey == Long.MAX_VALUE) {
|
||||
Assert.fail("Bad test data");
|
||||
}
|
||||
Record rec = table.getRecordAtOrAfter(lastKey);
|
||||
DBRecord rec = table.getRecordAtOrAfter(lastKey);
|
||||
assertEquals(rec.getKey(), lastKey);
|
||||
rec = table.getRecordAtOrAfter(lastKey + 1);
|
||||
assertNull(rec);
|
||||
@ -826,13 +826,13 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
@Test
|
||||
public void testGetLongKeyRecordAtOrBefore() throws IOException {
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, 16000, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, 16000, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
// At and Before tests
|
||||
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());
|
||||
int ix = findHoleBeforeLongKey(recs, i + 500);
|
||||
if (ix < 0) {
|
||||
@ -847,7 +847,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
if (firstKey == Long.MIN_VALUE) {
|
||||
Assert.fail("Bad test data");
|
||||
}
|
||||
Record rec = table.getRecordAtOrBefore(firstKey);
|
||||
DBRecord rec = table.getRecordAtOrBefore(firstKey);
|
||||
assertEquals(rec.getKey(), firstKey);
|
||||
rec = table.getRecordAtOrBefore(firstKey - 1);
|
||||
assertNull(rec);
|
||||
@ -856,7 +856,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testDeleteLongKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -870,7 +870,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 1;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
if ((recIx % 1000) == 0) {
|
||||
++recIx;
|
||||
@ -882,7 +882,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testForwardDeleteLongKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -898,7 +898,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testReverseDeleteLongKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -914,7 +914,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
public void testDeleteAllLongKeyRecords() throws IOException {
|
||||
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
|
||||
long txId = dbh.startTransaction();
|
||||
@ -934,7 +934,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -942,7 +942,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
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);
|
||||
|
||||
long txId = dbh.startTransaction();
|
||||
@ -953,7 +953,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = startIx != 0 ? 0 : (endIx + 1);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
if (recIx == startIx) {
|
||||
recIx = endIx + 1;
|
||||
@ -982,7 +982,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testUpdateLongKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -996,7 +996,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1005,7 +1005,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testUpdateBigLongKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -1019,7 +1019,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1034,7 +1034,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1047,7 +1047,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
assertTrue(!dbh.canUndo());
|
||||
assertTrue(!dbh.canRedo());
|
||||
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
@ -1058,7 +1058,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
// Update records
|
||||
long txId = dbh.startTransaction();
|
||||
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);
|
||||
table.putRecord(rec);
|
||||
}
|
||||
@ -1074,7 +1074,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1096,7 +1096,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -1109,7 +1109,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
assertTrue(!dbh.canUndo());
|
||||
assertTrue(!dbh.canRedo());
|
||||
|
||||
Record[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomLongKeyTableRecords(null, cnt, 1);
|
||||
|
||||
assertTrue(dbh.canUndo());
|
||||
assertTrue(!dbh.canRedo());
|
||||
@ -1144,13 +1144,13 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
|
||||
// Add records
|
||||
Record[] newRecs = new Record[recs.length + 100];
|
||||
DBRecord[] newRecs = new DBRecord[recs.length + 100];
|
||||
System.arraycopy(recs, 0, newRecs, 0, recs.length);
|
||||
txId = dbh.startTransaction();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
@ -1174,7 +1174,7 @@ public class DBLongKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recs.length, recIx);
|
||||
|
@ -464,7 +464,7 @@ public class DBTest extends AbstractGenericTest {
|
||||
}
|
||||
|
||||
Schema s = tables[1].getSchema();
|
||||
Record rec = s.createRecord(1);
|
||||
DBRecord rec = s.createRecord(1);
|
||||
|
||||
txId = dbh.startTransaction();
|
||||
try {
|
||||
|
@ -271,7 +271,7 @@ public class DBTestUtils {
|
||||
* @param doInsert insert record into table if true
|
||||
* @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 {
|
||||
long key;
|
||||
if (randomKey) {
|
||||
@ -281,7 +281,7 @@ public class DBTestUtils {
|
||||
key = table.getMaxKey() + 1;
|
||||
}
|
||||
try {
|
||||
Record rec = createRecord(table, key, varDataSize, doInsert);
|
||||
DBRecord rec = createRecord(table, key, varDataSize, doInsert);
|
||||
if (!randomKey) {
|
||||
Assert.assertEquals(rec.getKey(), table.getMaxKey());
|
||||
}
|
||||
@ -304,7 +304,7 @@ public class DBTestUtils {
|
||||
* @throws IOException
|
||||
* @throws DuplicateKeyException
|
||||
*/
|
||||
static Record createFixedKeyRecord(Table table, int varDataSize, boolean doInsert)
|
||||
static DBRecord createFixedKeyRecord(Table table, int varDataSize, boolean doInsert)
|
||||
throws IOException, DuplicateKeyException {
|
||||
int keyLength = 10;
|
||||
byte[] bytes = new byte[keyLength];
|
||||
@ -313,7 +313,7 @@ public class DBTestUtils {
|
||||
key.setBinaryData(bytes);
|
||||
|
||||
try {
|
||||
Record rec = createRecord(table, key, varDataSize, doInsert);
|
||||
DBRecord rec = createRecord(table, key, varDataSize, doInsert);
|
||||
Assert.assertEquals(key, rec.getKeyField());
|
||||
return rec;
|
||||
}
|
||||
@ -332,7 +332,7 @@ public class DBTestUtils {
|
||||
* @throws IOException
|
||||
* @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 {
|
||||
int keyLength =
|
||||
(maxKeyLength < 0) ? -maxKeyLength : DBTestUtils.getRandomKeyLength(maxKeyLength);
|
||||
@ -342,7 +342,7 @@ public class DBTestUtils {
|
||||
key.setBinaryData(bytes);
|
||||
|
||||
try {
|
||||
Record rec = createRecord(table, key, varDataSize, doInsert);
|
||||
DBRecord rec = createRecord(table, key, varDataSize, doInsert);
|
||||
Assert.assertEquals(key, rec.getKeyField());
|
||||
return rec;
|
||||
}
|
||||
@ -361,18 +361,18 @@ public class DBTestUtils {
|
||||
* @throws IOException
|
||||
* @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 {
|
||||
// Check for duplicate key
|
||||
if (doInsert) {
|
||||
Record oldRec = table.getRecord(key);
|
||||
DBRecord oldRec = table.getRecord(key);
|
||||
if (oldRec != null) {
|
||||
throw new DuplicateKeyException();
|
||||
}
|
||||
}
|
||||
|
||||
// Create record and fill with data
|
||||
Record rec = table.getSchema().createRecord(key);
|
||||
DBRecord rec = table.getSchema().createRecord(key);
|
||||
fillRecord(rec, varDataSize);
|
||||
|
||||
// Insert record if requested
|
||||
@ -395,18 +395,18 @@ public class DBTestUtils {
|
||||
* @throws IOException
|
||||
* @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 {
|
||||
// Check for duplicate key
|
||||
if (doInsert) {
|
||||
Record oldRec = table.getRecord(key);
|
||||
DBRecord oldRec = table.getRecord(key);
|
||||
if (oldRec != null) {
|
||||
throw new DuplicateKeyException();
|
||||
}
|
||||
}
|
||||
|
||||
// Create record and fill with data
|
||||
Record rec = table.getSchema().createRecord(key);
|
||||
DBRecord rec = table.getSchema().createRecord(key);
|
||||
fillRecord(rec, varDataSize);
|
||||
|
||||
// Insert record if requested
|
||||
@ -455,18 +455,18 @@ public class DBTestUtils {
|
||||
* @throws IOException
|
||||
* @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 {
|
||||
// Check for duplicate key
|
||||
if (doInsert) {
|
||||
Record oldRec = table.getRecord(key);
|
||||
DBRecord oldRec = table.getRecord(key);
|
||||
if (oldRec != null) {
|
||||
throw new DuplicateKeyException();
|
||||
}
|
||||
}
|
||||
|
||||
// Create record and fill with data
|
||||
Record rec = table.getSchema().createRecord(key);
|
||||
DBRecord rec = table.getSchema().createRecord(key);
|
||||
fillMidRangeRecord(rec, varDataSize);
|
||||
|
||||
// Insert record if requested
|
||||
@ -490,18 +490,18 @@ public class DBTestUtils {
|
||||
* @throws IOException
|
||||
* @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 {
|
||||
// Check for duplicate key
|
||||
if (doInsert) {
|
||||
Record oldRec = table.getRecord(key);
|
||||
DBRecord oldRec = table.getRecord(key);
|
||||
if (oldRec != null) {
|
||||
throw new DuplicateKeyException();
|
||||
}
|
||||
}
|
||||
|
||||
// Create record and fill with data
|
||||
Record rec = table.getSchema().createRecord(key);
|
||||
DBRecord rec = table.getSchema().createRecord(key);
|
||||
fillMidRangeRecord(rec, varDataSize);
|
||||
|
||||
// Insert record if requested
|
||||
@ -521,7 +521,7 @@ public class DBTestUtils {
|
||||
* NOTE: The StringField does not strictly follow the varDataSize paramter.
|
||||
* 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();
|
||||
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.
|
||||
* 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();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
|
@ -86,7 +86,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
long txId = dbh.startTransaction();
|
||||
Table table =
|
||||
DBTestUtils.createBinaryKeyTable(dbh, table1Name, DBTestUtils.ALL_TYPES, false);
|
||||
Record rec = null;
|
||||
DBRecord rec = null;
|
||||
try {
|
||||
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.
|
||||
* @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 {
|
||||
long txId = dbh.startTransaction();
|
||||
if (table == null) {
|
||||
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++) {
|
||||
try {
|
||||
recs[i] =
|
||||
@ -297,7 +297,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
* @param varDataSize size of variable length data fields.
|
||||
* @return Record[] records which were inserted.
|
||||
*/
|
||||
private Record[] createOrderedVarKeyTableRecords(int recordCnt, long keyIncrement,
|
||||
private DBRecord[] createOrderedVarKeyTableRecords(int recordCnt, long keyIncrement,
|
||||
int varDataSize) throws IOException {
|
||||
long txId = dbh.startTransaction();
|
||||
Table table =
|
||||
@ -305,7 +305,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
long key = 0;
|
||||
Field keyField = new LongField();
|
||||
|
||||
Record[] recs = new Record[recordCnt];
|
||||
DBRecord[] recs = new DBRecord[recordCnt];
|
||||
for (int i = 0; i < recordCnt; i++) {
|
||||
try {
|
||||
keyField.setLongValue(key);
|
||||
@ -331,7 +331,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
*/
|
||||
private void iterateVarKeyRecords(boolean testStoredDB, int recordCnt, long keyIncrement,
|
||||
int varDataSize) throws IOException {
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomVarKeyTableRecords(null, recordCnt, varDataSize);
|
||||
}
|
||||
@ -349,7 +349,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
int recIx = 0;
|
||||
RecordIterator iter = table.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -358,7 +358,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
recIx = recordCnt / 2;
|
||||
iter = table.iterator(recs[recIx].getKeyField());
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recordCnt, recIx);
|
||||
@ -367,7 +367,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
recIx = recordCnt - 1;
|
||||
iter = table.iterator(DBTestUtils.getMaxValue(MAX_VAR_KEY_LENGTH));
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -376,7 +376,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
recIx = recordCnt / 2;
|
||||
iter = table.iterator(recs[recIx].getKeyField());
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(-1, recIx);
|
||||
@ -388,7 +388,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
recs[minIx].getKeyField());
|
||||
recIx = minIx;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(recIx, maxIx + 1);
|
||||
@ -398,7 +398,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
recs[maxIx].getKeyField());
|
||||
recIx = maxIx;
|
||||
while (iter.hasPrevious()) {
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(recs[recIx--], rec);
|
||||
}
|
||||
assertEquals(recIx, minIx - 1);
|
||||
@ -515,7 +515,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
*/
|
||||
private void iterateVarKeys(boolean testStoredDB, int recordCnt, long keyIncrement,
|
||||
int varDataSize) throws IOException {
|
||||
Record[] recs = null;
|
||||
DBRecord[] recs = null;
|
||||
if (keyIncrement == 0) {
|
||||
recs = createRandomVarKeyTableRecords(null, recordCnt, varDataSize);
|
||||
}
|
||||
@ -692,7 +692,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
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);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
|
||||
@ -711,7 +711,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
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);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
assertEquals(SMALL_ITER_REC_CNT, table.getRecordCount());
|
||||
@ -729,22 +729,22 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
@Test
|
||||
public void testGetVarKeyRecordAfter() throws IOException {
|
||||
Record[] recs = createRandomVarKeyTableRecords(null, 16000, 1);
|
||||
DBRecord[] recs = createRandomVarKeyTableRecords(null, 16000, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
// After test
|
||||
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());
|
||||
}
|
||||
|
||||
// End test
|
||||
Record rec = table.getRecordAfter(recs[15999].getKeyField());
|
||||
DBRecord rec = table.getRecordAfter(recs[15999].getKeyField());
|
||||
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++) {
|
||||
if (DBTestUtils.increment((BinaryField) recs[i].getKeyField(),
|
||||
MAX_VAR_KEY_LENGTH).compareTo(recs[i + 1].getKeyField()) < 0) {
|
||||
@ -754,7 +754,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int findHoleBeforeVarKey(Record[] recs, int startIx) {
|
||||
private int findHoleBeforeVarKey(DBRecord[] recs, int startIx) {
|
||||
for (int i = startIx; i < recs.length; i++) {
|
||||
if (DBTestUtils.increment((BinaryField) recs[i - 1].getKeyField(),
|
||||
MAX_VAR_KEY_LENGTH).compareTo(recs[i].getKeyField()) < 0) {
|
||||
@ -766,13 +766,13 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
@Test
|
||||
public void testGetVarKeyRecordAtOrAfter() throws IOException {
|
||||
Record[] recs = createRandomVarKeyTableRecords(null, 16000, 1);
|
||||
DBRecord[] recs = createRandomVarKeyTableRecords(null, 16000, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
// At and After tests
|
||||
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());
|
||||
int ix = findHoleAfterVarKey(recs, i + 500);
|
||||
if (ix < 0) {
|
||||
@ -785,7 +785,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
// End tests
|
||||
Field lastKey = recs[15999].getKeyField();
|
||||
Record rec = table.getRecordAtOrAfter(lastKey);
|
||||
DBRecord rec = table.getRecordAtOrAfter(lastKey);
|
||||
assertEquals(rec.getKeyField(), lastKey);
|
||||
rec = table.getRecordAtOrAfter(
|
||||
DBTestUtils.increment((BinaryField) lastKey, MAX_VAR_KEY_LENGTH));
|
||||
@ -794,13 +794,13 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
@Test
|
||||
public void testGetVarKeyRecordAtOrBefore() throws IOException {
|
||||
Record[] recs = createRandomVarKeyTableRecords(null, 16000, 1);
|
||||
DBRecord[] recs = createRandomVarKeyTableRecords(null, 16000, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
// At and Before tests
|
||||
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());
|
||||
int ix = findHoleBeforeVarKey(recs, i + 500);
|
||||
if (ix < 0) {
|
||||
@ -813,7 +813,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
// End tests
|
||||
Field firstKey = recs[0].getKeyField();
|
||||
Record rec = table.getRecordAtOrBefore(firstKey);
|
||||
DBRecord rec = table.getRecordAtOrBefore(firstKey);
|
||||
assertEquals(rec.getKeyField(), firstKey);
|
||||
rec = table.getRecordAtOrBefore(
|
||||
DBTestUtils.decrement((BinaryField) firstKey, MAX_VAR_KEY_LENGTH));
|
||||
@ -823,7 +823,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testDeleteVarKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -837,7 +837,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 1;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
if ((recIx % 1000) == 0) {
|
||||
++recIx;
|
||||
@ -849,7 +849,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testForwardDeleteVarKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -865,7 +865,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testReverseDeleteVarKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -881,7 +881,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
public void testDeleteAllVarKeyRecords() throws IOException {
|
||||
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -901,7 +901,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -909,7 +909,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
|
||||
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);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -920,7 +920,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = startIx != 0 ? 0 : (endIx + 1);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
if (recIx == startIx) {
|
||||
recIx = endIx + 1;
|
||||
@ -943,7 +943,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testUpdateVarKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
//Record[] recs = createOrderedVarKeyTableRecords(cnt, 1, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
@ -958,7 +958,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -967,7 +967,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
@Test
|
||||
public void testUpdateBigVarKeyRecord() throws IOException {
|
||||
int cnt = SMALL_ITER_REC_CNT;
|
||||
Record[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
DBRecord[] recs = createRandomVarKeyTableRecords(null, cnt, 1);
|
||||
Arrays.sort(recs);
|
||||
Table table = dbh.getTable(table1Name);
|
||||
|
||||
@ -981,7 +981,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
RecordIterator iter = table.iterator();
|
||||
int recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
@ -996,7 +996,7 @@ public class DBVarKeyTableTest extends AbstractGenericTest {
|
||||
iter = table.iterator();
|
||||
recIx = 0;
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(recs[recIx++], rec);
|
||||
}
|
||||
assertEquals(cnt, recIx);
|
||||
|
@ -53,7 +53,7 @@ public class TableConcurrencyTest extends AbstractGenericTest {
|
||||
schema2 = table2.getSchema();
|
||||
for (byte i = 0; i < 100; i++) {
|
||||
|
||||
Record rec = schema1.createRecord(i);
|
||||
DBRecord rec = schema1.createRecord(i);
|
||||
rec.setLongValue(0, i);
|
||||
table1.putRecord(rec);
|
||||
|
||||
@ -226,7 +226,7 @@ public class TableConcurrencyTest extends AbstractGenericTest {
|
||||
table1.deleteRecord(10);// iterator already primed
|
||||
|
||||
assertTrue(iter.hasNext());
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(10, rec.getKey());
|
||||
|
||||
assertTrue(iter.hasNext());
|
||||
@ -271,7 +271,7 @@ public class TableConcurrencyTest extends AbstractGenericTest {
|
||||
table1.deleteRecord(10);// iterator already primed
|
||||
|
||||
assertTrue(iter.hasPrevious());
|
||||
Record rec = iter.previous();
|
||||
DBRecord rec = iter.previous();
|
||||
assertEquals(10, rec.getKey());
|
||||
|
||||
assertTrue(iter.hasPrevious());
|
||||
@ -458,7 +458,7 @@ public class TableConcurrencyTest extends AbstractGenericTest {
|
||||
table2.deleteRecord(getField((byte) 10));// iterator already primed
|
||||
|
||||
assertTrue(iter.hasNext());
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
assertEquals(getField((byte) 10), rec.getKeyField());
|
||||
|
||||
assertTrue(iter.hasNext());
|
||||
|
@ -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);
|
||||
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
|
||||
return record;
|
||||
}
|
||||
@ -270,7 +270,7 @@ public class TableTest extends AbstractGenericTest {
|
||||
|
||||
int n = bufferCount * RECORD_KEY_SPACING;
|
||||
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) {
|
||||
rec.setLongValue(0, i);
|
||||
rec.setIntValue(1, i);
|
||||
|
@ -124,7 +124,7 @@ public class RecoveryDBTest extends AbstractGenericTest {
|
||||
|
||||
private void tableFill(Table table, int recCnt, String baseName) throws Exception {
|
||||
for (int i = 0; i < recCnt; i++) {
|
||||
Record rec = SCHEMA.createRecord(i);
|
||||
DBRecord rec = SCHEMA.createRecord(i);
|
||||
rec.setString(0, baseName + i);
|
||||
table.putRecord(rec);
|
||||
}
|
||||
@ -152,12 +152,12 @@ public class RecoveryDBTest extends AbstractGenericTest {
|
||||
assertEquals(RECORD_COUNT / 2, table1.getRecordCount());
|
||||
|
||||
for (int i = 0; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table1.getRecord(i);
|
||||
DBRecord rec = table1.getRecord(i);
|
||||
assertNull(rec);
|
||||
}
|
||||
|
||||
for (int i = 1; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table1.getRecord(i);
|
||||
DBRecord rec = table1.getRecord(i);
|
||||
assertNotNull(rec);
|
||||
assertEquals("initTable1_" + i, rec.getString(0));
|
||||
}
|
||||
@ -171,7 +171,7 @@ public class RecoveryDBTest extends AbstractGenericTest {
|
||||
}
|
||||
|
||||
for (int i = 1; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table2.getRecord(i);
|
||||
DBRecord rec = table2.getRecord(i);
|
||||
assertNotNull(rec);
|
||||
assertEquals("initTable2_" + i, rec.getString(0));
|
||||
}
|
||||
@ -207,12 +207,12 @@ public class RecoveryDBTest extends AbstractGenericTest {
|
||||
assertEquals(RECORD_COUNT / 2, table1.getRecordCount());
|
||||
|
||||
for (int i = 0; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table1.getRecord(i);
|
||||
DBRecord rec = table1.getRecord(i);
|
||||
assertNull(rec);
|
||||
}
|
||||
|
||||
for (int i = 1; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table1.getRecord(i);
|
||||
DBRecord rec = table1.getRecord(i);
|
||||
assertNotNull(rec);
|
||||
assertEquals("initTable1_" + i, rec.getString(0));
|
||||
}
|
||||
@ -259,12 +259,12 @@ public class RecoveryDBTest extends AbstractGenericTest {
|
||||
assertEquals(RECORD_COUNT / 2, table1.getRecordCount());
|
||||
|
||||
for (int i = 0; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table1.getRecord(i);
|
||||
DBRecord rec = table1.getRecord(i);
|
||||
assertNull(rec);
|
||||
}
|
||||
|
||||
for (int i = 1; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table1.getRecord(i);
|
||||
DBRecord rec = table1.getRecord(i);
|
||||
assertNotNull(rec);
|
||||
assertEquals("initTable1_" + i, rec.getString(0));
|
||||
}
|
||||
@ -278,7 +278,7 @@ public class RecoveryDBTest extends AbstractGenericTest {
|
||||
}
|
||||
|
||||
for (int i = 1; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table2.getRecord(i);
|
||||
DBRecord rec = table2.getRecord(i);
|
||||
assertNotNull(rec);
|
||||
assertEquals("initTable2_" + i, rec.getString(0));
|
||||
}
|
||||
@ -315,12 +315,12 @@ public class RecoveryDBTest extends AbstractGenericTest {
|
||||
assertEquals(RECORD_COUNT / 2, table1.getRecordCount());
|
||||
|
||||
for (int i = 0; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table1.getRecord(i);
|
||||
DBRecord rec = table1.getRecord(i);
|
||||
assertNull(rec);
|
||||
}
|
||||
|
||||
for (int i = 1; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table1.getRecord(i);
|
||||
DBRecord rec = table1.getRecord(i);
|
||||
assertNotNull(rec);
|
||||
assertEquals("initTable1_" + i, rec.getString(0));
|
||||
}
|
||||
@ -334,7 +334,7 @@ public class RecoveryDBTest extends AbstractGenericTest {
|
||||
}
|
||||
|
||||
for (int i = 1; i < RECORD_COUNT; i += 2) {
|
||||
Record rec = table2.getRecord(i);
|
||||
DBRecord rec = table2.getRecord(i);
|
||||
assertNotNull(rec);
|
||||
assertEquals("initTable2_" + i, rec.getString(0));
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class PackedDatabaseTest extends AbstractGenericTest {
|
||||
dbh = new PackedDBHandle("MyContent");
|
||||
long txId = dbh.startTransaction();
|
||||
Table table = dbh.createTable("MyTable", TEST_SCHEMA);
|
||||
Record rec = TEST_SCHEMA.createRecord(1);
|
||||
DBRecord rec = TEST_SCHEMA.createRecord(1);
|
||||
rec.setString(0, "String1");
|
||||
table.putRecord(rec);
|
||||
dbh.endTransaction(txId, true);
|
||||
@ -115,7 +115,7 @@ public class PackedDatabaseTest extends AbstractGenericTest {
|
||||
assertNotNull(table);
|
||||
assertEquals(1, table.getRecordCount());
|
||||
|
||||
Record rec = table.getRecord(1);
|
||||
DBRecord rec = table.getRecord(1);
|
||||
assertNotNull(rec);
|
||||
assertEquals("String1", rec.getString(0));
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -35,7 +34,7 @@ class MetadataManager {
|
||||
if (table != null) {
|
||||
RecordIterator iterator = table.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
Record record = iterator.next();
|
||||
DBRecord record = iterator.next();
|
||||
String key = record.getString(0);
|
||||
String value = record.getString(1);
|
||||
metadata.put(key, value);
|
||||
@ -58,7 +57,7 @@ class MetadataManager {
|
||||
while(keyIterator.hasNext()) {
|
||||
String key = keyIterator.next();
|
||||
String value = metadata.get(key);
|
||||
Record record = SCHEMA.createRecord(id++);
|
||||
DBRecord record = SCHEMA.createRecord(id++);
|
||||
record.setString(0, key);
|
||||
record.setString(1, value);
|
||||
table.putRecord(record);
|
||||
|
@ -97,7 +97,7 @@ class OptionsDB extends AbstractOptions {
|
||||
return false;
|
||||
}
|
||||
RecordIterator iterator = propertyTable.iterator(new StringField(newSubListPath));
|
||||
Record rec = iterator.next();
|
||||
DBRecord rec = iterator.next();
|
||||
if (rec != null) {
|
||||
String keyName = ((StringField) rec.getKeyField()).getString();
|
||||
if (keyName.startsWith(newSubListPath)) {
|
||||
@ -106,7 +106,7 @@ class OptionsDB extends AbstractOptions {
|
||||
}
|
||||
|
||||
// move records
|
||||
ArrayList<Record> list = new ArrayList<>();
|
||||
ArrayList<DBRecord> list = new ArrayList<>();
|
||||
rec = propertyTable.getRecord(new StringField(oldPath));
|
||||
if (rec != null) {
|
||||
propertyTable.deleteRecord(new StringField(oldPath));
|
||||
@ -127,7 +127,7 @@ class OptionsDB extends AbstractOptions {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (Record updatedRec : list) {
|
||||
for (DBRecord updatedRec : list) {
|
||||
propertyTable.putRecord(updatedRec);
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ class OptionsDB extends AbstractOptions {
|
||||
// remove records
|
||||
RecordIterator iterator = propertyTable.iterator(new StringField(path));
|
||||
while (iterator.hasNext()) {
|
||||
Record rec = iterator.next();
|
||||
DBRecord rec = iterator.next();
|
||||
String keyName = ((StringField) rec.getKeyField()).getString();
|
||||
if (keyName.equals(path)) {
|
||||
iterator.delete();
|
||||
@ -186,7 +186,7 @@ class OptionsDB extends AbstractOptions {
|
||||
if (propertyTable != null) {
|
||||
RecordIterator recIt = propertyTable.iterator();
|
||||
while (recIt.hasNext()) {
|
||||
Record rec = recIt.next();
|
||||
DBRecord rec = recIt.next();
|
||||
names.add(rec.getKeyField().getString());
|
||||
}
|
||||
}
|
||||
@ -208,7 +208,7 @@ class OptionsDB extends AbstractOptions {
|
||||
if (propertyTable != null) {
|
||||
RecordIterator recIt = propertyTable.iterator();
|
||||
while (recIt.hasNext()) {
|
||||
Record rec = recIt.next();
|
||||
DBRecord rec = recIt.next();
|
||||
String key = rec.getKeyField().getString();
|
||||
if (optionName.equals(key)) {
|
||||
return true;
|
||||
@ -222,7 +222,7 @@ class OptionsDB extends AbstractOptions {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Record getPropertyRecord(String propertyName) {
|
||||
private DBRecord getPropertyRecord(String propertyName) {
|
||||
if (propertyTable == null) {
|
||||
return null;
|
||||
}
|
||||
@ -238,7 +238,7 @@ class OptionsDB extends AbstractOptions {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void putRecord(Record rec) {
|
||||
private void putRecord(DBRecord rec) {
|
||||
try {
|
||||
if (propertyTable == null) {
|
||||
propertyTable =
|
||||
@ -265,7 +265,7 @@ class OptionsDB extends AbstractOptions {
|
||||
@Override
|
||||
public Object getCurrentValue() {
|
||||
if (!isCached) {
|
||||
Record rec = getPropertyRecord(getName());
|
||||
DBRecord rec = getPropertyRecord(getName());
|
||||
if (rec == null) {
|
||||
value = getDefaultValue();
|
||||
}
|
||||
@ -295,7 +295,7 @@ class OptionsDB extends AbstractOptions {
|
||||
removePropertyFromDB(getName());
|
||||
}
|
||||
else {
|
||||
Record rec = PROPERTY_SCHEMA.createRecord(new StringField(getName()));
|
||||
DBRecord rec = PROPERTY_SCHEMA.createRecord(new StringField(getName()));
|
||||
OptionType optionType = getOptionType();
|
||||
rec.setByteValue(TYPE_COL, (byte) (optionType.ordinal()));
|
||||
rec.setString(VALUE_COL, optionType.convertObjectToString(newValue));
|
||||
@ -321,7 +321,7 @@ class OptionsDB extends AbstractOptions {
|
||||
Object defaultValue) {
|
||||
|
||||
if (type == OptionType.NO_TYPE) {
|
||||
Record record = getPropertyRecord(optionName);
|
||||
DBRecord record = getPropertyRecord(optionName);
|
||||
if (record != null) {
|
||||
type = OptionType.values()[record.getByteValue(TYPE_COL)];
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.*;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
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.
|
||||
* 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
|
||||
* 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()}.
|
||||
* @param objectRecord the valid record corresponding to the object to be retrieved and possibly
|
||||
* 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.
|
||||
*/
|
||||
public synchronized T get(Record objectRecord) {
|
||||
public synchronized T get(DBRecord objectRecord) {
|
||||
long key = objectRecord.getKey();
|
||||
KeyedSoftReference ref = map.get(key);
|
||||
if (ref != null) {
|
||||
|
@ -384,7 +384,7 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB
|
||||
private void createDatabase() throws IOException {
|
||||
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));
|
||||
table.putRecord(record);
|
||||
}
|
||||
@ -430,13 +430,13 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB
|
||||
|
||||
private void upgradeDatabase() throws IOException {
|
||||
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));
|
||||
table.putRecord(record);
|
||||
}
|
||||
|
||||
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
|
||||
// if record does not exist return 1;
|
||||
|
@ -291,7 +291,7 @@ class DataTypeArchiveDBChangeSet implements DataTypeArchiveChangeSet, DomainObje
|
||||
}
|
||||
RecordIterator it = table.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
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 {
|
||||
if (ids.size() > 0) {
|
||||
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;
|
||||
for (long id : ids) {
|
||||
rec.setKey(key++);
|
||||
|
@ -17,7 +17,7 @@ package ghidra.program.database;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import ghidra.util.Lock;
|
||||
|
||||
/**
|
||||
@ -140,7 +140,7 @@ abstract public class DatabaseObject {
|
||||
* @param record optional record which may be used to refresh invalid object
|
||||
* @return true if the object is valid.
|
||||
*/
|
||||
public boolean checkIsValid(Record record) {
|
||||
public boolean checkIsValid(DBRecord record) {
|
||||
if (deleted) {
|
||||
return false;
|
||||
}
|
||||
@ -199,7 +199,7 @@ abstract public class DatabaseObject {
|
||||
* 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.
|
||||
*/
|
||||
protected boolean refresh(Record record) {
|
||||
protected boolean refresh(DBRecord record) {
|
||||
return refresh();
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class OverlaySpaceAdapterDB {
|
||||
if (table != null) {
|
||||
RecordIterator it = table.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
String spaceName = rec.getString(OV_SPACE_NAME_COL);
|
||||
String templateSpaceName = rec.getString(OV_SPACE_BASE_COL);
|
||||
long minOffset = rec.getLongValue(OV_MIN_OFFSET_COL);
|
||||
@ -86,7 +86,7 @@ class OverlaySpaceAdapterDB {
|
||||
if (table == null) {
|
||||
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(1, ovSpace.getOverlayedSpace().getName());
|
||||
rec.setLongValue(OV_MIN_OFFSET_COL, ovSpace.getMinOffset());
|
||||
@ -105,7 +105,7 @@ class OverlaySpaceAdapterDB {
|
||||
if (table != null) {
|
||||
RecordIterator it = table.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
String spaceName = rec.getString(0);
|
||||
if (name.equals(spaceName)) {
|
||||
it.delete();
|
||||
@ -127,7 +127,7 @@ class OverlaySpaceAdapterDB {
|
||||
if (table != null) {
|
||||
RecordIterator it = table.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
OverlayAddressSpace space = map.remove(rec.getKey());
|
||||
if (space != null) {
|
||||
//maxId = Math.max(maxId, space.getUnique());
|
||||
@ -173,7 +173,7 @@ class OverlaySpaceAdapterDB {
|
||||
if (table != null) {
|
||||
RecordIterator it = table.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
String spaceName = rec.getString(0);
|
||||
if (oldName.equals(spaceName)) {
|
||||
it.delete();
|
||||
@ -202,7 +202,7 @@ class OverlaySpaceAdapterDB {
|
||||
if (table != null) {
|
||||
RecordIterator it = table.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
String oldUnderlyingSpaceName = rec.getString(OV_SPACE_BASE_COL);
|
||||
AddressSpace space = addrFactory.getAddressSpace(oldUnderlyingSpaceName);
|
||||
if (space != null && space.isNonLoadedMemorySpace()) {
|
||||
|
@ -1155,7 +1155,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
||||
if (name.equals(newName)) {
|
||||
return;
|
||||
}
|
||||
Record record = table.getRecord(new StringField(PROGRAM_NAME));
|
||||
DBRecord record = table.getRecord(new StringField(PROGRAM_NAME));
|
||||
record.setString(0, newName);
|
||||
table.putRecord(record);
|
||||
getTreeManager().setProgramName(name, newName);
|
||||
@ -1170,7 +1170,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1265,7 +1265,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
||||
}
|
||||
|
||||
private long getStoredBaseImageOffset() throws IOException {
|
||||
Record rec = table.getRecord(new StringField(IMAGE_OFFSET));
|
||||
DBRecord rec = table.getRecord(new StringField(IMAGE_OFFSET));
|
||||
if (rec != null) {
|
||||
return (new BigInteger(rec.getString(0), 16)).longValue();
|
||||
}
|
||||
@ -1325,7 +1325,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
||||
|
||||
if (commit) {
|
||||
try {
|
||||
Record record = SCHEMA.createRecord(new StringField(IMAGE_OFFSET));
|
||||
DBRecord record = SCHEMA.createRecord(new StringField(IMAGE_OFFSET));
|
||||
record.setString(0, Long.toHexString(base.getOffset()));
|
||||
table.putRecord(record);
|
||||
|
||||
@ -1384,7 +1384,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
||||
|
||||
private void createDatabase() throws IOException {
|
||||
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);
|
||||
table.putRecord(record);
|
||||
|
||||
@ -1432,7 +1432,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
||||
if (table == null) {
|
||||
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);
|
||||
|
||||
record = table.getRecord(new StringField(LANGUAGE_ID));
|
||||
@ -1501,7 +1501,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
||||
table = dbh.getTable(TABLE_NAME);
|
||||
Field key = new StringField(PROGRAM_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))) {
|
||||
return; // already has correct version
|
||||
}
|
||||
@ -1534,7 +1534,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
||||
}
|
||||
|
||||
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) {
|
||||
String s = record.getString(0);
|
||||
try {
|
||||
@ -1549,7 +1549,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
|
||||
|
||||
private void checkOldProperties(int openMode, TaskMonitor monitor)
|
||||
throws IOException, VersionException {
|
||||
Record record = table.getRecord(new StringField(EXECUTE_PATH));
|
||||
DBRecord record = table.getRecord(new StringField(EXECUTE_PATH));
|
||||
if (record != null) {
|
||||
if (openMode == READ_ONLY) {
|
||||
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);
|
||||
}
|
||||
|
||||
Record record = SCHEMA.createRecord(new StringField(LANGUAGE_ID));
|
||||
DBRecord record = SCHEMA.createRecord(new StringField(LANGUAGE_ID));
|
||||
record.setString(0, languageID.getIdAsString());
|
||||
table.putRecord(record);
|
||||
record = SCHEMA.createRecord(new StringField(COMPILER_SPEC_ID));
|
||||
|
@ -542,7 +542,7 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
|
||||
}
|
||||
RecordIterator it = table.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
ids.add(rec.getLongValue(0));
|
||||
}
|
||||
}
|
||||
@ -557,7 +557,7 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
|
||||
}
|
||||
RecordIterator it = table.iterator();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
Address addr1 = addrMap.decodeAddress(rec.getLongValue(0));
|
||||
Address addr2 = addrMap.decodeAddress(rec.getLongValue(1));
|
||||
// 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 {
|
||||
if (ids.size() > 0) {
|
||||
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;
|
||||
for (long id : ids) {
|
||||
rec.setKey(key++);
|
||||
@ -625,7 +625,7 @@ class ProgramDBChangeSet implements ProgramChangeSet, DomainObjectDBChangeSet {
|
||||
throws IOException {
|
||||
if (!set.isEmpty()) {
|
||||
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;
|
||||
for (KeyRange range : addrMap.getKeyRanges(set, false, false)) {
|
||||
rec.setKey(key++);
|
||||
|
@ -324,7 +324,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
||||
registryTable =
|
||||
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());
|
||||
table.putRecord(record);
|
||||
|
||||
@ -347,7 +347,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
||||
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));
|
||||
|
||||
record = table.getRecord(new StringField(LANGUAGE_VERSION));
|
||||
@ -377,7 +377,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
||||
|
||||
private void upgradeDatabase() throws IOException {
|
||||
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));
|
||||
table.putRecord(record);
|
||||
}
|
||||
@ -438,7 +438,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
||||
|
||||
clearCache(true);
|
||||
|
||||
Record record = SCHEMA.createRecord(new StringField(LANGUAGE_ID));
|
||||
DBRecord record = SCHEMA.createRecord(new StringField(LANGUAGE_ID));
|
||||
record.setString(VALUE_COL, languageID.getIdAsString());
|
||||
table.putRecord(record);
|
||||
|
||||
@ -472,7 +472,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
||||
try {
|
||||
for (Field key : registryTable.findRecords(new StringField(owner),
|
||||
PROPERTY_OWNER_COL)) {
|
||||
Record rec = registryTable.getRecord(key);
|
||||
DBRecord rec = registryTable.getRecord(key);
|
||||
if (propertyName.equals(rec.getString(PROPERTY_NAME_COL))) {
|
||||
int type = rec.getIntValue(PROPERTY_TYPE_COL);
|
||||
if (propertyType != type) {
|
||||
@ -495,7 +495,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
||||
}
|
||||
|
||||
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_NAME_COL, propertyName);
|
||||
rec.setIntValue(PROPERTY_TYPE_COL, propertyType);
|
||||
@ -526,7 +526,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
||||
return null;
|
||||
}
|
||||
|
||||
private PropertyMap getPropertyMap(Record rec) throws IOException {
|
||||
private PropertyMap getPropertyMap(DBRecord rec) throws IOException {
|
||||
try {
|
||||
PropertyMap map;
|
||||
int type = rec.getIntValue(PROPERTY_TYPE_COL);
|
||||
@ -579,7 +579,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
||||
try {
|
||||
for (Field key : registryTable.findRecords(new StringField(owner),
|
||||
PROPERTY_OWNER_COL)) {
|
||||
Record rec = registryTable.getRecord(key);
|
||||
DBRecord rec = registryTable.getRecord(key);
|
||||
list.add(getPropertyMap(rec));
|
||||
}
|
||||
}
|
||||
@ -596,7 +596,7 @@ class ProgramUserDataDB extends DomainObjectAdapterDB implements ProgramUserData
|
||||
propertyMapOwners = new HashSet<String>();
|
||||
RecordIterator recIter = registryTable.iterator();
|
||||
while (recIter.hasNext()) {
|
||||
Record rec = recIter.next();
|
||||
DBRecord rec = recIter.next();
|
||||
propertyMapOwners.add(rec.getString(PROPERTY_OWNER_COL));
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package ghidra.program.database.bookmark;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
import ghidra.program.database.DBObjectCache;
|
||||
import ghidra.program.database.DatabaseObject;
|
||||
import ghidra.program.model.address.Address;
|
||||
@ -28,9 +28,9 @@ import ghidra.program.model.listing.BookmarkType;
|
||||
public class BookmarkDB extends DatabaseObject implements Bookmark {
|
||||
|
||||
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());
|
||||
this.mgr = mgr;
|
||||
this.record = record;
|
||||
@ -46,7 +46,7 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
|
||||
* Update associated record
|
||||
* @param rec
|
||||
*/
|
||||
void setRecord(Record rec) {
|
||||
void setRecord(DBRecord rec) {
|
||||
if (rec.getKey() != key) {
|
||||
throw new IllegalArgumentException("Key mismatch");
|
||||
}
|
||||
@ -121,7 +121,7 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean refresh(Record rec) {
|
||||
protected boolean refresh(DBRecord rec) {
|
||||
if (rec == null) {
|
||||
rec = mgr.getRecord(key);
|
||||
}
|
||||
@ -136,7 +136,7 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
|
||||
* Returns record associated with this bookmark or
|
||||
* null if bookmark has been deleted.
|
||||
*/
|
||||
Record getRecord() {
|
||||
DBRecord getRecord() {
|
||||
return checkIsValid() ? record : null;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -117,7 +116,7 @@ abstract class BookmarkDBAdapter {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new IOException("Upgrade Cancelled");
|
||||
}
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
int typeId = getTypeId(rec);
|
||||
tmpAdapter.addType(typeId);
|
||||
Address addr = oldAddrMap.decodeAddress(rec.getLongValue(ADDRESS_COL));
|
||||
@ -138,7 +137,7 @@ abstract class BookmarkDBAdapter {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new IOException("Upgrade Cancelled");
|
||||
}
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
newAdapter.updateRecord(rec);
|
||||
monitor.setProgress(++cnt);
|
||||
}
|
||||
@ -151,7 +150,7 @@ abstract class BookmarkDBAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
static int getTypeId(Record rec) {
|
||||
static int getTypeId(DBRecord rec) {
|
||||
long key = rec.getKey();
|
||||
return (int) (key >> 48);
|
||||
}
|
||||
@ -181,7 +180,7 @@ abstract class BookmarkDBAdapter {
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
Record createBookmark(int typeId, String category, long index, String comment)
|
||||
DBRecord createBookmark(int typeId, String category, long index, String comment)
|
||||
throws IOException {
|
||||
throw new UnsupportedOperationException("Bookmarks are read-only and may not be created");
|
||||
}
|
||||
@ -191,7 +190,7 @@ abstract class BookmarkDBAdapter {
|
||||
* @param rec modified bookmark record
|
||||
* @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");
|
||||
}
|
||||
|
||||
@ -209,7 +208,7 @@ abstract class BookmarkDBAdapter {
|
||||
* @param id bookmark ID
|
||||
* @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.
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -55,7 +54,7 @@ class BookmarkDBAdapterV0 extends BookmarkDBAdapter {
|
||||
catch (VersionException e) {
|
||||
throw new AssertException();
|
||||
}
|
||||
Record[] oldTypes = oldMgr.getTypeRecords();
|
||||
DBRecord[] oldTypes = oldMgr.getTypeRecords();
|
||||
if (oldTypes.length == 0) {
|
||||
return;
|
||||
}
|
||||
@ -88,7 +87,7 @@ class BookmarkDBAdapterV0 extends BookmarkDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecord(long id) throws IOException {
|
||||
DBRecord getRecord(long id) throws IOException {
|
||||
return conversionAdapter.getRecord(id);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -75,7 +74,7 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
|
||||
AddressSet set = new AddressSet();
|
||||
RecordIterator recordIter = getRecordsByType(typeId);
|
||||
while (recordIter.hasNext()) {
|
||||
Record rec = recordIter.next();
|
||||
DBRecord rec = recordIter.next();
|
||||
Address addr = addrMap.decodeAddress(rec.getLongValue(V1_ADDRESS_COL));
|
||||
set.addRange(addr, addr);
|
||||
}
|
||||
@ -88,7 +87,7 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
|
||||
Field fv = new LongField(typeId);
|
||||
RecordIterator recordIter = table.indexIterator(V1_TYPE_ID_COL, fv, fv, true);
|
||||
while (recordIter.hasNext()) {
|
||||
Record rec = recordIter.next();
|
||||
DBRecord rec = recordIter.next();
|
||||
String cat = demangleTypeCategory(rec.getString(V1_TYPE_CATEGORY_COL));
|
||||
set.add(cat);
|
||||
}
|
||||
@ -99,13 +98,13 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecord(long id) throws IOException {
|
||||
DBRecord getRecord(long id) throws IOException {
|
||||
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);
|
||||
Record rec = BookmarkDBAdapter.SCHEMA.createRecord(key);
|
||||
DBRecord rec = BookmarkDBAdapter.SCHEMA.createRecord(key);
|
||||
rec.setLongValue(BookmarkDBAdapter.ADDRESS_COL, record.getLongValue(V1_ADDRESS_COL));
|
||||
rec.setString(BookmarkDBAdapter.CATEGORY_COL,
|
||||
demangleTypeCategory(record.getString(V1_TYPE_CATEGORY_COL)));
|
||||
@ -177,10 +176,10 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
|
||||
//==================================================================================================
|
||||
|
||||
private class BatchRecordIterator implements RecordIterator {
|
||||
private ListIterator<Record> iter;
|
||||
private ListIterator<DBRecord> iter;
|
||||
|
||||
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 ef = new LongField(end);
|
||||
RecordIterator recIter = table.indexIterator(V1_ADDRESS_COL, sf, ef, true);
|
||||
@ -201,12 +200,12 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record next() throws IOException {
|
||||
public DBRecord next() throws IOException {
|
||||
return iter.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Record previous() throws IOException {
|
||||
public DBRecord previous() throws IOException {
|
||||
return iter.previous();
|
||||
}
|
||||
|
||||
@ -223,7 +222,7 @@ class BookmarkDBAdapterV1 extends BookmarkDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Record convertRecord(Record record) {
|
||||
protected DBRecord convertRecord(DBRecord record) {
|
||||
return convertV1Record(record);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record getRecord(long id) throws IOException {
|
||||
DBRecord getRecord(long id) throws IOException {
|
||||
Table table = getTable(id);
|
||||
if (table == 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
|
||||
// Employing a separate category table would be faster
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
String cat = rec.getString(V3_CATEGORY_COL);
|
||||
if (cat != null && cat.length() != 0) {
|
||||
set.add(cat);
|
||||
@ -175,7 +175,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
|
||||
AddressSet set = new AddressSet();
|
||||
RecordIterator recordIter = getRecordsByType(typeID);
|
||||
while (recordIter.hasNext()) {
|
||||
Record rec = recordIter.next();
|
||||
DBRecord rec = recordIter.next();
|
||||
Address addr = addressMap.decodeAddress(rec.getLongValue(V3_ADDRESS_COL));
|
||||
set.addRange(addr, addr);
|
||||
}
|
||||
@ -200,7 +200,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record createBookmark(int typeID, String category, long index, String comment)
|
||||
DBRecord createBookmark(int typeID, String category, long index, String comment)
|
||||
throws IOException {
|
||||
if (!hasTable(typeID)) {
|
||||
return null;
|
||||
@ -210,7 +210,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
|
||||
long nextId = table.getKey() + 1;
|
||||
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.setString(V3_CATEGORY_COL, category);
|
||||
rec.setString(V3_COMMENT_COL, comment);
|
||||
@ -225,7 +225,7 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
void updateRecord(Record rec) throws IOException {
|
||||
void updateRecord(DBRecord rec) throws IOException {
|
||||
Table table = getTable(rec.getKey());
|
||||
table.putRecord(rec);
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
TaskMonitor.DUMMY);
|
||||
}
|
||||
|
||||
Record[] typeRecords = bookmarkTypeAdapter.getRecords();
|
||||
for (Record rec : typeRecords) {
|
||||
DBRecord[] typeRecords = bookmarkTypeAdapter.getRecords();
|
||||
for (DBRecord rec : typeRecords) {
|
||||
int typeId = (int) rec.getKey();
|
||||
BookmarkTypeDB type =
|
||||
new BookmarkTypeDB(typeId, rec.getString(BookmarkTypeDBAdapter.TYPE_NAME_COL));
|
||||
@ -157,7 +157,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
void bookmarkChanged(BookmarkDB bm) {
|
||||
lock.acquire();
|
||||
try {
|
||||
Record rec = bm.getRecord();
|
||||
DBRecord rec = bm.getRecord();
|
||||
if (rec != null) {
|
||||
bookmarkAdapter.updateRecord(rec);
|
||||
Address addr = bm.getAddress();
|
||||
@ -179,11 +179,11 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
private void upgradeOldBookmarks(ProgramDB programDB) {
|
||||
|
||||
OldBookmarkManager oldMgr = new OldBookmarkManager(programDB);
|
||||
Record[] oldTypes = oldMgr.getTypeRecords();
|
||||
DBRecord[] oldTypes = oldMgr.getTypeRecords();
|
||||
if (oldTypes.length == 0) {
|
||||
return;
|
||||
}
|
||||
for (Record oldType : oldTypes) {
|
||||
for (DBRecord oldType : oldTypes) {
|
||||
String type = oldType.getString(BookmarkTypeDBAdapter.TYPE_NAME_COL);
|
||||
AddressIterator iter = oldMgr.getBookmarkAddresses(type);
|
||||
while (iter.hasNext()) {
|
||||
@ -296,7 +296,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
bm.setComment(comment);
|
||||
}
|
||||
else {
|
||||
Record rec = bookmarkAdapter.createBookmark(typeId, category,
|
||||
DBRecord rec = bookmarkAdapter.createBookmark(typeId, category,
|
||||
addrMap.getKey(addr, true), comment);
|
||||
bm = new BookmarkDB(this, cache, rec);
|
||||
|
||||
@ -315,7 +315,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
return null;
|
||||
}
|
||||
|
||||
private BookmarkDB getBookmark(Record bookmarkRecord) {
|
||||
private BookmarkDB getBookmark(DBRecord bookmarkRecord) {
|
||||
BookmarkDB bm = cache.get(bookmarkRecord);
|
||||
if (bm == null) {
|
||||
bm = new BookmarkDB(this, cache, bookmarkRecord);
|
||||
@ -333,7 +333,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
RecordIterator iter =
|
||||
bookmarkAdapter.getRecordsByTypeAtAddress(typeId, addrMap.getKey(addr, false));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
String cat = rec.getString(BookmarkDBAdapter.CATEGORY_COL);
|
||||
if (category.equals(cat)) {
|
||||
return getBookmark(rec);
|
||||
@ -430,7 +430,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
RecordIterator iter =
|
||||
bookmarkAdapter.getRecordsByTypeAndCategory(bmt.getTypeId(), category);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
BookmarkDB bm = getBookmark(rec);
|
||||
removeBookmark(bm);
|
||||
monitor.checkCanceled();
|
||||
@ -458,8 +458,8 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
* @param id bookmark ID
|
||||
* @return bookmark record
|
||||
*/
|
||||
Record getRecord(long id) {
|
||||
Record rec = null;
|
||||
DBRecord getRecord(long id) {
|
||||
DBRecord rec = null;
|
||||
try {
|
||||
rec = bookmarkAdapter.getRecord(id);
|
||||
}
|
||||
@ -498,7 +498,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
RecordIterator iter =
|
||||
bookmarkAdapter.getRecordsByTypeAtAddress(typeId, addrMap.getKey(addr, false));
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
list.add(getBookmark(rec));
|
||||
}
|
||||
}
|
||||
@ -626,7 +626,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
try {
|
||||
BookmarkDB bm = cache.get(id);
|
||||
if (bm == null) {
|
||||
Record record = bookmarkAdapter.getRecord(id);
|
||||
DBRecord record = bookmarkAdapter.getRecord(id);
|
||||
if (record == null) {
|
||||
return null;
|
||||
}
|
||||
@ -847,7 +847,7 @@ public class BookmarkDBManager implements BookmarkManager, ErrorHandler, Manager
|
||||
lock.acquire();
|
||||
try {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -85,13 +85,13 @@ abstract class BookmarkTypeDBAdapter {
|
||||
* @return array of records
|
||||
* @throws IOException
|
||||
*/
|
||||
abstract Record[] getRecords() throws IOException;
|
||||
abstract DBRecord[] getRecords() throws IOException;
|
||||
|
||||
public int[] getTypeIds() throws IOException {
|
||||
Record[] typeRecords = getRecords();
|
||||
DBRecord[] typeRecords = getRecords();
|
||||
int[] ids = new int[typeRecords.length];
|
||||
for (int i = 0; i < typeRecords.length; i++) {
|
||||
Record rec = typeRecords[i];
|
||||
DBRecord rec = typeRecords[i];
|
||||
ids[i] = (int) rec.getKey();
|
||||
}
|
||||
return ids;
|
||||
|
@ -18,14 +18,14 @@ package ghidra.program.database.bookmark;
|
||||
import java.io.IOException;
|
||||
|
||||
import db.DBHandle;
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class BookmarkTypeDBAdapterNoTable extends BookmarkTypeDBAdapter {
|
||||
|
||||
private Record[] records = new Record[0];
|
||||
private DBRecord[] records = new DBRecord[0];
|
||||
|
||||
/**
|
||||
* @param dbHandle the database handle
|
||||
@ -44,7 +44,7 @@ public class BookmarkTypeDBAdapterNoTable extends BookmarkTypeDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record[] getRecords() throws IOException {
|
||||
DBRecord[] getRecords() throws IOException {
|
||||
return records;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -44,13 +43,13 @@ public class BookmarkTypeDBAdapterV0 extends BookmarkTypeDBAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
Record[] getRecords() throws IOException {
|
||||
ArrayList<Record> list = new ArrayList<Record>();
|
||||
DBRecord[] getRecords() throws IOException {
|
||||
ArrayList<DBRecord> list = new ArrayList<DBRecord>();
|
||||
RecordIterator iter = table.iterator();
|
||||
while (iter.hasNext()) {
|
||||
list.add(iter.next());
|
||||
}
|
||||
Record[] recs = new Record[list.size()];
|
||||
DBRecord[] recs = new DBRecord[list.size()];
|
||||
list.toArray(recs);
|
||||
return recs;
|
||||
}
|
||||
@ -58,7 +57,7 @@ public class BookmarkTypeDBAdapterV0 extends BookmarkTypeDBAdapter {
|
||||
@Override
|
||||
void addType(int typeId, String type) throws IOException {
|
||||
|
||||
Record rec = SCHEMA.createRecord(typeId);
|
||||
DBRecord rec = SCHEMA.createRecord(typeId);
|
||||
rec.setString(TYPE_NAME_COL, type);
|
||||
table.putRecord(rec);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -26,7 +25,7 @@ import ghidra.util.exception.DuplicateNameException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import db.Record;
|
||||
import db.DBRecord;
|
||||
|
||||
/**
|
||||
* Interface to manage bookmarks on a program.
|
||||
@ -41,7 +40,7 @@ class OldBookmarkManager {
|
||||
private Program program;
|
||||
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 LongIntHashedList bookmarkAddrIndex = new LongIntHashedList();
|
||||
@ -56,7 +55,7 @@ class OldBookmarkManager {
|
||||
// Create type records
|
||||
String[] types = getTypes();
|
||||
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]);
|
||||
bookmarkTypes.put(types[i], rec);
|
||||
}
|
||||
@ -189,9 +188,9 @@ class OldBookmarkManager {
|
||||
/**
|
||||
* Returns array of bookmark type records
|
||||
*/
|
||||
public Record[] getTypeRecords() {
|
||||
Collection<Record> c = bookmarkTypes.values();
|
||||
Record[] recs = new Record[c.size()];
|
||||
public DBRecord[] getTypeRecords() {
|
||||
Collection<DBRecord> c = bookmarkTypes.values();
|
||||
DBRecord[] recs = new DBRecord[c.size()];
|
||||
c.toArray(recs);
|
||||
return recs;
|
||||
}
|
||||
|
@ -260,12 +260,12 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
Instruction inst = null;
|
||||
RecordIterator recIt = instAdapter.getRecords(firstInstrStart, true);
|
||||
if (recIt.hasNext()) {
|
||||
Record rec = recIt.next();
|
||||
DBRecord rec = recIt.next();
|
||||
inst = getInstructionDB(rec);
|
||||
recIt.previous();
|
||||
}
|
||||
if (recIt.hasPrevious()) {
|
||||
Record rec = recIt.previous();
|
||||
DBRecord rec = recIt.previous();
|
||||
Instruction prevInst = getInstructionDB(rec);
|
||||
if (prevInst.getMaxAddress().compareTo(firstInstrStart) >= 0) {
|
||||
return prevInst;
|
||||
@ -275,12 +275,12 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
Data data = null;
|
||||
recIt = dataAdapter.getRecords(firstInstrStart, true);
|
||||
if (recIt.hasNext()) {
|
||||
Record rec = recIt.next();
|
||||
DBRecord rec = recIt.next();
|
||||
data = getDataDB(rec);
|
||||
recIt.previous();
|
||||
}
|
||||
if (recIt.hasPrevious()) {
|
||||
Record rec = recIt.previous();
|
||||
DBRecord rec = recIt.previous();
|
||||
Data prevData = getDataDB(rec);
|
||||
if (prevData.getMaxAddress().compareTo(firstInstrStart) >= 0) {
|
||||
return prevData;
|
||||
@ -930,8 +930,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
}
|
||||
|
||||
private CodeUnit getDefinedBefore(Address address) throws IOException {
|
||||
Record dataRec = dataAdapter.getRecordBefore(address);
|
||||
Record instRec = instAdapter.getRecordBefore(address);
|
||||
DBRecord dataRec = dataAdapter.getRecordBefore(address);
|
||||
DBRecord instRec = instAdapter.getRecordBefore(address);
|
||||
|
||||
if (dataRec == null && instRec == null) {
|
||||
return null;
|
||||
@ -1010,8 +1010,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
return cu;
|
||||
}
|
||||
try {
|
||||
Record dataRec = dataAdapter.getRecordBefore(address);
|
||||
Record instRec = instAdapter.getRecordBefore(address);
|
||||
DBRecord dataRec = dataAdapter.getRecordBefore(address);
|
||||
DBRecord instRec = instAdapter.getRecordBefore(address);
|
||||
|
||||
CodeUnit cuFirst = null, cuSecond = null;
|
||||
|
||||
@ -1320,7 +1320,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
try {
|
||||
CodeUnit cu = cache.get(addr);
|
||||
if (cu == null) {
|
||||
Record rec = dataAdapter.getRecord(addr);
|
||||
DBRecord rec = dataAdapter.getRecord(addr);
|
||||
return getDataDB(rec);
|
||||
}
|
||||
else if (cu instanceof Data) {
|
||||
@ -1350,7 +1350,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
public Instruction getInstructionBefore(Address addr) {
|
||||
lock.acquire();
|
||||
try {
|
||||
Record rec = instAdapter.getRecordBefore(addr);
|
||||
DBRecord rec = instAdapter.getRecordBefore(addr);
|
||||
return getInstructionDB(rec);
|
||||
}
|
||||
catch (IOException e) {
|
||||
@ -1374,7 +1374,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
public Instruction getInstructionAfter(Address addr) {
|
||||
lock.acquire();
|
||||
try {
|
||||
Record rec = instAdapter.getRecordAfter(addr);
|
||||
DBRecord rec = instAdapter.getRecordAfter(addr);
|
||||
return getInstructionDB(rec);
|
||||
}
|
||||
catch (IOException e) {
|
||||
@ -1548,7 +1548,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
public Data getDefinedDataAfter(Address addr) {
|
||||
lock.acquire();
|
||||
try {
|
||||
Record rec = dataAdapter.getRecordAfter(addr);
|
||||
DBRecord rec = dataAdapter.getRecordAfter(addr);
|
||||
return getDataDB(rec);
|
||||
}
|
||||
catch (IOException e) {
|
||||
@ -1573,7 +1573,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
public Data getDefinedDataBefore(Address addr) {
|
||||
lock.acquire();
|
||||
try {
|
||||
Record rec = dataAdapter.getRecordBefore(addr);
|
||||
DBRecord rec = dataAdapter.getRecordBefore(addr);
|
||||
return getDataDB(rec);
|
||||
}
|
||||
catch (IOException e) {
|
||||
@ -1682,7 +1682,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
while (true) {
|
||||
|
||||
if (nextInstAddr == null && instIter.hasNext()) {
|
||||
Record nextInstRec = instIter.next();
|
||||
DBRecord nextInstRec = instIter.next();
|
||||
nextInstAddr = addrMap.decodeAddress(nextInstRec.getKey());
|
||||
nextInstEndAddr = nextInstAddr;
|
||||
int protoID = nextInstRec.getIntValue(InstDBAdapter.PROTO_ID_COL);
|
||||
@ -1700,7 +1700,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
}
|
||||
|
||||
if (nextDataAddr == null && dataIter.hasNext()) {
|
||||
Record nextDataRec = dataIter.next();
|
||||
DBRecord nextDataRec = dataIter.next();
|
||||
nextDataAddr = addrMap.decodeAddress(nextDataRec.getKey());
|
||||
nextDataEndAddr = nextDataAddr;
|
||||
DataDB data = getDataDB(nextDataRec);
|
||||
@ -1919,7 +1919,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
|
||||
RecordIterator recIt = instAdapter.getRecords(startAddr, true);
|
||||
if (recIt.hasNext()) {
|
||||
Record rec = recIt.next();
|
||||
DBRecord rec = recIt.next();
|
||||
Instruction inst = getInstructionDB(rec);
|
||||
if (inst.getMinAddress().compareTo(endAddr) <= 0) {
|
||||
throw new CodeUnitInsertionException("Conflicting instruction exists at address " +
|
||||
@ -1928,7 +1928,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
recIt.previous();
|
||||
}
|
||||
if (recIt.hasPrevious()) {
|
||||
Record rec = recIt.previous();
|
||||
DBRecord rec = recIt.previous();
|
||||
Instruction inst = getInstructionDB(rec);
|
||||
if (inst.getMaxAddress().compareTo(startAddr) >= 0) {
|
||||
throw new CodeUnitInsertionException("Conflicting instruction exists at address " +
|
||||
@ -1938,7 +1938,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
|
||||
recIt = dataAdapter.getRecords(startAddr, true);
|
||||
if (recIt.hasNext()) {
|
||||
Record rec = recIt.next();
|
||||
DBRecord rec = recIt.next();
|
||||
Data data = getDataDB(rec);
|
||||
if (data.getMinAddress().compareTo(endAddr) <= 0) {
|
||||
throw new CodeUnitInsertionException("Conflicting data exists at address " +
|
||||
@ -1947,7 +1947,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
recIt.previous();
|
||||
}
|
||||
if (recIt.hasPrevious()) {
|
||||
Record rec = recIt.previous();
|
||||
DBRecord rec = recIt.previous();
|
||||
Data data = getDataDB(rec);
|
||||
if (data.getMaxAddress().compareTo(startAddr) >= 0) {
|
||||
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));
|
||||
}
|
||||
|
||||
Record record = dataAdapter.createData(addr, dataManager.getResolvedID(dataType));
|
||||
DBRecord record = dataAdapter.createData(addr, dataManager.getResolvedID(dataType));
|
||||
|
||||
DataType baseDt = dataType;
|
||||
if (baseDt instanceof TypeDef) {
|
||||
@ -2635,7 +2635,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
protected boolean isUndefined(Address address, long addr) {
|
||||
if (program.getMemory().contains(address)) {
|
||||
try {
|
||||
Record rec = dataAdapter.getRecord(addr);
|
||||
DBRecord rec = dataAdapter.getRecord(addr);
|
||||
if (rec == null) {
|
||||
rec = instAdapter.getRecord(addr);
|
||||
}
|
||||
@ -2668,7 +2668,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
RecordIterator it = dataAdapter.getRecords();
|
||||
while (it.hasNext()) {
|
||||
monitor.checkCanceled();
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
long id = rec.getLongValue(DataDBAdapter.DATA_TYPE_ID_COL);
|
||||
for (long dataTypeID : dataTypeIDs) {
|
||||
if (id == dataTypeID) {
|
||||
@ -2726,7 +2726,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
* the cache, create a new DB object and add it.
|
||||
* @param rec record for the instruction
|
||||
*/
|
||||
InstructionDB getInstructionDB(Record rec) {
|
||||
InstructionDB getInstructionDB(DBRecord rec) {
|
||||
lock.acquire();
|
||||
try {
|
||||
if (rec != null) {
|
||||
@ -2754,7 +2754,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
* create a new DB object and add it.
|
||||
* @param rec data record
|
||||
*/
|
||||
DataDB getDataDB(Record rec) {
|
||||
DataDB getDataDB(DBRecord rec) {
|
||||
lock.acquire();
|
||||
try {
|
||||
if (rec != null) {
|
||||
@ -2792,8 +2792,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
}
|
||||
|
||||
Address getDefinedAddressAfter(Address address) {
|
||||
Record dataRec = null;
|
||||
Record instRec = null;
|
||||
DBRecord dataRec = null;
|
||||
DBRecord instRec = null;
|
||||
try {
|
||||
dataRec = dataAdapter.getRecordAfter(address);
|
||||
instRec = instAdapter.getRecordAfter(address);
|
||||
@ -2876,7 +2876,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
RecordIterator iter = dataAdapter.getRecords(start, end, true);
|
||||
while (iter.hasNext()) {
|
||||
monitor.checkCanceled();
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
Data data = getDataDB(rec);
|
||||
addDataReferences(data, new ArrayList<Address>());
|
||||
}
|
||||
@ -3091,11 +3091,11 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
}
|
||||
|
||||
private InstructionDB getInstructionDB(long addr) throws IOException {
|
||||
Record rec = instAdapter.getRecord(addr);
|
||||
DBRecord rec = instAdapter.getRecord(addr);
|
||||
return getInstructionDB(rec);
|
||||
}
|
||||
|
||||
protected Record getInstructionRecord(long addr) {
|
||||
protected DBRecord getInstructionRecord(long addr) {
|
||||
try {
|
||||
return instAdapter.getRecord(addr);
|
||||
}
|
||||
@ -3115,7 +3115,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
return null;
|
||||
}
|
||||
|
||||
DataType getDataType(Record dataRecord) {
|
||||
DataType getDataType(DBRecord dataRecord) {
|
||||
if (dataRecord != null) {
|
||||
long datatypeID = dataRecord.getLongValue(DataDBAdapter.DATA_TYPE_ID_COL);
|
||||
DataType dt = dataManager.getDataType(datatypeID);
|
||||
@ -3323,7 +3323,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
public String getComment(int commentType, Address address) {
|
||||
try {
|
||||
long addr = addrMap.getKey(address, false);
|
||||
Record commentRec = getCommentAdapter().getRecord(addr);
|
||||
DBRecord commentRec = getCommentAdapter().getRecord(addr);
|
||||
if (commentRec != null) {
|
||||
return commentRec.getString(commentType);
|
||||
}
|
||||
@ -3353,7 +3353,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
lock.acquire();
|
||||
try {
|
||||
long addr = addrMap.getKey(address, true);
|
||||
Record commentRec = getCommentAdapter().getRecord(addr);
|
||||
DBRecord commentRec = getCommentAdapter().getRecord(addr);
|
||||
if (commentRec == null) {
|
||||
if (comment == null) {
|
||||
return;
|
||||
@ -3444,20 +3444,20 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
try {
|
||||
|
||||
// records are sorted by date ascending
|
||||
List<Record> allRecords = getHistoryRecords(addr, commentType);
|
||||
List<DBRecord> allRecords = getHistoryRecords(addr, commentType);
|
||||
|
||||
List<CommentHistory> results = new ArrayList<>();
|
||||
String comment = getComment(addr, commentType);
|
||||
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);
|
||||
List<Record> records = subListByDate(allRecords, date);
|
||||
List<DBRecord> records = subListByDate(allRecords, date);
|
||||
|
||||
List<StringDiff> diffs = new ArrayList<>(records.size());
|
||||
|
||||
String user = null;
|
||||
for (Record r : records) {
|
||||
for (DBRecord r : records) {
|
||||
user = r.getString(CommentHistoryAdapter.HISTORY_USER_COL);
|
||||
int pos1 = r.getIntValue(CommentHistoryAdapter.HISTORY_POS1_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
|
||||
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);
|
||||
List<Record> list = new ArrayList<>();
|
||||
List<DBRecord> list = new ArrayList<>();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
if (rec.getByteValue(CommentHistoryAdapter.HISTORY_TYPE_COL) == commentType) {
|
||||
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
|
||||
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--) {
|
||||
Record rec = records.get(i);
|
||||
DBRecord rec = records.get(i);
|
||||
if (date != rec.getLongValue(CommentHistoryAdapter.HISTORY_DATE_COL)) {
|
||||
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 {
|
||||
Record record = commentAdapter.getRecord(addrMap.getKey(addr, false));
|
||||
DBRecord record = commentAdapter.getRecord(addrMap.getKey(addr, false));
|
||||
if (record != null) {
|
||||
return record.getString(commentType);
|
||||
}
|
||||
@ -3523,7 +3523,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
try {
|
||||
RecordIterator it = dataAdapter.getRecords();
|
||||
while (it.hasNext()) {
|
||||
Record rec = it.next();
|
||||
DBRecord rec = it.next();
|
||||
long id = rec.getLongValue(DataDBAdapter.DATA_TYPE_ID_COL);
|
||||
if (id == oldDataTypeID) {
|
||||
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 {
|
||||
RecordIterator iter = commentAdapter.getRecords(start, end, true);
|
||||
while (iter.hasNext()) {
|
||||
Record rec = iter.next();
|
||||
DBRecord rec = iter.next();
|
||||
addCommentHistoryRecord(rec, CodeUnit.PRE_COMMENT);
|
||||
addCommentHistoryRecord(rec, CodeUnit.POST_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);
|
||||
if (comment != null) {
|
||||
createCommentHistoryRecord(addrMap.decodeAddress(commentRec.getKey()), commentType,
|
||||
@ -3608,7 +3608,7 @@ public class CodeManager implements ErrorHandler, ManagerDB {
|
||||
int count = 0;
|
||||
RecordIterator recIter = instAdapter.getRecords();
|
||||
while (recIter.hasNext()) {
|
||||
Record rec = recIter.next();
|
||||
DBRecord rec = recIter.next();
|
||||
|
||||
Address addr = addrMap.decodeAddress(rec.getKey());
|
||||
if (minAddr == null) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user