Skip to content

Commit

Permalink
ORC-1306: Fixed indented code style for Java modules
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
This pr is aimed at fixing all indentation style issues with java modules. And add indentation checking rules to checkstyle.xml.

```xml
    <module name="Indentation">
      <property name="severity" value="error"/>
      <property name="basicOffset" value="2"/>
      <property name="braceAdjustment" value="0"/>
      <property name="caseIndent" value="2"/>
      <property name="throwsIndent" value="2"/>
      <property name="lineWrappingIndentation" value="4"/>
      <property name="arrayInitIndent" value="2"/>
    </module>
```

### Why are the changes needed?
Automated checks save more time and nothing is missed.

### How was this patch tested?
Checking with maven-check-plugin.

Closes #1303 from guiyanakuang/ORC-1306.

Authored-by: Guiyanakuang <guiyanakuang@gmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
  • Loading branch information
guiyanakuang authored and dongjoon-hyun committed Nov 3, 2022
1 parent 87d23c5 commit 9cf9d26
Show file tree
Hide file tree
Showing 50 changed files with 2,378 additions and 2,354 deletions.
Expand Up @@ -83,14 +83,14 @@ public void run(String[] args) throws Exception {

public static CommandLine parseCommandLine(String[] args, boolean needsArgs) {
org.apache.commons.cli.Options options = new org.apache.commons.cli.Options()
.addOption("h", HELP, false, "Provide help")
.addOption("i", ITERATIONS, true, "Number of iterations")
.addOption("I", WARMUP_ITERATIONS, true, "Number of warmup iterations")
.addOption("f", FORK, true, "How many forks to use")
.addOption("t", TIME, true, "How long each iteration is in seconds")
.addOption("m", MIN_MEMORY, true, "The minimum size of each JVM")
.addOption("M", MAX_MEMORY, true, "The maximum size of each JVM")
.addOption("g", GC, false, "Should GC be profiled");
.addOption("h", HELP, false, "Provide help")
.addOption("i", ITERATIONS, true, "Number of iterations")
.addOption("I", WARMUP_ITERATIONS, true, "Number of warmup iterations")
.addOption("f", FORK, true, "How many forks to use")
.addOption("t", TIME, true, "How long each iteration is in seconds")
.addOption("m", MIN_MEMORY, true, "The minimum size of each JVM")
.addOption("M", MAX_MEMORY, true, "The maximum size of each JVM")
.addOption("g", GC, false, "Should GC be profiled");
CommandLine result;
try {
result = new DefaultParser().parse(options, args, true);
Expand Down Expand Up @@ -118,15 +118,15 @@ public static OptionsBuilder optionsBuilder(CommandLine options) {
}
if (options.hasOption(WARMUP_ITERATIONS)) {
builder.warmupIterations(Integer.parseInt(options.getOptionValue(
WARMUP_ITERATIONS)));
WARMUP_ITERATIONS)));
}
if (options.hasOption(FORK)) {
builder.forks(Integer.parseInt(options.getOptionValue(
FORK)));
FORK)));
}
if (options.hasOption(TIME)) {
TimeValue iterationTime = TimeValue.seconds(Long.parseLong(
options.getOptionValue(TIME)));
options.getOptionValue(TIME)));
builder.measurementTime(iterationTime);
builder.warmupTime(iterationTime);
}
Expand Down Expand Up @@ -168,9 +168,9 @@ private static Consumer<OrcFilterContext> createFilter(SearchArgument sArg,
normalize);
case "vector":
Reader.Options options = new Reader.Options(conf)
.searchArgument(sArg, new String[0])
.allowSARGToFilter(true)
.useSelected(true);
.searchArgument(sArg, new String[0])
.allowSARGToFilter(true)
.useSelected(true);
return FilterFactory.createBatchFilter(options,
FilterBenchUtil.schema,
false,
Expand Down
Expand Up @@ -35,8 +35,8 @@

class FilterBenchUtil {
static final TypeDescription schema = TypeDescription.createStruct()
.addField("f1", TypeDescription.createLong())
.addField("f2", TypeDescription.createLong());
.addField("f1", TypeDescription.createLong())
.addField("f2", TypeDescription.createLong());

static VectorizedRowBatch createBatch(Random rnd) {
VectorizedRowBatch b = schema.createRowBatch(1024);
Expand Down Expand Up @@ -71,11 +71,11 @@ static Map.Entry<SearchArgument, int[]> createSArg(Random rnd,
}

SearchArgument sArg = SearchArgumentFactory.newBuilder()
.startOr()
.in("f1", PredicateLeaf.Type.LONG, f1Values)
.in("f2", PredicateLeaf.Type.LONG, f2Values)
.end()
.build();
.startOr()
.in("f1", PredicateLeaf.Type.LONG, f1Values)
.in("f2", PredicateLeaf.Type.LONG, f2Values)
.end()
.build();
int[] s = sel.stream()
.mapToInt(Integer::intValue)
.toArray();
Expand Down Expand Up @@ -108,8 +108,8 @@ static Map.Entry<SearchArgument, int[]> createComplexSArg(Random rnd,
sel.add(selIdx);
}
builder
.in("f1", PredicateLeaf.Type.LONG, f1Values)
.in("f2", PredicateLeaf.Type.LONG, f2Values);
.in("f1", PredicateLeaf.Type.LONG, f1Values)
.in("f2", PredicateLeaf.Type.LONG, f2Values);
builder.end();
}
builder.end();
Expand Down
Expand Up @@ -127,7 +127,7 @@ private static long writeFile(TypeDescription schema, int rowCount, Path path)

private static TypeDescription createSchema(int colCount) {
TypeDescription schema = TypeDescription.createStruct()
.addField("id", TypeDescription.createLong());
.addField("id", TypeDescription.createLong());
for (int i = 1; i <= colCount; i++) {
TypeDescription fieldType;
switch (i % 3) {
Expand Down
Expand Up @@ -118,8 +118,8 @@ public void parquet(IOCounters counters) throws Exception {
conf.set("columns", "vendor_id,pickup_time");
conf.set("columns.types", "int,timestamp");
} else if ("sales".equals(dataset)) {
conf.set("columns", "sales_id,customer_id");
conf.set("columns.types", "bigint,bigint");
conf.set("columns", "sales_id,customer_id");
conf.set("columns.types", "bigint,bigint");
} else if ("github".equals(dataset)) {
conf.set("columns", "actor,created_at");
conf.set("columns.types", "struct<avatar_url:string,gravatar_id:string," +
Expand Down
9 changes: 9 additions & 0 deletions java/checkstyle.xml
Expand Up @@ -55,5 +55,14 @@
<property name="ignoreComments" value="true"/>
<property name="message" value="No starting LAND and LOR allowed."/>
</module>
<module name="Indentation">
<property name="severity" value="error"/>
<property name="basicOffset" value="2"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="2"/>
<property name="throwsIndent" value="2"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="2"/>
</module>
</module>
</module>
3 changes: 1 addition & 2 deletions java/core/src/java/org/apache/orc/OrcFile.java
Expand Up @@ -995,8 +995,7 @@ public static WriterOptions writerOptions(Properties tableProperties,

private static MemoryManager memoryManager = null;

private static synchronized
MemoryManager getStaticMemoryManager(Configuration conf) {
private static synchronized MemoryManager getStaticMemoryManager(Configuration conf) {
if (memoryManager == null) {
memoryManager = new MemoryManagerImpl(conf);
}
Expand Down
213 changes: 106 additions & 107 deletions java/core/src/java/org/apache/orc/OrcUtils.java
Expand Up @@ -122,83 +122,83 @@ private static void appendOrcTypes(List<OrcProto.Type> result, TypeDescription t
.build());
}
switch (typeDescr.getCategory()) {
case BOOLEAN:
type.setKind(OrcProto.Type.Kind.BOOLEAN);
break;
case BYTE:
type.setKind(OrcProto.Type.Kind.BYTE);
break;
case SHORT:
type.setKind(OrcProto.Type.Kind.SHORT);
break;
case INT:
type.setKind(OrcProto.Type.Kind.INT);
break;
case LONG:
type.setKind(OrcProto.Type.Kind.LONG);
break;
case FLOAT:
type.setKind(OrcProto.Type.Kind.FLOAT);
break;
case DOUBLE:
type.setKind(OrcProto.Type.Kind.DOUBLE);
break;
case STRING:
type.setKind(OrcProto.Type.Kind.STRING);
break;
case CHAR:
type.setKind(OrcProto.Type.Kind.CHAR);
type.setMaximumLength(typeDescr.getMaxLength());
break;
case VARCHAR:
type.setKind(OrcProto.Type.Kind.VARCHAR);
type.setMaximumLength(typeDescr.getMaxLength());
break;
case BINARY:
type.setKind(OrcProto.Type.Kind.BINARY);
break;
case TIMESTAMP:
type.setKind(OrcProto.Type.Kind.TIMESTAMP);
break;
case TIMESTAMP_INSTANT:
case BOOLEAN:
type.setKind(OrcProto.Type.Kind.BOOLEAN);
break;
case BYTE:
type.setKind(OrcProto.Type.Kind.BYTE);
break;
case SHORT:
type.setKind(OrcProto.Type.Kind.SHORT);
break;
case INT:
type.setKind(OrcProto.Type.Kind.INT);
break;
case LONG:
type.setKind(OrcProto.Type.Kind.LONG);
break;
case FLOAT:
type.setKind(OrcProto.Type.Kind.FLOAT);
break;
case DOUBLE:
type.setKind(OrcProto.Type.Kind.DOUBLE);
break;
case STRING:
type.setKind(OrcProto.Type.Kind.STRING);
break;
case CHAR:
type.setKind(OrcProto.Type.Kind.CHAR);
type.setMaximumLength(typeDescr.getMaxLength());
break;
case VARCHAR:
type.setKind(OrcProto.Type.Kind.VARCHAR);
type.setMaximumLength(typeDescr.getMaxLength());
break;
case BINARY:
type.setKind(OrcProto.Type.Kind.BINARY);
break;
case TIMESTAMP:
type.setKind(OrcProto.Type.Kind.TIMESTAMP);
break;
case TIMESTAMP_INSTANT:
type.setKind(OrcProto.Type.Kind.TIMESTAMP_INSTANT);
break;
case DATE:
type.setKind(OrcProto.Type.Kind.DATE);
break;
case DECIMAL:
type.setKind(OrcProto.Type.Kind.DECIMAL);
type.setPrecision(typeDescr.getPrecision());
type.setScale(typeDescr.getScale());
break;
case LIST:
type.setKind(OrcProto.Type.Kind.LIST);
type.addSubtypes(children.get(0).getId());
break;
case MAP:
type.setKind(OrcProto.Type.Kind.MAP);
for(TypeDescription t: children) {
type.addSubtypes(t.getId());
}
break;
case STRUCT:
type.setKind(OrcProto.Type.Kind.STRUCT);
for(TypeDescription t: children) {
type.addSubtypes(t.getId());
}
for(String field: typeDescr.getFieldNames()) {
type.addFieldNames(field);
}
break;
case UNION:
type.setKind(OrcProto.Type.Kind.UNION);
for(TypeDescription t: children) {
type.addSubtypes(t.getId());
}
break;
default:
throw new IllegalArgumentException("Unknown category: " +
typeDescr.getCategory());
case DATE:
type.setKind(OrcProto.Type.Kind.DATE);
break;
case DECIMAL:
type.setKind(OrcProto.Type.Kind.DECIMAL);
type.setPrecision(typeDescr.getPrecision());
type.setScale(typeDescr.getScale());
break;
case LIST:
type.setKind(OrcProto.Type.Kind.LIST);
type.addSubtypes(children.get(0).getId());
break;
case MAP:
type.setKind(OrcProto.Type.Kind.MAP);
for(TypeDescription t: children) {
type.addSubtypes(t.getId());
}
break;
case STRUCT:
type.setKind(OrcProto.Type.Kind.STRUCT);
for(TypeDescription t: children) {
type.addSubtypes(t.getId());
}
for(String field: typeDescr.getFieldNames()) {
type.addFieldNames(field);
}
break;
case UNION:
type.setKind(OrcProto.Type.Kind.UNION);
for(TypeDescription t: children) {
type.addSubtypes(t.getId());
}
break;
default:
throw new IllegalArgumentException("Unknown category: " +
typeDescr.getCategory());
}
result.add(type.build());
if (children != null) {
Expand Down Expand Up @@ -297,12 +297,11 @@ TypeDescription convertTypeFromProtobuf(List<OrcProto.Type> types,
result = TypeDescription.createString();
break;
case CHAR:
case VARCHAR: {
result = type.getKind() == OrcProto.Type.Kind.CHAR ?
TypeDescription.createChar() : TypeDescription.createVarchar();
if (type.hasMaximumLength()) {
result.withMaxLength(type.getMaximumLength());
}
case VARCHAR:
result = type.getKind() == OrcProto.Type.Kind.CHAR ?
TypeDescription.createChar() : TypeDescription.createVarchar();
if (type.hasMaximumLength()) {
result.withMaxLength(type.getMaximumLength());
}
break;
case BINARY:
Expand All @@ -318,15 +317,15 @@ TypeDescription convertTypeFromProtobuf(List<OrcProto.Type> types,
result = TypeDescription.createDate();
break;
case DECIMAL: {
result = TypeDescription.createDecimal();
if (type.hasScale()) {
result.withScale(type.getScale());
}
if (type.hasPrecision()) {
result.withPrecision(type.getPrecision());
}
result = TypeDescription.createDecimal();
if (type.hasScale()) {
result.withScale(type.getScale());
}
break;
if (type.hasPrecision()) {
result.withPrecision(type.getPrecision());
}
}
break;
case LIST:
if (type.getSubtypesCount() != 1) {
throw new FileFormatException("LIST type should contain exactly " +
Expand All @@ -345,27 +344,27 @@ TypeDescription convertTypeFromProtobuf(List<OrcProto.Type> types,
convertTypeFromProtobuf(types, type.getSubtypes(1)));
break;
case STRUCT: {
result = TypeDescription.createStruct();
for(int f=0; f < type.getSubtypesCount(); ++f) {
String name = type.getFieldNames(f);
name = name.startsWith("`") ? name : "`" + name + "`";
String fieldName = ParserUtils.parseName(new ParserUtils.StringPosition(name));
result.addField(fieldName, convertTypeFromProtobuf(types, type.getSubtypes(f)));
}
result = TypeDescription.createStruct();
for(int f=0; f < type.getSubtypesCount(); ++f) {
String name = type.getFieldNames(f);
name = name.startsWith("`") ? name : "`" + name + "`";
String fieldName = ParserUtils.parseName(new ParserUtils.StringPosition(name));
result.addField(fieldName, convertTypeFromProtobuf(types, type.getSubtypes(f)));
}
break;
}
break;
case UNION: {
if (type.getSubtypesCount() == 0) {
throw new FileFormatException("UNION type should contain at least" +
" one subtype but has none");
}
result = TypeDescription.createUnion();
for(int f=0; f < type.getSubtypesCount(); ++f) {
result.addUnionChild(
convertTypeFromProtobuf(types, type.getSubtypes(f)));
}
if (type.getSubtypesCount() == 0) {
throw new FileFormatException("UNION type should contain at least" +
" one subtype but has none");
}
break;
result = TypeDescription.createUnion();
for(int f=0; f < type.getSubtypesCount(); ++f) {
result.addUnionChild(
convertTypeFromProtobuf(types, type.getSubtypes(f)));
}
}
break;
default:
throw new IllegalArgumentException("Unknown ORC type " + type.getKind());
}
Expand Down
2 changes: 1 addition & 1 deletion java/core/src/java/org/apache/orc/Reader.java
Expand Up @@ -236,7 +236,7 @@ class Options implements Cloneable {
private boolean allowPluginFilters = false;
private int minSeekSize = (int) OrcConf.ORC_MIN_DISK_SEEK_SIZE.getDefaultValue();
private double minSeekSizeTolerance = (double) OrcConf.ORC_MIN_DISK_SEEK_SIZE_TOLERANCE
.getDefaultValue();
.getDefaultValue();
private int rowBatchSize = (int) OrcConf.ROW_BATCH_SIZE.getDefaultValue();

/**
Expand Down

0 comments on commit 9cf9d26

Please sign in to comment.