Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release'

  • Loading branch information...
commit 330f54777cc614486a9a40f7c440270f732567d5 2 parents f5412d4 + 95dd064
@mbostock mbostock authored
View
2  README.md
@@ -20,7 +20,7 @@ Cube is built with the following open-source systems and libraries:
* [Node.js](http://nodejs.org/)
* [PEG.js](http://pegjs.majda.cz/)
* [Vows](http://vowsjs.org/)
-* [websocket-client](/pgriess/node-websocket-client)
+* [websocket](/Worlize/WebSocket-Node)
* [websocket-server](/miksago/node-websocket-server)
## Contributing
View
466 lib/cube/server/event-expression.js
@@ -11,6 +11,7 @@ module.exports = (function(){
parse: function(input, startRule) {
var parseFunctions = {
"_": parse__,
+ "array_literal": parse_array_literal,
"character_escape_sequence": parse_character_escape_sequence,
"digit": parse_digit,
"digit19": parse_digit19,
@@ -875,161 +876,184 @@ module.exports = (function(){
}
- var savedPos6 = pos;
+ var savedPos7 = pos;
if (input.substr(pos, 2) === "eq") {
- var result20 = "eq";
+ var result23 = "eq";
pos += 2;
} else {
- var result20 = null;
+ var result23 = null;
if (reportMatchFailures) {
matchFailed("\"eq\"");
}
}
- var result21 = result20 !== null
+ var result24 = result23 !== null
? (function() { return filterEqual; })()
: null;
- if (result21 !== null) {
- var result19 = result21;
+ if (result24 !== null) {
+ var result22 = result24;
} else {
- var result19 = null;
- pos = savedPos6;
+ var result22 = null;
+ pos = savedPos7;
}
- if (result19 !== null) {
- var result0 = result19;
+ if (result22 !== null) {
+ var result0 = result22;
} else {
- var savedPos5 = pos;
+ var savedPos6 = pos;
if (input.substr(pos, 2) === "gt") {
- var result17 = "gt";
+ var result20 = "gt";
pos += 2;
} else {
- var result17 = null;
+ var result20 = null;
if (reportMatchFailures) {
matchFailed("\"gt\"");
}
}
- var result18 = result17 !== null
+ var result21 = result20 !== null
? (function() { return filterGreater; })()
: null;
- if (result18 !== null) {
- var result16 = result18;
+ if (result21 !== null) {
+ var result19 = result21;
} else {
- var result16 = null;
- pos = savedPos5;
+ var result19 = null;
+ pos = savedPos6;
}
- if (result16 !== null) {
- var result0 = result16;
+ if (result19 !== null) {
+ var result0 = result19;
} else {
- var savedPos4 = pos;
+ var savedPos5 = pos;
if (input.substr(pos, 2) === "ge") {
- var result14 = "ge";
+ var result17 = "ge";
pos += 2;
} else {
- var result14 = null;
+ var result17 = null;
if (reportMatchFailures) {
matchFailed("\"ge\"");
}
}
- var result15 = result14 !== null
+ var result18 = result17 !== null
? (function() { return filterGreaterOrEqual; })()
: null;
- if (result15 !== null) {
- var result13 = result15;
+ if (result18 !== null) {
+ var result16 = result18;
} else {
- var result13 = null;
- pos = savedPos4;
+ var result16 = null;
+ pos = savedPos5;
}
- if (result13 !== null) {
- var result0 = result13;
+ if (result16 !== null) {
+ var result0 = result16;
} else {
- var savedPos3 = pos;
+ var savedPos4 = pos;
if (input.substr(pos, 2) === "lt") {
- var result11 = "lt";
+ var result14 = "lt";
pos += 2;
} else {
- var result11 = null;
+ var result14 = null;
if (reportMatchFailures) {
matchFailed("\"lt\"");
}
}
- var result12 = result11 !== null
+ var result15 = result14 !== null
? (function() { return filterLess; })()
: null;
- if (result12 !== null) {
- var result10 = result12;
+ if (result15 !== null) {
+ var result13 = result15;
} else {
- var result10 = null;
- pos = savedPos3;
+ var result13 = null;
+ pos = savedPos4;
}
- if (result10 !== null) {
- var result0 = result10;
+ if (result13 !== null) {
+ var result0 = result13;
} else {
- var savedPos2 = pos;
+ var savedPos3 = pos;
if (input.substr(pos, 2) === "le") {
- var result8 = "le";
+ var result11 = "le";
pos += 2;
} else {
- var result8 = null;
+ var result11 = null;
if (reportMatchFailures) {
matchFailed("\"le\"");
}
}
- var result9 = result8 !== null
+ var result12 = result11 !== null
? (function() { return filterLessOrEqual; })()
: null;
- if (result9 !== null) {
- var result7 = result9;
+ if (result12 !== null) {
+ var result10 = result12;
} else {
- var result7 = null;
- pos = savedPos2;
+ var result10 = null;
+ pos = savedPos3;
}
- if (result7 !== null) {
- var result0 = result7;
+ if (result10 !== null) {
+ var result0 = result10;
} else {
- var savedPos1 = pos;
+ var savedPos2 = pos;
if (input.substr(pos, 2) === "ne") {
- var result5 = "ne";
+ var result8 = "ne";
pos += 2;
} else {
- var result5 = null;
+ var result8 = null;
if (reportMatchFailures) {
matchFailed("\"ne\"");
}
}
- var result6 = result5 !== null
+ var result9 = result8 !== null
? (function() { return filterNotEqual; })()
: null;
- if (result6 !== null) {
- var result4 = result6;
+ if (result9 !== null) {
+ var result7 = result9;
} else {
- var result4 = null;
- pos = savedPos1;
+ var result7 = null;
+ pos = savedPos2;
}
- if (result4 !== null) {
- var result0 = result4;
+ if (result7 !== null) {
+ var result0 = result7;
} else {
- var savedPos0 = pos;
+ var savedPos1 = pos;
if (input.substr(pos, 2) === "re") {
- var result2 = "re";
+ var result5 = "re";
pos += 2;
} else {
- var result2 = null;
+ var result5 = null;
if (reportMatchFailures) {
matchFailed("\"re\"");
}
}
- var result3 = result2 !== null
+ var result6 = result5 !== null
? (function() { return filterRegularExpression; })()
: null;
- if (result3 !== null) {
- var result1 = result3;
+ if (result6 !== null) {
+ var result4 = result6;
} else {
- var result1 = null;
- pos = savedPos0;
+ var result4 = null;
+ pos = savedPos1;
}
- if (result1 !== null) {
- var result0 = result1;
+ if (result4 !== null) {
+ var result0 = result4;
} else {
- var result0 = null;;
+ var savedPos0 = pos;
+ if (input.substr(pos, 2) === "in") {
+ var result2 = "in";
+ pos += 2;
+ } else {
+ var result2 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"in\"");
+ }
+ }
+ var result3 = result2 !== null
+ ? (function() { return filterIn; })()
+ : null;
+ if (result3 !== null) {
+ var result1 = result3;
+ } else {
+ var result1 = null;
+ pos = savedPos0;
+ }
+ if (result1 !== null) {
+ var result0 = result1;
+ } else {
+ var result0 = null;;
+ };
};
};
};
@@ -1128,59 +1152,64 @@ module.exports = (function(){
}
- var result8 = parse_string();
- if (result8 !== null) {
- var result0 = result8;
+ var result9 = parse_array_literal();
+ if (result9 !== null) {
+ var result0 = result9;
} else {
- var result7 = parse_number();
- if (result7 !== null) {
- var result0 = result7;
+ var result8 = parse_string();
+ if (result8 !== null) {
+ var result0 = result8;
} else {
- var savedPos1 = pos;
- if (input.substr(pos, 4) === "true") {
- var result5 = "true";
- pos += 4;
- } else {
- var result5 = null;
- if (reportMatchFailures) {
- matchFailed("\"true\"");
- }
- }
- var result6 = result5 !== null
- ? (function() { return true; })()
- : null;
- if (result6 !== null) {
- var result4 = result6;
- } else {
- var result4 = null;
- pos = savedPos1;
- }
- if (result4 !== null) {
- var result0 = result4;
+ var result7 = parse_number();
+ if (result7 !== null) {
+ var result0 = result7;
} else {
- var savedPos0 = pos;
- if (input.substr(pos, 5) === "false") {
- var result2 = "false";
- pos += 5;
+ var savedPos1 = pos;
+ if (input.substr(pos, 4) === "true") {
+ var result5 = "true";
+ pos += 4;
} else {
- var result2 = null;
+ var result5 = null;
if (reportMatchFailures) {
- matchFailed("\"false\"");
+ matchFailed("\"true\"");
}
}
- var result3 = result2 !== null
- ? (function() { return false; })()
+ var result6 = result5 !== null
+ ? (function() { return true; })()
: null;
- if (result3 !== null) {
- var result1 = result3;
+ if (result6 !== null) {
+ var result4 = result6;
} else {
- var result1 = null;
- pos = savedPos0;
+ var result4 = null;
+ pos = savedPos1;
}
- if (result1 !== null) {
- var result0 = result1;
+ if (result4 !== null) {
+ var result0 = result4;
} else {
- var result0 = null;;
+ var savedPos0 = pos;
+ if (input.substr(pos, 5) === "false") {
+ var result2 = "false";
+ pos += 5;
+ } else {
+ var result2 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"false\"");
+ }
+ }
+ var result3 = result2 !== null
+ ? (function() { return false; })()
+ : null;
+ if (result3 !== null) {
+ var result1 = result3;
+ } else {
+ var result1 = null;
+ pos = savedPos0;
+ }
+ if (result1 !== null) {
+ var result0 = result1;
+ } else {
+ var result0 = null;;
+ };
};
};
};
@@ -1195,6 +1224,215 @@ module.exports = (function(){
return result0;
}
+ function parse_array_literal() {
+ var cacheKey = 'array_literal@' + pos;
+ var cachedResult = cache[cacheKey];
+ if (cachedResult) {
+ pos = cachedResult.nextPos;
+ return cachedResult.result;
+ }
+
+
+ var savedPos2 = pos;
+ var savedPos3 = pos;
+ if (input.substr(pos, 1) === "[") {
+ var result10 = "[";
+ pos += 1;
+ } else {
+ var result10 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"[\"");
+ }
+ }
+ if (result10 !== null) {
+ var result11 = parse__();
+ if (result11 !== null) {
+ var result12 = parse_literal();
+ if (result12 !== null) {
+ var result13 = [];
+ var savedPos4 = pos;
+ var result17 = parse__();
+ if (result17 !== null) {
+ if (input.substr(pos, 1) === ",") {
+ var result18 = ",";
+ pos += 1;
+ } else {
+ var result18 = null;
+ if (reportMatchFailures) {
+ matchFailed("\",\"");
+ }
+ }
+ if (result18 !== null) {
+ var result19 = parse__();
+ if (result19 !== null) {
+ var result20 = parse_literal();
+ if (result20 !== null) {
+ var result16 = [result17, result18, result19, result20];
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ while (result16 !== null) {
+ result13.push(result16);
+ var savedPos4 = pos;
+ var result17 = parse__();
+ if (result17 !== null) {
+ if (input.substr(pos, 1) === ",") {
+ var result18 = ",";
+ pos += 1;
+ } else {
+ var result18 = null;
+ if (reportMatchFailures) {
+ matchFailed("\",\"");
+ }
+ }
+ if (result18 !== null) {
+ var result19 = parse__();
+ if (result19 !== null) {
+ var result20 = parse_literal();
+ if (result20 !== null) {
+ var result16 = [result17, result18, result19, result20];
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ }
+ if (result13 !== null) {
+ var result14 = parse__();
+ if (result14 !== null) {
+ if (input.substr(pos, 1) === "]") {
+ var result15 = "]";
+ pos += 1;
+ } else {
+ var result15 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"]\"");
+ }
+ }
+ if (result15 !== null) {
+ var result8 = [result10, result11, result12, result13, result14, result15];
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ var result9 = result8 !== null
+ ? (function(first, rest) { return [first].concat(rest.map(function(d) { return d[3]; })); })(result8[2], result8[3])
+ : null;
+ if (result9 !== null) {
+ var result7 = result9;
+ } else {
+ var result7 = null;
+ pos = savedPos2;
+ }
+ if (result7 !== null) {
+ var result0 = result7;
+ } else {
+ var savedPos0 = pos;
+ var savedPos1 = pos;
+ if (input.substr(pos, 1) === "[") {
+ var result4 = "[";
+ pos += 1;
+ } else {
+ var result4 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"[\"");
+ }
+ }
+ if (result4 !== null) {
+ var result5 = parse__();
+ if (result5 !== null) {
+ if (input.substr(pos, 1) === "]") {
+ var result6 = "]";
+ pos += 1;
+ } else {
+ var result6 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"]\"");
+ }
+ }
+ if (result6 !== null) {
+ var result2 = [result4, result5, result6];
+ } else {
+ var result2 = null;
+ pos = savedPos1;
+ }
+ } else {
+ var result2 = null;
+ pos = savedPos1;
+ }
+ } else {
+ var result2 = null;
+ pos = savedPos1;
+ }
+ var result3 = result2 !== null
+ ? (function() { return []; })()
+ : null;
+ if (result3 !== null) {
+ var result1 = result3;
+ } else {
+ var result1 = null;
+ pos = savedPos0;
+ }
+ if (result1 !== null) {
+ var result0 = result1;
+ } else {
+ var result0 = null;;
+ };
+ }
+
+
+
+ cache[cacheKey] = {
+ nextPos: pos,
+ result: result0
+ };
+ return result0;
+ }
+
function parse_string() {
var cacheKey = 'string@' + pos;
var cachedResult = cache[cacheKey];
@@ -2628,6 +2866,8 @@ module.exports = (function(){
filterRegularExpression = filter("$regex"),
+ filterIn = filter("$in"),
+
exists = {$exists: true};
View
9 lib/cube/server/event-expression.peg
@@ -8,6 +8,7 @@
filterLessOrEqual = filter("$lte"),
filterNotEqual = filter("$ne"),
filterRegularExpression = filter("$regex"),
+ filterIn = filter("$in"),
exists = {$exists: true};
function noop() {}
@@ -106,16 +107,22 @@ filter_operator
/ "le" { return filterLessOrEqual; }
/ "ne" { return filterNotEqual; }
/ "re" { return filterRegularExpression; }
+ / "in" { return filterIn; }
identifier
= first:[a-zA-Z_$] rest:[a-zA-Z0-9_$]* { return first + rest.join(""); }
literal
- = string
+ = array_literal
+ / string
/ number
/ "true" { return true; }
/ "false" { return false; }
+array_literal
+ = "[" _ first:literal rest:(_ "," _ literal)* _ "]" { return [first].concat(rest.map(function(d) { return d[3]; })); }
+ / "[" _ "]" { return []; }
+
string "string"
= '"' chars:double_string_char* '"' { return chars.join(""); }
/ "'" chars:single_string_char* "'" { return chars.join(""); }
View
466 lib/cube/server/metric-expression.js
@@ -12,6 +12,7 @@ module.exports = (function(){
var parseFunctions = {
"_": parse__,
"additive_operator": parse_additive_operator,
+ "array_literal": parse_array_literal,
"character_escape_sequence": parse_character_escape_sequence,
"digit": parse_digit,
"digit19": parse_digit19,
@@ -1965,161 +1966,184 @@ module.exports = (function(){
}
- var savedPos6 = pos;
+ var savedPos7 = pos;
if (input.substr(pos, 2) === "eq") {
- var result20 = "eq";
+ var result23 = "eq";
pos += 2;
} else {
- var result20 = null;
+ var result23 = null;
if (reportMatchFailures) {
matchFailed("\"eq\"");
}
}
- var result21 = result20 !== null
+ var result24 = result23 !== null
? (function() { return filterEqual; })()
: null;
- if (result21 !== null) {
- var result19 = result21;
+ if (result24 !== null) {
+ var result22 = result24;
} else {
- var result19 = null;
- pos = savedPos6;
+ var result22 = null;
+ pos = savedPos7;
}
- if (result19 !== null) {
- var result0 = result19;
+ if (result22 !== null) {
+ var result0 = result22;
} else {
- var savedPos5 = pos;
+ var savedPos6 = pos;
if (input.substr(pos, 2) === "gt") {
- var result17 = "gt";
+ var result20 = "gt";
pos += 2;
} else {
- var result17 = null;
+ var result20 = null;
if (reportMatchFailures) {
matchFailed("\"gt\"");
}
}
- var result18 = result17 !== null
+ var result21 = result20 !== null
? (function() { return filterGreater; })()
: null;
- if (result18 !== null) {
- var result16 = result18;
+ if (result21 !== null) {
+ var result19 = result21;
} else {
- var result16 = null;
- pos = savedPos5;
+ var result19 = null;
+ pos = savedPos6;
}
- if (result16 !== null) {
- var result0 = result16;
+ if (result19 !== null) {
+ var result0 = result19;
} else {
- var savedPos4 = pos;
+ var savedPos5 = pos;
if (input.substr(pos, 2) === "ge") {
- var result14 = "ge";
+ var result17 = "ge";
pos += 2;
} else {
- var result14 = null;
+ var result17 = null;
if (reportMatchFailures) {
matchFailed("\"ge\"");
}
}
- var result15 = result14 !== null
+ var result18 = result17 !== null
? (function() { return filterGreaterOrEqual; })()
: null;
- if (result15 !== null) {
- var result13 = result15;
+ if (result18 !== null) {
+ var result16 = result18;
} else {
- var result13 = null;
- pos = savedPos4;
+ var result16 = null;
+ pos = savedPos5;
}
- if (result13 !== null) {
- var result0 = result13;
+ if (result16 !== null) {
+ var result0 = result16;
} else {
- var savedPos3 = pos;
+ var savedPos4 = pos;
if (input.substr(pos, 2) === "lt") {
- var result11 = "lt";
+ var result14 = "lt";
pos += 2;
} else {
- var result11 = null;
+ var result14 = null;
if (reportMatchFailures) {
matchFailed("\"lt\"");
}
}
- var result12 = result11 !== null
+ var result15 = result14 !== null
? (function() { return filterLess; })()
: null;
- if (result12 !== null) {
- var result10 = result12;
+ if (result15 !== null) {
+ var result13 = result15;
} else {
- var result10 = null;
- pos = savedPos3;
+ var result13 = null;
+ pos = savedPos4;
}
- if (result10 !== null) {
- var result0 = result10;
+ if (result13 !== null) {
+ var result0 = result13;
} else {
- var savedPos2 = pos;
+ var savedPos3 = pos;
if (input.substr(pos, 2) === "le") {
- var result8 = "le";
+ var result11 = "le";
pos += 2;
} else {
- var result8 = null;
+ var result11 = null;
if (reportMatchFailures) {
matchFailed("\"le\"");
}
}
- var result9 = result8 !== null
+ var result12 = result11 !== null
? (function() { return filterLessOrEqual; })()
: null;
- if (result9 !== null) {
- var result7 = result9;
+ if (result12 !== null) {
+ var result10 = result12;
} else {
- var result7 = null;
- pos = savedPos2;
+ var result10 = null;
+ pos = savedPos3;
}
- if (result7 !== null) {
- var result0 = result7;
+ if (result10 !== null) {
+ var result0 = result10;
} else {
- var savedPos1 = pos;
+ var savedPos2 = pos;
if (input.substr(pos, 2) === "ne") {
- var result5 = "ne";
+ var result8 = "ne";
pos += 2;
} else {
- var result5 = null;
+ var result8 = null;
if (reportMatchFailures) {
matchFailed("\"ne\"");
}
}
- var result6 = result5 !== null
+ var result9 = result8 !== null
? (function() { return filterNotEqual; })()
: null;
- if (result6 !== null) {
- var result4 = result6;
+ if (result9 !== null) {
+ var result7 = result9;
} else {
- var result4 = null;
- pos = savedPos1;
+ var result7 = null;
+ pos = savedPos2;
}
- if (result4 !== null) {
- var result0 = result4;
+ if (result7 !== null) {
+ var result0 = result7;
} else {
- var savedPos0 = pos;
+ var savedPos1 = pos;
if (input.substr(pos, 2) === "re") {
- var result2 = "re";
+ var result5 = "re";
pos += 2;
} else {
- var result2 = null;
+ var result5 = null;
if (reportMatchFailures) {
matchFailed("\"re\"");
}
}
- var result3 = result2 !== null
+ var result6 = result5 !== null
? (function() { return filterRegularExpression; })()
: null;
- if (result3 !== null) {
- var result1 = result3;
+ if (result6 !== null) {
+ var result4 = result6;
} else {
- var result1 = null;
- pos = savedPos0;
+ var result4 = null;
+ pos = savedPos1;
}
- if (result1 !== null) {
- var result0 = result1;
+ if (result4 !== null) {
+ var result0 = result4;
} else {
- var result0 = null;;
+ var savedPos0 = pos;
+ if (input.substr(pos, 2) === "in") {
+ var result2 = "in";
+ pos += 2;
+ } else {
+ var result2 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"in\"");
+ }
+ }
+ var result3 = result2 !== null
+ ? (function() { return filterIn; })()
+ : null;
+ if (result3 !== null) {
+ var result1 = result3;
+ } else {
+ var result1 = null;
+ pos = savedPos0;
+ }
+ if (result1 !== null) {
+ var result0 = result1;
+ } else {
+ var result0 = null;;
+ };
};
};
};
@@ -2218,59 +2242,64 @@ module.exports = (function(){
}
- var result8 = parse_string();
- if (result8 !== null) {
- var result0 = result8;
+ var result9 = parse_array_literal();
+ if (result9 !== null) {
+ var result0 = result9;
} else {
- var result7 = parse_number();
- if (result7 !== null) {
- var result0 = result7;
+ var result8 = parse_string();
+ if (result8 !== null) {
+ var result0 = result8;
} else {
- var savedPos1 = pos;
- if (input.substr(pos, 4) === "true") {
- var result5 = "true";
- pos += 4;
- } else {
- var result5 = null;
- if (reportMatchFailures) {
- matchFailed("\"true\"");
- }
- }
- var result6 = result5 !== null
- ? (function() { return true; })()
- : null;
- if (result6 !== null) {
- var result4 = result6;
- } else {
- var result4 = null;
- pos = savedPos1;
- }
- if (result4 !== null) {
- var result0 = result4;
+ var result7 = parse_number();
+ if (result7 !== null) {
+ var result0 = result7;
} else {
- var savedPos0 = pos;
- if (input.substr(pos, 5) === "false") {
- var result2 = "false";
- pos += 5;
+ var savedPos1 = pos;
+ if (input.substr(pos, 4) === "true") {
+ var result5 = "true";
+ pos += 4;
} else {
- var result2 = null;
+ var result5 = null;
if (reportMatchFailures) {
- matchFailed("\"false\"");
+ matchFailed("\"true\"");
}
}
- var result3 = result2 !== null
- ? (function() { return false; })()
+ var result6 = result5 !== null
+ ? (function() { return true; })()
: null;
- if (result3 !== null) {
- var result1 = result3;
+ if (result6 !== null) {
+ var result4 = result6;
} else {
- var result1 = null;
- pos = savedPos0;
+ var result4 = null;
+ pos = savedPos1;
}
- if (result1 !== null) {
- var result0 = result1;
+ if (result4 !== null) {
+ var result0 = result4;
} else {
- var result0 = null;;
+ var savedPos0 = pos;
+ if (input.substr(pos, 5) === "false") {
+ var result2 = "false";
+ pos += 5;
+ } else {
+ var result2 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"false\"");
+ }
+ }
+ var result3 = result2 !== null
+ ? (function() { return false; })()
+ : null;
+ if (result3 !== null) {
+ var result1 = result3;
+ } else {
+ var result1 = null;
+ pos = savedPos0;
+ }
+ if (result1 !== null) {
+ var result0 = result1;
+ } else {
+ var result0 = null;;
+ };
};
};
};
@@ -2285,6 +2314,215 @@ module.exports = (function(){
return result0;
}
+ function parse_array_literal() {
+ var cacheKey = 'array_literal@' + pos;
+ var cachedResult = cache[cacheKey];
+ if (cachedResult) {
+ pos = cachedResult.nextPos;
+ return cachedResult.result;
+ }
+
+
+ var savedPos2 = pos;
+ var savedPos3 = pos;
+ if (input.substr(pos, 1) === "[") {
+ var result10 = "[";
+ pos += 1;
+ } else {
+ var result10 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"[\"");
+ }
+ }
+ if (result10 !== null) {
+ var result11 = parse__();
+ if (result11 !== null) {
+ var result12 = parse_literal();
+ if (result12 !== null) {
+ var result13 = [];
+ var savedPos4 = pos;
+ var result17 = parse__();
+ if (result17 !== null) {
+ if (input.substr(pos, 1) === ",") {
+ var result18 = ",";
+ pos += 1;
+ } else {
+ var result18 = null;
+ if (reportMatchFailures) {
+ matchFailed("\",\"");
+ }
+ }
+ if (result18 !== null) {
+ var result19 = parse__();
+ if (result19 !== null) {
+ var result20 = parse_literal();
+ if (result20 !== null) {
+ var result16 = [result17, result18, result19, result20];
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ while (result16 !== null) {
+ result13.push(result16);
+ var savedPos4 = pos;
+ var result17 = parse__();
+ if (result17 !== null) {
+ if (input.substr(pos, 1) === ",") {
+ var result18 = ",";
+ pos += 1;
+ } else {
+ var result18 = null;
+ if (reportMatchFailures) {
+ matchFailed("\",\"");
+ }
+ }
+ if (result18 !== null) {
+ var result19 = parse__();
+ if (result19 !== null) {
+ var result20 = parse_literal();
+ if (result20 !== null) {
+ var result16 = [result17, result18, result19, result20];
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ } else {
+ var result16 = null;
+ pos = savedPos4;
+ }
+ }
+ if (result13 !== null) {
+ var result14 = parse__();
+ if (result14 !== null) {
+ if (input.substr(pos, 1) === "]") {
+ var result15 = "]";
+ pos += 1;
+ } else {
+ var result15 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"]\"");
+ }
+ }
+ if (result15 !== null) {
+ var result8 = [result10, result11, result12, result13, result14, result15];
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ } else {
+ var result8 = null;
+ pos = savedPos3;
+ }
+ var result9 = result8 !== null
+ ? (function(first, rest) { return [first].concat(rest.map(function(d) { return d[3]; })); })(result8[2], result8[3])
+ : null;
+ if (result9 !== null) {
+ var result7 = result9;
+ } else {
+ var result7 = null;
+ pos = savedPos2;
+ }
+ if (result7 !== null) {
+ var result0 = result7;
+ } else {
+ var savedPos0 = pos;
+ var savedPos1 = pos;
+ if (input.substr(pos, 1) === "[") {
+ var result4 = "[";
+ pos += 1;
+ } else {
+ var result4 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"[\"");
+ }
+ }
+ if (result4 !== null) {
+ var result5 = parse__();
+ if (result5 !== null) {
+ if (input.substr(pos, 1) === "]") {
+ var result6 = "]";
+ pos += 1;
+ } else {
+ var result6 = null;
+ if (reportMatchFailures) {
+ matchFailed("\"]\"");
+ }
+ }
+ if (result6 !== null) {
+ var result2 = [result4, result5, result6];
+ } else {
+ var result2 = null;
+ pos = savedPos1;
+ }
+ } else {
+ var result2 = null;
+ pos = savedPos1;
+ }
+ } else {
+ var result2 = null;
+ pos = savedPos1;
+ }
+ var result3 = result2 !== null
+ ? (function() { return []; })()
+ : null;
+ if (result3 !== null) {
+ var result1 = result3;
+ } else {
+ var result1 = null;
+ pos = savedPos0;
+ }
+ if (result1 !== null) {
+ var result0 = result1;
+ } else {
+ var result0 = null;;
+ };
+ }
+
+
+
+ cache[cacheKey] = {
+ nextPos: pos,
+ result: result0
+ };
+ return result0;
+ }
+
function parse_string() {
var cacheKey = 'string@' + pos;
var cachedResult = cache[cacheKey];
@@ -3718,6 +3956,8 @@ module.exports = (function(){
filterRegularExpression = filter("$regex"),
+ filterIn = filter("$in"),
+
exists = {$exists: true};
View
9 lib/cube/server/metric-expression.peg
@@ -9,6 +9,7 @@
filterLessOrEqual = filter("$lte"),
filterNotEqual = filter("$ne"),
filterRegularExpression = filter("$regex"),
+ filterIn = filter("$in"),
exists = {$exists: true};
function add(a, b) { return a + b; }
@@ -181,16 +182,22 @@ filter_operator
/ "le" { return filterLessOrEqual; }
/ "ne" { return filterNotEqual; }
/ "re" { return filterRegularExpression; }
+ / "in" { return filterIn; }
identifier
= first:[a-zA-Z_$] rest:[a-zA-Z0-9_$]* { return first + rest.join(""); }
literal
- = string
+ = array_literal
+ / string
/ number
/ "true" { return true; }
/ "false" { return false; }
+array_literal
+ = "[" _ first:literal rest:(_ "," _ literal)* _ "]" { return [first].concat(rest.map(function(d) { return d[3]; })); }
+ / "[" _ "]" { return []; }
+
string "string"
= '"' chars:double_string_char* '"' { return chars.join(""); }
/ "'" chars:single_string_char* "'" { return chars.join(""); }
View
8 package.json
@@ -1,6 +1,6 @@
{
"name": "cube",
- "version": "0.0.12",
+ "version": "0.0.13",
"description": "A system for time series visualization using MongoDB, Node and D3.",
"keywords": ["time series", "visualization"],
"homepage": "http://square.github.com/cube/",
@@ -8,11 +8,11 @@
"repository": {"type": "git", "url": "http://github.com/square/cube.git"},
"main": "./lib/cube",
"dependencies": {
- "d3": "2.5.2",
- "mongodb": "0.9.6-15",
+ "d3": "2.6.0",
+ "mongodb": "0.9.7-1.3",
"pegjs": "0.6.2",
"vows": "0.5.11",
- "websocket": "0.0.16",
+ "websocket": "1.0.2",
"websocket-server": "1.4.04"
}
}
View
5 test/event-expression-test.js
@@ -197,6 +197,11 @@ suite.addBatch({
var filter = {};
parser.parse("test.re(i, \"foo\")").filter(filter);
assert.deepEqual(filter, {"d.i": {$regex: "foo"}});
+ },
+ "the in filter results in a $in query filter": function(e) {
+ var filter = {};
+ parser.parse("test.in(i, [\"foo\", 42])").filter(filter);
+ assert.deepEqual(filter, {"d.i": {$in: ["foo", 42]}});
}
}
View
5 test/metric-expression-test.js
@@ -283,6 +283,11 @@ suite.addBatch({
var filter = {};
parser.parse("sum(test.re(i, \"foo\"))").filter(filter);
assert.deepEqual(filter, {"d.i": {$regex: "foo"}});
+ },
+ "the in filter results in a $in query filter": function(e) {
+ var filter = {};
+ parser.parse("sum(test.in(i, [\"foo\", 42]))").filter(filter);
+ assert.deepEqual(filter, {"d.i": {$in: ["foo", 42]}});
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.