microsoft / hyperspace

An open source indexing subsystem that brings index-based query acceleration to Apache Spark™ and big data workloads.
https://aka.ms/hyperspace
Apache License 2.0
424 stars 115 forks source link

[WIP] Introduce conditional compilation macros #456

Closed clee704 closed 3 years ago

clee704 commented 3 years ago

What is the context for this pull request?

What changes were proposed in this pull request?

Introduce conditional compilation macros for Spark-version-dependent compilation. Currently, we are relying on Spark-version-specific source directories and they work nicely, but sometimes it's not easy to extract differences into separate files without duplicating a lot of code, introducing performance overhead, and/or impacting the code readability.

For example, in #443, I added annotations for StructType serialization/deserialization because without them it doesn't work in Spark 2.4. However, those annotations do unnecessary extra things for Spark 3+. There are ways to handle the issue with version-specific source directories, but using macros is the cleanest: no duplication, no runtime overhead, and readable.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Unit test (see MacroTest.scala)

clee704 commented 3 years ago

Will revisit later