Class QueryStringManipulator
- java.lang.Object
-
- com.microstrategy.utils.querydetails.QueryStringManipulator
-
- Direct Known Subclasses:
RwQueryDetailHandler
public class QueryStringManipulator extends java.lang.Object
THIS CLASS IS NOT SUPPORTED FOR USE IN CUSTOM APPLICATION DEVELOPMENT. THE CLASS IS SUBJECT TO CHANGE IN FUTURE RELEASES AND SOME METHODS AND PROPERTIES MAY NOT BE SUITABLE FOR CUSTOM DEVELOPMENT. Query string manipulation methods from Integrity Manager It provides the functionality for extract info, split SQL, find CSI, align two query (for comparison) from query strings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
QueryStringManipulator.StatementIndex
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEYWORD_SQL_END
static java.lang.String
KEYWORD_SQL_START
protected static java.util.regex.Pattern
MDX_STATEMENTS_PASS_PATTERN
static java.util.regex.Pattern
PATTERN_TO_STATEMENT
protected java.lang.String
queryString
-
Constructor Summary
Constructors Constructor Description QueryStringManipulator(java.lang.String queryString)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String[]
alignBaseAndTargetQueries(java.lang.String base, java.lang.String target)
Align the base and target query string.java.util.List<java.lang.Integer>
findCsiEndIndexesByKeywordPatterns()
Find CSI end indexes from a query detail.protected java.util.List<java.lang.Integer>
findIndexesByKeywordPattern(java.util.regex.Pattern pattern)
protected java.util.List<java.lang.Integer>
findIndexesByKeywordPattern(java.util.regex.Pattern pattern, java.lang.String queryString)
protected java.util.List<java.lang.Integer>
findIndexesByKeywordPattern(java.util.regex.Pattern pattern, java.lang.String queryString, boolean shouldAtNewLine)
Find the indexes of the matched pattern.java.util.List<java.lang.Integer>
findMdxPassEndIndexesByPatterns(java.lang.String queryString)
Find mdx end indexes.java.util.List<java.lang.Integer>
findMdxPassStartIndexesByPatterns(java.lang.String mdxString)
Find mdx start indexes.java.util.List<QueryStringManipulator.StatementIndex>
findMdxStatementsStartIndexesByPatterns()
Find mdx start indexes.java.util.List<java.lang.Integer>
findSinglePassQueryStartIndexesByPatterns()
Find start indexes of a single pass query.java.util.List<java.lang.Integer>
findSinglePassQueryStartIndexesByPatterns(java.lang.String queryString)
Find start indexes of a single pass query.java.util.List<java.lang.Integer>
findSinglePassQueryStartIndexesByPatterns(java.lang.String queryString, boolean shouldStarAtNewLine)
Find start indexes of a single pass query.java.util.List<java.lang.Integer>
findSqlPassEndIndexesByPatterns(java.lang.String queryString)
Find sql passes end indexes.java.util.List<java.lang.Integer>
findSqlPassStartIndexesByPatterns(java.lang.String sqlString)
Find sql passes start indexes.java.util.List<QueryStringManipulator.StatementIndex>
findSqlStatementsStartIndexesByPatterns()
Find statement start indexes.java.util.List<QueryStringManipulator.StatementIndex>
findStatementStartIndexesByPatterns(java.util.Map<java.lang.String,java.util.regex.Pattern> patterns, QueryStringManipulator.StatementIndex.StatementType type)
Find statement start indexes.protected java.util.List<QueryStringManipulator.StatementIndex>
mergeStatementIndex(java.util.List<QueryStringManipulator.StatementIndex> dest, java.util.List<java.lang.Integer> source)
protected java.util.List<QueryStringManipulator.StatementIndex>
mergeStatementIndex(java.util.List<QueryStringManipulator.StatementIndex> dest, java.util.List<java.lang.Integer> source, QueryStringManipulator.StatementIndex.StatementType type)
protected java.lang.String
removeNoisesFromStatement(java.lang.String statement)
void
setServerLocale(java.util.Set<java.util.Locale> serverLocale)
static java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Integer>>
splitQueryStrings(java.lang.String queryStrings)
Split a multi-pass query strings into an array.static java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Integer>>
splitQueryStrings(java.lang.String queryStrings, boolean shouldStartAtNewLine)
Split a multi-pass query strings into an array.protected java.lang.String
wrangleMdxSnippetFoundAmongQueryDetail(java.lang.String statement)
protected java.lang.String
wrangleSqlSnippetFoundAmongQueryDetail(java.lang.String statement)
protected java.lang.String
wrangleStatementsSnippetFoundAmongQueryDetail(java.lang.String statement, java.util.function.Function<java.lang.String,java.util.List<java.lang.Integer>> sqlPassStartIndexesFinder, java.util.function.Function<java.lang.String,java.util.List<java.lang.Integer>> sqlPassEndIndexesFinder)
-
-
-
Field Detail
-
KEYWORD_SQL_START
public static final java.lang.String KEYWORD_SQL_START
- See Also:
- Constant Field Values
-
KEYWORD_SQL_END
public static final java.lang.String KEYWORD_SQL_END
- See Also:
- Constant Field Values
-
PATTERN_TO_STATEMENT
public static final java.util.regex.Pattern PATTERN_TO_STATEMENT
-
MDX_STATEMENTS_PASS_PATTERN
protected static final java.util.regex.Pattern MDX_STATEMENTS_PASS_PATTERN
-
queryString
protected java.lang.String queryString
-
-
Method Detail
-
splitQueryStrings
public static java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Integer>> splitQueryStrings(java.lang.String queryStrings)
Split a multi-pass query strings into an array.- Parameters:
queryStrings
- The query string to split.- Returns:
- A list of pairs, each of which represents (the string, the offsets in the original string).
-
splitQueryStrings
public static java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.Integer>> splitQueryStrings(java.lang.String queryStrings, boolean shouldStartAtNewLine)
Split a multi-pass query strings into an array.- Parameters:
queryStrings
- The query string to split.- Returns:
- A list of pairs, each of which represents (the string, the offsets in the original string).
-
findSinglePassQueryStartIndexesByPatterns
public java.util.List<java.lang.Integer> findSinglePassQueryStartIndexesByPatterns()
Find start indexes of a single pass query.- Returns:
- The indexes.
-
findSinglePassQueryStartIndexesByPatterns
public java.util.List<java.lang.Integer> findSinglePassQueryStartIndexesByPatterns(java.lang.String queryString)
Find start indexes of a single pass query.- Returns:
- The indexes.
-
findSinglePassQueryStartIndexesByPatterns
public java.util.List<java.lang.Integer> findSinglePassQueryStartIndexesByPatterns(java.lang.String queryString, boolean shouldStarAtNewLine)
Find start indexes of a single pass query.- Parameters:
shouldStarAtNewLine
- The query should start at a new line after at least one empty line.- Returns:
- The indexes.
-
findStatementStartIndexesByPatterns
public java.util.List<QueryStringManipulator.StatementIndex> findStatementStartIndexesByPatterns(java.util.Map<java.lang.String,java.util.regex.Pattern> patterns, QueryStringManipulator.StatementIndex.StatementType type)
Find statement start indexes. Usually, they start with SQL Statements: or MDX Statements:.- Returns:
- The indexes.
-
findSqlStatementsStartIndexesByPatterns
public java.util.List<QueryStringManipulator.StatementIndex> findSqlStatementsStartIndexesByPatterns()
Find statement start indexes.- Returns:
- The indexes.
-
findSqlPassStartIndexesByPatterns
public java.util.List<java.lang.Integer> findSqlPassStartIndexesByPatterns(java.lang.String sqlString)
Find sql passes start indexes.- Returns:
- The indexes.
-
findSqlPassEndIndexesByPatterns
public java.util.List<java.lang.Integer> findSqlPassEndIndexesByPatterns(java.lang.String queryString)
Find sql passes end indexes.- Returns:
- The indexes.
-
findMdxStatementsStartIndexesByPatterns
public java.util.List<QueryStringManipulator.StatementIndex> findMdxStatementsStartIndexesByPatterns()
Find mdx start indexes.- Returns:
- The indexes.
-
findMdxPassStartIndexesByPatterns
public java.util.List<java.lang.Integer> findMdxPassStartIndexesByPatterns(java.lang.String mdxString)
Find mdx start indexes.- Returns:
- The indexes.
-
findMdxPassEndIndexesByPatterns
public java.util.List<java.lang.Integer> findMdxPassEndIndexesByPatterns(java.lang.String queryString)
Find mdx end indexes.- Returns:
- The indexes.
-
mergeStatementIndex
protected java.util.List<QueryStringManipulator.StatementIndex> mergeStatementIndex(java.util.List<QueryStringManipulator.StatementIndex> dest, java.util.List<java.lang.Integer> source)
-
mergeStatementIndex
protected java.util.List<QueryStringManipulator.StatementIndex> mergeStatementIndex(java.util.List<QueryStringManipulator.StatementIndex> dest, java.util.List<java.lang.Integer> source, QueryStringManipulator.StatementIndex.StatementType type)
-
wrangleStatementsSnippetFoundAmongQueryDetail
protected java.lang.String wrangleStatementsSnippetFoundAmongQueryDetail(java.lang.String statement, java.util.function.Function<java.lang.String,java.util.List<java.lang.Integer>> sqlPassStartIndexesFinder, java.util.function.Function<java.lang.String,java.util.List<java.lang.Integer>> sqlPassEndIndexesFinder)
-
wrangleSqlSnippetFoundAmongQueryDetail
protected java.lang.String wrangleSqlSnippetFoundAmongQueryDetail(java.lang.String statement)
-
wrangleMdxSnippetFoundAmongQueryDetail
protected java.lang.String wrangleMdxSnippetFoundAmongQueryDetail(java.lang.String statement)
-
removeNoisesFromStatement
protected java.lang.String removeNoisesFromStatement(java.lang.String statement)
-
findCsiEndIndexesByKeywordPatterns
public java.util.List<java.lang.Integer> findCsiEndIndexesByKeywordPatterns()
Find CSI end indexes from a query detail.- Returns:
- The indexes.
-
findIndexesByKeywordPattern
protected java.util.List<java.lang.Integer> findIndexesByKeywordPattern(java.util.regex.Pattern pattern)
-
findIndexesByKeywordPattern
protected java.util.List<java.lang.Integer> findIndexesByKeywordPattern(java.util.regex.Pattern pattern, java.lang.String queryString)
-
findIndexesByKeywordPattern
protected java.util.List<java.lang.Integer> findIndexesByKeywordPattern(java.util.regex.Pattern pattern, java.lang.String queryString, boolean shouldAtNewLine)
Find the indexes of the matched pattern.- Parameters:
pattern
- The pattern.queryString
- The string to query.shouldAtNewLine
- The pattern should be at the start of a new line right after an empty line.- Returns:
- The indexes found.
-
alignBaseAndTargetQueries
public static java.lang.String[] alignBaseAndTargetQueries(java.lang.String base, java.lang.String target)
Align the base and target query string.- Parameters:
base
- The base query string.target
- The target query string.- Returns:
- A 2-dimension array which stores the aligned base and target query respectively.
-
setServerLocale
public void setServerLocale(java.util.Set<java.util.Locale> serverLocale)
-
-