trait LayerDataFrameWriter extends AnyRef
Custom Spark DataFrameWriter for writing data to a given layer.
The layer type will be inferred from the layer configuration. Therefore the api to write to index layer or versioned layer is the same. To write to an index or versioned layer, your application must perform the following operations:
- Have some data as a DataFrame.
- Use LayerDataFrameWriter.DataFrameExt.writeLayer to create a LayerDataFrameWriter.
- Call withDataConverter to specify how the data groupings should be merged to a single data file. This is not necessary if the data is stored in avro, parquet, or protobuf as the appropriate DataConverter will be inferred by the layer's content type.
- Call save to save the data stored in the DataFrame to the given layer
Below is an example written in Scala that demonstrates how to write data to an index layer:
import com.here.platform.data.client.spark.LayerDataFrameWriter.DataFrameExt val spark = SparkSession .builder() .appName(getClass.getSimpleName) .master("local[*]") .getOrCreate() val dataFrame: DataFrame = ??? dataFrame .writeLayer(catalogHrn, indexLayer) .save()
Java developers should use com.here.platform.data.client.spark.javadsl.JavaLayerDataFrameWriter#writeLayer instead of dataFrame.writeLayer:
Dataset<Row> df = ??? JavaLayerDataFrameWriter.create(df) .writeLayer(catalogHrn, layerId) .save()
The batch size (number of Row
s) for a grouping can be restricted to a certain amount by setting the
option olp.groupedBatchSize
(ie 2 for 2 Row
s to be in each group):
val dataFrame: DataFrame = ??? dataFrame .writeLayer(catalogHrn, indexLayer) .option("olp.groupedBatchSize", 2) .save()
- Note
If the save method cannot correctly infer the DataConverter from the layer content type, the application will be required to provide the DataConverter using the withDataConverter method.
- Alphabetic
- By Inheritance
- LayerDataFrameWriter
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
option(key: String, value: String): LayerDataFrameWriter
Adds an option for the underlying data source.
-
abstract
def
option(key: String, value: Boolean): LayerDataFrameWriter
Adds an option for the underlying data source.
-
abstract
def
option(key: String, value: Long): LayerDataFrameWriter
Adds an option for the underlying data source.
-
abstract
def
option(key: String, value: Double): LayerDataFrameWriter
Adds an option for the underlying data source.
-
abstract
def
save(): Unit
Save the data to the given layer *
-
abstract
def
withDataConverter(dataConverter: DataConverter): LayerDataFrameWriter
Specify a
DataConverter
to convert a collection of dataRow
to an aggregated data file as a byte array. -
abstract
def
withDataConverter(dataConverter: DataConverter): LayerDataFrameWriter
Specify a
DataConverter
to convert a collection of dataRow
to an aggregated data file as a byte array. -
abstract
def
withDependencies(dependencies: Seq[VersionDependency]): LayerDataFrameWriter
Specify the dependencies to be used for write operation
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()