Skip to content

Instantly share code, notes, and snippets.

@phantomjinx
Last active August 29, 2015 14:09
Show Gist options
  • Save phantomjinx/b19b30235c9465e5d0c6 to your computer and use it in GitHub Desktop.
Save phantomjinx/b19b30235c9465e5d0c6 to your computer and use it in GitHub Desktop.
private static Pattern CACHE_HINT = Pattern.compile("/\\*\\+?\\s*cache(\\(\\s*(pref_mem)?\\s*(ttl:\\d{1,19})?\\s*(updatable)?\\s*(scope:(session|vdb|user))?[^\\)]*\\))?[^\\*]*\\*\\/.*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); //$NON-NLS-1$
static CacheHint getQueryCacheOption(String query) {
Matcher match = CACHE_HINT.matcher(query);
if (match.matches()) {
CacheHint hint = new CacheHint();
if (match.group(2) !=null) {
hint.setPrefersMemory(true);
}
String ttl = match.group(3);
if (ttl != null) {
hint.setTtl(Long.valueOf(ttl.substring(4)));
}
if (match.group(4) != null) {
hint.setUpdatable(true);
}
String scope = match.group(5);
if (scope != null) {
scope = scope.substring(6);
hint.setScope(scope);
}
return hint;
}
return null;
}
engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java: container.setCacheHint(c.getCacheHint());
engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java: query.setCacheHint(hint);
engine/src/main/java/org/teiid/query/parser/QueryParser.java: result.setCacheHint(SQLParserUtil.getQueryCacheOption(sql));
engine/src/main/java/org/teiid/query/parser/QueryParser.java: result.setCacheHint(SQLParserUtil.getQueryCacheOption(sql));
engine/src/main/java/org/teiid/query/sql/lang/Command.java: public void setCacheHint(CacheHint cacheHint) {
engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java: public void setCacheHint(CacheHint cacheHint) {
engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java: id.setCacheHint(hint);
engine/src/main/java/org/teiid/query/tempdata/GlobalTableStoreImpl.java: id.setCacheHint(hint);
engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java: proc.setCacheHint(null);
odata/src/main/java/org/teiid/odata/LocalClient.java: query.setCacheHint(hint);
olingo/src/main/java/org/teiid/olingo/LocalClient.java: query.setCacheHint(hint);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment