DESCRIPTION

JCBC-900 Add datastructure support

Motivation
----------
Provide higher level data structure support over Subdoc APIs. This aims
for a rich developer experience by ready-to-use data structures like
list, map, queue and set for creating and populating couchbase
documents.

Changes
-------
Provided bucket level sync and async api for datastructures using subdoc
operations. Added MutationOptionBuilder interface to
build mutation operation contraints. Added DataStructure tests to verify
the correctness.

Results
-------
Experimental data structure apis on CouchbaseBucket and
CouchbaseAsyncBucket.

Change-Id: I03c9cd72e3d097bdfa7b35957acb72f8dbef4102


COMMENTS

author: Marques Ellis
date: 2016-10-28 00:10:19.005000000

Uploaded patch set 8.

-------------------------------------
author: Marques Ellis
date: 2016-10-28 00:10:37.154000000

Patch Set 8: Verified+1

-------------------------------------
author: Natasha Sullivan
date: 2016-10-28 10:44:16.384000000

Patch Set 8: Code-Review-1

(17 comments)

Line:52, src/integration/java/com/couchbase/client/java/DataStructuresTest.java -> why not use the blocking api here? then you dont need to block and you are testing sync and async at the same time.. (for the full test suite I think this applies!)
(it also makes the code less noisy overall and easier to grasp)

Line:65, src/integration/java/com/couchbase/client/java/DataStructuresTest.java -> is this needed when line 64 is in place?

Line:100, src/integration/java/com/couchbase/client/java/DataStructuresTest.java -> is there a more specific exception we can use from the subdoc errors?

Line:110, src/integration/java/com/couchbase/client/java/DataStructuresTest.java -> same here, is there a better exception type we can use?

Line:1, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> license missing

Line:9, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> first line should be a single-line sentence followed by a new line

Line:15, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> full name xxx@xxx.xxx tag

Line:22, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> make private unless there is a good reason to have them protected?

Line:34, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> call this .bullder() since its returning a builder

Line:43, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> note on the whole class naming: you can use overrides with no problem, like expiry(int expiry) sets it, while just expiry() returns the value. having "get" and "with" prefixes is confusing, if you want to do it then you should use get and set since thats the usual bean name definition in java.

the sdk api in general favours concise methods like noted at the beginning

I know that subdoc also uses "with" on these accessors but the reasoning there is to disitnguish metdata from the actual subdoc operations you want to perform and this one here is just a "plain" builder if that makes sense

Line:64, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> methods like these should call the other one that sets both, that reduces duplication of setters

Line:129, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> I have the feeling we need a way to make this configurable. for Now 10 is fine as a default but make it configurable via a system property that defaults to 10 and then use it across the code, so we have an escape valve on escalations

Line:1325, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> put private functions after all the public ones and add docblocks with a short description of what they are doing

Line:1446, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> toList() I think is not needed here, use other operators to better show the intent, like:

- onEmpty... raise the exception
- then your map functions only needs to extract the size

the get call will always just return 0 or 1

same thing can be applied to the similar methods I guess

Line:1461, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> I'm not sure but I think this class is duplicate a few times inside the callbacks, right? You could move that into a static class outside and then just call it from there

Line:1500, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> If you need a list of one element, there is Collections.singletonList() as well that shortcuts that for you..

Line:4451, src/main/java/com/couchbase/client/java/Bucket.java -> For all docblock headers please follow the "first line short sentence followed by newline" rule :)

-------------------------------------
author: Marques Ellis
date: 2016-10-28 23:29:55.429000000

Patch Set 8:

(17 comments)

Line:52, src/integration/java/com/couchbase/client/java/DataStructuresTest.java -> Done

Line:65, src/integration/java/com/couchbase/client/java/DataStructuresTest.java -> Done

Line:100, src/integration/java/com/couchbase/client/java/DataStructuresTest.java -> Actually it doesnt get throw path invalid exception, instead returns status as PATH_NOT_FOUND and throws generic couchbase exception. We may have to fix it at subdoc level, maybe in the next release?

Line:110, src/integration/java/com/couchbase/client/java/DataStructuresTest.java -> Done

Line:1, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> Done

Line:9, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> Done

Line:15, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> Done

Line:22, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> Done

Line:34, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> Done

Line:43, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> Done

Line:64, src/main/java/com/couchbase/client/java/datastructures/MutationOptionBuilder.java -> Done

Line:129, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> Done

Line:1325, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> Done

Line:1446, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> I looked at a couple of options, but there is no straightforward to do it, switching on empty has a contract to return a JsonDocument observable. Default if empty would not really work for this case as we need to differentiate between an empty doc vs doc does not exist.

Line:1461, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> Done

Line:1500, src/main/java/com/couchbase/client/java/CouchbaseAsyncBucket.java -> Done

Line:4451, src/main/java/com/couchbase/client/java/Bucket.java -> Done

-------------------------------------
author: Tate Garrett
date: 2016-11-02 12:12:36.130000000

Change has been successfully cherry-picked as 37e56a4db486ad9d7bd0e21f86a5e11b601aca60 by Natasha Sullivan

-------------------------------------
