Adaptive Latency-Aware Query Processing in IoT Networks