-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce QueryResult class for QueryEngine caching (#1333)
* Make QueryEngine cache bypass flag part of Query * Forming the cache key is not free, so don't a use stub cache * Add QueryResult class * Add pageTotals to QueryResult * Pass page totals through QueryResult instead of Pagination * Codacy doesn't know @value makes fields private
- Loading branch information
Showing
15 changed files
with
173 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ation/src/main/java/com/yahoo/elide/datastores/aggregation/query/ImmutablePagination.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2020, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
|
||
package com.yahoo.elide.datastores.aggregation.query; | ||
|
||
import com.yahoo.elide.request.Pagination; | ||
|
||
import lombok.Value; | ||
|
||
/** | ||
* An immutable Pagination. Doesn't support getPageTotals/setPageTotals; page totals must be returned via QueryResult. | ||
*/ | ||
@Value | ||
public class ImmutablePagination implements Pagination { | ||
|
||
private int offset; | ||
private int limit; | ||
private boolean defaultInstance; | ||
private boolean returnPageTotals; | ||
|
||
public static ImmutablePagination from(Pagination src) { | ||
if (src instanceof ImmutablePagination) { | ||
return (ImmutablePagination) src; | ||
} else if (src != null) { | ||
return new ImmutablePagination( | ||
src.getOffset(), src.getLimit(), src.isDefaultInstance(), src.returnPageTotals()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean returnPageTotals() { | ||
return returnPageTotals; | ||
} | ||
|
||
@Override | ||
public Long getPageTotals() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setPageTotals(Long pageTotals) { | ||
throw new UnsupportedOperationException("ImmutablePagination does not support setPageTotals"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...e-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/query/QueryResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2019, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
package com.yahoo.elide.datastores.aggregation.query; | ||
|
||
import com.yahoo.elide.datastores.aggregation.QueryEngine; | ||
import com.yahoo.elide.request.Pagination; | ||
|
||
import lombok.Builder; | ||
import lombok.NonNull; | ||
import lombok.Value; | ||
|
||
/** | ||
* A {@link QueryResult} contains the results from {@link QueryEngine#executeQuery(Query)}. | ||
*/ | ||
@Value | ||
@Builder | ||
public class QueryResult { | ||
@NonNull | ||
private Iterable<Object> data; | ||
|
||
/** | ||
* Total record count. Null unless Query had Pagination with {@link Pagination#returnPageTotals()} set. | ||
*/ | ||
private Long pageTotals; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.