Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9d028d6
PECOBLR-1121 Add unit tests for DatabricksArrowBuf.
tejassp-db Dec 22, 2025
30926b2
PECOBLR-1121 Formatting.
tejassp-db Dec 23, 2025
3e30c75
Merge branch 'PECOBLR-1121/arrow-patch/stack-2' into PECOBLR-1121/arr…
tejassp-db Dec 23, 2025
c06b7e5
PECOBLR-1121 Add unit tests for all arrow patched classes.
tejassp-db Dec 23, 2025
e50fd34
PECOBLR-1121 format code
tejassp-db Dec 26, 2025
180bfe5
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Dec 30, 2025
4890feb
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Dec 31, 2025
c309a03
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Jan 2, 2026
1879285
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Jan 5, 2026
663796c
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Jan 5, 2026
237829d
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Jan 13, 2026
f00607f
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Jan 19, 2026
518a459
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Jan 23, 2026
615b43a
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Jan 30, 2026
c11c586
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Feb 4, 2026
fe13bb8
PECOBLR-1121 Change tests to run only in JVM 16+ with nio reflection …
tejassp-db Feb 4, 2026
6bc997c
PECOBLR-1121 add DatabricksReferenceManagerNOOPTest.
tejassp-db Feb 4, 2026
9041c31
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Feb 4, 2026
ebb0b60
PECOBLR-1121 Use try-with-resources in tests
tejassp-db Feb 4, 2026
618b912
PECOBLR-1121 Add tests for empty buffer.
tejassp-db Feb 4, 2026
ef6413c
PECOBLR-1121 Fix warnings
tejassp-db Feb 6, 2026
fe45d57
Merge branch 'PECOBLR-1121/arrow-patch/stack-1' into PECOBLR-1121/arr…
tejassp-db Mar 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package org.apache.arrow.memory;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Random;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnJre;
import org.junit.jupiter.api.condition.JRE;

/** Test allocation reservation */
@Tag("Jvm17PlusAndArrowToNioReflectionDisabled")
@EnabledOnJre({JRE.JAVA_17, JRE.JAVA_21})
public class DatabricksAllocationReservationTest {
/** Test reserve and allocate */
@Test
public void testReservation() {
DatabricksBufferAllocator allocator = new DatabricksBufferAllocator();
DatabricksAllocationReservation reservation = new DatabricksAllocationReservation(allocator);

Random random = new Random();
long totalReservation = 0;
for (int i = 0; i < 1000; i++) {
long size = random.nextInt(1000);
assertTrue(reservation.reserve(size), "Reservation should return true");
totalReservation += size;
assertEquals(totalReservation, reservation.getSizeLong(), "Reservation should match");
}

ArrowBuf buffer = reservation.allocateBuffer();
assertInstanceOf(DatabricksArrowBuf.class, buffer, "Buffer type should match");
assertTrue(buffer.capacity() >= totalReservation, "Reservation should be allocated");
}

/** Test fail on reuse */
@Test
public void testFailureOnReuse() {
long bufferSize = 1024;
DatabricksBufferAllocator allocator = new DatabricksBufferAllocator();
DatabricksAllocationReservation reservation = new DatabricksAllocationReservation(allocator);
reservation.reserve(bufferSize);

ArrowBuf buffer = reservation.allocateBuffer();
assertInstanceOf(DatabricksArrowBuf.class, buffer, "Buffer type should match");
assertTrue(buffer.capacity() >= bufferSize, "Reservation should be allocated");

assertTrue(reservation.isUsed(), "Reservation should be used");

assertThrows(
IllegalStateException.class,
() -> reservation.reserve(10L),
"Reuse after allocate should fail");
assertThrows(
IllegalStateException.class,
reservation::allocateBuffer,
"Reuse after allocate should fail");
}

/** Test fail on reuse after close */
@Test
public void testFailureOnClose() {
long bufferSize = 1024;
DatabricksBufferAllocator allocator = new DatabricksBufferAllocator();
DatabricksAllocationReservation reservation = new DatabricksAllocationReservation(allocator);
reservation.reserve(bufferSize);

ArrowBuf buffer = reservation.allocateBuffer();
assertInstanceOf(DatabricksArrowBuf.class, buffer, "Buffer type should match");
assertTrue(buffer.capacity() >= bufferSize, "Reservation should be allocated");

reservation.close();
assertTrue(reservation.isClosed(), "Reservation should have been closed");

assertThrows(
IllegalStateException.class,
() -> reservation.reserve(10L),
"Reuse after close should fail");
assertThrows(
IllegalStateException.class, reservation::allocateBuffer, "Reuse after close should fail");
}
}
Loading
Loading