Search in sources :

Example 6 with FilesFacade

use of io.questdb.std.FilesFacade in project questdb by bluestreak01.

the class O3CopyJob method updatePartition.

private static void updatePartition(long timestampMergeIndexAddr, long srcDataMax, long srcOooMax, long srcOooPartitionLo, long srcOooPartitionHi, long timestampMin, long timestampMax, long partitionTimestamp, long srcTimestampFd, long srcTimestampAddr, long srcTimestampSize, boolean partitionMutates, TableWriter tableWriter) {
    final FilesFacade ff = tableWriter.getFilesFacade();
    O3Utils.unmap(ff, srcTimestampAddr, srcTimestampSize);
    try {
        try {
            O3Utils.close(ff, srcTimestampFd);
        } finally {
            notifyWriter(srcOooPartitionLo, srcOooPartitionHi, timestampMin, timestampMax, partitionTimestamp, srcOooMax, srcDataMax, partitionMutates, tableWriter);
        }
    } finally {
        if (timestampMergeIndexAddr != 0) {
            Vect.freeMergedIndex(timestampMergeIndexAddr);
        }
        tableWriter.o3CountDownDoneLatch();
    }
}
Also used : FilesFacade(io.questdb.std.FilesFacade)

Example 7 with FilesFacade

use of io.questdb.std.FilesFacade in project questdb by bluestreak01.

the class AbstractCairoTest method assertMemoryLeak.

protected static void assertMemoryLeak(@Nullable FilesFacade ff, TestUtils.LeakProneCode code) throws Exception {
    final FilesFacade ff2 = ff;
    TestUtils.assertMemoryLeak(() -> {
        AbstractCairoTest.ff = ff2;
        try {
            code.run();
            engine.releaseInactive();
            Assert.assertEquals(0, engine.getBusyWriterCount());
            Assert.assertEquals(0, engine.getBusyReaderCount());
        } finally {
            engine.clear();
            AbstractCairoTest.ff = null;
        }
    });
}
Also used : FilesFacade(io.questdb.std.FilesFacade)

Example 8 with FilesFacade

use of io.questdb.std.FilesFacade in project questdb by bluestreak01.

the class SqlCodeGeneratorTest method testLatestByIOFailure.

@Test
public void testLatestByIOFailure() throws Exception {
    assertMemoryLeak(() -> {
        FilesFacade ff = new FilesFacadeImpl() {

            @Override
            public long openRO(LPSZ name) {
                if (Chars.endsWith(name, "b.d")) {
                    return -1;
                }
                return super.openRO(name);
            }
        };
        CairoConfiguration configuration = new DefaultCairoConfiguration(root) {

            @Override
            public FilesFacade getFilesFacade() {
                return ff;
            }
        };
        try (CairoEngine engine = new CairoEngine(configuration);
            SqlCompiler compiler = new SqlCompiler(engine)) {
            try {
                compiler.compile(("create table x as " + "(" + "select rnd_double(0)*100 a, rnd_symbol(5,4,4,1) b, timestamp_sequence(0, 100000000000) k from" + " long_sequence(200)" + ") timestamp(k) partition by DAY"), sqlExecutionContext);
                try (final RecordCursorFactory factory = compiler.compile("select * from x latest by b where b = 'PEHN' and a < 22", sqlExecutionContext).getRecordCursorFactory()) {
                    try {
                        assertCursor("a\tb\tk\n" + "5.942010834028\tPEHN\t1970-08-03T02:53:20.000000Z\n", factory, true, true, false);
                        Assert.fail();
                    } catch (CairoException e) {
                        TestUtils.assertContains(e.getFlyweightMessage(), "could not open");
                    }
                }
                Assert.assertEquals(0, engine.getBusyReaderCount());
                Assert.assertEquals(0, engine.getBusyWriterCount());
            } finally {
                engine.clear();
            }
        }
    });
}
Also used : FilesFacade(io.questdb.std.FilesFacade) RecordCursorFactory(io.questdb.cairo.sql.RecordCursorFactory) LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 9 with FilesFacade

use of io.questdb.std.FilesFacade in project questdb by bluestreak01.

the class SqlCompilerTest method testInsertAsSelectTemporaryIOError.

@Test
public void testInsertAsSelectTemporaryIOError() throws Exception {
    AtomicBoolean inError = new AtomicBoolean(true);
    FilesFacade ff = new FilesFacadeImpl() {

        int pageCount = 0;

        @Override
        public long getMapPageSize() {
            return getPageSize();
        }

        @Override
        public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
            if (inError.get() && pageCount++ == 13) {
                return -1;
            }
            return super.mmap(fd, len, offset, flags, memoryTag);
        }
    };
    assertInsertAsSelectIOError(inError, ff);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FilesFacade(io.questdb.std.FilesFacade) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 10 with FilesFacade

use of io.questdb.std.FilesFacade in project questdb by bluestreak01.

the class SqlCompilerTest method testInsertAsSelectPersistentIOError.

@Test
public void testInsertAsSelectPersistentIOError() throws Exception {
    AtomicBoolean inError = new AtomicBoolean(true);
    FilesFacade ff = new FilesFacadeImpl() {

        int pageCount = 0;

        @Override
        public long getMapPageSize() {
            return getPageSize();
        }

        @Override
        public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
            if (inError.get() && pageCount++ > 12) {
                return -1;
            }
            return super.mmap(fd, len, offset, flags, memoryTag);
        }
    };
    assertInsertAsSelectIOError(inError, ff);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FilesFacade(io.questdb.std.FilesFacade) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Aggregations

FilesFacade (io.questdb.std.FilesFacade)29 FilesFacadeImpl (io.questdb.std.FilesFacadeImpl)14 Test (org.junit.Test)14 Path (io.questdb.std.str.Path)13 MemoryMARW (io.questdb.cairo.vm.api.MemoryMARW)6 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)4 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)3 SqlCompiler (io.questdb.griffin.SqlCompiler)3 LPSZ (io.questdb.std.str.LPSZ)3 MemoryCMARWImpl (io.questdb.cairo.vm.MemoryCMARWImpl)2 Rnd (io.questdb.std.Rnd)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 TableModel (io.questdb.cairo.TableModel)1 MemoryARW (io.questdb.cairo.vm.api.MemoryARW)1 LineTcpSender (io.questdb.cutlass.line.LineTcpSender)1 SqlException (io.questdb.griffin.SqlException)1 BindVariableServiceImpl (io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl)1 DateFormat (io.questdb.std.datetime.DateFormat)1 TimestampFormatCompiler (io.questdb.std.datetime.microtime.TimestampFormatCompiler)1 File (java.io.File)1