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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions parquet-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,34 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<dependencies>
<dependency>
<groupId>org.apache.parquet</groupId>
<artifactId>parquet-generator</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.apache.parquet.version.Generator</mainClass>
<includePluginDependencies>true</includePluginDependencies>
<arguments>
<argument>${basedir}/target/generated-src</argument>
</arguments>
<sourceRoot>${basedir}/target/generated-src</sourceRoot>
</configuration>
</plugin>
</plugins>
</build>
</project>
103 changes: 0 additions & 103 deletions parquet-common/src/main/java/org/apache/parquet/Version.java

This file was deleted.

11 changes: 6 additions & 5 deletions parquet-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
</properties>

<dependencies>
<dependency>
<groupId>org.apache.parquet</groupId>
<artifactId>parquet-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import java.io.FileWriter;
import java.io.IOException;

import org.apache.parquet.bytes.BytesUtils;

/**
*
* This class generates bit packers that pack the most significant bit first.
Expand Down Expand Up @@ -214,7 +212,7 @@ private static void generateUnpack(FileWriter fw, int bitWidth, int batch, boole
fw.append(" out[" + align(valueIndex, 2) + " + outPos] =\n");

int startIndex = valueIndex * bitWidth / 8;
int endIndex = BytesUtils.paddedByteCountFromBits((valueIndex + 1) * bitWidth);
int endIndex = paddedByteCountFromBits((valueIndex + 1) * bitWidth);

for (int byteIndex = startIndex; byteIndex < endIndex; byteIndex++) {
if (byteIndex == startIndex) {
Expand Down Expand Up @@ -256,4 +254,9 @@ private static String align(int value, int digits) {
result.append(valueString);
return result.toString();
}

// duplicated from BytesUtils to avoid a circular dependency between parquet-common and parquet-generator
private static int paddedByteCountFromBits(int bitLength) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why these changes should be included in the version pull request. Maybe this was an accident?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to break circular dependency between parquet-generator and parquet-common.

This was the only method from parquet-common that was used by parquet-generator, so I've just copied it here and removed dependency on parquet-common (have a look at parquet-generator/pom.xml change).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that makes sense to me. Sounds good.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah sort of a bummer but not too bad. Can you add a comment to this method:

// duplicated from BytesUtils to avoid a circular dependency between parquet-common and parquet-generator
// TODO: fix the circular dependency by moving the shared bits to a 3rd module (PARQUET-XXXX)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add a comment about ByteUtils. Not sure it is worth fixing though as the method is one-liner, is not parquet specific and easy to understand.

return (bitLength + 7) / 8;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.
*/
package org.apache.parquet.version;

/**
* main class for code generation hook in build for version generation
*/
public class Generator {
public static void main(String[] args) throws Exception {
VersionGenerator.main(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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.
*/
package org.apache.parquet.version;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class VersionGenerator {

public static void main(String[] args) throws IOException {
File srcFile = new File(args[0] + "/org/apache/parquet/Version.java");
srcFile = srcFile.getAbsoluteFile();
File parent = srcFile.getParentFile();
if (!parent.exists()) {
if (!parent.mkdirs()) {
throw new IOException("Couldn't mkdirs for " + parent);
}
}
new VersionGenerator(srcFile).run();
}

private final FileWriter writer;

public VersionGenerator(File file) throws IOException {
this.writer = new FileWriter(file);
}

public void run() throws IOException {
InputStream in = VersionGenerator.class.getResourceAsStream("/parquet-version.properties");
if (in == null) {
throw new IOException("/parquet-version.properties not found");
}
Properties props = new Properties();
props.load(in);

add("package org.apache.parquet;\n" +
"\n" +
"/**\n" +
" * This class is auto-generated by {@link org.apache.parquet.version.VersionGenerator}\n" +
" * Do not manually edit!\n" +
" */\n");

add("public class Version {\n");

add(" public static final String VERSION_NUMBER = \"");
add(props.getProperty("versionNumber"));
add("\";\n");

add(" public static final String FULL_VERSION = \"");
add(props.getProperty("fullVersion"));
add("\";\n\n");

add(" public static void main(String[] args) {\n");
add(" System.out.println(FULL_VERSION);\n");
add(" }\n");

add("}\n");
writer.close();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the main method, this looks compatible with the old Version class to me. While it's nit-picking and probably over-cautious, I think we should probably include main.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

private void add(String s) throws IOException {
writer.write(s);
}
}
20 changes: 20 additions & 0 deletions parquet-generator/src/main/resources/parquet-version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# 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.

versionNumber = ${project.version}
fullVersion = parquet-mr version ${project.version} (build ${buildNumber})