Skip to content

Commit

Permalink
[Improvement][Spark] Change VertexWriter constructor signature (#314)
Browse files Browse the repository at this point in the history
On branch 313-replace-scala-option
 Changes to be committed:
	modified:   spark/src/main/scala/com/alibaba/graphar/graph/GraphWriter.scala
	modified:   spark/src/main/scala/com/alibaba/graphar/writer/VertexWriter.scala
  • Loading branch information
SemyonSinchenko committed Jan 3, 2024
1 parent 4d626cd commit 9ca5bc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class GraphWriter() {
val df_with_index = df_and_mapping._1
indexMappings += label -> df_and_mapping._2
val writer =
new VertexWriter(prefix, vertexInfo, df_with_index, Some(vertex_num))
new VertexWriter(prefix, vertexInfo, df_with_index, vertex_num)
writer.writeVertexProperties()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@ object VertexWriter {
* the vertex info that describes the vertex type.
* @param vertexDf
* the input vertex DataFrame.
* @param numVertices
* the number of vertices, if negative value is passed, then vertexDF.count
* will be used
*/
class VertexWriter(
prefix: String,
vertexInfo: VertexInfo,
vertexDf: DataFrame,
numVertices: Option[Long] = None
numVertices: Long = -1
) {
private val spark = vertexDf.sparkSession
validate()
private val vertexNum: Long = numVertices match {
case None => vertexDf.count()
case _ => numVertices.get
}
private val vertexNum: Long =
if (numVertices < 0) vertexDf.count else numVertices
writeVertexNum()

private var chunks: DataFrame = VertexWriter.repartitionAndSort(
Expand Down

0 comments on commit 9ca5bc3

Please sign in to comment.