Standalone fluent query-assertion builder. It is parameterized at construction with the CairoEngine, default SqlExecutionContext and a pre-assertion hook, and carries its own copies of the cursor-assertion and factory-memory-leak primitives so it does not depend on the test base clas
| 62 | * construction-time collaborators for a single assertion. |
| 63 | */ |
| 64 | public class QueryAssertion { |
| 65 | private static final double EPSILON = 0.000001; |
| 66 | private static final boolean[] FACTORY_TAGS = new boolean[MemoryTag.SIZE]; |
| 67 | private static final Log LOG = LogFactory.getLog(QueryAssertion.class); |
| 68 | private final long[] SNAPSHOT = new long[MemoryTag.SIZE]; |
| 69 | private final Runnable prepareHook; |
| 70 | private final CharSequence query; |
| 71 | private final LongList rows = new LongList(); |
| 72 | private final StringSink sink = new StringSink(); |
| 73 | private Class<?> baseFactoryClass; |
| 74 | private SqlCompiler compiler; |
| 75 | private SqlExecutionContext context; |
| 76 | private CharSequence ddl; |
| 77 | private CharSequence ddl2; |
| 78 | private ObjList<CharSequence> ddl2More; |
| 79 | private ObjList<CharSequence> ddlMore; |
| 80 | private CairoEngine engine; |
| 81 | private boolean expectSize; |
| 82 | private IntList expectedColumnTypes; |
| 83 | private CharSequence expectedPlan; |
| 84 | private CharSequence expectedTimestamp; |
| 85 | private TimestampOrder expectedTimestampOrder = TimestampOrder.ASC; |
| 86 | private RecordCursorFactory factory; |
| 87 | private boolean fullFatJoins; |
| 88 | private boolean isRandomAccessInferred; |
| 89 | private boolean isTimestampInferred; |
| 90 | private boolean leakCheck = true; |
| 91 | private long memoryUsage = -1; |
| 92 | private boolean memoryUsageCheck = true; |
| 93 | private boolean overridden; |
| 94 | private ObjList<CharSequence> planFragments; |
| 95 | private ObjList<CharSequence> planFragmentsAbsent; |
| 96 | private boolean sizeCanBeVariable; |
| 97 | private boolean supportsRandomAccess = true; |
| 98 | |
| 99 | public QueryAssertion(CairoEngine engine, SqlExecutionContext context, Runnable prepareHook, CharSequence query) { |
| 100 | this.engine = engine; |
| 101 | this.context = context; |
| 102 | this.prepareHook = prepareHook; |
| 103 | this.query = query; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * External-factory mode. The builder asserts {@code factory}, which the caller built and owns, instead |
| 108 | * of compiling SQL. It does NOT run the prepare hook, DDL, leak check, factory free, or the shared |
| 109 | * memory-snapshot accounting, and it asserts each cursor through caller-local scratch buffers, so it is |
| 110 | * safe to call concurrently from multiple worker threads. Pass the per-thread context via |
| 111 | * {@link #withContext(SqlExecutionContext)}. |
| 112 | */ |
| 113 | public QueryAssertion(CairoEngine engine, RecordCursorFactory factory) { |
| 114 | this.engine = engine; |
| 115 | this.context = null; |
| 116 | this.prepareHook = null; |
| 117 | this.query = null; |
| 118 | this.factory = factory; |
| 119 | this.leakCheck = false; |
| 120 | } |
| 121 |
nothing calls this directly
no test coverage detected
searching dependent graphs…