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

[refactor] Refactored into multiple modules to be compatible with different spark version features #239

Merged
merged 9 commits into from
Dec 3, 2024

Conversation

gnehil
Copy link
Contributor

@gnehil gnehil commented Dec 2, 2024

Proposed changes

Issue Number: close #xxx

Problem Summary:

In the past, all codes were in the same module. In order to be compatible with different Spark versions, many features available in higher versions were abandoned, which brought inconvenience to use.
So refactoring is imperative.
After reconstruction, it is divided into the following modules:

├── spark-doris-connector-base
├── spark-doris-connector-dist
├── spark-doris-connector-it
├── spark-doris-connector-shims
├── spark-doris-connector-spark-2
└── spark-doris-connector-spark-3
  • spark-doris-connector-base
    This module contains the basic implementation of interaction with Doris, such as reading, writing and other API access.
    In this module, there are several important abstractions, DorisReader, DorisWriter and DorisCommitter

    • DorisReader
      This interface provides hashNext and next methods to determine whether the reading is finished and to obtain the next piece of data. Currently, two reading methods based on Thrift and Arrow Flight SQL are implemented.
    • DorisWriter
      This interface mainly provides the load and stop methods for writing a piece of data and stopping an import task.
    • DorisCommitter
      This interface mainly provides commit and abort methods for committing and rolling back transactions.
      Considering the consistency of writing and transaction processing, the write processor based on stream load or copy into implements both DorisWriter and DorisCommitter in the same class.
  • spark-doris-connector-dist
    This module is used to package.

  • spark-doris-connector-it
    This module is for end-to-end testing.

  • spark-doris-connector-shims
    This module is a shim layer used to implement functions of different spark versions.
    Currently, the version split is only based on spark 3.

├── spark-doris-connector-shims_spark-3.0
├── spark-doris-connector-shims_spark-3.1
├── spark-doris-connector-shims_spark-3.2
├── spark-doris-connector-shims_spark-3.3
├── spark-doris-connector-shims_spark-3.4
├── spark-doris-connector-shims_spark-3.5
└── spark-doris-connector-shims_spark-3-base

For the future higher spark 4 version, you can also add modules here to implement the function of minor version differences.

  • spark-doris-connector-spark-2
    This module is implemented based on spark 2.
  • spark-doris-connector-spark-3
    This module is implemented based on spark 3. It relies on different shim layers for different minor versions, which provides better compatibility.

In addition, a new feature has been added: converting and reading Bitmap type data through Arrow Flight SQL
Example

val df = spark.read
.format("doris")
.option("doris.fenodes", "192.168.0.1:8030")
.option("doris.read.arrow-flight-sql.port", "11110")
.option("doris.table.identifier", "test.t_bitmap_read")
.option("user", "root")
.option("password", "")
.option("doris.read.mode", "arrow")
.option("doris.read.bitmap-to-string", "true")
.load

Result

+------+----------------------+
| k1   | v1                   |
+------+----------------------+
|    1 | 243                  |
|    2 | 1,2,3,4,5,434543     |
|    3 | 287667876573         |
+------+----------------------+

Convert a bitmap into a comma-delimited string containing all the set BIT bits. If the input is null, null will be returned.

Checklist(Required)

  1. Does it affect the original behavior: (Yes/No/I Don't know)
  2. Has unit tests been added: (Yes/No/No Need)
  3. Has document been added or modified: (Yes/No/No Need)
  4. Does it need to update dependencies: (Yes/No)
  5. Are there any changes that cannot be rolled back: (Yes/No)

Further comments

If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...

gnehil added 9 commits August 27, 2024 14:47
# Conflicts:
#	spark-doris-connector/pom.xml
#	spark-doris-connector/spark-doris-connector-base/src/main/java/org/apache/doris/spark/cfg/SparkSettings.java
#	spark-doris-connector/spark-doris-connector-base/src/main/java/org/apache/doris/spark/rest/RestService.java
#	spark-doris-connector/spark-doris-connector-base/src/main/scala/org/apache/doris/spark/rdd/AbstractDorisRDDIterator.scala
#	spark-doris-connector/spark-doris-connector-base/src/main/scala/org/apache/doris/spark/rdd/AbstractValueReader.scala
#	spark-doris-connector/spark-doris-connector-base/src/main/scala/org/apache/doris/spark/rdd/ScalaADBCValueReader.scala
#	spark-doris-connector/spark-doris-connector-base/src/main/scala/org/apache/doris/spark/rdd/ScalaDorisRDD.scala
#	spark-doris-connector/spark-doris-connector-base/src/main/scala/org/apache/doris/spark/rdd/ScalaValueReader.scala
#	spark-doris-connector/spark-doris-connector-base/src/main/scala/org/apache/doris/spark/sql/ScalaDorisRowRDD.scala
Copy link
Member

@JNSimba JNSimba left a comment

Choose a reason for hiding this comment

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

Good Job, LGTM

@JNSimba JNSimba merged commit a75cf3b into apache:master Dec 3, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants