-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GROUND-23] De-relationalize Cassandra schema #72
base: master
Are you sure you want to change the base?
Conversation
scripts/cassandra/cassandra.cql
Outdated
@@ -21,9 +21,12 @@ create table version ( | |||
create table version_successor ( | |||
id bigint PRIMARY KEY, | |||
from_version_id bigint, | |||
to_version_id bigint | |||
to_version_id bigint, | |||
item_id_set set<bigint> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a set
? Each version successor should only be a part of one Item
's DAG. The VersionHistoryDag
table was meant to be for quick access, but I'm not convinced that that's the case now that I think about it.
Regardless, there should just be one Item
id per VersionSuccessor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The item_id_set
has been updated to to store a single item_id
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.slf4j.Logger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports should stay in alphabetical order.
lineageEdgeVersionIds.add(lineageEdgeSet.getLong("lineage_edge_version_id")); | ||
} while (lineageEdgeSet.next()); | ||
} | ||
List<Long> lineageEdgeVersionIds = resultSet.getSet("lineage_edge_version_id_set", Long.class).stream().collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you create a new List
from a Set
instead of streaming? See this constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use the constructor
@@ -192,6 +276,63 @@ public void delete(List<DbDataContainer> predicates, String table) { | |||
this.session.execute(statement); | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -192,6 +276,63 @@ public void delete(List<DbDataContainer> predicates, String table) { | |||
this.session.execute(statement); | |||
} | |||
|
|||
/** | |||
* Deletes a column from a table (sets column to null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleting a column from a table sounds very different from changing it to null. I think setColumnValueToNull
might be a more apt name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation was a mistake, the method does actually delete columns. The docs (and method) has been updated
this.session.execute(statement); | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -84,6 +87,65 @@ public void insert(String table, List<DbDataContainer> insertValues) { | |||
this.session.execute(statement); | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too indented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
edgeInsertion.add(new DbDataContainer("edge_version_id", GroundType.LONG, edgeVersionId)); | ||
|
||
this.dbClient.insert("graph_version_edge", edgeInsertion); | ||
Set<Long> edge = new HashSet<Long>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think HashSet<>
is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
edgeVersionIds.add(edgeSet.getLong("edge_version_id")); | ||
} while (edgeSet.next()); | ||
} | ||
List<Long> edgeVersionIds = resultSet.getSet("edge_version_set", Long.class).stream().collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as Vikram's; new ArrayList<>(set)
should be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use the ArrayList constructor
Move table structure_version_attribute into map column of structure_version
Move graph_version_edge into set column of graph_version (edge_version_set)
Move lineage_graph_version_edge into lineage_graph_version (with set lineage_edge_version_id_set)
change item_id_set to a singular item_id
Codecov Report
@@ Coverage Diff @@
## master #72 +/- ##
============================================
- Coverage 85.1% 84.94% -0.16%
- Complexity 626 637 +11
============================================
Files 115 115
Lines 3027 3083 +56
Branches 223 222 -1
============================================
+ Hits 2576 2619 +43
- Misses 405 419 +14
+ Partials 46 45 -1
Continue to review full report at Codecov.
|
now accepts a list of columns to delete
Will merge this after porting the Cassandra schema over. |
I encapsulated some tables via Cassandra set and map collections. This uses fewer reads when accessing the data, which should be best practice.