# Industry 4.0 towards Forestry 4.0: Fire Detection Use Case +
## 5 Methodology
### Dynamic Query Window-Based Selector for Stream Rate Change
#### 5.3.2 The Proposed Dynamic Window-Based Selector
Both the input stream rate and the current status of live jobs help the optimizer to choose the suitable window configuration whenever the stream rate fluctuates. The knowledgebase contains the previous recommended window configurations of different stream rates, including window type and size regarding the relationship between the identified inputs, query workload requirements and infrastructure specifications. We built the knowledgebase to get recommendations for window configuration regarding workload requirements, including latency and data enrichment over stream rate changes. More specifically, Figure 13 depicts the four-quadrant matrix model of window configurations, including type and size for low and high stream rates. The quadrant matrix model represents the information extracted from the conducted experiments in the study in Section 5.2.3. Two workload requirements are carried out on different stream rates which are latency and data enrichment. To simplify the evaluated results shown on quadrant matrix model (i.e., decision making tool), we scale the 10 generated input stream rates into the following two categories (see Section 5.2.3); low stream rate which comprises of first five stream rates i.e., 60, 120, 180, 240, and 300; high stream rate which comprises of last five stream rates i.e., 360, 420, 480, 540, and 600. For example, suppose the end-user application requires that results are produced with high stream data with higher latency irrespective of stream rate. In that case, the recommended window configuration is sliding with a large window size. Another example could be latency-sensitive scenarios where the recommended window configuration must be tumbling window with small window size. For the latency-sensitive cases and need a reasonable resulted data size, a sliding window with small window size configuration can compromise on these two contradicting requirements. On the other hand, in high stream data, the session window with large window size configuration can significantly gain a feasible result size while maintaining an acceptable latency. We built this knowledgebase based on our experiments, but it will gradually evolve as more, and more complicated scenarios occur during various query executions. This knowledgebase acts as the core component for the dynamic window configuration algorithm and recommendation of the optimal query window configuration (see Table 3). Here we introduced our dynamic query stream processing algorithm-Dynamic Window Configuration (DWC) that integrates the discussed cost model based on stream data characteristics, application workload requirements and resource constraints. For simplicity, stream data characteristics including stream rate and application workload requirements are used. The DWC algorithm uses the historical statistics of the last executed windows to configure the window type and size of the fluctuated stream rates. Before we explain the DWC algorithm, we first introduce two data structures that are used to track the stream statistics and current window sizes. First, we use historical statistics denoted as \(Stream\_Stat\_Histo\) which contains \(Stream\_Rate\_Last\) to show the ingested stream rate and \(Window\_Size\_Last\) to record the last recommended window size for the last executed windows. The number of the last executed windows is configurable. A snapshot of historical statistics is described in JSON-like format as follows:  
```
1 Uniform*1: \"PresentID\": '1', 'BshName': \"AdapuitionWindow\": \"Run\": '00, 'CUP': 4 'Reguirements': [ 'Latency': 'Low', 'Low', 'Accuracy



Second, we track the current window size using live statistics (denoted as _Window_Size_Current_) which indicates the configured window size for the current stream rate. Algorithm 1 presents the core function that calculates the next window configuration including window type and size based on the recommended window configuration fetched from the knowledgebase. The input of the DWC algorithm is the _Workload_Requirements_List_ which identified by the use case.