Skip to content

Commit

Permalink
Two speedups to IndexNameExpressionResolver
Browse files Browse the repository at this point in the history
Two obvious speedups to the IndexNameExpressionResolver where we can
defer an expensive lookup from either the indices lookup or the thread
context to if and when we actually need it.
  • Loading branch information
original-brownbear committed Sep 4, 2024
1 parent 87e257e commit 3dc1739
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,17 +567,14 @@ private static boolean shouldTrackConcreteIndex(Context context, IndicesOptions
// Exclude this one as it's a net-new system index, and we explicitly don't want those.
return false;
}
if (DataStream.isFailureStoreFeatureFlagEnabled()) {
IndexAbstraction indexAbstraction = context.getState().metadata().getIndicesLookup().get(index.getName());
if (context.options.allowFailureIndices() == false) {
DataStream parentDataStream = indexAbstraction.getParentDataStream();
if (parentDataStream != null && parentDataStream.isFailureStoreEnabled()) {
if (parentDataStream.isFailureStoreIndex(index.getName())) {
if (options.ignoreUnavailable()) {
return false;
} else {
throw new FailureIndexNotSupportedException(index);
}
if (DataStream.isFailureStoreFeatureFlagEnabled() && context.options.allowFailureIndices() == false) {
DataStream parentDataStream = context.getState().metadata().getIndicesLookup().get(index.getName()).getParentDataStream();
if (parentDataStream != null && parentDataStream.isFailureStoreEnabled()) {
if (parentDataStream.isFailureStoreIndex(index.getName())) {
if (options.ignoreUnavailable()) {
return false;
} else {
throw new FailureIndexNotSupportedException(index);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,10 @@ public static SystemIndexAccessLevel getSystemIndexAccessLevel(ThreadContext thr
// This method intentionally cannot return BACKWARDS_COMPATIBLE_ONLY - that access level should only be used manually
// in known special cases.
final String headerValue = threadContext.getHeader(SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY);
final String productHeaderValue = threadContext.getHeader(EXTERNAL_SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY);

final boolean allowed = Booleans.parseBoolean(headerValue, true);
if (allowed) {
if (productHeaderValue != null) {
if (threadContext.getHeader(EXTERNAL_SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY) != null) {
return SystemIndexAccessLevel.RESTRICTED;
} else {
return SystemIndexAccessLevel.ALL;
Expand Down

0 comments on commit 3dc1739

Please sign in to comment.