admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Quintiq file version 2.0
#parent: #root
StaticMethod CreateDataPieces (LibDEF_DataTransfers dataTransfers_i, NamedValueTree nvt_i)
{
  Description:
  [*
    This is for creating data pieces for multiple data transfers using the given NVT (so 1 NVT for all the given data transfers).
    Each data transfer might have different chunk size limit, so this means different number of chunks of the NVT (the NVT will be chunked differently).
    The algorithm used here is to save performance cost by avoiding redundant NVT chunking for data transfers with the same chunk size limit (by reusing the previous NVT chunking result).
  *]
  TextBody:
  [*
    // Create the data pieces for every data transfer.
    // To save performance on chunking, first sort the dataTransfers based on the
    // totalContentLength and ChunkSizeLimit (they are possible to be different for each target),
    // Then only do chunking if any of them is different. Else reuse the previous one
    dataTransfersSorted := selectsortedset( dataTransfers_i, Elements, dt, true,
                                            dt.TotalContentLength(),
                                            dt.ChunkSizeLimit() );
    previousDt := null( LibDEF_DataTransfer );
    nvtContainerFromPrev := null( LibDEF_NamedValueTreeContainer, owning );
    traverse( dataTransfersSorted, Elements, dt )
    {
      LibDEF_Util::EventLog( dt.IntegrationEvent(), "Preparing data pieces (chunking NVT)." );
      
      if( isnull( previousDt )
          or isnull( nvtContainerFromPrev )
          or previousDt.TotalContentLength() <> dt.TotalContentLength()
          or previousDt.ChunkSizeLimit() <> dt.ChunkSizeLimit() )
      {
        nvtContainerFromPrev := dt.CreateDataPieces( nvt_i );
      }
      else
      {
        dt.CreateDataPieces( nvtContainerFromPrev );
      }
      previousDt := dt;
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}