让我们考虑以下代码段作为示例:
var len = 1000000,
testArr = []
for (var i = 0; i < len; i++) {
testArr.push(i+1)
}
function mprofile(name, subject, object) {
var start = new Date().getTime(),
result = subject(object),
end = new Date().getTime() - start
console.log(name)
console.log('Result: ' + result)
console.log(end)
}
var length = testArr.length,
start = new Date().getTime(),
cnt = 0
for (i = 0; i < length; i++) {
cnt += testArr[i]
}
console.log('Regular loop:')
console.log('Result: ' + cnt)
console.log(new Date().getTime() - start); …Run Code Online (Sandbox Code Playgroud) 我有以下设置:
CREATE TABLE IF NOT EXISTS request_income_buffer (
timestamp UInt64,
timestamp_micro Float32,
traceId Int64,
host String,
type String,
service String,
message String,
caller String,
context String
) ENGINE = Kafka('kafka:9092', 'request_income', 'group', 'JSONEachRow');
CREATE MATERIALIZED VIEW IF NOT EXISTS request_income
ENGINE = MergeTree(date, microtime, 8192) AS
SELECT
toDate(toDateTime(timestamp)) AS `date`,
toDateTime(timestamp) as `date_time`,
timestamp,
timestamp_micro AS `microtime`,
traceId,
host,
type,
service,
message,
caller,
context
FROM
request_income_buffer;
Run Code Online (Sandbox Code Playgroud)
我想添加新列,例如。ip到my request_income表。根据文档,为了做到这一点,我需要执行以下步骤:
分离视图以停止接收来自 Kafka 的消息。
分离表请求收入;
由于 Kafka 引擎不支持ALTER …