Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for writing Ion Binary #39

Closed
wants to merge 1 commit into from
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
7 changes: 6 additions & 1 deletion config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
~ You may not use this file except in compliance with the License.
~ A copy of the License is located at:
~
~ http://aws.amazon.com/apache2.0/
~ http://aws.amazon.com/apache2.0/
~
~ or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down Expand Up @@ -41,6 +41,11 @@
<property name="eachLine" value="true"/>
</module>

<module name="Header">
<property name="headerFile" value="config/checkstyle/copyright-header" />
<property name="fileExtensions" value="java,kt" />
</module>

<module name="TreeWalker">
<module name="SuppressionCommentFilter" /> <!-- allows for CHECKSTYLE:OFF comments -->
<module name="OuterTypeFilename"/>
Expand Down
13 changes: 13 additions & 0 deletions config/checkstyle/copyright-header
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file 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.
*
*/
2 changes: 1 addition & 1 deletion config/intellij/codestyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
~ You may not use this file except in compliance with the License.
~ A copy of the License is located at:
~
~ http://aws.amazon.com/apache2.0/
~ http://aws.amazon.com/apache2.0/
~
~ or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
2 changes: 1 addition & 1 deletion integration-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
8 changes: 4 additions & 4 deletions integration-test/docker/conf/beeline-log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at:
#
# http://aws.amazon.com/apache2.0/
#
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file 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.
#
#
#

status = INFO
Expand Down
8 changes: 4 additions & 4 deletions integration-test/docker/conf/hive-exec-log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at:
#
# http://aws.amazon.com/apache2.0/
#
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file 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.
#
#
#

status = INFO
Expand Down
8 changes: 4 additions & 4 deletions integration-test/docker/conf/hive-log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at:
#
# http://aws.amazon.com/apache2.0/
#
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file 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.
#
#
#

status = INFO
Expand Down
2 changes: 1 addition & 1 deletion integration-test/docker/conf/hive-site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
~ You may not use this file except in compliance with the License.
~ A copy of the License is located at:
~
~ http://aws.amazon.com/apache2.0/
~ http://aws.amazon.com/apache2.0/
~
~ or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
2 changes: 1 addition & 1 deletion integration-test/docker/conf/ivysettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
~ You may not use this file except in compliance with the License.
~ A copy of the License is located at:
~
~ http://aws.amazon.com/apache2.0/
~ http://aws.amazon.com/apache2.0/
~
~ or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
8 changes: 4 additions & 4 deletions integration-test/docker/conf/llap-daemon-log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at:
#
# http://aws.amazon.com/apache2.0/
#
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file 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.
#
#
#

status = INFO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down Expand Up @@ -62,7 +62,7 @@ public static void afterClass() {

/**
* Drops all hive tables to ensure a clean metastore. This will not clean up HDFS, it only removes the Hive tables
* which are views on the HDFS test data
* which are views on the HDFS test data.
*/
@Before
public void before() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand All @@ -13,15 +13,35 @@
*/

/**
* Utility functions for dealing with the local file system
* Utility functions for dealing with the local file system.
*/
@file:JvmName("FileSystemUtil")

package software.amazon.ionhiveserde.integrationtest

import java.io.File

/**
* Creates the directory including parent directories if necessary.
*
* @param path path to create the directory.
* @return true if the directory was created, false otherwise.
*/
fun mkdir(path: String) = File(path).mkdirs()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I would add the return type on the Kotlin signature as well, in case we alter the body in a way that alters the return type. Documents and possibly catches us from making an API change.

Since I am here. Are we planning to add the program that analyzes API changes for us on each version (todo or issue here would suffice)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#40

This is part of test code so we don't need to care much about breaking changes. Also since the SerDe not a general purpose library but a Hive plugin backward compatibility is not that important, it's more important to be compatible with Hive versions


/**
* Removes path recursively.
*
* @param path path to be removed.
* @return true if the path was removed, false otherwise.
*/
fun rm(path: String) = File(path).deleteRecursively()

fun String.sanitize() = this.replace(Regex("[<>:,()]"), "_")
/**
* Sanitizes a String to be a valid path by replacing invalid sequences with the replacement string.
*
* @param replacement String to be used, defaults to `"_"`.
*
* @return sanitized String.
*/
fun String.sanitize(replacement: String = "_") = this.replace(Regex("[<>:,()]"), replacement)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand All @@ -13,7 +13,7 @@
*/

/**
* Ion related utility methods to be used in the test scope
* Ion related utility methods to be used in the test scope.
*/
@file:JvmName("IonUtil")

Expand All @@ -25,23 +25,23 @@ import software.amazon.ion.IonValue
import software.amazon.ion.IonWriter
import software.amazon.ion.system.IonSystemBuilder
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream

/** Standard Ion system with no catalog. */
val ION: IonSystem = IonSystemBuilder.standard().build()

// Extensions

/**
* [IonSystem.singleValue] from a local path
* [IonSystem.singleValue] from a local path.
*/
fun IonSystem.singleValueFromPath(path: String): IonValue = this.singleValue(File(path).readBytes())

/** [IonSystem.newTextWriter] from the local path */
/** [IonSystem.newTextWriter] from the local path. */
fun IonSystem.newTextWriterFromPath(path: String): IonWriter = ION.newTextWriter(FileOutputStream(File(path)))

/** [IonSystem.newBinaryWriterFromPath] from the local path */
/** [IonSystem.newBinaryWriterFromPath] from the local path. */
fun IonSystem.newBinaryWriterFromPath(path: String): IonWriter = ION.newBinaryWriter(FileOutputStream(File(path)))

/** Struct keys as a sequence */
/** Struct keys as a sequence. */
fun IonStruct.keys(): Sequence<String> = this.asSequence().map { it.fieldName }
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You may not use this file except in compliance with the License.
* A copy of the License is located at:
*
* http://aws.amazon.com/apache2.0/
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
Expand All @@ -23,12 +23,23 @@ package software.amazon.ionhiveserde.integrationtest.docker
* See https://github.com/amzn/ion-hive-serde/issues/37 for more info
*/
object HDFS {

/**
* Puts all data in path to HDFS /data directory
*
* @param path path relative to the shared directory
*/
@JvmStatic
fun put(path: String) {
runInDocker("hadoop fs -mkdir -p /data")
runInDocker("hadoop fs -put -f /$SHARED_DIR/$path /data")
}

/**
* Removes data from HDFS
*
* @param path HDFS absolute path
*/
@JvmStatic
fun rm(path: String) = runInDocker("hadoop fs -rm -r -f $path")
}
Loading