这是能够流利地写入我的日志的记录。
var cols = 5;
var rows = 5;
function connectedPoints(point) {
var connectedPoints = [];
// First test if the point is on an edge
var topEdge = point/cols < 1;
var leftEdge = point%cols == 0;
var rightEdge = point%cols == cols-1;
var bottomEdge = point/cols >= rows-1;
// Add points that are above the point
if (!topEdge) {
if (!leftEdge) {
connectedPoints.push(returnIfNotNegative(point-cols-1));
}
connectedPoints.push(returnIfNotNegative(point-cols));
if (!rightEdge) {
connectedPoints.push(returnIfNotNegative(point-cols+1));
}
}
// Add points that are to the left or right of the point
if (!leftEdge) {
connectedPoints.push(returnIfNotNegative(point-1));
}
if (!rightEdge) {
connectedPoints.push(returnIfNotNegative(point+1));
}
// Add points that are below the point
if (!bottomEdge) {
if (!leftEdge) {
connectedPoints.push(returnIfNotNegative(point+cols-1));
}
connectedPoints.push(returnIfNotNegative(point+cols));
if (!rightEdge) {
connectedPoints.push(returnIfNotNegative(point+cols+1));
}
}
console.log(connectedPoints);
}
function returnIfNotNegative(point) {
if (point < 0) {
return null;
}
return point;
}
connectedPoints(0);
日期时间是流利的时间键。我如何将这段时间放在json字符串中?
答案 0 :(得分:0)
我的朋友帮助了我。他使用了这个流畅的插件:
http://docs.fluentd.org/articles/filter-plugin-overview
这是配置:
<filter trackLog>
type record_modifier
<record>
fluentd_time ${Time.now.strftime("%Y-%m-%d %H:%M:%S")}
</record>
</filter>
<match trackLog>
type record_modifier
tag trackLog.finished
</match>
<match trackLog.finished>
type webhdfs
host localhost
port 50070
path /data/trackLog/%Y%m%d_%H
username hdfs
output_include_tag false
remove_prefix trackLog.finished
output_include_time false
buffer_type file
buffer_path /mnt/ramdisk/trackLog
buffer_chunk_limit 4m
buffer_queue_limit 50
flush_interval 5s
</match>