Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
66 changes: 59 additions & 7 deletions docs/source/developers/java/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,67 @@ integration tests, you would do:
Code Style
==========

Code style is enforced with Checkstyle. The configuration is located at `checkstyle`_.
You can also just check the style without building the project.
This checks the code style of all source code under the current directory or from within an individual module.
The current Java code styles are configured as follows:

- Indent: Tabs & spaces (2 spaces per tab)
- Google Java Format: Reformats Java source code to comply with `Google Java Style`_.
- Configure license headers for Java & XML files

Java code style is checked by `Spotless`_ during the build, and the continuous integration build will verify
that changes adhere to the style guide.

.. code-block:: xml

<java>
<indent>
...
</indent>
<googleJavaFormat/>
<licenseHeader>
...
</licenseHeader>
</java>
<pom>
<indent>
...
</indent>
<sortPom>
...
</sortPom>
</pom>

Automatically fixing code style issues
--------------------------------------

- You can also just check the style without building the project with `mvn spotless:check`.
- The Java code style can be corrected from the command line by using the following commands: `mvn spotless:apply`.

.. code-block:: bash

user@machine repo % mvn spotless:check
[ERROR] > The following files had format violations:
[ERROR] src\main\java\com\diffplug\gradle\spotless\FormatExtension.java
[ERROR] -\t\t····if·(targets.length·==·0)·{
[ERROR] +\t\tif·(targets.length·==·0)·{
[ERROR] Run 'mvn spotless:apply' to fix these violations.
user@machine repo % mvn spotless:apply
[INFO] BUILD SUCCESS
user@machine repo % mvn spotless:check
[INFO] BUILD SUCCESS

Code Formatter for Intellij IDEA and Eclipse
--------------------------------------------

Follow the instructions for:

- `Eclipse`_
- `IntelliJ`_

.. code-block::

$ mvn checkstyle:check

.. _benchmark: https://github.com/ursacomputing/benchmarks
.. _archery: https://github.com/apache/arrow/blob/main/dev/conbench_envs/README.md#L188
.. _conbench: https://github.com/conbench/conbench
.. _checkstyle: https://github.com/apache/arrow/blob/main/java/dev/checkstyle/checkstyle.xml
.. _Spotless: https://github.com/diffplug/spotless
.. _Google Java Style: https://google.github.io/styleguide/javaguide.html
.. _Eclipse: https://github.com/google/google-java-format?tab=readme-ov-file#eclipse
.. _IntelliJ: https://github.com/google/google-java-format?tab=readme-ov-file#intellij-android-studio-and-other-jetbrains-ides
Binary file added java/.mvn/.DS_Store
Binary file not shown.
Binary file added java/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions java/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
19 changes: 9 additions & 10 deletions java/adapter/avro/pom.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->

license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@
package org.apache.arrow.adapter.avro;

import java.io.IOException;

import org.apache.arrow.util.Preconditions;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.avro.Schema;
import org.apache.avro.io.Decoder;

/**
* Utility class to convert Avro objects to columnar Arrow format objects.
*/
/** Utility class to convert Avro objects to columnar Arrow format objects. */
public class AvroToArrow {

/**
* Fetch the data from {@link Decoder} and convert it to Arrow objects.
* Only for testing purpose.
* Fetch the data from {@link Decoder} and convert it to Arrow objects. Only for testing purpose.
*
* @param schema avro schema.
* @param decoder avro decoder
* @param config configuration of the conversion.
Expand All @@ -48,15 +45,14 @@ static VectorSchemaRoot avroToArrow(Schema schema, Decoder decoder, AvroToArrowC

/**
* Fetch the data from {@link Decoder} and iteratively convert it to Arrow objects.
*
* @param schema avro schema
* @param decoder avro decoder
* @param config configuration of the conversion.
* @throws IOException on error
*/
public static AvroToArrowVectorIterator avroToArrowIterator(
Schema schema,
Decoder decoder,
AvroToArrowConfig config) throws IOException {
Schema schema, Decoder decoder, AvroToArrowConfig config) throws IOException {

Preconditions.checkNotNull(schema, "Avro schema object cannot be null");
Preconditions.checkNotNull(decoder, "Avro decoder object cannot be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,33 @@
package org.apache.arrow.adapter.avro;

import java.util.Set;

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.util.Preconditions;
import org.apache.arrow.vector.dictionary.DictionaryProvider;

/**
* This class configures the Avro-to-Arrow conversion process.
*/
/** This class configures the Avro-to-Arrow conversion process. */
public class AvroToArrowConfig {

private final BufferAllocator allocator;

/**
* The maximum rowCount to read each time when partially convert data.
* Default value is 1024 and -1 means read all data into one vector.
* The maximum rowCount to read each time when partially convert data. Default value is 1024 and
* -1 means read all data into one vector.
*/
private final int targetBatchSize;

/**
* The dictionary provider used for enum type.
* If avro schema has enum type, will create dictionary and update this provider.
* The dictionary provider used for enum type. If avro schema has enum type, will create
* dictionary and update this provider.
*/
private final DictionaryProvider.MapDictionaryProvider provider;

/**
* The field names which to skip when reading decoder values.
*/
/** The field names which to skip when reading decoder values. */
private final Set<String> skipFieldNames;

/**
* Instantiate an instance.
*
* @param allocator The memory allocator to construct the Arrow vectors with.
* @param targetBatchSize The maximum rowCount to read each time when partially convert data.
* @param provider The dictionary provider used for enum type, adapter will update this provider.
Expand All @@ -59,8 +56,10 @@ public class AvroToArrowConfig {
DictionaryProvider.MapDictionaryProvider provider,
Set<String> skipFieldNames) {

Preconditions.checkArgument(targetBatchSize == AvroToArrowVectorIterator.NO_LIMIT_BATCH_SIZE ||
targetBatchSize > 0, "invalid targetBatchSize: %s", targetBatchSize);
Preconditions.checkArgument(
targetBatchSize == AvroToArrowVectorIterator.NO_LIMIT_BATCH_SIZE || targetBatchSize > 0,
"invalid targetBatchSize: %s",
targetBatchSize);

this.allocator = allocator;
this.targetBatchSize = targetBatchSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@

import java.util.HashSet;
import java.util.Set;

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.dictionary.DictionaryProvider;

/**
* This class builds {@link AvroToArrowConfig}s.
*/
/** This class builds {@link AvroToArrowConfig}s. */
public class AvroToArrowConfigBuilder {

private BufferAllocator allocator;
Expand All @@ -36,9 +33,7 @@ public class AvroToArrowConfigBuilder {

private Set<String> skipFieldNames;

/**
* Default constructor for the {@link AvroToArrowConfigBuilder}.
*/
/** Default constructor for the {@link AvroToArrowConfigBuilder}. */
public AvroToArrowConfigBuilder(BufferAllocator allocator) {
this.allocator = allocator;
this.targetBatchSize = AvroToArrowVectorIterator.DEFAULT_BATCH_SIZE;
Expand All @@ -61,14 +56,8 @@ public AvroToArrowConfigBuilder setSkipFieldNames(Set<String> skipFieldNames) {
return this;
}

/**
* This builds the {@link AvroToArrowConfig} from the provided params.
*/
/** This builds the {@link AvroToArrowConfig} from the provided params. */
public AvroToArrowConfig build() {
return new AvroToArrowConfig(
allocator,
targetBatchSize,
provider,
skipFieldNames);
return new AvroToArrowConfig(allocator, targetBatchSize, provider, skipFieldNames);
}
}
Loading