Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
ray6080 committed Jan 2, 2023
1 parent eb4f114 commit 124cb6f
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 56 deletions.
4 changes: 2 additions & 2 deletions src/include/processor/operator/scan/generic_scan_rel_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace processor {
class RelTableCollection {
public:
RelTableCollection(
vector<DirectedRelTableData*> tables, vector<unique_ptr<ScanRelTableState>> tableScanStates)
vector<DirectedRelTableData*> tables, vector<unique_ptr<RelTableScanState>> tableScanStates)
: tables{std::move(tables)}, tableScanStates{std::move(tableScanStates)} {}

void resetState();
Expand All @@ -23,7 +23,7 @@ class RelTableCollection {

private:
vector<DirectedRelTableData*> tables;
vector<unique_ptr<ScanRelTableState>> tableScanStates;
vector<unique_ptr<RelTableScanState>> tableScanStates;

uint32_t currentRelTableIdxToScan = UINT32_MAX;
uint32_t nextRelTableIdxToScan = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/include/processor/operator/scan/scan_rel_table_columns.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ScanRelTableColumns : public ScanRelTable, public SelVectorOverWriter {
: ScanRelTable{inNodeIDVectorPos, std::move(outputVectorsPos),
PhysicalOperatorType::SCAN_REL_TABLE_COLUMNS, std::move(child), id, paramsString},
tableData{tableData} {
scanState = make_unique<ScanRelTableState>(
boundNodeTableID, std::move(propertyIds), ScanRelDataType::COLUMNS);
scanState = make_unique<RelTableScanState>(
boundNodeTableID, std::move(propertyIds), RelTableDataType::COLUMNS);
}
~ScanRelTableColumns() override = default;

Expand All @@ -30,7 +30,7 @@ class ScanRelTableColumns : public ScanRelTable, public SelVectorOverWriter {

private:
DirectedRelTableData* tableData;
unique_ptr<ScanRelTableState> scanState;
unique_ptr<RelTableScanState> scanState;
};

} // namespace processor
Expand Down
6 changes: 3 additions & 3 deletions src/include/processor/operator/scan/scan_rel_table_lists.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ScanRelTableLists : public ScanRelTable {
: ScanRelTable{inNodeIDVectorPos, std::move(outputVectorsPos),
PhysicalOperatorType::SCAN_REL_TABLE_LISTS, std::move(child), id, paramsString},
tableData{tableData} {
scanState = make_unique<ScanRelTableState>(
boundNodeTableID, std::move(propertyIds), ScanRelDataType::LISTS);
scanState = make_unique<RelTableScanState>(
boundNodeTableID, std::move(propertyIds), RelTableDataType::LISTS);
}
~ScanRelTableLists() override = default;

Expand All @@ -30,7 +30,7 @@ class ScanRelTableLists : public ScanRelTable {

private:
DirectedRelTableData* tableData;
unique_ptr<ScanRelTableState> scanState;
unique_ptr<RelTableScanState> scanState;
};

} // namespace processor
Expand Down
2 changes: 0 additions & 2 deletions src/include/storage/store/node_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ class NodeTable {
void scan(Transaction* transaction, const shared_ptr<ValueVector>& inputIDVector,
const vector<uint32_t>& columnIdxes, vector<shared_ptr<ValueVector>> outputVectors);

// TODO(Guodong): Do we really need this function?
inline Column* getPropertyColumn(uint64_t propertyIdx) {
return propertyColumns[propertyIdx].get();
}
inline PrimaryKeyIndex* getPKIndex() const { return pkIndex.get(); }
inline NodesStatisticsAndDeletedIDs* getNodeStatisticsAndDeletedIDs() const {
return nodesStatisticsAndDeletedIDs;
}
// TODO(Guodong): Do we really need this function?
inline table_id_t getTableID() const { return tableID; }

node_offset_t addNodeAndResetProperties(ValueVector* primaryKeyVector);
Expand Down
19 changes: 0 additions & 19 deletions src/include/storage/store/rel_local_store.h

This file was deleted.

26 changes: 12 additions & 14 deletions src/include/storage/store/rel_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@ using table_adj_lists_map_t = unordered_map<table_id_t, unique_ptr<AdjLists>>;
using table_property_columns_map_t = unordered_map<table_id_t, vector<unique_ptr<Column>>>;
using table_property_lists_map_t = unordered_map<table_id_t, vector<unique_ptr<Lists>>>;

// TODO(Guodong): Rename to RelTableDataType
enum class ScanRelDataType : uint8_t {
enum class RelTableDataType : uint8_t {
COLUMNS = 0,
LISTS = 1,
};

// TODO(Guodong): Rename to RelTableScanState
struct ScanRelTableState {
struct RelTableScanState {
public:
explicit ScanRelTableState(
table_id_t boundNodeTableID, vector<uint32_t> propertyIds, ScanRelDataType scanRelDataType)
: scanRelDataType{scanRelDataType}, boundNodeTableID{boundNodeTableID},
explicit RelTableScanState(table_id_t boundNodeTableID, vector<uint32_t> propertyIds,
RelTableDataType relTableDataType)
: relTableDataType{relTableDataType}, boundNodeTableID{boundNodeTableID},
propertyIds{std::move(propertyIds)} {
if (scanRelDataType == ScanRelDataType::LISTS) {
if (relTableDataType == RelTableDataType::LISTS) {
syncState = make_unique<ListSyncState>();
// The first listHandle is for adj lists.
listHandles.resize(this->propertyIds.size() + 1);
Expand All @@ -39,11 +37,11 @@ struct ScanRelTableState {
}

bool hasMoreAndSwitchSourceIfNecessary() const {
return scanRelDataType == ScanRelDataType::LISTS &&
return relTableDataType == RelTableDataType::LISTS &&
syncState->hasMoreAndSwitchSourceIfNecessary();
}

ScanRelDataType scanRelDataType;
RelTableDataType relTableDataType;
table_id_t boundNodeTableID;
vector<uint32_t> propertyIds;
// sync state between adj and property lists
Expand Down Expand Up @@ -79,10 +77,10 @@ class DirectedRelTableData {
AdjColumn* getAdjColumn(table_id_t boundNodeTableID);
AdjLists* getAdjLists(table_id_t boundNodeTableID);

inline void scan(Transaction* transaction, ScanRelTableState& scanState,
inline void scan(Transaction* transaction, RelTableScanState& scanState,
const shared_ptr<ValueVector>& inNodeIDVector,
vector<shared_ptr<ValueVector>>& outputVectors) {
if (scanState.scanRelDataType == ScanRelDataType::COLUMNS) {
if (scanState.relTableDataType == RelTableDataType::COLUMNS) {
scanColumns(transaction, scanState, inNodeIDVector, outputVectors);
} else {
scanLists(transaction, scanState, inNodeIDVector, outputVectors);
Expand All @@ -97,10 +95,10 @@ class DirectedRelTableData {
vector<unique_ptr<ListsUpdateIterator>> getListsUpdateIterators(table_id_t srcTableID);

private:
void scanColumns(Transaction* transaction, ScanRelTableState& scanState,
void scanColumns(Transaction* transaction, RelTableScanState& scanState,
const shared_ptr<ValueVector>& inNodeIDVector,
vector<shared_ptr<ValueVector>>& outputVectors);
void scanLists(Transaction* transaction, ScanRelTableState& scanState,
void scanLists(Transaction* transaction, RelTableScanState& scanState,
const shared_ptr<ValueVector>& inNodeIDVector,
vector<shared_ptr<ValueVector>>& outputVectors);

Expand Down
8 changes: 4 additions & 4 deletions src/processor/mapper/map_extend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static unique_ptr<RelTableCollection> populateRelTableCollection(table_id_t boun
const RelExpression& rel, RelDirection direction, const expression_vector& properties,
const RelsStore& relsStore) {
vector<DirectedRelTableData*> tables;
vector<unique_ptr<ScanRelTableState>> tableScanStates;
vector<unique_ptr<RelTableScanState>> tableScanStates;
for (auto relTableID : rel.getTableIDs()) {
auto relTable = relsStore.getRelTable(relTableID);
if (!relTable->hasAdjColumn(direction, boundNodeTableID) &&
Expand All @@ -39,10 +39,10 @@ static unique_ptr<RelTableCollection> populateRelTableCollection(table_id_t boun
INVALID_PROPERTY_ID);
}
tableScanStates.push_back(
make_unique<ScanRelTableState>(boundNodeTableID, std::move(propertyIds),
make_unique<RelTableScanState>(boundNodeTableID, std::move(propertyIds),
relsStore.hasAdjColumn(direction, boundNodeTableID, relTableID) ?
ScanRelDataType::COLUMNS :
ScanRelDataType::LISTS));
RelTableDataType::COLUMNS :
RelTableDataType::LISTS));
}
return make_unique<RelTableCollection>(std::move(tables), std::move(tableScanStates));
}
Expand Down
14 changes: 7 additions & 7 deletions src/processor/operator/scan/generic_scan_rel_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ bool RelTableCollection::scan(const shared_ptr<ValueVector>& inVector,
vector<shared_ptr<ValueVector>>& outputVectors, Transaction* transaction) {
do {
if (tableScanStates[currentRelTableIdxToScan]->hasMoreAndSwitchSourceIfNecessary()) {
if (tableScanStates[currentRelTableIdxToScan]->scanRelDataType ==
storage::ScanRelDataType::COLUMNS) {
if (tableScanStates[currentRelTableIdxToScan]->relTableDataType ==
storage::RelTableDataType::COLUMNS) {
outputVectors[0]->state->selVector->resetSelectorToValuePosBufferWithSize(1);
outputVectors[0]->state->selVector->selectedPositions[0] =
inVector->state->selVector->selectedPositions[0];
Expand All @@ -25,8 +25,8 @@ bool RelTableCollection::scan(const shared_ptr<ValueVector>& inVector,
if (currentRelTableIdxToScan == tableScanStates.size()) {
return false;
}
if (tableScanStates[currentRelTableIdxToScan]->scanRelDataType ==
storage::ScanRelDataType::COLUMNS) {
if (tableScanStates[currentRelTableIdxToScan]->relTableDataType ==
storage::RelTableDataType::COLUMNS) {
outputVectors[0]->state->selVector->resetSelectorToValuePosBufferWithSize(1);
outputVectors[0]->state->selVector->selectedPositions[0] =
inVector->state->selVector->selectedPositions[0];
Expand All @@ -42,10 +42,10 @@ bool RelTableCollection::scan(const shared_ptr<ValueVector>& inVector,
}

unique_ptr<RelTableCollection> RelTableCollection::clone() const {
vector<unique_ptr<ScanRelTableState>> clonedScanStates;
vector<unique_ptr<RelTableScanState>> clonedScanStates;
for (auto& scanState : tableScanStates) {
clonedScanStates.push_back(make_unique<ScanRelTableState>(
scanState->boundNodeTableID, scanState->propertyIds, scanState->scanRelDataType));
clonedScanStates.push_back(make_unique<RelTableScanState>(
scanState->boundNodeTableID, scanState->propertyIds, scanState->relTableDataType));
}
return make_unique<RelTableCollection>(tables, std::move(clonedScanStates));
}
Expand Down
4 changes: 2 additions & 2 deletions src/storage/store/rel_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void DirectedRelTableData::initializeListsForBoundNodeTabl(RelTableSchema* table
}
}

void DirectedRelTableData::scanColumns(Transaction* transaction, ScanRelTableState& scanState,
void DirectedRelTableData::scanColumns(Transaction* transaction, RelTableScanState& scanState,
const shared_ptr<ValueVector>& inNodeIDVector, vector<shared_ptr<ValueVector>>& outputVectors) {
auto adjColumn = adjColumns.at(scanState.boundNodeTableID).get();
// Note: The scan operator should guarantee that the first property in the output is adj column.
Expand All @@ -108,7 +108,7 @@ void DirectedRelTableData::scanColumns(Transaction* transaction, ScanRelTableSta
}
}

void DirectedRelTableData::scanLists(Transaction* transaction, ScanRelTableState& scanState,
void DirectedRelTableData::scanLists(Transaction* transaction, RelTableScanState& scanState,
const shared_ptr<ValueVector>& inNodeIDVector, vector<shared_ptr<ValueVector>>& outputVectors) {
auto adjList = getAdjLists(scanState.boundNodeTableID);
if (scanState.syncState->isBoundNodeOffsetInValid()) {
Expand Down

0 comments on commit 124cb6f

Please sign in to comment.