Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Add ResultSetRegistry storage [1/N] #331

Merged
merged 3 commits into from
Apr 3, 2023
Merged

Conversation

ienkovich
Copy link
Contributor

This first part introduces ResultSetRegistry to store execution results. We still don't use data and schema providers to access them, which will be introduced in the following patches.

Here is the list of changes:

  • Add ResultSetRegistry storage to hold execution results. RelAlgExecutor puts execution results there
  • Replace TemporaryTable structure with ResultSetTable and ResultSetTableToken. A token is used to access actual ResultSet objects. It also holds database id and table id to later access data and schema through providers. The execution result is removed from the registry when its token is destroyed
  • ExecutionResult now holds a token instead of ResultSet objects
  • ColumnarResults is moved to the new library because it is still used to columnarize result data when zero-copy fetch or a simple copy cannot be used
  • Column names are added to the ResultSet structure to have full schema information in it. It will be important later when we enable query execution on result sets

@ienkovich ienkovich force-pushed the ienkovihc/rs-registry-01 branch from 774bcce to a9efe32 Compare March 29, 2023 02:16

add_library(ResultSetRegistry ${result_set_registry_source_files})

target_link_libraries(ResultSetRegistry SchemaMgr ResultSet StringDictionary DataMgr IR Shared Logger Utils)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the DataMgr is included in the ResultSetReginstry.h, so it should be a public dependency. Can others be private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many headers included in the ResultSetRegistry.h which include headers from DataProvider, ResultSet, SchemaMgr, Shared. How do you determine only DataMgr should be public?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was simply the first on the list. I didn't mean it has to be the only one. Rather, I wondered if we can hide any.

Signed-off-by: ienkovich <[email protected]>
@ienkovich ienkovich requested a review from kurapov-peter March 30, 2023 19:21
CHECK(tables_.count(token.tableId()));
std::unique_ptr<TableData> table = std::move(tables_.at(token.tableId()));
mapd_unique_lock<mapd_shared_mutex> table_lock(table->mutex);
tables_.erase(token.tableId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that you hold data_mutex_ here to prevent map rebalancing? Would it be possible to change the container (to limit pointers invalidation) and narrow the lock scope? I'm not sure it's too important, just a note.

Copy link
Contributor Author

@ienkovich ienkovich Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it matters much which exact structure we use for tables_. We would still need a lock to read/write this structure. And the fact that this map holds unique_ptr with table data allows us to release the lock once table data is found and a table lock is obtained. So I usually do data_lock.unlock(); when the required table is locked and the scope of this global data lock shouldn't be too big.

Copy link
Contributor

@kurapov-peter kurapov-peter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ienkovich ienkovich merged commit 46c3384 into main Apr 3, 2023
@ienkovich ienkovich deleted the ienkovihc/rs-registry-01 branch April 3, 2023 17:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants