summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/value.cpp
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2015-05-28 16:25:55 -0400
committerCharlie Swanson <charlie.swanson@mongodb.com>2015-06-18 14:50:53 -0400
commitc317c2b9416ffeb9a79ac8bec1eb79ae10448a4a (patch)
treef9ece61a2eba4d1e0e808be027c3250018b22e29 /src/mongo/db/pipeline/value.cpp
parentd9a33681a85c160cb8367b04da9c539614d6b26a (diff)
downloadmongo-c317c2b9416ffeb9a79ac8bec1eb79ae10448a4a.tar.gz
SERVER-4589: Add $arrayElemAt aggregation expression
Diffstat (limited to 'src/mongo/db/pipeline/value.cpp')
-rw-r--r--src/mongo/db/pipeline/value.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/value.cpp b/src/mongo/db/pipeline/value.cpp
index 833d7ac23de..0d55a309002 100644
--- a/src/mongo/db/pipeline/value.cpp
+++ b/src/mongo/db/pipeline/value.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/pipeline/value.h"
#include <cmath>
+#include <limits>
#include <boost/functional/hash.hpp>
#include "mongo/base/compare_numbers.h"
@@ -822,6 +823,22 @@ namespace mongo {
return Undefined;
}
+ bool Value::integral() const {
+ switch (getType()) {
+ case NumberInt:
+ return true;
+ case NumberLong:
+ return (_storage.longValue <= numeric_limits<int>::max()
+ && _storage.longValue >= numeric_limits<int>::min());
+ case NumberDouble:
+ return (_storage.doubleValue <= numeric_limits<int>::max()
+ && _storage.doubleValue >= numeric_limits<int>::min()
+ && _storage.doubleValue == static_cast<int>(_storage.doubleValue));
+ default:
+ return false;
+ }
+ }
+
size_t Value::getApproximateSize() const {
switch(getType()) {
case Code: