forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-44396][CONNECT] Direct Arrow Deserialization
### What changes were proposed in this pull request? This PR adds direct arrow to user object deserialization to the Spark Connect Scala Client. ### Why are the changes needed? We want to decouple the scala client from catalyst. We need a way to encode user object from and to arrrow. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Added tests to `ArrowEncoderSuite`. Closes apache#42011 from hvanhovell/SPARK-44396. Authored-by: Herman van Hovell <herman@databricks.com> Signed-off-by: Herman van Hovell <herman@databricks.com>
- Loading branch information
1 parent
047fad5
commit 5939b75
Showing
11 changed files
with
1,085 additions
and
178 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
38 changes: 38 additions & 0 deletions
38
.../src/main/scala-2.12/org/apache/spark/sql/connect/client/arrow/ScalaCollectionUtils.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,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.spark.sql.connect.client.arrow | ||
|
||
import scala.collection.generic.{GenericCompanion, GenMapFactory} | ||
import scala.collection.mutable | ||
import scala.reflect.ClassTag | ||
|
||
import org.apache.spark.sql.connect.client.arrow.ArrowDeserializers.resolveCompanion | ||
|
||
/** | ||
* A couple of scala version specific collection utility functions. | ||
*/ | ||
private[arrow] object ScalaCollectionUtils { | ||
def getIterableCompanion(tag: ClassTag[_]): GenericCompanion[Iterable] = { | ||
ArrowDeserializers.resolveCompanion[GenericCompanion[Iterable]](tag) | ||
} | ||
def getMapCompanion(tag: ClassTag[_]): GenMapFactory[Map] = { | ||
resolveCompanion[GenMapFactory[Map]](tag) | ||
} | ||
def wrap[T](array: AnyRef): mutable.WrappedArray[T] = { | ||
mutable.WrappedArray.make(array) | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
.../src/main/scala-2.13/org/apache/spark/sql/connect/client/arrow/ScalaCollectionUtils.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,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.spark.sql.connect.client.arrow | ||
|
||
import scala.collection.{mutable, IterableFactory, MapFactory} | ||
import scala.reflect.ClassTag | ||
|
||
import org.apache.spark.sql.connect.client.arrow.ArrowDeserializers.resolveCompanion | ||
|
||
/** | ||
* A couple of scala version specific collection utility functions. | ||
*/ | ||
private[arrow] object ScalaCollectionUtils { | ||
def getIterableCompanion(tag: ClassTag[_]): IterableFactory[Iterable] = { | ||
ArrowDeserializers.resolveCompanion[IterableFactory[Iterable]](tag) | ||
} | ||
def getMapCompanion(tag: ClassTag[_]): MapFactory[Map] = { | ||
resolveCompanion[MapFactory[Map]](tag) | ||
} | ||
def wrap[T](array: AnyRef): mutable.WrappedArray[T] = { | ||
mutable.WrappedArray.make(array.asInstanceOf[Array[T]]) | ||
} | ||
} |
Oops, something went wrong.