Renamed Record class to DBRecord

This commit is contained in:
ghidra1 2020-12-28 13:30:36 -05:00
parent 04276e9522
commit db1e3d1b62
305 changed files with 1902 additions and 1959 deletions

View file

@ -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);

View file

@ -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());
}

View file

@ -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);
}

View file

@ -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());
}

View file

@ -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();

View file

@ -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();

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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);

View file

@ -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;

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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);
}