dosubot[bot] commented on issue #2605:
URL: 
https://github.com/apache/incubator-hugegraph/issues/2605#issuecomment-2256452921

   <!-- Answer -->
   The `newPartition` method is called in the `PartitionService` class within 
the `getPartitionByCode` method. Specifically, it is invoked when a partition 
is not found for a given code, and a new partition needs to be created.
   
   Here is the relevant code snippet:
   
   ```java
   public Metapb.PartitionShard getPartitionByCode(String graphName, long code) 
throws PDException {
       if (code < 0 || code >= PartitionUtils.MAX_VALUE) {
           throw new PDException(Pdpb.ErrorType.NOT_FOUND_VALUE, "code error");
       }
       // Find the partition ID based on the code, and if it doesn't find, 
create a new partition
       Metapb.Partition partition = partitionMeta.getPartitionByCode(graphName, 
code);
   
       if (partition == null) {
           synchronized (this) {
               if (partition == null) {
                   partition = newPartition(graphName, code);
               }
           }
       }
   
       Metapb.PartitionShard partShard = Metapb.PartitionShard.newBuilder()
                                                              
.setPartition(partition)
                                                              
.setLeader(storeService.getLeader(
                                                                      
partition, 0))
                                                              .build();
       log.debug(
               "{} Partition get code = {}, partition id  = {}, start = {}, end 
= {}, leader = {}",
               graphName, (code), partition.getId(), partition.getStartKey(),
               partition.getEndKey(), partShard.getLeader());
   
       return partShard;
   }
   ```
   
   In this snippet, `newPartition` is called to handle the creation of a new 
partition when the partition for the given code does not exist 
<sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/PartitionService.java)</sup><sup>[[2]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/PartitionEngine.java)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to