Copy a graph block for block, which is what AS COPY OF asked for - #207
Merged
Merged
Conversation
A graph created AS COPY OF another one used to be refused when the source held tables, because a props directory names the blocks its columns live in and a copy that walked them wrong would be a copy that read as data. It walks them right now, and the mirror of free_graph_storage is what says which ones there are: a table per table in the catalog, keeping the name and taking a new id, and per id the segments the old id addressed, read whole and written into blocks of their own. The copy is by value and shares nothing with the source. A copy that pointed at the same segments would be a second name for one graph and the first write to either would show up in both. Every segment block is copied byte for byte, so it costs a read and a write per block and no decode, and what a column holds is none of the copy's business: the labels, the validity, the key index, the CSR pair per group, the edge properties and the tombstones a node table has all carry over the same way. The directories are re-encoded, because a directory names the blocks its segments live in and those are now different blocks. The statistics carry over too, since the copy holds the same rows and gathering them again would read every column for numbers the file already has. AS COPY OF now also takes CURRENT_PROPERTY_GRAPH, which is the graph the statement is against, the same thing a USE clause names. That is what a copy of a loaded file means, and it is what the gql-compat case for GG05 uses, since what the working graph is called is the adapter's business. Nothing is published along the way. The table index and the statistics are staged and the checkpoint that stores the catalog makes all three visible together, so a copy that fails halfway leaves the file exactly as it was. A graph asked to be replaced by a copy of itself is refused rather than emptied, because a replacement frees what the old graph held before it writes the new one. optional/gg05/graph-as-copy-of-holds-the-rows passes, so the corpus is at 225 passing, was 224.
23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A graph created
AS COPY OFanother one used to be refused when the source held tables, because a props directory names the blocks its columns live in and a copy that walked them wrong would be a copy that read as data. It walks them right now, and the mirror offree_graph_storageis what says which ones there are: a table per table in the catalog, keeping the name and taking a new id, and per id the segments the old id addressed, read whole and written into blocks of their own.The copy is by value and shares nothing with the source. A copy that pointed at the same segments would be a second name for one graph and the first write to either would show up in both. Every segment block is copied byte for byte, so it costs a read and a write per block and no decode, and what a column holds is none of the copy's business: the labels, the validity, the key index, the CSR pair per group, the edge properties and the tombstones a node table has all carry over the same way. The directories are re-encoded, because a directory names the blocks its segments live in and those are now different blocks. The statistics carry over too, since the copy holds the same rows and gathering them again would read every column for numbers the file already has.
AS COPY OFnow also takesCURRENT_PROPERTY_GRAPH, which is the graph the statement is against, the same thing aUSEclause names. That is what a copy of a loaded file means, and it is what the gql-compat case for GG05 uses, since what the working graph is called is the adapter's business.Nothing is published along the way. The table index and the statistics are staged and the checkpoint that stores the catalog makes all three visible together, so a copy that fails halfway leaves the file exactly as it was. A graph asked to be replaced by a copy of itself is refused rather than emptied, because a replacement frees what the old graph held before it writes the new one.
Three tests: the storage one asserts the copy's blocks are different blocks holding the same bytes, entry for entry over both tables, and the session one asserts the copy answers the query the source answers and still does after the copy is dropped, which is what proves the blocks were its own. The paired harness change is tamnd/gql-compat#26, which adds
optional/gg05/graph-as-copy-of-holds-the-rows, and zu passes it: the corpus is at 225 passing, was 224.