Skip to content

Can Nebula2Nebula support multi-thread sync ? #136

Description

@awang12345

reason
The current logic is to read all the partition data and then compose insert statements to write it out to new nebula .
It's possible to run out of memory if you have a large amount of data, and of course spark does overflow to disk, but I did run into OOM job interruptions. In addition, it does not give full play to the ability of multitasking, in fact, it is completely possible to split the partition, each partition a task, read a partition to write, the efficiency will be much higher.

// multi-thread sync  one partition data of tag or edge
for (partitionId <- 1 to partitions) {
      val task = new Runnable {
        def run(): Unit = {
          syncTagPartitionData(spark,
            ........
            partitionId
          )
        }
      }
 
      threadPool.execute(task);
    }

//set  special scan partitionId  
   val nebulaReadVertexConfig: ReadNebulaConfig = ReadNebulaConfig
      .builder()
      .with.....
      ......
      .withPartitionId(partitionId) 
      .build()
    var vertex = spark.read.nebula(sourceConfig, nebulaReadVertexConfig).loadVerticesToDF()
 
  // create task for special partition id
   class SimpleScan(nebulaOptions: NebulaOptions, nebulaTotalPart: Int, schema: StructType)
  extends Scan
    with Batch {
  override def planInputPartitions(): Array[InputPartition] = {
    //return special partiton id for task
    if (nebulaOptions.readPartitionId != null && nebulaOptions.readPartitionId > 0) {
      LOG.info(s"planInputPartitions partions:${nebulaOptions.readPartitionId}")
      return Array(NebulaPartitionBatch(Array(nebulaOptions.readPartitionId)))
    }
    .....
  }
  

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/questionType: question about the product

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions