Skip to content

Commit

Permalink
apacheGH-40820: [Java] Adding Spotless to Adapter module (apache#42048)
Browse files Browse the repository at this point in the history
### Rationale for this change

Adding code style and formatting options for Adapter module. 
- [X] Avro
- [x] JDBC
- [x] Orc

### What changes are included in this PR?

Code formatting spotless plugin has been added. 

### Are these changes tested?

Yes, but doesn't involve test cases, the plugin itself corrects. 

### Are there any user-facing changes?
* GitHub Issue: apache#40820

Authored-by: Vibhatha Abeykoon <[email protected]>
Signed-off-by: David Li <[email protected]>
  • Loading branch information
vibhatha authored Jun 10, 2024
1 parent f0a6f49 commit 7179511
Show file tree
Hide file tree
Showing 129 changed files with 2,858 additions and 2,745 deletions.
5 changes: 5 additions & 0 deletions java/adapter/avro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<description>(Contrib/Experimental) A library for converting Avro data to Arrow data.</description>
<url>http://maven.apache.org</url>

<properties>
<checkstyle.config.location>dev/checkstyle/checkstyle-spotless.xml</checkstyle.config.location>
<spotless.java.excludes>none</spotless.java.excludes>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.arrow</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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 +44,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 @@ -14,40 +14,35 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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 +54,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 @@ -14,18 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.arrow.adapter.avro;

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 +32,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 +55,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

0 comments on commit 7179511

Please sign in to comment.