content: package com.tencent.angel.graph.model.general.init;
  
  import com.tencent.angel.graph.common.psf.param.LongKeysUpdateParam;
  import com.tencent.angel.graph.utils.GraphMatrixUtils;
  import com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam;
  import com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam;
  import com.tencent.angel.ml.matrix.psf.update.base.UpdateFunc;
  import com.tencent.angel.ps.storage.vector.ServerLongAnyRow;
  import com.tencent.angel.ps.storage.vector.element.IElement;
  import com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp;
  
  public class GeneralInit extends UpdateFunc {
    /**
     * Create a new UpdateParam
     */
    public GeneralInit(LongKeysUpdateParam param) {
      super(param);
    }
  
    public GeneralInit() {
      this(null);
    }
  
    @Override
    public void partitionUpdate(PartitionUpdateParam partParam) {
      GeneralPartUpdateParam initParam = (GeneralPartUpdateParam) partParam;
      ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, initParam);
  
      // Get nodes and features
      ILongKeyAnyValuePartOp split = (ILongKeyAnyValuePartOp) initParam.getKeyValuePart();
      long[] nodeIds = split.getKeys();
      IElement[] neighbors = split.getValues();
  
      row.startWrite();
      try {
        for(int i = 0; i < nodeIds.length; i++) {
          row.set(nodeIds[i], neighbors[i]);
        }
      } finally {
        row.endWrite();
      }
    }
  }
  