-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reproducible ID support like in Almond
- Loading branch information
1 parent
18dbad8
commit c327a73
Showing
4 changed files
with
26 additions
and
8 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
modules/almond-spark/src/main/scala/org/apache/spark/sql/almondinternals/Id.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,21 @@ | ||
package org.apache.spark.sql.almondinternals | ||
|
||
import java.util.concurrent.atomic.AtomicInteger | ||
import java.util.{Locale, UUID} | ||
|
||
object Id { | ||
|
||
def generate(): String = | ||
if (useRandomIds) | ||
UUID.randomUUID().toString | ||
else | ||
idCount.incrementAndGet().toString | ||
|
||
private lazy val useRandomIds: Boolean = | ||
Option(System.getenv("ALMOND_USE_RANDOM_IDS")) | ||
.orElse(sys.props.get("almond.ids.random")) | ||
.forall(s => s == "1" || s.toLowerCase(Locale.ROOT) == "true") | ||
|
||
private val idCount = new AtomicInteger(222222) | ||
|
||
} |
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