Skip to content

Commit c1a77a7

Browse files
authored
add extra tests for index inserts (#51)
* add extra tests for index inserts * fix compile error
1 parent d6004aa commit c1a77a7

File tree

6 files changed

+208
-0
lines changed

6 files changed

+208
-0
lines changed

simple/run-big-all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function main () {
55
big: true,
66

77
documents: true,
8+
indexes: true,
89
ioless: true,
910
edges: true,
1011
search: true,

simple/run-big-indexes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function main () {
2+
require("./simple/test").test({
3+
outputCsv: true,
4+
big: true,
5+
indexes: true
6+
});
7+
}
8+
if (typeof arango !== "undefined") {
9+
main();
10+
}

simple/run-medium-all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function main () {
55
medium: true,
66

77
documents: true,
8+
indexes: true,
89
ioless: true,
910
edges: true,
1011
search: true,

simple/run-small-all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function main () {
55
small: true,
66

77
documents: true,
8+
indexes: true,
89
ioless: true,
910
edges: true,
1011
search: true,

simple/run-tiny-all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function main () {
66
small: false,
77

88
documents: true,
9+
indexes: true,
910
ioless: true,
1011
edges: true,
1112
search: true,

simple/test.js

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ exports.test = function (global) {
105105
global.search = global.search || false;
106106
global.phrase = global.phrase || false;
107107
global.noMaterializationSearch = global.noMaterializationSearch || false;
108+
global.indexes = global.indexes || false;
108109
global.crud = global.crud || false;
109110
global.crudSearch = global.crudSearch || false;
110111
global.subqueryTests = global.subqueryTests || false;
@@ -833,6 +834,62 @@ exports.test = function (global) {
833834
}
834835
}
835836
},
837+
838+
// /////////////////////////////////////////////////////////////////////////////
839+
// indexes tests
840+
// /////////////////////////////////////////////////////////////////////////////
841+
842+
insertIndexOne = function (params) {
843+
let c = db._collection(params.collection),
844+
n = parseInt(params.collection.replace(/[a-z]+/g, ""), 10);
845+
846+
// perform small batch document operations
847+
const batchSize = params.batchSize || 100;
848+
let docs = [];
849+
if (params.type === "string") {
850+
for (let i = 0; i < n; ++i) {
851+
docs.push({ value1: "testmann1234" + i });
852+
if (docs.length === batchSize) {
853+
c.insert(docs);
854+
docs = [];
855+
}
856+
}
857+
} else {
858+
for (let i = 0; i < n; ++i) {
859+
docs.push({ value1: i });
860+
if (docs.length === batchSize) {
861+
c.insert(docs);
862+
docs = [];
863+
}
864+
}
865+
}
866+
},
867+
868+
insertIndexTwo = function (params) {
869+
let c = db._collection(params.collection),
870+
n = parseInt(params.collection.replace(/[a-z]+/g, ""), 10);
871+
872+
// perform small batch document operations
873+
const batchSize = params.batchSize || 100;
874+
let docs = [];
875+
if (params.type === "string") {
876+
for (let i = 0; i < n; ++i) {
877+
docs.push({ value1: "testmann1234" + i, value2: "testmannabc" + i });
878+
if (docs.length === batchSize) {
879+
c.insert(docs);
880+
docs = [];
881+
}
882+
}
883+
} else {
884+
for (let i = 0; i < n; ++i) {
885+
docs.push({ value1: i, value2: i });
886+
if (docs.length === batchSize) {
887+
c.insert(docs);
888+
docs = [];
889+
}
890+
}
891+
}
892+
},
836893

837894
// /////////////////////////////////////////////////////////////////////////////
838895
// CRUD Tests
@@ -2269,6 +2326,119 @@ exports.test = function (global) {
22692326
params: { func: rangesSubquery, optimize: false, distinct: true }
22702327
}
22712328
];
2329+
2330+
// tests for index selectivity estimates
2331+
let indexesTests = [
2332+
{
2333+
name: "indexes-insert1-numeric",
2334+
params: {
2335+
func: insertIndexOne,
2336+
setup: function (params) {
2337+
drop(params);
2338+
create(params);
2339+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2340+
},
2341+
type: "number",
2342+
teardown: drop
2343+
}
2344+
},
2345+
{
2346+
name: "indexes-insert1-numeric-noestimates",
2347+
params: {
2348+
func: insertIndexOne,
2349+
setup: function (params) {
2350+
drop(params);
2351+
create(params);
2352+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2353+
},
2354+
type: "number",
2355+
teardown: drop
2356+
}
2357+
},
2358+
{
2359+
name: "indexes-insert1-string",
2360+
params: {
2361+
func: insertIndexOne,
2362+
setup: function (params) {
2363+
drop(params);
2364+
create(params);
2365+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2366+
},
2367+
type: "string",
2368+
teardown: drop
2369+
}
2370+
},
2371+
{
2372+
name: "indexes-insert1-string-noestimates",
2373+
params: {
2374+
func: insertIndexOne,
2375+
setup: function (params) {
2376+
drop(params);
2377+
create(params);
2378+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2379+
},
2380+
type: "string",
2381+
teardown: drop
2382+
}
2383+
},
2384+
{
2385+
name: "indexes-insert2-numeric",
2386+
params: {
2387+
func: insertIndexTwo,
2388+
setup: function (params) {
2389+
drop(params);
2390+
create(params);
2391+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2392+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"] });
2393+
},
2394+
type: "number",
2395+
teardown: drop
2396+
}
2397+
},
2398+
{
2399+
name: "indexes-insert2-numeric-noestimates",
2400+
params: {
2401+
func: insertIndexTwo,
2402+
setup: function (params) {
2403+
drop(params);
2404+
create(params);
2405+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2406+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"], estimates: false });
2407+
},
2408+
type: "number",
2409+
teardown: drop
2410+
}
2411+
},
2412+
{
2413+
name: "indexes-insert2-string",
2414+
params: {
2415+
func: insertIndexTwo,
2416+
setup: function (params) {
2417+
drop(params);
2418+
create(params);
2419+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"] });
2420+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"] });
2421+
},
2422+
type: "string",
2423+
teardown: drop
2424+
}
2425+
},
2426+
{
2427+
name: "indexes-insert2-string-noestimates",
2428+
params: {
2429+
func: insertIndexTwo,
2430+
setup: function (params) {
2431+
drop(params);
2432+
create(params);
2433+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value1"], estimates: false });
2434+
db[params.collection].ensureIndex({ type: "persistent", fields: ["value2"], estimates: false });
2435+
},
2436+
type: "string",
2437+
teardown: drop
2438+
}
2439+
},
2440+
];
2441+
22722442
// Tests without collections/IO, to focus on aql block performance.
22732443
let iolessTests = [
22742444
{
@@ -3350,6 +3520,30 @@ exports.test = function (global) {
33503520

33513521
runTestSuite("Arango Search No Materialization", arangosearchNoMaterializationTests, options);
33523522
}
3523+
3524+
// indexes tests
3525+
if (global.indexes) {
3526+
options = {
3527+
runs: global.runs,
3528+
digits: global.digits,
3529+
setup: function (/* params */) {},
3530+
teardown: function () {},
3531+
collections: [],
3532+
removeFromResult: 1
3533+
};
3534+
3535+
if (global.tiny) {
3536+
options.collections.push({ name: "indexes1000", label: "1k", size: 1000 });
3537+
} else if (global.small) {
3538+
options.collections.push({ name: "indexes10000", label: "10k", size: 10000 });
3539+
} else if (global.medium) {
3540+
options.collections.push({ name: "indexes100000", label: "100k", size: 100000 });
3541+
} else if (global.big) {
3542+
options.collections.push({ name: "indexes1000000", label: "1000k", size: 1000000 });
3543+
}
3544+
3545+
runTestSuite("indexes", indexesTests, options);
3546+
}
33533547

33543548
// crud tests
33553549
if (global.crud) {

0 commit comments

Comments
 (0)