1
0
Fork 0

fixed iterate

This commit is contained in:
Frank Celler 2013-01-12 21:02:31 +01:00
parent e95b2e0f7e
commit 3187fcb4f7
2 changed files with 32 additions and 18 deletions

View File

@ -1648,10 +1648,17 @@ function ArangoCollection (database, data) {
if (limit === null) {
if (probability >= 1.0) {
stmt = internal.sprintf("FOR d IN %s RETURN d", this.name());
cursor = this.all();
}
else {
stmt = internal.sprintf("FOR d IN %s FILTER rand() >= @prob RETURN d", this.name());
stmt = internal.db._createStatement({ query: stmt });
if (probability < 1.0) {
stmt.bind("prob", probability);
}
cursor = stmt.execute();
}
}
else {
@ -1664,21 +1671,21 @@ function ArangoCollection (database, data) {
}
if (probability >= 1.0) {
stmt = internal.sprintf("FOR d IN %s LIMIT %d RETURN d", this.name(), limit);
cursor = this.all().limit(limit);
}
else {
stmt = internal.sprintf("FOR d IN %s FILTER rand() >= @prob LIMIT %d RETURN d",
this.name(), limit);
stmt = internal.db._createStatement({ query: stmt });
if (probability < 1.0) {
stmt.bind("prob", probability);
}
cursor = stmt.execute();
}
}
stmt = internal.db._createStatement({ query: stmt, batchSize: 100 });
if (probability < 1.0) {
stmt.bind("prob", probability);
}
cursor = stmt.execute();
pos = 0;
while (cursor.hasNext()) {

View File

@ -249,10 +249,17 @@
if (limit === null) {
if (probability >= 1.0) {
stmt = internal.sprintf("FOR d IN %s RETURN d", this.name());
cursor = this.all();
}
else {
stmt = internal.sprintf("FOR d IN %s FILTER rand() >= @prob RETURN d", this.name());
stmt = internal.db._createStatement({ query: stmt });
if (probability < 1.0) {
stmt.bind("prob", probability);
}
cursor = stmt.execute();
}
}
else {
@ -265,21 +272,21 @@
}
if (probability >= 1.0) {
stmt = internal.sprintf("FOR d IN %s LIMIT %d RETURN d", this.name(), limit);
cursor = this.all().limit(limit);
}
else {
stmt = internal.sprintf("FOR d IN %s FILTER rand() >= @prob LIMIT %d RETURN d",
this.name(), limit);
stmt = internal.db._createStatement({ query: stmt });
if (probability < 1.0) {
stmt.bind("prob", probability);
}
cursor = stmt.execute();
}
}
stmt = internal.db._createStatement({ query: stmt });
if (probability < 1.0) {
stmt.bind("prob", probability);
}
cursor = stmt.execute();
pos = 0;
while (cursor.hasNext()) {