Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

seanlobo
Copy link

I encapsulated some tables via Cassandra set and map collections. This uses fewer reads when accessing the data, which should be best practice.

@vsreekanti
Copy link
Member

The Travis CI build failed. @seanlobo, you can see the failing tests here.

@@ -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>
Copy link
Member

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.

Copy link
Author

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;
Copy link
Member

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());
Copy link
Member

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.

Copy link
Author

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

/**
Copy link
Member

Choose a reason for hiding this comment

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

Formatting.

Copy link
Author

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)
Copy link
Member

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?

Copy link
Author

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

/**
Copy link
Member

Choose a reason for hiding this comment

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

Formatting.

Copy link
Author

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

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Too indented.

Copy link
Author

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>();
Copy link
Contributor

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.

Copy link
Author

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());
Copy link
Contributor

@kevinji kevinji Apr 14, 2017

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.

Copy link
Author

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

@seanlobo seanlobo force-pushed the cassandra-schema branch from 3be7de3 to af28a05 Compare May 3, 2017 05:49
@codecov-io
Copy link

codecov-io commented May 3, 2017

Codecov Report

Merging #72 into master will decrease coverage by 0.15%.
The diff coverage is 85.84%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
...cassandra/CassandraLineageGraphVersionFactory.java 100% <100%> (+2.43%) 5 <0> (-1) ⬇️
...ns/cassandra/CassandraVersionSuccessorFactory.java 94% <100%> (+1.14%) 10 <3> (+3) ⬆️
...models/cassandra/CassandraGraphVersionFactory.java 100% <100%> (+2.7%) 5 <0> (-1) ⬇️
...s/cassandra/CassandraVersionHistoryDagFactory.java 100% <100%> (ø) 12 <1> (-2) ⬇️
app/db/CassandraResults.java 81.48% <33.33%> (-13.76%) 13 <2> (+2)
app/db/CassandraClient.java 88.61% <80.35%> (-6.91%) 21 <6> (+10)
...ls/cassandra/CassandraStructureVersionFactory.java 94.59% <90.9%> (-0.41%) 6 <0> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1f5130...a2ea3a8. Read the comment docs.

now accepts a list of columns to delete
@vsreekanti
Copy link
Member

Will merge this after porting the Cassandra schema over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants