Skip to content

Commit

Permalink
Don't use hardcoded configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed May 18, 2018
1 parent 8c56ae4 commit 5a735af
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ class CodeGeneratorWithInterpretedFallbackSuite extends SparkFunSuite with PlanT
val input = Seq(LongType, IntegerType)
.zipWithIndex.map(x => BoundReference(x._2, x._1, true))

withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> "CODEGEN_ONLY") {
val codegenOnly = CodegenObjectFactoryMode.CODEGEN_ONLY.toString
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> codegenOnly) {
val obj = UnsafeProjection.createObject(input)
assert(obj.getClass.getName.contains("GeneratedClass$SpecificUnsafeProjection"))
}

withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> "NO_CODEGEN") {
val noCodegen = CodegenObjectFactoryMode.NO_CODEGEN.toString
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> noCodegen) {
val obj = UnsafeProjection.createObject(input)
assert(obj.isInstanceOf[InterpretedUnsafeProjection])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ trait ExpressionEvalHelper extends GeneratorDrivenPropertyChecks with PlanTestBa
expression: Expression,
expected: Any,
inputRow: InternalRow = EmptyRow): Unit = {
for (fallbackMode <- Seq("CODEGEN_ONLY", "NO_CODEGEN")) {
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode) {
val modes = Seq(CodegenObjectFactoryMode.CODEGEN_ONLY, CodegenObjectFactoryMode.NO_CODEGEN)
for (fallbackMode <- modes) {
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode.toString) {
val unsafeRow = evaluateWithUnsafeProjection(expression, inputRow)
val input = if (inputRow == EmptyRow) "" else s", input: $inputRow"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with PlanTestB
private def roundedSize(size: Int) = ByteArrayMethods.roundNumberOfBytesToNearestWord(size)

private def testBothCodegenAndInterpreted(name: String)(f: => Unit): Unit = {
for (fallbackMode <- Seq("CODEGEN_ONLY", "NO_CODEGEN")) {
val modes = Seq(CodegenObjectFactoryMode.CODEGEN_ONLY, CodegenObjectFactoryMode.NO_CODEGEN)
for (fallbackMode <- modes) {
test(name + " with " + fallbackMode) {
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode) {
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode.toString) {
f
}
}
Expand Down

0 comments on commit 5a735af

Please sign in to comment.