Add Datatypes examples to Spanner sample.#1498
Conversation
| } | ||
|
|
||
| /** Class to contain venue sample data. */ | ||
| static class Venue { |
There was a problem hiding this comment.
I'm ok w/ this for the sample, but best practice is implementing equals, hashcode, and clone.
(and yes, I rarely do that) See effective Java for details (I'll send an internal link)
lesv
left a comment
There was a problem hiding this comment.
A lot of nits on my part, nothing that should block, but a lot that you should consider.
| List<Mutation> mutations = new ArrayList<>(); | ||
| for (Venue venue : VENUES) { | ||
| mutations.add( | ||
| Mutation.newInsertBuilder("Venues") |
There was a problem hiding this comment.
Ok, but it would be more readable as
.set("VenueId").to(venue.venueId)
.set("VenueName").to(venue.venueName)
...
| /** Class to contain venue sample data. */ | ||
| static class Venue { | ||
|
|
||
| final long venueId; |
There was a problem hiding this comment.
If the class is Venue, then why mention in on each member? Your going to type it a lot?
There was a problem hiding this comment.
Leaving as is for now.
| boolean exampleBool = true; | ||
| Statement statement = | ||
| Statement.newBuilder( | ||
| "SELECT VenueId, VenueName, OutdoorVenue FROM Venues \n" |
There was a problem hiding this comment.
Does spanner require the \n ? if not, why is it here?
| BaseEncoding.base64().encode("Hello World 1".getBytes())); | ||
| Statement statement = | ||
| Statement.newBuilder( | ||
| "SELECT VenueId, VenueName FROM Venues \n" |
| .bind("outdoorVenue") | ||
| .to(exampleBool) | ||
| .build(); | ||
| // We use a try-with-resource block to automatically release resources held by ResultSet. |
There was a problem hiding this comment.
This has been in the language for a while, it really doesn't need to be called out every time it's used.
lesv
left a comment
There was a problem hiding this comment.
LGTM - but consider testing impact.
| id.getInstanceId().getInstance(), | ||
| id.getDatabase(), | ||
| Arrays.asList( | ||
| "CREATE TABLE Venues (" |
There was a problem hiding this comment.
Probably ok for the sample, but might make testing difficult at times. (using a dynamic table name would be better)
No description provided.