我知道我可以如下创建Stream Analytics窗口:
// #include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <string.h>
#include <boost/timer.hpp>
#include <unistd.h>
// Big Endian (network order)
unsigned int fromBytes(unsigned char b[4]) {
return b[3] | b[2]<<8 | b[1]<<16 | b[0]<<24;
}
void toBytes(unsigned int x, unsigned char (&b)[4]) {
b[3] = x;
b[2] = x>>8;
b[1] = x>>16;
b[0] = x>>24;
}
int main(int argc, char const *argv[])
{
int sock, valread;
struct sockaddr_in address;
int opt = 1;
int addrlen = sizeof(address);
// We'll be passing uint32's back and forth
unsigned char recv_buffer[4] = {0};
unsigned char send_buffer[4] = {0};
// Create socket for TCP server
sock = socket(AF_INET, SOCK_STREAM, 0);
// Set TCP_NODELAY so that writes won't be batched
setsockopt(sock, SOL_SOCKET, TCP_NODELAY, &opt, sizeof(opt));
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(8080);
// Accept one client connection
if (connect(sock, (struct sockaddr *)&address, (socklen_t)addrlen) != 0) {
throw("connect failed");
}
unsigned int lastReceived = 0;
while (true) {
toBytes(++lastReceived, send_buffer);
write(sock, send_buffer, 4);
valread = read(sock, recv_buffer, 4);
lastReceived = fromBytes(recv_buffer);
}
}
这将使窗口每30秒固定一次。
是否可以使30秒动态化?这意味着我们会在不同的时间表上互相看到多个窗口。
我正在尝试使用参考输入文件,并且我想从参考文件中获取秒数,而不是在查询中进行固定。
如果我使用参考文件中的输入创建窗口,则会收到错误消息:
错误:无效的窗口持续时间:“ timespanInSeconds”。窗口持续时间必须为正浮点常数。
即使它似乎是一个有效的json编号。我想做的事甚至有可能吗?
答案 0 :(得分:1)
我发现的文档中的内容: https://msdn.microsoft.com/en-us/azure/stream-analytics/reference/tumbling-window-azure-stream-analytics
它说明:
一个大整数,描述窗口的大小。 windowsize是静态的,无法在运行时动态更改。