-
Notifications
You must be signed in to change notification settings - Fork 102
/
MLDB-1120-sparse-mutable-values.js
122 lines (104 loc) · 2.73 KB
/
MLDB-1120-sparse-mutable-values.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// This file is part of MLDB. Copyright 2015 mldb.ai inc. All rights reserved.
var mldb = require('mldb')
var unittest = require('mldb/unittest')
var dataset_config = {
type: 'sparse.mutable',
id: 'test'
};
var dataset = mldb.createDataset(dataset_config);
var ts = new Date(2015, 01, 01);
// Check all lengths of strings
dataset.recordRow("rowa1", [ [ "a", "a", ts ] ]);
dataset.recordRow("rowa2", [ [ "ab", "ab", ts ] ]);
dataset.recordRow("rowa3", [ [ "abc", "abc", ts ] ]);
dataset.recordRow("rowa4", [ [ "abcd", "abcd", ts ] ]);
dataset.recordRow("rowa5", [ [ "abcde", "abcde", ts ] ]);
dataset.recordRow("rowa6", [ [ "abcdef", "abcdef", ts ] ]);
dataset.recordRow("rowa7", [ [ "abcdefg", "abcdefg", ts ] ]);
// Check all lengths of utf-8 strings
dataset.recordRow("rowb1", [ [ "é", "é", ts ] ]);
dataset.recordRow("rowb2", [ [ "éb", "éb", ts ] ]);
dataset.recordRow("rowb3", [ [ "ébc", "ébc", ts ] ]);
dataset.recordRow("rowb4", [ [ "ébcd", "ébcd", ts ] ]);
dataset.recordRow("rowb5", [ [ "ébcde", "ébcde", ts ] ]);
dataset.recordRow("rowb6", [ [ "ébcdef", "ébcdef", ts ] ]);
dataset.recordRow("rowb7", [ [ "ébcdefg", "ébcdefg", ts ] ]);
// Check small integers
dataset.recordRow("rowc1", [ [ "x", 0, ts ] ]);
dataset.recordRow("rowc2", [ [ "x", 1, ts ] ]);
dataset.recordRow("rowc3", [ [ "x", -1, ts ] ]);
dataset.commit();
var resp = mldb.get('/v1/query', { q: "select * from test order by rowName()", format: 'sparse' }).json;
mldb.log(resp);
var expected = [
[
[ "_rowName", "rowa1" ],
[ "a", "a" ]
],
[
[ "_rowName", "rowa2" ],
[ "ab", "ab" ]
],
[
[ "_rowName", "rowa3" ],
[ "abc", "abc" ]
],
[
[ "_rowName", "rowa4" ],
[ "abcd", "abcd" ]
],
[
[ "_rowName", "rowa5" ],
[ "abcde", "abcde" ]
],
[
[ "_rowName", "rowa6" ],
[ "abcdef", "abcdef" ]
],
[
[ "_rowName", "rowa7" ],
[ "abcdefg", "abcdefg" ]
],
[
[ "_rowName", "rowb1" ],
[ "é", "é" ]
],
[
[ "_rowName", "rowb2" ],
[ "éb", "éb" ]
],
[
[ "_rowName", "rowb3" ],
[ "ébc", "ébc" ]
],
[
[ "_rowName", "rowb4" ],
[ "ébcd", "ébcd" ]
],
[
[ "_rowName", "rowb5" ],
[ "ébcde", "ébcde" ]
],
[
[ "_rowName", "rowb6" ],
[ "ébcdef", "ébcdef" ]
],
[
[ "_rowName", "rowb7" ],
[ "ébcdefg", "ébcdefg" ]
],
[
[ "_rowName", "rowc1" ],
[ "x", 0 ]
],
[
[ "_rowName", "rowc2" ],
[ "x", 1 ]
],
[
[ "_rowName", "rowc3" ],
[ "x", -1 ]
]
];
unittest.assertEqual(expected, resp);
"success"