MCPcopy Index your code
hub / github.com/questdb/questdb / createTempFile

Method createTempFile

core/src/test/java/io/questdb/test/FilesTest.java:1553–1575  ·  view source on GitHub ↗
(Path path, String fileName, String fileContent)

Source from the content-addressed store, hash-verified

1551 }
1552
1553 private static void createTempFile(Path path, String fileName, String fileContent) {
1554 final int buffSize = fileContent.length() * 3;
1555 final long buffPtr = Unsafe.malloc(buffSize, MemoryTag.NATIVE_DEFAULT);
1556 final byte[] bytes = fileContent.getBytes(Files.UTF_8);
1557 long p = buffPtr;
1558 for (int i = 0, n = bytes.length; i < n; i++) {
1559 Unsafe.putByte(p++, bytes[i]);
1560 }
1561 Unsafe.putByte(p, (byte) 0);
1562 long fd = -1;
1563 try {
1564 fd = Files.openAppend(path.concat(fileName).$());
1565 if (fd > -1) {
1566 Files.truncate(fd, 0);
1567 Files.append(fd, buffPtr, bytes.length);
1568 Files.sync();
1569 }
1570 Assert.assertTrue(Files.exists(fd));
1571 } finally {
1572 Files.close(fd);
1573 Unsafe.free(buffPtr, buffSize, MemoryTag.NATIVE_DEFAULT);
1574 }
1575 }
1576
1577 private static void testAllocateConcurrent0(FilesFacade ff, String pathName, int index, AtomicInteger errors) {
1578 try (

Callers 11

testUnlinkMethod · 0.95
emptyHistogramsInLogMethod · 0.80
emptyLogMethod · 0.80
loadTxnWriterMethod · 0.80
loadLibMethod · 0.80
setupMethod · 0.80

Calls 14

mallocMethod · 0.95
putByteMethod · 0.95
openAppendMethod · 0.95
truncateMethod · 0.95
appendMethod · 0.95
syncMethod · 0.95
existsMethod · 0.95
closeMethod · 0.95
freeMethod · 0.95
concatMethod · 0.80
lengthMethod · 0.65
$Method · 0.65

Tested by

no test coverage detected