Created
November 15, 2018 16:32
-
-
Save Yengas/a7f4c1fc8a53254768b17e4e27275352 to your computer and use it in GitHub Desktop.
Spark at Getir - 01
This file contains hidden or 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
// Previous approach to conversion | |
// definition | |
def rowToDocument(row: Row): BsonDocument | |
// usage | |
rowToDocument(row) // for each line | |
// The (micro) optimized approach | |
// definition | |
def rowToDocumentMapper(schema: StructType): (Row) => BsonDocument | |
// usage | |
val mapper = rowToDocumentMapper(dataSet.schema) // one time, before starting the row writing | |
mapper(row) // for each line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment