Search in sources :

Example 36 with Path

use of io.questdb.std.str.Path in project questdb by bluestreak01.

the class TxSerializer method serializeJson.

public void serializeJson(String json, String target) {
    Gson des = new Gson();
    TxFileStruct tx = des.fromJson(json, TxFileStruct.class);
    if (tx.ATTACHED_PARTITION_SIZE != 0 && (tx.ATTACHED_PARTITIONS == null || tx.ATTACHED_PARTITION_SIZE != tx.ATTACHED_PARTITIONS.size())) {
        String arraySize = tx.ATTACHED_PARTITIONS == null ? "null" : Integer.toString(tx.ATTACHED_PARTITIONS.size());
        throw new IllegalArgumentException("ATTACHED_PARTITIONS array size of " + arraySize + " is different from ATTACHED_PARTITION_SIZE of " + tx.ATTACHED_PARTITION_SIZE);
    }
    if (tx.TX_OFFSET_MAP_WRITER_COUNT != 0 && (tx.SYMBOLS == null || tx.TX_OFFSET_MAP_WRITER_COUNT != tx.SYMBOLS.size())) {
        String arraySize = tx.SYMBOLS == null ? "null" : Integer.toString(tx.SYMBOLS.size());
        throw new IllegalArgumentException("SYMBOLS array size if " + arraySize + "is different from MAP_WRITER_COUNT of " + tx.TX_OFFSET_MAP_WRITER_COUNT);
    }
    long fileSize = tx.calculateFileSize();
    try (Path path = new Path()) {
        path.put(target).$();
        try (MemoryCMARW rwTxMem = Vm.getSmallCMARWInstance(ff, path, MemoryTag.MMAP_DEFAULT)) {
            Vect.memset(rwTxMem.addressOf(0), fileSize, 0);
            rwTxMem.setTruncateSize(fileSize);
            rwTxMem.putLong(TX_OFFSET_TXN, tx.TX_OFFSET_TXN);
            rwTxMem.putLong(TX_OFFSET_TRANSIENT_ROW_COUNT, tx.TX_OFFSET_TRANSIENT_ROW_COUNT);
            rwTxMem.putLong(TX_OFFSET_FIXED_ROW_COUNT, tx.TX_OFFSET_FIXED_ROW_COUNT);
            rwTxMem.putLong(TX_OFFSET_MIN_TIMESTAMP, tx.TX_OFFSET_MIN_TIMESTAMP);
            rwTxMem.putLong(TX_OFFSET_MAX_TIMESTAMP, tx.TX_OFFSET_MAX_TIMESTAMP);
            rwTxMem.putLong(TX_OFFSET_DATA_VERSION, tx.TX_OFFSET_DATA_VERSION);
            rwTxMem.putLong(TX_OFFSET_STRUCT_VERSION, tx.TX_OFFSET_STRUCT_VERSION);
            rwTxMem.putLong(TX_OFFSET_TXN_CHECK, tx.TX_OFFSET_TXN_CHECK);
            rwTxMem.putInt(TX_OFFSET_MAP_WRITER_COUNT, tx.TX_OFFSET_MAP_WRITER_COUNT);
            rwTxMem.putLong(TX_OFFSET_PARTITION_TABLE_VERSION, tx.TX_OFFSET_PARTITION_TABLE_VERSION);
            if (tx.TX_OFFSET_MAP_WRITER_COUNT != 0) {
                int isym = 0;
                for (TxFileStruct.SymbolInfo si : tx.SYMBOLS) {
                    long offset = getSymbolWriterIndexOffset(isym++);
                    rwTxMem.putInt(offset, si.COUNT);
                    offset += 4;
                    rwTxMem.putInt(offset, si.UNCOMMITTED_COUNT);
                }
            }
            rwTxMem.putInt(getPartitionTableSizeOffset(tx.TX_OFFSET_MAP_WRITER_COUNT), tx.ATTACHED_PARTITION_SIZE * 8 * 4);
            if (tx.ATTACHED_PARTITION_SIZE != 0) {
                int ipart = 0;
                for (TxFileStruct.AttachedPartition part : tx.ATTACHED_PARTITIONS) {
                    long offset = getPartitionTableIndexOffset(tx.TX_OFFSET_MAP_WRITER_COUNT, 4 * ipart++);
                    rwTxMem.putLong(offset, part.TS);
                    offset += 8;
                    rwTxMem.putLong(offset, part.SIZE);
                    offset += 8;
                    rwTxMem.putLong(offset, part.NAME_TX);
                    offset += 8;
                    rwTxMem.putLong(offset, part.DATA_TX);
                }
            }
        }
    }
}
Also used : Path(io.questdb.std.str.Path) MemoryCMARW(io.questdb.cairo.vm.api.MemoryCMARW) Gson(com.google.gson.Gson)

Example 37 with Path

use of io.questdb.std.str.Path in project questdb by bluestreak01.

the class ZipTest method testGzip.

@Test
public void testGzip() throws Exception {
    try (Path path = new Path()) {
        File outFile = temp.newFile("x");
        File expected = new File(ZipTest.class.getResource("/zip-test/large.csv").getFile());
        final int available = 64 * 1024;
        long in = Unsafe.malloc(available, MemoryTag.NATIVE_DEFAULT);
        long out = Unsafe.malloc(available / 2, MemoryTag.NATIVE_DEFAULT);
        try {
            long strm = Zip.deflateInit();
            try {
                long pIn = 0;
                long pOut = 0;
                long fdIn = Files.openRO(path.of(expected.getAbsolutePath()).$());
                try {
                    long fdOut = Files.openRW(path.of(outFile.getAbsolutePath()).$());
                    try {
                        // header
                        Files.write(fdOut, Zip.gzipHeader, Zip.gzipHeaderLen, pOut);
                        pOut += Zip.gzipHeaderLen;
                        int len;
                        int crc = 0;
                        while ((len = (int) Files.read(fdIn, in, available, pIn)) > 0) {
                            pIn += len;
                            Zip.setInput(strm, in, len);
                            crc = Zip.crc32(crc, in, len);
                            do {
                                int ret;
                                if ((ret = Zip.deflate(strm, out, available, false)) < 0) {
                                    throw new FatalError("Error in deflator: " + ret);
                                }
                                int have = available - Zip.availOut(strm);
                                if (have > 0) {
                                    Files.write(fdOut, out, have, pOut);
                                    pOut += have;
                                }
                            } while (Zip.availIn(strm) > 0);
                        }
                        int ret;
                        do {
                            if ((ret = Zip.deflate(strm, out, available, true)) < 0) {
                                throw new FatalError("Error in deflator: " + ret);
                            }
                            int have = available - Zip.availOut(strm);
                            if (have > 0) {
                                Files.write(fdOut, out, have, pOut);
                                pOut += have;
                            }
                        } while (ret != 1);
                        // write trailer
                        Unsafe.getUnsafe().putInt(out, crc);
                        Unsafe.getUnsafe().putInt(out + 4, (int) pIn);
                        Files.write(fdOut, out, 8, pOut);
                    } finally {
                        Files.close(fdOut);
                    }
                } finally {
                    Files.close(fdIn);
                }
            } finally {
                Zip.deflateEnd(strm);
            }
        } finally {
            Unsafe.free(in, available, MemoryTag.NATIVE_DEFAULT);
            Unsafe.free(out, available / 2, MemoryTag.NATIVE_DEFAULT);
        }
        // ok. read what we produced
        File actual = temp.newFile();
        try (GZIPInputStream is = new GZIPInputStream(new FileInputStream(outFile));
            FileOutputStream fos = new FileOutputStream(actual)) {
            byte[] buf = new byte[16 * 1024];
            int l;
            while ((l = is.read(buf)) > 0) {
                fos.write(buf, 0, l);
            }
        }
        TestUtils.assertEquals(expected, actual);
    }
}
Also used : Path(io.questdb.std.str.Path) GZIPInputStream(java.util.zip.GZIPInputStream) FatalError(io.questdb.std.ex.FatalError) FileOutputStream(java.io.FileOutputStream) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 38 with Path

use of io.questdb.std.str.Path in project questdb by bluestreak01.

the class O3PartitionJob method processPartition.

public static void processPartition(CharSequence pathToTable, int partitionBy, ObjList<MemoryMAR> columns, ObjList<MemoryCARW> oooColumns, long srcOooLo, long srcOooHi, long srcOooMax, long o3TimestampMin, long o3TimestampMax, long partitionTimestamp, long maxTimestamp, long srcDataMax, long srcDataTxn, boolean last, long txn, long sortedTimestampsAddr, TableWriter tableWriter, AtomicInteger columnCounter, O3Basket o3Basket, long tmpBuf) {
    // is out of order data hitting the last partition?
    // if so we do not need to re-open files and write to existing file descriptors
    final long o3TimestampLo = getTimestampIndexValue(sortedTimestampsAddr, srcOooLo);
    final RecordMetadata metadata = tableWriter.getMetadata();
    final int timestampIndex = metadata.getTimestampIndex();
    final Path path = Path.getThreadLocal(pathToTable);
    TableUtils.setPathForPartition(path, partitionBy, o3TimestampLo, false);
    final int pplen = path.length();
    TableUtils.txnPartitionConditionally(path, srcDataTxn);
    final int plen = path.length();
    long srcTimestampFd = 0;
    long dataTimestampLo;
    long dataTimestampHi;
    final FilesFacade ff = tableWriter.getFilesFacade();
    if (srcDataMax < 1) {
        if (!last) {
            try {
                LOG.debug().$("would create [path=").$(path.chop$().slash$()).$(']').$();
                createDirsOrFail(ff, path, tableWriter.getConfiguration().getMkDirMode());
            } catch (Throwable e) {
                LOG.error().$("process new partition error [table=").$(tableWriter.getTableName()).$(", e=").$(e).I$();
                tableWriter.o3BumpErrorCount();
                tableWriter.o3ClockDownPartitionUpdateCount();
                tableWriter.o3CountDownDoneLatch();
                throw e;
            }
        }
        publishOpenColumnTasks(txn, columns, oooColumns, pathToTable, srcOooLo, srcOooHi, srcOooMax, o3TimestampMin, o3TimestampMax, o3TimestampLo, partitionTimestamp, // below parameters are unused by this type of append
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, srcDataTxn, OPEN_NEW_PARTITION_FOR_APPEND, // timestamp fd
        0, 0, 0, timestampIndex, sortedTimestampsAddr, tableWriter, columnCounter, o3Basket, tmpBuf);
    } else {
        long srcTimestampAddr = 0;
        long srcTimestampSize = 0;
        int prefixType;
        long prefixLo;
        long prefixHi;
        int mergeType;
        long mergeDataLo;
        long mergeDataHi;
        long mergeO3Lo;
        long mergeO3Hi;
        int suffixType;
        long suffixLo;
        long suffixHi;
        final int openColumnMode;
        try {
            // so this check is for matching ceilings
            if (last) {
                dataTimestampHi = maxTimestamp;
                srcTimestampSize = srcDataMax * 8L;
                // negative fd indicates descriptor reuse
                srcTimestampFd = -columns.getQuick(getPrimaryColumnIndex(timestampIndex)).getFd();
                srcTimestampAddr = mapRW(ff, -srcTimestampFd, srcTimestampSize, MemoryTag.MMAP_O3);
            } else {
                srcTimestampSize = srcDataMax * 8L;
                // out of order data is going into archive partition
                // we need to read "low" and "high" boundaries of the partition. "low" being oldest timestamp
                // and "high" being newest
                dFile(path.trimTo(plen), metadata.getColumnName(timestampIndex));
                // also track the fd that we need to eventually close
                srcTimestampFd = openRW(ff, path, LOG);
                srcTimestampAddr = mapRW(ff, srcTimestampFd, srcTimestampSize, MemoryTag.MMAP_O3);
                dataTimestampHi = Unsafe.getUnsafe().getLong(srcTimestampAddr + srcTimestampSize - Long.BYTES);
            }
            dataTimestampLo = Unsafe.getUnsafe().getLong(srcTimestampAddr);
            // create copy jobs
            // we will have maximum of 3 stages:
            // - prefix data
            // - merge job
            // - suffix data
            // 
            // prefix and suffix can be sourced either from OO fully or from Data (written to disk) fully
            // so for prefix and suffix we will need a flag indicating source of the data
            // as well as range of rows in that source
            prefixType = O3_BLOCK_NONE;
            prefixLo = -1;
            prefixHi = -1;
            mergeType = O3_BLOCK_NONE;
            mergeDataLo = -1;
            mergeDataHi = -1;
            mergeO3Lo = -1;
            mergeO3Hi = -1;
            suffixType = O3_BLOCK_NONE;
            suffixLo = -1;
            suffixHi = -1;
            assert srcTimestampFd != -1 && srcTimestampFd != 1;
            int branch;
            if (o3TimestampLo > dataTimestampLo) {
                if (o3TimestampLo >= dataTimestampHi) {
                    // +------+
                    // | data |
                    // |      |
                    // +------+
                    // 
                    // +-----+
                    // | OOO |
                    // |     |
                    // 
                    branch = 1;
                    suffixType = O3_BLOCK_O3;
                    suffixLo = srcOooLo;
                    suffixHi = srcOooHi;
                } else {
                    // 
                    // +------+
                    // |      |
                    // |      | +-----+
                    // | data | | OOO |
                    // +------+
                    prefixType = O3_BLOCK_DATA;
                    prefixLo = 0;
                    prefixHi = Vect.boundedBinarySearch64Bit(srcTimestampAddr, o3TimestampLo, 0, srcDataMax - 1, BinarySearch.SCAN_DOWN);
                    mergeDataLo = prefixHi + 1;
                    mergeO3Lo = srcOooLo;
                    if (o3TimestampMax < dataTimestampHi) {
                        // 
                        // |      | +-----+
                        // | data | | OOO |
                        // |      | +-----+
                        // +------+
                        branch = 2;
                        mergeO3Hi = srcOooHi;
                        mergeDataHi = Vect.boundedBinarySearch64Bit(srcTimestampAddr, o3TimestampMax - 1, mergeDataLo, srcDataMax - 1, BinarySearch.SCAN_DOWN);
                        if (mergeDataLo > mergeDataHi) {
                            // the OO data implodes right between rows of existing data
                            // so we will have both data prefix and suffix and the middle bit
                            // is the out of order
                            mergeType = O3_BLOCK_O3;
                        } else {
                            mergeType = O3_BLOCK_MERGE;
                        }
                        suffixType = O3_BLOCK_DATA;
                        suffixLo = mergeDataHi + 1;
                        suffixHi = srcDataMax - 1;
                        assert suffixLo <= suffixHi;
                    } else if (o3TimestampMax > dataTimestampHi) {
                        // 
                        // |      | +-----+
                        // | data | | OOO |
                        // |      | |     |
                        // +------+ |     |
                        // |     |
                        // +-----+
                        branch = 3;
                        mergeO3Hi = Vect.boundedBinarySearchIndexT(sortedTimestampsAddr, dataTimestampHi, srcOooLo, srcOooHi, BinarySearch.SCAN_UP);
                        mergeDataHi = srcDataMax - 1;
                        mergeType = O3_BLOCK_MERGE;
                        suffixType = O3_BLOCK_O3;
                        suffixLo = mergeO3Hi + 1;
                        suffixHi = srcOooHi;
                    } else {
                        // 
                        // |      | +-----+
                        // | data | | OOO |
                        // |      | |     |
                        // +------+ +-----+
                        // 
                        branch = 4;
                        mergeType = O3_BLOCK_MERGE;
                        mergeO3Hi = srcOooHi;
                        mergeDataHi = srcDataMax - 1;
                    }
                }
            } else {
                // +-----+
                // | OOO |
                // 
                // +------+
                // | data |
                prefixType = O3_BLOCK_O3;
                prefixLo = srcOooLo;
                if (dataTimestampLo < o3TimestampMax) {
                    // 
                    // +------+  | OOO |
                    // | data |  +-----+
                    // |      |
                    mergeDataLo = 0;
                    prefixHi = Vect.boundedBinarySearchIndexT(sortedTimestampsAddr, dataTimestampLo, srcOooLo, srcOooHi, BinarySearch.SCAN_DOWN);
                    mergeO3Lo = prefixHi + 1;
                    if (o3TimestampMax < dataTimestampHi) {
                        // |      | |     |
                        // |      | | OOO |
                        // | data | +-----+
                        // |      |
                        // +------+
                        branch = 5;
                        mergeType = O3_BLOCK_MERGE;
                        mergeO3Hi = srcOooHi;
                        mergeDataHi = Vect.boundedBinarySearch64Bit(srcTimestampAddr, o3TimestampMax, 0, srcDataMax - 1, BinarySearch.SCAN_DOWN);
                        suffixLo = mergeDataHi + 1;
                        suffixType = O3_BLOCK_DATA;
                        suffixHi = srcDataMax - 1;
                    } else if (o3TimestampMax > dataTimestampHi) {
                        // |      | |     |
                        // |      | | OOO |
                        // | data | |     |
                        // +------+ |     |
                        // +-----+
                        branch = 6;
                        mergeDataHi = srcDataMax - 1;
                        mergeO3Hi = Vect.boundedBinarySearchIndexT(sortedTimestampsAddr, dataTimestampHi - 1, mergeO3Lo, srcOooHi, BinarySearch.SCAN_DOWN);
                        if (mergeO3Lo > mergeO3Hi) {
                            mergeType = O3_BLOCK_DATA;
                        } else {
                            mergeType = O3_BLOCK_MERGE;
                        }
                        if (mergeO3Hi < srcOooHi) {
                            suffixLo = mergeO3Hi + 1;
                            suffixType = O3_BLOCK_O3;
                            suffixHi = Math.max(suffixLo, srcOooHi);
                        }
                    } else {
                        // |      | |     |
                        // |      | | OOO |
                        // | data | |     |
                        // +------+ +-----+
                        branch = 7;
                        mergeType = O3_BLOCK_MERGE;
                        mergeO3Hi = srcOooHi;
                        mergeDataHi = srcDataMax - 1;
                    }
                } else {
                    // +-----+
                    // | OOO |
                    // +-----+
                    // 
                    // +------+
                    // | data |
                    // 
                    branch = 8;
                    prefixHi = srcOooHi;
                    suffixType = O3_BLOCK_DATA;
                    suffixLo = 0;
                    suffixHi = srcDataMax - 1;
                }
            }
            LOG.debug().$("o3 merge [branch=").$(branch).$(", prefixType=").$(prefixType).$(", prefixLo=").$(prefixLo).$(", prefixHi=").$(prefixHi).$(", o3TimestampLo=").$ts(o3TimestampLo).$(", o3TimestampMin=").$ts(o3TimestampMin).$(", o3TimestampMax=").$ts(o3TimestampMax).$(", dataTimestampLo=").$ts(dataTimestampLo).$(", dataTimestampHi=").$ts(dataTimestampHi).$(", partitionTimestamp=").$ts(partitionTimestamp).$(", srcDataMax=").$(srcDataMax).$(", mergeType=").$(mergeType).$(", mergeDataLo=").$(mergeDataLo).$(", mergeDataHi=").$(mergeDataHi).$(", mergeO3Lo=").$(mergeO3Lo).$(", mergeO3Hi=").$(mergeO3Hi).$(", suffixType=").$(suffixType).$(", suffixLo=").$(suffixLo).$(", suffixHi=").$(suffixHi).$(", table=").$(pathToTable).I$();
            if (prefixType == O3_BLOCK_NONE) {
                // We do not need to create a copy of partition when we simply need to append
                // existing the one.
                openColumnMode = OPEN_MID_PARTITION_FOR_APPEND;
            } else {
                txnPartition(path.trimTo(pplen), txn);
                createDirsOrFail(ff, path.slash$(), tableWriter.getConfiguration().getMkDirMode());
                if (last) {
                    openColumnMode = OPEN_LAST_PARTITION_FOR_MERGE;
                } else {
                    openColumnMode = OPEN_MID_PARTITION_FOR_MERGE;
                }
            }
        } catch (Throwable e) {
            LOG.error().$("process existing partition error [table=").$(tableWriter.getTableName()).$(", e=").$(e).I$();
            O3Utils.unmap(ff, srcTimestampAddr, srcTimestampSize);
            O3Utils.close(ff, srcTimestampFd);
            tableWriter.o3BumpErrorCount();
            tableWriter.o3ClockDownPartitionUpdateCount();
            tableWriter.o3CountDownDoneLatch();
            throw e;
        }
        // Compute max timestamp as maximum of out of order data and
        // data in existing partition.
        // When partition is new, the data timestamp is MIN_LONG
        final long timestampMax = Math.max(o3TimestampMax, dataTimestampHi);
        publishOpenColumnTasks(txn, columns, oooColumns, pathToTable, srcOooLo, srcOooHi, srcOooMax, o3TimestampMin, // <-- this is max of OOO and data chunk
        timestampMax, o3TimestampLo, partitionTimestamp, prefixType, prefixLo, prefixHi, mergeType, mergeDataLo, mergeDataHi, mergeO3Lo, mergeO3Hi, suffixType, suffixLo, suffixHi, srcDataMax, srcDataTxn, openColumnMode, srcTimestampFd, srcTimestampAddr, srcTimestampSize, timestampIndex, sortedTimestampsAddr, tableWriter, columnCounter, o3Basket, tmpBuf);
    }
}
Also used : RecordMetadata(io.questdb.cairo.sql.RecordMetadata) Path(io.questdb.std.str.Path)

Example 39 with Path

use of io.questdb.std.str.Path in project questdb by bluestreak01.

the class O3OpenColumnJob method openColumn.

public static void openColumn(int openColumnMode, CharSequence pathToTable, CharSequence columnName, AtomicInteger columnCounter, AtomicInteger partCounter, int columnType, long timestampMergeIndexAddr, long srcOooFixAddr, long srcOooVarAddr, long srcOooLo, long srcOooHi, long srcOooMax, long timestampMin, long timestampMax, long oooTimestampLo, long partitionTimestamp, long srcDataTop, long srcDataMax, long srcDataTxn, long txn, int prefixType, long prefixLo, long prefixHi, int mergeType, long mergeOOOLo, long mergeOOOHi, long mergeDataLo, long mergeDataHi, int suffixType, long suffixLo, long suffixHi, long srcTimestampFd, long srcTimestampAddr, long srcTimestampSize, boolean isIndexed, long activeFixFd, long activeVarFd, TableWriter tableWriter, BitmapIndexWriter indexWriter, long tmpBuf) {
    final long mergeLen = mergeOOOHi - mergeOOOLo + 1 + mergeDataHi - mergeDataLo + 1;
    final Path pathToPartition = Path.getThreadLocal(pathToTable);
    TableUtils.setPathForPartition(pathToPartition, tableWriter.getPartitionBy(), oooTimestampLo, false);
    final int pplen = pathToPartition.length();
    TableUtils.txnPartitionConditionally(pathToPartition, srcDataTxn);
    final int plen = pathToPartition.length();
    // append jobs do not set value of part counter, we do it here for those
    switch(openColumnMode) {
        case OPEN_MID_PARTITION_FOR_APPEND:
            appendMidPartition(pathToPartition, plen, columnName, columnCounter, columnType, srcOooFixAddr, srcOooVarAddr, srcOooLo, srcOooHi, srcOooMax, timestampMin, timestampMax, partitionTimestamp, srcDataTop, srcDataMax, isIndexed, srcTimestampFd, srcTimestampAddr, srcTimestampSize, tableWriter, indexWriter, tmpBuf);
            break;
        case OPEN_MID_PARTITION_FOR_MERGE:
            mergeMidPartition(pathToPartition, plen, pplen, columnName, columnCounter, partCounter, columnType, timestampMergeIndexAddr, srcOooFixAddr, srcOooVarAddr, srcOooLo, srcOooHi, srcOooMax, timestampMin, timestampMax, partitionTimestamp, srcDataTop, srcDataMax, txn, prefixType, prefixLo, prefixHi, mergeType, mergeOOOLo, mergeOOOHi, mergeDataLo, mergeDataHi, mergeLen, suffixType, suffixLo, suffixHi, isIndexed, srcTimestampFd, srcTimestampAddr, srcTimestampSize, tableWriter, indexWriter, tmpBuf);
            break;
        case OPEN_LAST_PARTITION_FOR_MERGE:
            mergeLastPartition(pathToPartition, pplen, columnName, columnCounter, partCounter, columnType, timestampMergeIndexAddr, srcOooFixAddr, srcOooVarAddr, srcOooLo, srcOooHi, srcOooMax, timestampMin, timestampMax, partitionTimestamp, srcDataTop, srcDataMax, txn, prefixType, prefixLo, prefixHi, mergeType, mergeOOOLo, mergeOOOHi, mergeDataLo, mergeDataHi, mergeLen, suffixType, suffixLo, suffixHi, isIndexed, activeFixFd, activeVarFd, srcTimestampFd, srcTimestampAddr, srcTimestampSize, tableWriter, indexWriter, tmpBuf);
            break;
        case OPEN_NEW_PARTITION_FOR_APPEND:
            appendNewPartition(pathToPartition, plen, columnName, columnCounter, columnType, timestampMergeIndexAddr, srcOooFixAddr, srcOooVarAddr, srcOooLo, srcOooHi, srcOooMax, timestampMin, timestampMax, partitionTimestamp, srcDataMax, isIndexed, tableWriter, indexWriter);
            break;
        default:
            break;
    }
}
Also used : Path(io.questdb.std.str.Path)

Example 40 with Path

use of io.questdb.std.str.Path in project questdb by bluestreak01.

the class BinarySearchTest method testFindReverseTwoValues.

@Test
public void testFindReverseTwoValues() throws Exception {
    assertMemoryLeak(() -> {
        try (Path path = new Path()) {
            path.of(root).concat("binsearch.d").$();
            try (MemoryMA appendMem = Vm.getSmallCMARWInstance(FilesFacadeImpl.INSTANCE, path, MemoryTag.MMAP_DEFAULT)) {
                appendMem.putLong(1);
                appendMem.putLong(3);
                try (MemoryMR mem = Vm.getMRInstance(FilesFacadeImpl.INSTANCE, path, 400 * Long.BYTES, MemoryTag.MMAP_DEFAULT)) {
                    Assert.assertEquals(0, BinarySearch.find(mem, 2, 0, 1, BinarySearch.SCAN_UP));
                }
            }
        }
    });
}
Also used : Path(io.questdb.std.str.Path) MemoryMA(io.questdb.cairo.vm.api.MemoryMA) MemoryMR(io.questdb.cairo.vm.api.MemoryMR) Test(org.junit.Test)

Aggregations

Path (io.questdb.std.str.Path)141 Test (org.junit.Test)89 File (java.io.File)14 FilesFacade (io.questdb.std.FilesFacade)13 MemoryCMARW (io.questdb.cairo.vm.api.MemoryCMARW)10 MemoryMR (io.questdb.cairo.vm.api.MemoryMR)10 Rnd (io.questdb.std.Rnd)10 AbstractCairoTest (io.questdb.cairo.AbstractCairoTest)7 MemoryMA (io.questdb.cairo.vm.api.MemoryMA)7 MemoryMARW (io.questdb.cairo.vm.api.MemoryMARW)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)6 NativeLPSZ (io.questdb.std.str.NativeLPSZ)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 SOCountDownLatch (io.questdb.mp.SOCountDownLatch)5 LPSZ (io.questdb.std.str.LPSZ)5 RecordCursor (io.questdb.cairo.sql.RecordCursor)4 RowCursor (io.questdb.cairo.sql.RowCursor)4 MemoryARW (io.questdb.cairo.vm.api.MemoryARW)4 RingQueue (io.questdb.mp.RingQueue)4