For Coundberry Server: it aims to add a new api so that Twittermap server can check whether a query can solve by view (cached result) or not.
For Twittermap application: it aims to disable the button of sidebar when view is not established. And enable sidebar when query can solved by the view. It can improve the user experience about content in the sidebar.
Implementation
For cloudberry
RequestRouter.scala
Make the name of client and other variable names more general.
Cloudberry.scala
Add new web socket for checking whether a query can be solved by view.
routes
Add address for new api in routes
JsonParser.scala
Add a function to get queryID
QueryPlanner.scala
Add a function to return whether there is matched views for a query.
Extract a function to find the matched views for a query.
ViewStatusClientTest.scala
Three tests for ViewSatusClient.
ViewStatusClient.scala1. This is a reactive client which checks whether a query can be solved by the existed view.
2. When client receiving message: parse the json to queries, and for each query let planner to decide whether it can be solved by view.
3. Return the "isQuerySolvableByView" result with queryID to frontend
For twittermap
TwitterMapApplication.scala
Add a WebSocket that send query to Cloudberry
application.conf, common/services.js, routes
Add related address for new api
index.scala.html
Add id for sidebar button.
sidebar/controllers.js1. Add a WebSocket that send query to Cloudberry
2. When the keywords changed, we need to: clear previous timer, close and disable sidebar, and set a new timer for new keywords. The timer sends query to check whether it is solvable, every one second.
3. When receiving messages from websocket, check its queryID and result. If queryID is matched and result is true, enable the sidebar button and clear timer.
Result
In this demo:
"code" is a keyword without cached view
"water" is a keyword already cached.
Resources
To add an api to Cloudberry, and let Twittermap communicate with it, some related document of the Play Framework, and akka Framework may be help.
To Do List
[x] Add a socket in Twittermap to sent query to Cloudberry
[x] Add a entry in Cloudberry to receive the query from client
[x] Add a ViewStatusClient in Cloudberry to check whether a query can solve by view
Overview
Implementation
For cloudberry
ViewStatusClient.scala 1. This is a reactive client which checks whether a query can be solved by the existed view. 2. When client receiving message: parse the json to queries, and for each query let planner to decide whether it can be solved by view. 3. Return the "isQuerySolvableByView" result with queryID to frontend
For twittermap
Result
In this demo:
Resources
To add an api to Cloudberry, and let Twittermap communicate with it, some related document of the Play Framework, and akka Framework may be help.
To Do List
Add a socket in Twittermap to sent query to CloudberryAdd a entry in Cloudberry to receive the query from clientAdd a ViewStatusClient in Cloudberry to check whether a query can solve by viewDisable sidebar button when view not existsSet timer to send query