use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class TxnScoreboardTest method testWideRange.
@Test
public void testWideRange() throws Exception {
TestUtils.assertMemoryLeak(() -> {
try (final Path shmPath = new Path();
final TxnScoreboard scoreboard = new TxnScoreboard(FilesFacadeImpl.INSTANCE, shmPath.of(root), 1024)) {
scoreboard.acquireTxn(15);
scoreboard.releaseTxn(15);
scoreboard.acquireTxn(900992);
}
});
}
use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class TableWriterTest method testRemoveColumn.
private void testRemoveColumn(TableModel model) throws Exception {
TestUtils.assertMemoryLeak(() -> {
CairoTestUtils.create(model);
long ts = TimestampFormatUtils.parseTimestamp("2013-03-04T00:00:00.000Z");
Rnd rnd = new Rnd();
try (TableWriter writer = new TableWriter(configuration, model.getName())) {
// optional
writer.warmUp();
ts = append10KProducts(ts, rnd, writer);
writer.removeColumn("supplier");
final NativeLPSZ lpsz = new NativeLPSZ();
try (Path path = new Path()) {
path.of(root).concat(model.getName());
final int plen = path.length();
FF.iterateDir(path.$(), (file, type) -> {
lpsz.of(file);
if (type == Files.DT_DIR && !Files.isDots(lpsz)) {
Assert.assertFalse(FF.exists(path.trimTo(plen).concat(lpsz).concat("supplier.i").$()));
Assert.assertFalse(FF.exists(path.trimTo(plen).concat(lpsz).concat("supplier.d").$()));
Assert.assertFalse(FF.exists(path.trimTo(plen).concat(lpsz).concat("supplier.top").$()));
}
});
}
ts = append10KNoSupplier(ts, rnd, writer);
writer.commit();
Assert.assertEquals(20000, writer.size());
}
try (TableWriter writer = new TableWriter(configuration, model.getName())) {
append10KNoSupplier(ts, rnd, writer);
writer.commit();
Assert.assertEquals(30000, writer.size());
}
});
}
use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class TableWriterTest method testOpenWriterMissingTxFile.
@Test
public void testOpenWriterMissingTxFile() throws Exception {
TestUtils.assertMemoryLeak(() -> {
CairoTestUtils.createAllTable(configuration, PartitionBy.NONE);
try (Path path = new Path()) {
Assert.assertTrue(FF.remove(path.of(root).concat("all").concat(TableUtils.TXN_FILE_NAME).$()));
try {
new TableWriter(configuration, "all");
Assert.fail();
} catch (CairoException ignore) {
}
}
});
}
use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class TxnTest method testFailedTxWriterDoesNotCorruptTable.
@Test
public void testFailedTxWriterDoesNotCorruptTable() throws Exception {
TestUtils.assertMemoryLeak(() -> {
FilesFacade errorFf = new FilesFacadeImpl() {
@Override
public long mremap(long fd, long addr, long previousSize, long newSize, long offset, int mode, int memoryTag) {
return -1;
}
};
FilesFacadeImpl cleanFf = new FilesFacadeImpl();
assertMemoryLeak(() -> {
String tableName = "txntest";
try (Path path = new Path()) {
try (MemoryMARW mem = Vm.getCMARWInstance();
TableModel model = new TableModel(configuration, tableName, PartitionBy.DAY)) {
model.timestamp();
TableUtils.createTable(configuration, mem, path, model, 1);
}
}
try (Path path = new Path()) {
path.of(configuration.getRoot()).concat(tableName);
int testPartitionCount = 3000;
try (TxWriter txWriter = new TxWriter(cleanFf, path, PartitionBy.DAY)) {
// Add lots of partitions
for (int i = 0; i < testPartitionCount; i++) {
txWriter.updatePartitionSizeByTimestamp(i * Timestamps.DAY_MICROS, i + 1);
}
txWriter.updateMaxTimestamp(testPartitionCount * Timestamps.DAY_MICROS + 1);
txWriter.finishPartitionSizeUpdate();
txWriter.commit(CommitMode.SYNC, new ObjList<>());
}
// Reopen without OS errors
try (TxWriter txWriter = new TxWriter(cleanFf, path, PartitionBy.DAY)) {
// Read lots of partitions
Assert.assertEquals(testPartitionCount, txWriter.getPartitionCount());
for (int i = 0; i < testPartitionCount - 1; i++) {
Assert.assertEquals(i + 1, txWriter.getPartitionSize(i));
}
}
// Open with OS error to file extend
try (TxWriter ignored = new TxWriter(errorFf, path, PartitionBy.DAY)) {
Assert.fail("Should not be able to extend on opening");
} catch (CairoException ex) {
// expected
}
// Reopen without OS errors
try (TxWriter txWriter = new TxWriter(cleanFf, path, PartitionBy.DAY)) {
// Read lots of partitions
Assert.assertEquals(testPartitionCount, txWriter.getPartitionCount());
for (int i = 0; i < testPartitionCount - 1; i++) {
Assert.assertEquals(i + 1, txWriter.getPartitionSize(i));
}
}
}
});
});
}
use of io.questdb.std.str.Path in project questdb by bluestreak01.
the class BitmapIndexTest method testWriterConstructorKeyMismatch.
@Test
public void testWriterConstructorKeyMismatch() throws Exception {
TestUtils.assertMemoryLeak(() -> {
try (MemoryA mem = openKey()) {
mem.putByte(BitmapIndexUtils.SIGNATURE);
mem.skip(20);
mem.putLong(300);
mem.skip(BitmapIndexUtils.KEY_FILE_RESERVED - mem.getAppendOffset());
}
// Memory impl will round truncate size to the OS page size.
// Therefore, truncate file manually to below the expected file size
final FilesFacade ff = FilesFacadeImpl.INSTANCE;
try (Path path = new Path()) {
path.of(configuration.getRoot()).concat("x").put(".k").$();
long fd = TableUtils.openFileRWOrFail(ff, path);
try {
ff.truncate(fd, 64);
} finally {
ff.close(fd);
}
}
assertWriterConstructorFail("Key count");
});
}
Aggregations