@Test public void testFactory() throws Exception { TestUtils.assertMemoryLeak(() -> { final int N = 100; try (TableModel model = new TableModel(configuration, "x", PartitionBy.DAY). col("a", ColumnType.STRING). col("b", ColumnType.SYMBOL).indexed(true, N / 4). col("i", ColumnType.INT). col("c", ColumnType.SYMBOL).indexed(true, N / 4). timestamp() ) { CairoTestUtils.create(model); } final Rnd rnd = new Rnd(); final String[] symbols = new String[N]; final int M = 1000; final long increment = 1000000 * 60L * 10; for (int i = 0; i < N; i++) { symbols[i] = rnd.nextChars(8).toString(); } long timestamp = 0; try (TableWriter writer = new TableWriter(configuration, "x")) { for (int i = 0; i < M; i++) { TableWriter.Row row = writer.newRow(timestamp += increment); row.putStr(0, rnd.nextChars(20)); row.putSym(1, symbols[rnd.nextPositiveInt() % N]); row.putInt(2, rnd.nextInt()); row.putSym(3, symbols[rnd.nextPositiveInt() % N]); row.append(); } writer.commit(); } try (CairoEngine engine = new CairoEngine(configuration)) { FullFwdDataFrameCursorFactory factory = new FullFwdDataFrameCursorFactory(engine, "x", 0); long count = 0; try (DataFrameCursor cursor = factory.getCursor(AllowAllCairoSecurityContext.INSTANCE)) { DataFrame frame; while ((frame = cursor.next()) != null) { count += frame.getRowHi() - frame.getRowLo(); } } Assert.assertEquals(0, engine.getBusyReaderCount()); Assert.assertEquals(M, count); try (TableWriter writer = engine.getWriter(AllowAllCairoSecurityContext.INSTANCE, "x")) { writer.removeColumn("b"); } try { factory.getCursor(AllowAllCairoSecurityContext.INSTANCE); Assert.fail(); } catch (ReaderOutOfDateException ignored) { } } }); }
@Override public DataFrameCursor getCursor(CairoSecurityContext securityContext) { return cursor.of(getReader(securityContext)); }
FullFwdDataFrameCursorFactory extends AbstractDataFrameCursorFactory { @Override public DataFrameCursor getCursor(CairoSecurityContext securityContext) { return cursor.of(getReader(securityContext)); } }
FullFwdDataFrameCursorFactory extends AbstractDataFrameCursorFactory { @Override public DataFrameCursor getCursor(CairoSecurityContext securityContext) { return cursor.of(getReader(securityContext)); } FullFwdDataFrameCursorFactory(CairoEngine engine, String tableName, long tableVersion); }
FullFwdDataFrameCursorFactory extends AbstractDataFrameCursorFactory { @Override public DataFrameCursor getCursor(CairoSecurityContext securityContext) { return cursor.of(getReader(securityContext)); } FullFwdDataFrameCursorFactory(CairoEngine engine, String tableName, long tableVersion); @Override DataFrameCursor getCursor(CairoSecurityContext securityContext); }
FullFwdDataFrameCursorFactory extends AbstractDataFrameCursorFactory { @Override public DataFrameCursor getCursor(CairoSecurityContext securityContext) { return cursor.of(getReader(securityContext)); } FullFwdDataFrameCursorFactory(CairoEngine engine, String tableName, long tableVersion); @Override DataFrameCursor getCursor(CairoSecurityContext securityContext);  }