-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the ORC version that corresponds to the Spark version [databricks] (
#4408) * try to remove shade * 312db build * 301db build * CDH shim * Add license to pass RAT check * Use Spark OrcFilters instead of the copied one; Comment a test case * Remove protobuf and hive storage api version proterties * Remove the dependency of Guava; Refactor * Put mudules into specific profiles * Fix thread factory builder bug * Add dependency * Update test case * Fix shading overlapping resource warning * Update the test cases * Update version after 22.02 changed to 22.04 accordingly Signed-off-by: Chong Gao <res_life@163.com>
- Loading branch information
Chong Gao
authored
Feb 8, 2022
1 parent
434ee37
commit 215541a
Showing
31 changed files
with
732 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2022, NVIDIA CORPORATION. | ||
Licensed 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. | ||
--> | ||
|
||
<!-- Filter unused classes for shade purpose, generate a jar with shaded classifier --> | ||
<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> | ||
|
||
<parent> | ||
<groupId>com.nvidia</groupId> | ||
<artifactId>rapids-4-spark-parent</artifactId> | ||
<version>22.04.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>rapids-4-spark-common_2.12</artifactId> | ||
<name>RAPIDS Accelerator for Apache Spark Common</name> | ||
<description>Utility code that is common across the RAPIDS Accelerator projects</description> | ||
<version>22.04.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.scala-lang</groupId> | ||
<artifactId>scala-library</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.scalatest</groupId> | ||
<artifactId>scalatest_${scala.binary.version}</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<!-- Include the properties file to provide the build information. --> | ||
<directory>${project.build.directory}/extra-resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
<resource> | ||
<directory>${project.basedir}/..</directory> | ||
<targetPath>META-INF</targetPath> | ||
<includes> | ||
<!-- The NOTICE will be taken care of by the antrun task below --> | ||
<include>LICENSE</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default-test-jar</id> | ||
<phase>none</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- disable surefire as tests are some place else --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>true</skipTests> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>net.alchim31.maven</groupId> | ||
<artifactId>scala-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.rat</groupId> | ||
<artifactId>apache-rat-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.scalatest</groupId> | ||
<artifactId>scalatest-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
23 changes: 23 additions & 0 deletions
23
common/src/main/scala/com/nvidia/spark/rapids/CheckUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2022, NVIDIA CORPORATION. | ||
* | ||
* Licensed 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 com.nvidia.spark.rapids | ||
|
||
object CheckUtils { | ||
def checkArgument(expression: Boolean, msg: String): Unit = { | ||
if (!expression) throw new IllegalArgumentException(msg) | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
common/src/main/scala/com/nvidia/spark/rapids/ThreadFactoryBuilder.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2022, NVIDIA CORPORATION. | ||
* | ||
* Licensed 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 com.nvidia.spark.rapids | ||
|
||
import java.util.concurrent.{Executors, ThreadFactory} | ||
import java.util.concurrent.atomic.AtomicLong | ||
|
||
// This is similar to Guava ThreadFactoryBuilder | ||
// Avoid to use Guava as it is a messy dependency in practice. | ||
class ThreadFactoryBuilder { | ||
private var nameFormat = Option.empty[String] | ||
private var daemon = Option.empty[Boolean] | ||
|
||
def setNameFormat(nameFormat: String): ThreadFactoryBuilder = { | ||
nameFormat.format(0) | ||
this.nameFormat = Some(nameFormat) | ||
this | ||
} | ||
|
||
def setDaemon(daemon: Boolean): ThreadFactoryBuilder = { | ||
this.daemon = Some(daemon) | ||
this | ||
} | ||
|
||
def build(): ThreadFactory = { | ||
val count = nameFormat.map(_ => new AtomicLong(0)) | ||
new ThreadFactory() { | ||
private val defaultThreadFactory = Executors.defaultThreadFactory | ||
|
||
override def newThread(r: Runnable): Thread = { | ||
val thread = defaultThreadFactory.newThread(r) | ||
nameFormat.foreach(f => thread.setName(f.format(count.get.getAndIncrement()))) | ||
daemon.foreach(b => thread.setDaemon(b)) | ||
thread | ||
} | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
common/src/test/scala/com/nvidia/spark/rapids/ThreadFactoryBuilderTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) 2022, NVIDIA CORPORATION. | ||
* | ||
* Licensed 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 com.nvidia.spark.rapids | ||
|
||
import java.util.concurrent.{Callable, Executors} | ||
|
||
import org.scalatest.FunSuite | ||
|
||
class ThreadFactoryBuilderTest extends FunSuite { | ||
|
||
test("test thread factory builder") { | ||
val pool1 = Executors.newFixedThreadPool(2, | ||
new ThreadFactoryBuilder().setNameFormat("thread-pool1-1 %s").setDaemon(true).build()) | ||
try { | ||
var ret = pool1.submit(new Callable[String] { | ||
override def call(): String = { | ||
assert(Thread.currentThread().isDaemon) | ||
assert(Thread.currentThread().getName == "thread-pool1-1 0") | ||
"" | ||
} | ||
}) | ||
// waits and retrieves the result, if above asserts failed, will get execution exception | ||
ret.get() | ||
ret = pool1.submit(() => { | ||
assert(Thread.currentThread().isDaemon) | ||
assert(Thread.currentThread().getName == "thread-pool1-1 1") | ||
"" | ||
}) | ||
ret.get() | ||
} finally { | ||
pool1.shutdown() | ||
} | ||
|
||
val pool2 = Executors.newFixedThreadPool(2, | ||
new ThreadFactoryBuilder().setNameFormat("pool2-%d").build()) | ||
try { | ||
var ret = pool2.submit(new Callable[String] { | ||
override def call(): String = { | ||
assert(!Thread.currentThread().isDaemon) | ||
assert(Thread.currentThread().getName == "pool2-0") | ||
"" | ||
} | ||
}) | ||
ret.get() | ||
ret = pool2.submit(() => { | ||
assert(!Thread.currentThread().isDaemon) | ||
assert(Thread.currentThread().getName == "pool2-1") | ||
"" | ||
}) | ||
ret.get() | ||
} finally { | ||
pool2.shutdown() | ||
} | ||
|
||
val pool3 = Executors.newFixedThreadPool(2, | ||
new ThreadFactoryBuilder().setNameFormat("pool3-%d").setDaemon(false).build()) | ||
try { | ||
pool3.submit(new Callable[String] { | ||
override def call(): String = { | ||
assert(!Thread.currentThread().isDaemon) | ||
assert(Thread.currentThread().getName == "pool3-0") | ||
"" | ||
} | ||
}).get() | ||
} finally { | ||
pool3.shutdown() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.