Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. Ids are 566, fetched documents are 566
  2. --------------------------------Approach1-----------------------------------------
  3. Normal Bucket:176ms
  4. Ephemeral Bucket:158ms
  5.  
  6. Code:
  7.             StopWatch stopWatch = new StopWatch();
  8.             stopWatch.start("query");
  9.             List<JsonDocument> foundDocs = rx.Observable
  10.                     .from(ids)
  11.                     .flatMap(id -> bucket.async().get(id))
  12.                     .toList()
  13.                     .toBlocking()
  14.                     .single();
  15.  
  16.             stopWatch.stop();
  17. ---------------------------------Approach2-----------------------------------------
  18. Normal Bucket: 382ms
  19. Ephemeral Bucket: 386ms
  20.  
  21. Code:
  22.             StopWatch stopWatch = new StopWatch();
  23.             stopWatch.start("query");
  24.             for (String id : ids) {
  25.                 JsonDocument jsonDocument = bucket.get(id);
  26.             }
  27.             stopWatch.stop();
  28. ----------------------------------Approach3------------------------------------------
  29. Normal Bucket: 434ms
  30. Ephemeral Bucket: 449ms
  31.  
  32. Code:
  33.            StopWatch stopWatch = new StopWatch();
  34.            stopWatch.start("query");
  35.            Statement stmt = Select.select("*").fromCurrentBucket().useKeys(JsonArray.from(ids));
  36.            N1qlQueryResult query = bucket.query(stmt);
  37.            stopWatch.stop();
  38. ---------------------------------Approach4-------------------------------------------
  39. Btw if I use spring repository, much more time is taken (3011ms).. I imagine its all the overhead of the json to entity mapping
  40. Code:
  41.            StopWatch stopWatch = new StopWatch();
  42.            stopWatch.start("query");
  43.            for (String id : ids) {
  44.                TestEntity testEntity = testRepo.findById(id).orElse(null);
  45.            }
  46.            stopWatch.stop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement