Skip to content

Commit 140eec6

Browse files
authored
Fix java formatting (#7703)
PJF is generally what you want for java. I'm biased though since I had heavy input on the code it produces --------- Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 04159b8 commit 140eec6

42 files changed

Lines changed: 404 additions & 381 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

java/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import net.ltgt.gradle.errorprone.errorprone
66
plugins {
77
id("com.diffplug.spotless") version "8.4.0"
88
id("com.palantir.git-version") version "5.0.0"
9+
id("com.palantir.java-format") version "2.90.0"
910
id("net.ltgt.errorprone") version "5.1.0" apply false
1011
id("com.google.protobuf") version "0.10.0" apply false
1112
id("com.vanniktech.maven.publish") version "0.36.0" apply false
@@ -39,8 +40,13 @@ allprojects {
3940

4041
spotless {
4142
java {
42-
palantirJavaFormat()
43+
palantirJavaFormat().formatJavadoc(true)
4344
licenseHeaderFile("${rootProject.projectDir}/.spotless/java-license-header.txt")
45+
removeUnusedImports()
46+
forbidWildcardImports()
47+
importOrder("")
48+
trimTrailingWhitespace()
49+
leadingTabsToSpaces(4)
4450
targetExclude("**/generated/**")
4551
targetExcludeIfContentContains("// spotless:disabled")
4652
}

java/vortex-jni/src/main/java/dev/vortex/DateTimeUtil.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,20 @@
1212
/**
1313
* Utility class for date and time conversions in Vortex.
1414
*
15-
* <p>This class provides helper functions for converting Java date/time objects
16-
* to nanoseconds since the Unix epoch, which is the internal representation
17-
* used by Vortex for temporal data.</p>
15+
* <p>This class provides helper functions for converting Java date/time objects to nanoseconds since the Unix epoch,
16+
* which is the internal representation used by Vortex for temporal data.
1817
*
19-
* <p>Helpful functions borrowed from Iceberg class with same name.</p>
18+
* <p>Helpful functions borrowed from Iceberg class with same name.
2019
*/
2120
public final class DateTimeUtil {
22-
/**
23-
* The Unix epoch as an OffsetDateTime (1970-01-01T00:00:00Z).
24-
*/
21+
/** The Unix epoch as an OffsetDateTime (1970-01-01T00:00:00Z). */
2522
public static final OffsetDateTime EPOCH = Instant.ofEpochSecond(0).atOffset(ZoneOffset.UTC);
2623

2724
/**
2825
* Converts a LocalDateTime to nanoseconds since the Unix epoch.
2926
*
30-
* <p>The LocalDateTime is assumed to be in UTC timezone for conversion purposes.
31-
* When decoded back to LocalDateTime, the timezone information will not be preserved.</p>
27+
* <p>The LocalDateTime is assumed to be in UTC timezone for conversion purposes. When decoded back to
28+
* LocalDateTime, the timezone information will not be preserved.
3229
*
3330
* @param dateTime the LocalDateTime to convert
3431
* @return nanoseconds since the Unix epoch
@@ -40,7 +37,7 @@ public static long nanosFromTimestamp(LocalDateTime dateTime) {
4037
/**
4138
* Converts an OffsetDateTime to nanoseconds since the Unix epoch.
4239
*
43-
* <p>The timezone information in the OffsetDateTime is preserved during conversion.</p>
40+
* <p>The timezone information in the OffsetDateTime is preserved during conversion.
4441
*
4542
* @param dateTime the OffsetDateTime to convert
4643
* @return nanoseconds since the Unix epoch

java/vortex-jni/src/main/java/dev/vortex/api/DataSource.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
import org.apache.arrow.vector.types.pojo.Schema;
1919

2020
/**
21-
* A set of Vortex files opened through a {@link Session}. Data sources are cheap to open
22-
* (only the first file is read eagerly, to determine the schema) and can be scanned
23-
* multiple times.
21+
* A set of Vortex files opened through a {@link Session}. Data sources are cheap to open (only the first file is read
22+
* eagerly, to determine the schema) and can be scanned multiple times.
2423
*
25-
* <p>Native resources are released automatically via {@link VortexCleaner} when the
26-
* data source becomes unreachable.
24+
* <p>Native resources are released automatically via {@link VortexCleaner} when the data source becomes unreachable.
2725
*/
2826
public final class DataSource {
2927
private final Session session;
@@ -42,8 +40,8 @@ public static DataSource open(Session session, String uri) {
4240
}
4341

4442
/**
45-
* Open one or more URIs or globs. When a glob is used, the first match is opened eagerly;
46-
* subsequent matches are opened lazily on scan.
43+
* Open one or more URIs or globs. When a glob is used, the first match is opened eagerly; subsequent matches are
44+
* opened lazily on scan.
4745
*
4846
* @param session open session
4947
* @param uri single URI or glob
@@ -54,8 +52,8 @@ public static DataSource open(Session session, String uri, Map<String, String> p
5452
}
5553

5654
/**
57-
* Open one or more URIs or globs. When a glob is used, the first match is opened eagerly;
58-
* subsequent matches are opened lazily on scan.
55+
* Open one or more URIs or globs. When a glob is used, the first match is opened eagerly; subsequent matches are
56+
* opened lazily on scan.
5957
*
6058
* @param session open session
6159
* @param uris URIs or globs to scan
@@ -82,9 +80,8 @@ public Schema arrowSchema(BufferAllocator allocator) {
8280
}
8381

8482
/**
85-
* Row count along with the precision of that estimate. Mirrors the Rust
86-
* {@code Option<Precision<u64>>} returned by {@code DataSource::row_count}:
87-
* {@link RowCount.Unknown} when no estimate is available, {@link RowCount.Estimate}
83+
* Row count along with the precision of that estimate. Mirrors the Rust {@code Option<Precision<u64>>} returned by
84+
* {@code DataSource::row_count}: {@link RowCount.Unknown} when no estimate is available, {@link RowCount.Estimate}
8885
* for an inexact hint, {@link RowCount.Exact} when the count is authoritative.
8986
*/
9087
public RowCount rowCount() {

java/vortex-jni/src/main/java/dev/vortex/api/Expression.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
/**
1212
* A Vortex expression node backed by a native pointer.
1313
*
14-
* <p>Expressions are composed via the static factories ({@link #root()}, {@link
15-
* #getItem(String, Expression)}, etc.). Each returned {@code Expression} owns its native
16-
* pointer; the pointer is released automatically when the {@code Expression} is no longer
17-
* reachable. Passing an expression as an input to a builder does <em>not</em> transfer
14+
* <p>Expressions are composed via the static factories ({@link #root()}, {@link #getItem(String, Expression)}, etc.).
15+
* Each returned {@code Expression} owns its native pointer; the pointer is released automatically when the
16+
* {@code Expression} is no longer reachable. Passing an expression as an input to a builder does <em>not</em> transfer
1817
* ownership — the resulting expression is an independent copy on the native side.
1918
*/
2019
public final class Expression {

java/vortex-jni/src/main/java/dev/vortex/api/Partition.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
import org.apache.arrow.vector.ipc.ArrowReader;
1515

1616
/**
17-
* A unit of scan work that materializes into an Arrow stream. Partitions are single-pass:
18-
* calling {@link #scanArrow(BufferAllocator)} consumes the partition and transfers
19-
* ownership of its native memory to the returned {@link ArrowReader}. If the partition
20-
* is never consumed, its native memory is released automatically via {@link VortexCleaner}.
17+
* A unit of scan work that materializes into an Arrow stream. Partitions are single-pass: calling
18+
* {@link #scanArrow(BufferAllocator)} consumes the partition and transfers ownership of its native memory to the
19+
* returned {@link ArrowReader}. If the partition is never consumed, its native memory is released automatically via
20+
* {@link VortexCleaner}.
2121
*/
2222
public final class Partition {
2323
private final Session session;
@@ -52,9 +52,8 @@ public OptionalLong rowCount() {
5252
}
5353

5454
/**
55-
* Consume the partition and return an {@link ArrowReader} that yields record batches.
56-
* The caller must close the reader when finished; doing so releases the native partition
57-
* resources as well.
55+
* Consume the partition and return an {@link ArrowReader} that yields record batches. The caller must close the
56+
* reader when finished; doing so releases the native partition resources as well.
5857
*/
5958
public ArrowReader scanArrow(BufferAllocator allocator) {
6059
if (!consumed.compareAndSet(false, true)) {

java/vortex-jni/src/main/java/dev/vortex/api/Scan.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
/**
1717
* A lazy handle to a set of {@link Partition partitions}.
1818
*
19-
* <p>Once a scan has produced its last partition it is effectively exhausted; native
20-
* resources are released automatically via {@link VortexCleaner} when the scan becomes
21-
* unreachable.
19+
* <p>Once a scan has produced its last partition it is effectively exhausted; native resources are released
20+
* automatically via {@link VortexCleaner} when the scan becomes unreachable.
2221
*/
2322
public final class Scan implements Iterator<Partition> {
2423
private final Session session;
@@ -39,8 +38,7 @@ static Scan fromPointer(Session session, long pointer) {
3938
}
4039

4140
/**
42-
* Arrow schema produced by this scan. Must be called before the first call to
43-
* {@link #hasNext()}/{@link #next()}.
41+
* Arrow schema produced by this scan. Must be called before the first call to {@link #hasNext()}/{@link #next()}.
4442
*/
4543
public Schema arrowSchema(BufferAllocator allocator) {
4644
try (ArrowSchema schema = ArrowSchema.allocateNew(allocator)) {

java/vortex-jni/src/main/java/dev/vortex/api/ScanOptions.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
/**
1111
* Scan configuration passed to {@link DataSource#scan(ScanOptions)}.
1212
*
13-
* <p>All fields are optional. A call to {@link #of()} returns a default that reads every
14-
* row and column.
13+
* <p>All fields are optional. A call to {@link #of()} returns a default that reads every row and column.
1514
*/
1615
@Value.Immutable
1716
public interface ScanOptions {
@@ -29,8 +28,8 @@ public interface ScanOptions {
2928
OptionalLong rowRangeEnd();
3029

3130
/**
32-
* Sorted ascending row indices that should be included in (or excluded from) the scan,
33-
* depending on {@link #selectionMode()}.
31+
* Sorted ascending row indices that should be included in (or excluded from) the scan, depending on
32+
* {@link #selectionMode()}.
3433
*/
3534
Optional<long[]> selectionIndices();
3635

java/vortex-jni/src/main/java/dev/vortex/api/Session.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
import dev.vortex.jni.NativeSession;
99

1010
/**
11-
* Handle to a native Vortex session. The session owns a current-thread async runtime and
12-
* is the entry point for opening {@link DataSource data sources} and {@link VortexWriter
13-
* writers}.
11+
* Handle to a native Vortex session. The session owns a current-thread async runtime and is the entry point for opening
12+
* {@link DataSource data sources} and {@link VortexWriter writers}.
1413
*
15-
* <p>Sessions are safe to share across threads within a process, though concrete
16-
* operations (scans, writes) remain single-threaded on the session's runtime thread.
14+
* <p>Sessions are safe to share across threads within a process, though concrete operations (scans, writes) remain
15+
* single-threaded on the session's runtime thread.
1716
*
18-
* <p>Native resources are released automatically when the session becomes unreachable,
19-
* via {@link VortexCleaner}.
17+
* <p>Native resources are released automatically when the session becomes unreachable, via {@link VortexCleaner}.
2018
*/
2119
public final class Session {
2220
private final long pointer;

java/vortex-jni/src/main/java/dev/vortex/api/VortexWriter.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
/**
1919
* Writer for Vortex files.
2020
*
21-
* <p>Batches are accepted via the Arrow C Data Interface: callers export an Arrow record
22-
* batch to an {@code ArrowArray} / {@code ArrowSchema} pair and pass the addresses to
23-
* {@link #writeBatch(long, long)}. The writer accepts up to four in-flight batches
24-
* on the session's runtime thread before back-pressuring the caller.
21+
* <p>Batches are accepted via the Arrow C Data Interface: callers export an Arrow record batch to an {@code ArrowArray}
22+
* / {@code ArrowSchema} pair and pass the addresses to {@link #writeBatch(long, long)}. The writer accepts up to four
23+
* in-flight batches on the session's runtime thread before back-pressuring the caller.
2524
*
26-
* <p>Call {@link #close()} to flush remaining batches and finalize the file. If the writer
27-
* becomes unreachable without an explicit {@code close()}, {@link VortexCleaner} will flush
28-
* and release native resources as a backstop — but callers should always finalize
29-
* explicitly so that I/O errors surface through the normal call path.
25+
* <p>Call {@link #close()} to flush remaining batches and finalize the file. If the writer becomes unreachable without
26+
* an explicit {@code close()}, {@link VortexCleaner} will flush and release native resources as a backstop — but
27+
* callers should always finalize explicitly so that I/O errors surface through the normal call path.
3028
*/
3129
public final class VortexWriter implements AutoCloseable {
3230
private final long pointer;
@@ -44,8 +42,8 @@ private VortexWriter(long pointer) {
4442
}
4543

4644
/**
47-
* Create a writer that streams records into the file at {@code uri}. The Arrow schema
48-
* describes the exact layout of every batch written.
45+
* Create a writer that streams records into the file at {@code uri}. The Arrow schema describes the exact layout of
46+
* every batch written.
4947
*/
5048
public static VortexWriter create(
5149
Session session, String uri, Schema arrowSchema, Map<String, String> options, BufferAllocator allocator)

java/vortex-jni/src/main/java/dev/vortex/arrow/ArrowAllocation.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88

99
/**
1010
* Utility class for managing Apache Arrow memory allocation.
11-
* <p>
12-
* This class provides a global shared root allocator for Arrow memory operations
13-
* used throughout the Vortex JNI layer. The allocator is configured with the maximum
14-
* available heap size to allow for efficient memory management.
15-
* </p>
11+
*
12+
* <p>This class provides a global shared root allocator for Arrow memory operations used throughout the Vortex JNI
13+
* layer. The allocator is configured with the maximum available heap size to allow for efficient memory management.
1614
*/
1715
public final class ArrowAllocation {
1816
private static final RootAllocator ROOT_ALLOCATOR = new RootAllocator(Long.MAX_VALUE);
@@ -21,11 +19,9 @@ private ArrowAllocation() {}
2119

2220
/**
2321
* Returns the shared root allocator instance for Apache Arrow operations.
24-
* <p>
25-
* This allocator is shared across all Arrow operations in the JVM and is configured
26-
* to use the maximum available memory. It should be used as the parent allocator
27-
* for all Arrow memory operations within the Vortex system.
28-
* </p>
22+
*
23+
* <p>This allocator is shared across all Arrow operations in the JVM and is configured to use the maximum available
24+
* memory. It should be used as the parent allocator for all Arrow memory operations within the Vortex system.
2925
*
3026
* @return the shared {@link BufferAllocator} instance
3127
*/

0 commit comments

Comments
 (0)