Cpaulyz opened a new pull request, #11566:
URL: https://github.com/apache/iotdb/pull/11566

   ## Description
   
   Currently, if a template is activated in the SchemaRegion, all the mnode 
sequences are traversed when fetchSchema. For example, 100,000 devices with 30 
measurements per device will traverse 3,000,000 mnode.
   
   This PR is optimised so that for devices that use templates. Interface 
`skipTemplateChildren(IDeviceMNode device)` is provided by traverser framework. 
In the example above, only 100,000 mnode need to be traversed.
   
   ## Test
   ```java
   @Test
   public void testFetchPerformance() throws Exception {
     ISchemaRegion schemaRegion = getSchemaRegion("root.sg", 0);
     List<String> measurements = new ArrayList<>();
     List<TSDataType> dataTypes = new ArrayList<>();
     List<TSEncoding> encodings = new ArrayList<>();
     List<CompressionType> compressors = new ArrayList<>();
     for (int i = 0; i < 30; i++) {
       measurements.add("s" + i);
       dataTypes.add(TSDataType.INT64);
       encodings.add(TSEncoding.PLAIN);
       compressors.add(CompressionType.SNAPPY);
     }
     Template template = new Template("t1", measurements, dataTypes, encodings, 
compressors);
     template.setId(1);
   
     long startTime = System.currentTimeMillis();
     for (int i = 0; i < 100000; i++) {
       schemaRegion.activateSchemaTemplate(
           SchemaRegionWritePlanFactory.getActivateTemplateInClusterPlan(
               new PartialPath("root.sg.d" + i), 1, template.getId()),
           template);
     }
     System.out.println("activateSchemaTemplate cost: " + 
(System.currentTimeMillis() - startTime));
     startTime = System.currentTimeMillis();
     ISchemaTree schemaTree =
         schemaRegion.fetchSchema(ALL_MATCH_SCOPE, Collections.singletonMap(1, 
template), false);
     System.out.println("fetchSchema cost: " + (System.currentTimeMillis() - 
startTime));
   }
   ```
   
   
   Currently, if a template is activated in the SchemaRegion, all the mnode 
sequences are traversed when fetchingSchema. For example, 100000 devices with 
30 measurements per device will traverse 3000000 mnode.
   
   This PR is optimised so that for devices that use templates, other devices 
are skipped. In the example above, only 100000 mnode need to be traversed.


-- 
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]

Reply via email to