You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2021/07/06 13:16:32 UTC

[GitHub] [drill] Leon-WTF commented on pull request #2225: DRILL-7922: Add import profile function

Leon-WTF commented on pull request #2225:
URL: https://github.com/apache/drill/pull/2225#issuecomment-874750796


   Thanks congļ¼Œjust if we use queryId as the cache key, it may conflict when two users upload different profile jsons with same query id at the same time(Though this may be a rare condition). What do you think?
   
   > @Leon-WTF Hi. I think we made things complicated. There is a suggestion to revise :
   > 
   > 1. Define the cache above the `getProfileJSON(@PathParam("queryid") String queryId)`
   > 
   > ```java
   >   // provide cache for view the profile
   >   private static final Cache<String, String> PROFILE_CACHE =
   >       CacheBuilder
   >         .newBuilder()
   >           .expireAfterAccess(1, TimeUnit.MINUTES)
   >             .build();
   > ```
   > 
   > 1. Add the if-else in the `getProfileJSON(@PathParam("queryid") String queryId)`
   > 
   > ```java
   > String content = PROFILE_CACHE.getIfPresent(queryId);
   > if (content == null) {
   >  // return the new
   > } else {
   >   PROFILE_CACHE.invalidate(queryId);
   >   // then, return the cache
   > }
   > ```
   > 
   > 1. Cache the data in the `viewProfile(@FormDataParam(PROFILE_DATA) String content)`
   > 
   > ```java
   > PROFILE_CACHE.put(profile.getQueryId(), content);
   > ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org