You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/02/21 19:21:14 UTC
[01/21] git commit: fix forgot password and remove google analytics
Repository: incubator-usergrid
Updated Branches:
refs/heads/master 57f0a9475 -> 9aff385f5
refs/heads/two-dot-o ba7d5ae36 -> 0f5ad3393
refs/pull/58/merge [deleted] 1637dfacf
fix forgot password and remove google analytics
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/47bce9df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/47bce9df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/47bce9df
Branch: refs/heads/master
Commit: 47bce9df699dd07608fcf79e632785009519e425
Parents: 2c4af65
Author: Shawn Feldman <sh...@gmail.com>
Authored: Thu Feb 20 14:02:19 2014 -0700
Committer: Shawn Feldman <sh...@gmail.com>
Committed: Thu Feb 20 14:02:19 2014 -0700
----------------------------------------------------------------------
portal/config.js | 15 ---------------
portal/js/login/forgot-password-controller.js | 6 ++++--
2 files changed, 4 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/47bce9df/portal/config.js
----------------------------------------------------------------------
diff --git a/portal/config.js b/portal/config.js
index 3f0010e..a78d776 100644
--- a/portal/config.js
+++ b/portal/config.js
@@ -1,20 +1,5 @@
var Usergrid = Usergrid || {};
-//Google Analytics
-var _gaq = _gaq || [];
-_gaq.push(['_setAccount', 'UA-4084158-4']);
-try{
- (function(document) {
- if(!document){
- return;
- }
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
- })(document || null);
-}catch(e){};
-//End Google Analytics
-
Usergrid.showNotifcations = true;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/47bce9df/portal/js/login/forgot-password-controller.js
----------------------------------------------------------------------
diff --git a/portal/js/login/forgot-password-controller.js b/portal/js/login/forgot-password-controller.js
index bf5fc08..ece3082 100644
--- a/portal/js/login/forgot-password-controller.js
+++ b/portal/js/login/forgot-password-controller.js
@@ -1,11 +1,13 @@
'use strict'
+
AppServices.Controllers.controller('ForgotPasswordCtrl',
['ug',
'$scope',
'$rootScope',
'$location',
- 'utility', function (ug, $scope, $rootScope, $location) {
+ '$sce',
+ 'utility', function (ug, $scope, $rootScope, $location,$sce) {
$rootScope.activeUI && $location.path('/');
- $scope.forgotPWiframeURL = $scope.apiUrl + '/management/users/resetpw';
+ $scope.forgotPWiframeURL = $sce.trustAsResourceUrl( $scope.apiUrl + '/management/users/resetpw');
}]);
[18/21] git commit: Merge branch 'two-dot-o' of
github.com:usergrid/usergrid into two-dot-o
Posted by sn...@apache.org.
Merge branch 'two-dot-o' of github.com:usergrid/usergrid into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c27b2167
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c27b2167
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c27b2167
Branch: refs/heads/two-dot-o
Commit: c27b2167a344c3bc4ef56fcfe71f01ddd59cae51
Parents: 9b7ec93 c0543f5
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Feb 21 10:52:26 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Feb 21 10:52:26 2014 -0700
----------------------------------------------------------------------
stack/corepersistence/index/pom.xml | 190 -
.../index/EntityCollectionIndex.java | 41 -
.../index/impl/EntityCollectionIndexImpl.java | 235 -
.../persistence/index/impl/IndexModule.java | 32 -
.../index/impl/ElasticSearchTest.java | 262 -
.../persistence/index/impl/EntityIndexTest.java | 279 -
.../persistence/utils/ElasticSearchRule.java | 65 -
.../index/src/test/resources/log4j.properties | 15 -
.../index/src/test/resources/sample-large.json | 39603 -----------------
.../index/src/test/resources/sample-small.json | 222 -
stack/corepersistence/query/pom.xml | 233 +
.../query/src/test/resources/log4j.properties | 30 +
stack/corepersistence/queryindex/pom.xml | 228 +
.../persistence/query/tree/QueryFilter.g | 311 +
.../queryindex/src/main/java/QueryFilter.tokens | 47 +
.../ApplicationAlreadyExistsException.java | 37 +
.../DuplicateUniquePropertyExistsException.java | 52 +
.../exceptions/EntityNotFoundException.java | 45 +
.../exceptions/JsonReadException.java | 27 +
.../exceptions/JsonWriteException.java | 27 +
.../exceptions/LockingException.java | 65 +
.../exceptions/NoFullTextIndexException.java | 50 +
.../exceptions/NoIndexException.java | 50 +
.../exceptions/NotImplementedException.java | 58 +
.../exceptions/PersistenceException.java | 45 +
.../PropertyTypeConversionException.java | 71 +
.../exceptions/QueryIterationException.java | 13 +
.../exceptions/QueryParseException.java | 63 +
.../exceptions/QueryTokenException.java | 52 +
.../persistence/exceptions/QueueException.java | 61 +
.../RequiredPropertyNotFoundException.java | 41 +
.../TransactionNotFoundException.java | 45 +
.../UnexpectedEntityTypeException.java | 45 +
.../index/EntityCollectionIndex.java | 46 +
.../persistence/index/EntitySearchResults.java | 65 +
.../index/impl/EntityCollectionIndexImpl.java | 272 +
.../persistence/index/impl/IndexModule.java | 32 +
.../persistence/query/AggregateCounter.java | 48 +
.../persistence/query/AggregateCounterSet.java | 116 +
.../persistence/query/AssociatedEntityRef.java | 21 +
.../persistence/query/CollectionRef.java | 26 +
.../persistence/query/ConnectedEntityRef.java | 22 +
.../persistence/query/ConnectionRef.java | 34 +
.../persistence/query/CounterResolution.java | 84 +
.../usergrid/persistence/query/EntityRef.java | 28 +
.../usergrid/persistence/query/Query.java | 1099 +
.../usergrid/persistence/query/QueryUtils.java | 34 +
.../usergrid/persistence/query/Results.java | 1284 +
.../persistence/query/SimpleEntityRef.java | 129 +
.../usergrid/persistence/query/ir/AllNode.java | 45 +
.../usergrid/persistence/query/ir/AndNode.java | 43 +
.../persistence/query/ir/BooleanNode.java | 48 +
.../query/ir/EmailIdentifierNode.java | 28 +
.../query/ir/NameIdentifierNode.java | 28 +
.../persistence/query/ir/NodeVisitor.java | 71 +
.../usergrid/persistence/query/ir/NotNode.java | 62 +
.../usergrid/persistence/query/ir/OrNode.java | 52 +
.../persistence/query/ir/OrderByNode.java | 84 +
.../persistence/query/ir/QueryNode.java | 28 +
.../persistence/query/ir/SearchVisitor.java | 68 +
.../query/ir/UuidIdentifierNode.java | 32 +
.../persistence/query/ir/WithinNode.java | 87 +
.../persistence/query/tree/AndOperand.java | 48 +
.../persistence/query/tree/BooleanLiteral.java | 48 +
.../persistence/query/tree/BooleanOperand.java | 48 +
.../persistence/query/tree/ContainsOperand.java | 69 +
.../query/tree/ContainsProperty.java | 57 +
.../usergrid/persistence/query/tree/Equal.java | 52 +
.../persistence/query/tree/EqualityOperand.java | 88 +
.../persistence/query/tree/FloatLiteral.java | 57 +
.../persistence/query/tree/GreaterThan.java | 52 +
.../query/tree/GreaterThanEqual.java | 56 +
.../persistence/query/tree/LessThan.java | 52 +
.../persistence/query/tree/LessThanEqual.java | 54 +
.../persistence/query/tree/Literal.java | 38 +
.../persistence/query/tree/LiteralFactory.java | 58 +
.../persistence/query/tree/LongLiteral.java | 64 +
.../persistence/query/tree/NotOperand.java | 45 +
.../persistence/query/tree/NumericLiteral.java | 24 +
.../persistence/query/tree/Operand.java | 47 +
.../persistence/query/tree/OrOperand.java | 53 +
.../persistence/query/tree/Property.java | 62 +
.../query/tree/QueryFilterLexer.java | 2565 ++
.../query/tree/QueryFilterParser.java | 2186 +
.../persistence/query/tree/QueryVisitor.java | 90 +
.../persistence/query/tree/StringLiteral.java | 82 +
.../persistence/query/tree/UUIDLiteral.java | 49 +
.../persistence/query/tree/WithinOperand.java | 111 +
.../persistence/query/tree/WithinProperty.java | 54 +
.../usergrid/persistence/utils/AESUtils.java | 83 +
.../usergrid/persistence/utils/BCrypt.java | 627 +
.../usergrid/persistence/utils/ClassUtils.java | 58 +
.../usergrid/persistence/utils/CodecUtils.java | 45 +
.../persistence/utils/ConversionUtils.java | 765 +
.../usergrid/persistence/utils/DateUtils.java | 88 +
.../persistence/utils/InflectionUtils.java | 51 +
.../usergrid/persistence/utils/Inflector.java | 553 +
.../usergrid/persistence/utils/JsonUtils.java | 329 +
.../usergrid/persistence/utils/ListUtils.java | 230 +
.../usergrid/persistence/utils/MapUtils.java | 377 +
.../usergrid/persistence/utils/NumberUtils.java | 35 +
.../persistence/utils/PasswordUtils.java | 28 +
.../usergrid/persistence/utils/StringUtils.java | 172 +
.../usergrid/persistence/utils/TimeUtils.java | 88 +
.../usergrid/persistence/utils/UUIDUtils.java | 412 +
.../usergrid/persistence/utils/Version.java | 428 +
.../persistence/utils/package-info.java | 18 +
.../index/impl/ElasticSearchTest.java | 262 +
.../persistence/index/impl/EntityIndexTest.java | 306 +
.../usergrid/persistence/query/QueryTest.java | 312 +
.../persistence/query/tree/GrammarTreeTest.java | 608 +
.../persistence/query/tree/LongLiteralTest.java | 62 +
.../query/tree/StringLiteralTest.java | 88 +
.../persistence/utils/ElasticSearchRule.java | 65 +
.../src/test/resources/log4j.properties | 15 +
.../src/test/resources/sample-large.json | 39603 +++++++++++++++++
.../src/test/resources/sample-small.json | 222 +
117 files changed, 57851 insertions(+), 40944 deletions(-)
----------------------------------------------------------------------
[07/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/BCrypt.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/BCrypt.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/BCrypt.java
new file mode 100644
index 0000000..0b0e49b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/BCrypt.java
@@ -0,0 +1,627 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+//Copyright (c) 2006 Damien Miller <dj...@mindrot.org>
+//
+// Permission to use, copy, modify, and distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+import java.io.UnsupportedEncodingException;
+import java.security.SecureRandom;
+
+
+/**
+ * BCrypt implements OpenBSD-style Blowfish password hashing using the scheme described in "A Future-Adaptable Password
+ * Scheme" by Niels Provos and David Mazieres.
+ * <p/>
+ * This password hashing system tries to thwart off-line password cracking using a computationally-intensive hashing
+ * algorithm, based on Bruce Schneier's Blowfish cipher. The work factor of the algorithm is parameterised, so it can be
+ * increased as computers get faster.
+ * <p/>
+ * Usage is really simple. To hash a password for the first time, call the hashpw method with a random salt, like this:
+ * <p/>
+ * <code> String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt()); <br /> </code>
+ * <p/>
+ * To check whether a plaintext password matches one that has been hashed previously, use the checkpw method:
+ * <p/>
+ * <code> if (BCrypt.checkpw(candidate_password, stored_hash))<br /> System.out.println("It
+ * matches");<br /> else<br /> System.out.println("It does not match");<br /> </code>
+ * <p/>
+ * The gensalt() method takes an optional parameter (logRounds) that determines the computational complexity of the
+ * hashing:
+ * <p/>
+ * <code> String strong_salt = BCrypt.gensalt(10)<br /> String stronger_salt = BCrypt.gensalt(12)<br /> </code>
+ * <p/>
+ * The amount of work increases exponentially (2**logRounds), so each increment is twice as much work. The default
+ * logRounds is 10, and the valid range is 4 to 31.
+ *
+ * @version 0.2
+ */
+public class BCrypt {
+ private static final int BCRYPT_SALT_LEN = 16;
+
+ // Blowfish parameters
+ private static final int BLOWFISH_NUM_ROUNDS = 16;
+
+ // Initial contents of key schedule
+ private static final int[] P_orig = {
+ 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, 0x452821e6,
+ 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b
+ };
+ private static final int[] S_orig = {
+ 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, 0x24a19947,
+ 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
+ 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, 0xc5d1b023, 0x286085f0, 0xca417918,
+ 0xb8db38ef, 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
+ 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af,
+ 0x7c72e993, 0xb3ee1411, 0x636fbc2a, 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
+ 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60,
+ 0x5dec8032, 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
+ 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, 0x6a51a0d2,
+ 0xd8542f68, 0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
+ 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, 0xe06f75d8, 0x85c12073, 0x401a449f,
+ 0x56c16aa6, 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
+ 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6,
+ 0x409f60c4, 0x5e5c9ec2, 0x196a2463, 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
+ 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39,
+ 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
+ 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, 0x9e5c57bb,
+ 0xca6f8ca0, 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
+ 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, 0x9a53e479, 0xb6f84565, 0xd28e49bc,
+ 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
+ 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb,
+ 0xf2122b64, 0x8888b812, 0x900df01c, 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
+ 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81,
+ 0xd2ada8d9, 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
+ 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, 0x2464369b,
+ 0xf009b91e, 0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
+ 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, 0xd60f573f, 0xbc9bc6e4, 0x2b60a476,
+ 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
+ 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0,
+ 0x49a7df7d, 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29,
+ 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6,
+ 0xf0255dc1, 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
+ 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37,
+ 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, 0xd19113f9, 0x7ca92ff6,
+ 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e,
+ 0xa4751e41, 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
+ 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f,
+ 0x2e6b7124, 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, 0xec7aec3a, 0xdb851dfa,
+ 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002,
+ 0x133ae4dd, 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
+ 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c,
+ 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, 0xc6150eba, 0x94e2ea78,
+ 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e,
+ 0xeac31f66, 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
+ 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830,
+ 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, 0xeecc86bc, 0x60622ca7,
+ 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5,
+ 0xc021b8f7, 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
+ 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb,
+ 0x532e3054, 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, 0x5d4a14d9, 0xe864b7e3,
+ 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d,
+ 0x41cd2105, 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
+ 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a,
+ 0x0c55f5ea, 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, 0x7cde3759, 0xcbee7460,
+ 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc,
+ 0x800bcadc, 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
+ 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, 0xe93d5a68,
+ 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a,
+ 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af, 0x70f4ddd3,
+ 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
+ 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2,
+ 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9,
+ 0xee39d7ab, 0x3b124e8b, 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7,
+ 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
+ 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, 0xfdf8e802,
+ 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f,
+ 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60, 0xdff8e8a3,
+ 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
+ 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f,
+ 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8,
+ 0x991be14c, 0xdb6e6b0d, 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92,
+ 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
+ 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, 0x6a124237,
+ 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386,
+ 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086, 0x60787bf8,
+ 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
+ 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3,
+ 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770,
+ 0x8cd55591, 0xc902de4c, 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1,
+ 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
+ 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, 0x9af88c27,
+ 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63,
+ 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188, 0x39720a3d,
+ 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
+ 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234,
+ 0x92638212, 0x670efa8e, 0x406000e0, 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
+ 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be,
+ 0x6a366eb4, 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
+ 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8,
+ 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
+ 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, 0x80e4a915, 0x87b08601, 0x9b09e6ad,
+ 0x3b3ee593, 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
+ 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d,
+ 0x283b57cc, 0xf8d56629, 0x79132e28, 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
+ 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb,
+ 0x26dcf319, 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
+ 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, 0xa8b6e37e,
+ 0xc3293d46, 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
+ 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, 0xdda26a7e, 0x3a59ff45, 0x3e350a44,
+ 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
+ 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428,
+ 0x95983a1d, 0x06b89fb4, 0xce6ea048, 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
+ 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3,
+ 0xa1e8aac7, 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
+ 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, 0xfae59361,
+ 0xceb69ceb, 0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
+ 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, 0x1b0a7441, 0x4ba3348c, 0xc5be7120,
+ 0xc37632d8, 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
+ 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162,
+ 0x5a75ebb5, 0x6e163697, 0x88d273cc, 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
+ 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c,
+ 0xcd769c2b, 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
+ 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869,
+ 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
+ };
+
+ // bcrypt IV: "OrpheanBeholderScryDoubt"
+ private static final int[] BF_CRYPT_CYPHERTEXT = {
+ 0x4f727068, 0x65616e42, 0x65686f6c, 0x64657253, 0x63727944, 0x6f756274
+ };
+
+ // Table for Base64 encoding
+ private static final char[] BASE64_CODE = {
+ '.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
+ };
+
+ // Table for Base64 decoding
+ private static final byte[] INDEX_64 = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, -1, -1, -1, -1, -1, -1, -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, -1, -1, -1, -1, -1, -1, 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, -1, -1, -1, -1, -1
+ };
+
+ // Expanded Blowfish key
+ private int[] p;
+ private int[] s;
+
+
+ /**
+ * Encode a byte array using bcrypt's slightly-modified base64 encoding scheme. Note that this is *not* compatible
+ * with the standard MIME-base64 encoding.
+ *
+ * @param d the byte array to encode
+ * @param len the number of bytes to encode
+ *
+ * @return base64-encoded string
+ *
+ * @throws IllegalArgumentException if the length is invalid
+ */
+ private static String encodeBase64( byte[] d, int len ) throws IllegalArgumentException {
+ int off = 0;
+ StringBuilder rs = new StringBuilder();
+ int c1;
+ int c2;
+
+ if ( ( len <= 0 ) || ( len > d.length ) ) {
+ throw new IllegalArgumentException( "Invalid len" );
+ }
+
+ while ( off < len ) {
+ c1 = d[off++] & 0xff;
+ rs.append( BASE64_CODE[( c1 >> 2 ) & 0x3f] );
+ c1 = ( c1 & 0x03 ) << 4;
+ if ( off >= len ) {
+ rs.append( BASE64_CODE[c1 & 0x3f] );
+ break;
+ }
+ c2 = d[off++] & 0xff;
+ c1 |= ( c2 >> 4 ) & 0x0f;
+ rs.append( BASE64_CODE[c1 & 0x3f] );
+ c1 = ( c2 & 0x0f ) << 2;
+ if ( off >= len ) {
+ rs.append( BASE64_CODE[c1 & 0x3f] );
+ break;
+ }
+ c2 = d[off++] & 0xff;
+ c1 |= ( c2 >> 6 ) & 0x03;
+ rs.append( BASE64_CODE[c1 & 0x3f] );
+ rs.append( BASE64_CODE[c2 & 0x3f] );
+ }
+ return rs.toString();
+ }
+
+
+ /**
+ * Look up the 3 bits base64-encoded by the specified character, range-checking againt conversion table
+ *
+ * @param x the base64-encoded value
+ *
+ * @return the decoded value of x
+ */
+ private static byte char64( char x ) {
+ if ( ( x < 0 ) || ( x > INDEX_64.length ) ) {
+ return -1;
+ }
+ return INDEX_64[x];
+ }
+
+
+ /**
+ * Decode a string encoded using bcrypt's base64 scheme to a byte array. Note that this is *not* compatible with the
+ * standard MIME-base64 encoding.
+ *
+ * @param s the string to decode
+ * @param maxolen the maximum number of bytes to decode
+ *
+ * @return an array containing the decoded bytes
+ *
+ * @throws IllegalArgumentException if maxolen is invalid
+ */
+ private static byte[] decodeBase64( String s, int maxolen ) throws IllegalArgumentException {
+ StringBuilder rs = new StringBuilder();
+ int off = 0;
+ int slen = s.length();
+ int olen = 0;
+ byte[] ret;
+ byte c1;
+ byte c2;
+ byte c3;
+ byte c4;
+ byte o;
+
+ if ( maxolen <= 0 ) {
+ throw new IllegalArgumentException( "Invalid maxolen" );
+ }
+
+ while ( ( off < slen - 1 ) && ( olen < maxolen ) ) {
+ c1 = char64( s.charAt( off++ ) );
+ c2 = char64( s.charAt( off++ ) );
+ if ( ( c1 == -1 ) || ( c2 == -1 ) ) {
+ break;
+ }
+ o = ( byte ) ( c1 << 2 );
+ o |= ( c2 & 0x30 ) >> 4;
+ rs.append( ( char ) o );
+ if ( ( ++olen >= maxolen ) || ( off >= slen ) ) {
+ break;
+ }
+ c3 = char64( s.charAt( off++ ) );
+ if ( c3 == -1 ) {
+ break;
+ }
+ o = ( byte ) ( ( c2 & 0x0f ) << 4 );
+ o |= ( c3 & 0x3c ) >> 2;
+ rs.append( ( char ) o );
+ if ( ( ++olen >= maxolen ) || ( off >= slen ) ) {
+ break;
+ }
+ c4 = char64( s.charAt( off++ ) );
+ o = ( byte ) ( ( c3 & 0x03 ) << 6 );
+ o |= c4;
+ rs.append( ( char ) o );
+ ++olen;
+ }
+
+ ret = new byte[olen];
+ for ( off = 0; off < olen; off++ ) {
+ ret[off] = ( byte ) rs.charAt( off );
+ }
+ return ret;
+ }
+
+
+ /**
+ * Blowfish encipher a single 64-bit block encoded as two 32-bit halves
+ *
+ * @param lr an array containing the two 32-bit half blocks
+ * @param off the position in the array of the blocks
+ */
+ private void encipher( int[] lr, int off ) {
+ int i;
+ int n;
+ int l = lr[off];
+ int r = lr[off + 1];
+
+ l ^= p[0];
+ for ( i = 0; i <= BLOWFISH_NUM_ROUNDS - 2; ) {
+ // Feistel substitution on left word
+ n = s[( l >> 24 ) & 0xff];
+ n += s[0x100 | ( ( l >> 16 ) & 0xff )];
+ n ^= s[0x200 | ( ( l >> 8 ) & 0xff )];
+ n += s[0x300 | ( l & 0xff )];
+ r ^= n ^ p[++i];
+
+ // Feistel substitution on right word
+ n = s[( r >> 24 ) & 0xff];
+ n += s[0x100 | ( ( r >> 16 ) & 0xff )];
+ n ^= s[0x200 | ( ( r >> 8 ) & 0xff )];
+ n += s[0x300 | ( r & 0xff )];
+ l ^= n ^ p[++i];
+ }
+ lr[off] = r ^ p[BLOWFISH_NUM_ROUNDS + 1];
+ lr[off + 1] = l;
+ }
+
+
+ /**
+ * Cyclically extract a word of key material
+ *
+ * @param data the string to extract the data from
+ * @param offp a "pointer" (as a one-entry array) to the current offset into data
+ *
+ * @return the next word of material from data
+ */
+ private static int streamtoword( byte[] data, int[] offp ) {
+ int i;
+ int word = 0;
+ int off = offp[0];
+
+ for ( i = 0; i < 4; i++ ) {
+ word = ( word << 8 ) | ( data[off] & 0xff );
+ off = ( off + 1 ) % data.length;
+ }
+
+ offp[0] = off;
+ return word;
+ }
+
+
+ /** Initialise the Blowfish key schedule */
+ private void initKey() {
+ p = P_orig.clone();
+ s = S_orig.clone();
+ }
+
+
+ /**
+ * Key the Blowfish cipher
+ *
+ * @param key an array containing the key
+ */
+ private void key( byte[] key ) {
+ int i;
+ int[] koffp = { 0 };
+ int[] lr = { 0, 0 };
+ int plen = p.length;
+ int slen = s.length;
+
+ for ( i = 0; i < plen; i++ ) {
+ p[i] = p[i] ^ streamtoword( key, koffp );
+ }
+
+ for ( i = 0; i < plen; i += 2 ) {
+ encipher( lr, 0 );
+ p[i] = lr[0];
+ p[i + 1] = lr[1];
+ }
+
+ for ( i = 0; i < slen; i += 2 ) {
+ encipher( lr, 0 );
+ s[i] = lr[0];
+ s[i + 1] = lr[1];
+ }
+ }
+
+
+ /**
+ * Perform the "enhanced key schedule" step described by Provos and Mazieres in "A Future-Adaptable Password Scheme"
+ * http://www.openbsd.org/papers/bcrypt-paper.ps
+ *
+ * @param data salt information
+ * @param key password information
+ */
+ private void ekskey( byte[] data, byte[] key ) {
+ int i;
+ int[] koffp = { 0 };
+ int[] doffp = { 0 };
+ int[] lr = { 0, 0 };
+ int plen = p.length;
+ int slen = s.length;
+
+ for ( i = 0; i < plen; i++ ) {
+ p[i] = p[i] ^ streamtoword( key, koffp );
+ }
+
+ for ( i = 0; i < plen; i += 2 ) {
+ lr[0] ^= streamtoword( data, doffp );
+ lr[1] ^= streamtoword( data, doffp );
+ encipher( lr, 0 );
+ p[i] = lr[0];
+ p[i + 1] = lr[1];
+ }
+
+ for ( i = 0; i < slen; i += 2 ) {
+ lr[0] ^= streamtoword( data, doffp );
+ lr[1] ^= streamtoword( data, doffp );
+ encipher( lr, 0 );
+ s[i] = lr[0];
+ s[i + 1] = lr[1];
+ }
+ }
+
+
+ /**
+ * Perform the central password hashing step in the bcrypt scheme
+ *
+ * @param password the password to hash
+ * @param salt the binary salt to hash with the password
+ * @param logRounds the binary logarithm of the number of rounds of hashing to apply
+ *
+ * @return an array containing the binary hashed password
+ */
+ private byte[] cryptRaw( byte[] password, byte[] salt, int logRounds ) {
+ int rounds;
+ int i;
+ int j;
+ int[] cdata = BF_CRYPT_CYPHERTEXT.clone();
+ int clen = cdata.length;
+ byte[] ret;
+
+ if ( ( logRounds < 4 ) || ( logRounds > 31 ) ) {
+ throw new IllegalArgumentException( "Bad number of rounds" );
+ }
+ rounds = 1 << logRounds;
+ if ( salt.length != BCRYPT_SALT_LEN ) {
+ throw new IllegalArgumentException( "Bad salt length" );
+ }
+
+ initKey();
+ ekskey( salt, password );
+ for ( i = 0; i < rounds; i++ ) {
+ key( password );
+ key( salt );
+ }
+
+ for ( i = 0; i < 64; i++ ) {
+ for ( j = 0; j < ( clen >> 1 ); j++ ) {
+ encipher( cdata, j << 1 );
+ }
+ }
+
+ ret = new byte[clen * 4];
+ for ( i = 0, j = 0; i < clen; i++ ) {
+ ret[j++] = ( byte ) ( ( cdata[i] >> 24 ) & 0xff );
+ ret[j++] = ( byte ) ( ( cdata[i] >> 16 ) & 0xff );
+ ret[j++] = ( byte ) ( ( cdata[i] >> 8 ) & 0xff );
+ ret[j++] = ( byte ) ( cdata[i] & 0xff );
+ }
+ return ret;
+ }
+
+
+ /**
+ * Hash a password using the OpenBSD bcrypt scheme
+ *
+ * @param password the password to hash
+ * @param salt the salt to hash with (perhaps generated using BCrypt.gensalt)
+ *
+ * @return the hashed password
+ */
+ public static String hashpw( String password, String salt ) {
+ BCrypt b;
+ String realSalt;
+ byte[] passwordb;
+ byte[] saltb;
+ byte[] hashed;
+ char minor = ( char ) 0;
+ int rounds;
+ int off;
+ StringBuilder rs = new StringBuilder();
+
+ if ( ( salt.charAt( 0 ) != '$' ) || ( salt.charAt( 1 ) != '2' ) ) {
+ throw new IllegalArgumentException( "Invalid salt version" );
+ }
+ if ( salt.charAt( 2 ) == '$' ) {
+ off = 3;
+ }
+ else {
+ minor = salt.charAt( 2 );
+ if ( ( minor != 'a' ) || ( salt.charAt( 3 ) != '$' ) ) {
+ throw new IllegalArgumentException( "Invalid salt revision" );
+ }
+ off = 4;
+ }
+
+ // Extract number of rounds
+ if ( salt.charAt( off + 2 ) > '$' ) {
+ throw new IllegalArgumentException( "Missing salt rounds" );
+ }
+ rounds = Integer.parseInt( salt.substring( off, off + 2 ) );
+
+ realSalt = salt.substring( off + 3, off + 25 );
+ try {
+ passwordb = ( password + ( minor >= 'a' ? "\000" : "" ) ).getBytes( "UTF-8" );
+ }
+ catch ( UnsupportedEncodingException uee ) {
+ throw new AssertionError( "UTF-8 is not supported" );
+ }
+
+ saltb = decodeBase64( realSalt, BCRYPT_SALT_LEN );
+
+ b = new BCrypt();
+ hashed = b.cryptRaw( passwordb, saltb, rounds );
+
+ rs.append( "$2" );
+ if ( minor >= 'a' ) {
+ rs.append( minor );
+ }
+ rs.append( "$" );
+ if ( rounds < 10 ) {
+ rs.append( "0" );
+ }
+ rs.append( Integer.toString( rounds ) );
+ rs.append( "$" );
+ rs.append( encodeBase64( saltb, saltb.length ) );
+ rs.append( encodeBase64( hashed, BF_CRYPT_CYPHERTEXT.length * 4 - 1 ) );
+ return rs.toString();
+ }
+
+
+ /**
+ * Generate a salt for use with the BCrypt.hashpw() method
+ *
+ * @param logRounds the log2 of the number of rounds of hashing to apply - the work factor therefore increases as
+ * 2**logRounds.
+ * @param random an instance of SecureRandom to use
+ *
+ * @return an encoded salt value
+ */
+ public static String gensalt( int logRounds, SecureRandom random ) {
+ StringBuilder rs = new StringBuilder();
+ byte[] rnd = new byte[BCRYPT_SALT_LEN];
+
+ random.nextBytes( rnd );
+
+ rs.append( "$2a$" );
+ if ( logRounds < 10 ) {
+ rs.append( "0" );
+ }
+ rs.append( Integer.toString( logRounds ) );
+ rs.append( "$" );
+ rs.append( encodeBase64( rnd, rnd.length ) );
+ return rs.toString();
+ }
+
+
+ /**
+ * Generate a salt for use with the BCrypt.hashpw() method
+ *
+ * @param logRounds the log2 of the number of rounds of hashing to apply - the work factor therefore increases as
+ * 2**logRounds.
+ *
+ * @return an encoded salt value
+ */
+ public static String gensalt( int logRounds ) {
+ return gensalt( logRounds, new SecureRandom() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ClassUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ClassUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ClassUtils.java
new file mode 100644
index 0000000..3e193f8
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ClassUtils.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+
+public class ClassUtils extends org.apache.commons.lang.ClassUtils {
+
+ @SuppressWarnings("unchecked")
+ public static <A, B> B cast( A a ) {
+ return ( B ) a;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ private static final Set<Class<?>> WRAPPER_TYPES = new HashSet<Class<?>>(
+ Arrays.asList( Boolean.class, Byte.class, Character.class, Double.class, Float.class, Integer.class,
+ Long.class, Short.class, Void.class ) );
+
+
+ public static boolean isWrapperType( Class<?> clazz ) {
+ return WRAPPER_TYPES.contains( clazz );
+ }
+
+
+ public static boolean isPrimitiveType( Class<?> clazz ) {
+ if ( clazz == null ) {
+ return false;
+ }
+ return clazz.isPrimitive() || isWrapperType( clazz );
+ }
+
+
+ public static boolean isBasicType( Class<?> clazz ) {
+ if ( clazz == null ) {
+ return false;
+ }
+ return ( String.class.isAssignableFrom( clazz ) ) || isPrimitiveType( clazz );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/CodecUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/CodecUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/CodecUtils.java
new file mode 100644
index 0000000..f90e57e
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/CodecUtils.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import java.util.UUID;
+
+import org.apache.commons.codec.binary.Base64;
+
+import static org.apache.usergrid.persistence.utils.ConversionUtils.bytes;
+
+
+public class CodecUtils {
+
+ public static Base64 base64 = new Base64( true );
+
+
+ public static String base64( byte[] bytes ) {
+ return base64.encodeToString( bytes );
+ }
+
+
+ public static String base64( UUID uuid ) {
+ return base64.encodeToString( bytes( uuid ) );
+ }
+
+
+ public static String base64( String str ) {
+ return Base64.encodeBase64URLSafeString( bytes( str ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ConversionUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ConversionUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ConversionUtils.java
new file mode 100644
index 0000000..cc688c0
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ConversionUtils.java
@@ -0,0 +1,765 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.commons.lang.math.NumberUtils;
+
+
+/** Convenience methods for converting to and from formats, primarily between byte arrays and UUIDs, Strings,
+ * and Longs. */
+public class ConversionUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger( ConversionUtils.class );
+
+ /**
+ *
+ */
+ public static final String UTF8_ENCODING = "UTF-8";
+
+ /**
+ *
+ */
+ public static final String ASCII_ENCODING = "US-ASCII";
+
+ public static final ByteBuffer HOLDER = ByteBuffer.wrap( new byte[] { 0 } );
+
+
+ /**
+ * @param uuid
+ * @return
+ */
+ public static UUID uuid( byte[] uuid ) {
+ return uuid( uuid, 0 );
+ }
+
+
+ /**
+ * @param uuid
+ * @param offset
+ * @return
+ */
+ public static UUID uuid( byte[] uuid, int offset ) {
+ ByteBuffer bb = ByteBuffer.wrap( uuid, offset, 16 );
+ return new UUID( bb.getLong(), bb.getLong() );
+ }
+
+
+ public static UUID uuid( ByteBuffer bb ) {
+ if ( bb == null ) {
+ return null;
+ }
+ if ( bb.remaining() < 16 ) {
+ return null;
+ }
+ bb = bb.slice();
+ return new UUID( bb.getLong(), bb.getLong() );
+ }
+
+
+ /**
+ * @param uuid
+ * @return
+ */
+ public static UUID uuid( String uuid ) {
+ try {
+ return UUID.fromString( uuid );
+ }
+ catch ( Exception e ) {
+ logger.error( "Bad UUID", e );
+ }
+ return UUIDUtils.ZERO_UUID;
+ }
+
+
+ /**
+ * @param obj
+ * @return
+ */
+ public static UUID uuid( Object obj ) {
+ return uuid( obj, UUIDUtils.ZERO_UUID );
+ }
+
+
+ public static UUID uuid( Object obj, UUID defaultValue ) {
+ if ( obj instanceof UUID ) {
+ return ( UUID ) obj;
+ }
+ else if ( obj instanceof byte[] ) {
+ return uuid( ( byte[] ) obj );
+ }
+ else if ( obj instanceof ByteBuffer ) {
+ return uuid( ( ByteBuffer ) obj );
+ }
+ else if ( obj instanceof String ) {
+ return uuid( ( String ) obj );
+ }
+ return defaultValue;
+ }
+
+
+ /**
+ * @param uuid
+ * @return
+ */
+ public static byte[] bytes( UUID uuid ) {
+ if ( uuid == null ) {
+ return null;
+ }
+ long msb = uuid.getMostSignificantBits();
+ long lsb = uuid.getLeastSignificantBits();
+ byte[] buffer = new byte[16];
+
+ for ( int i = 0; i < 8; i++ ) {
+ buffer[i] = ( byte ) ( msb >>> ( 8 * ( 7 - i ) ) );
+ }
+ for ( int i = 8; i < 16; i++ ) {
+ buffer[i] = ( byte ) ( lsb >>> ( 8 * ( 7 - i ) ) );
+ }
+
+ return buffer;
+ }
+
+
+ public static ByteBuffer bytebuffer( UUID uuid ) {
+ if ( uuid == null ) {
+ return null;
+ }
+ return ByteBuffer.wrap( bytes( uuid ) );
+ }
+
+
+ /**
+ * @param uuid
+ * @return
+ */
+ public static byte[] uuidToBytesNullOk( UUID uuid ) {
+ if ( uuid != null ) {
+ return bytes( uuid );
+ }
+ return new byte[16];
+ }
+
+
+ /**
+ * @param s
+ * @return
+ */
+ public static byte[] bytes( String s ) {
+ return bytes( s, UTF8_ENCODING );
+ }
+
+
+ public static ByteBuffer bytebuffer( String s ) {
+ return ByteBuffer.wrap( bytes( s ) );
+ }
+
+
+ /**
+ * @param s
+ * @return
+ */
+ public static byte[] ascii( String s ) {
+ if ( s == null ) {
+ return new byte[0];
+ }
+ return bytes( s, ASCII_ENCODING );
+ }
+
+
+ public ByteBuffer asciibuffer( String s ) {
+ return ByteBuffer.wrap( ascii( s ) );
+ }
+
+
+ /**
+ * @param s
+ * @param encoding
+ * @return
+ */
+ public static byte[] bytes( String s, String encoding ) {
+ try {
+ return s.getBytes( encoding );
+ }
+ catch ( UnsupportedEncodingException e ) {
+ // logger.log(Level.SEVERE, "UnsupportedEncodingException ", e);
+ throw new RuntimeException( e );
+ }
+ }
+
+
+ public static byte[] bytes( ByteBuffer bb ) {
+ byte[] b = new byte[bb.remaining()];
+ bb.duplicate().get( b );
+ return b;
+ }
+
+
+ public static ByteBuffer bytebuffer( String s, String encoding ) {
+ return ByteBuffer.wrap( bytes( s, encoding ) );
+ }
+
+
+ /**
+ * @param b
+ * @return
+ */
+ public static byte[] bytes( Boolean b ) {
+ byte[] bytes = new byte[1];
+ bytes[0] = b ? ( byte ) 1 : 0;
+ return bytes;
+ }
+
+
+ public static ByteBuffer bytebuffer( Boolean b ) {
+ return ByteBuffer.wrap( bytes( b ) );
+ }
+
+
+ /**
+ * @param val
+ * @return
+ */
+ public static byte[] bytes( Long val ) {
+ ByteBuffer buf = ByteBuffer.allocate( 8 );
+ buf.order( ByteOrder.BIG_ENDIAN );
+ buf.putLong( val );
+ return buf.array();
+ }
+
+
+ public static ByteBuffer bytebuffer( Long val ) {
+ ByteBuffer buf = ByteBuffer.allocate( 8 );
+ buf.order( ByteOrder.BIG_ENDIAN );
+ buf.putLong( val );
+ return ( ByteBuffer ) buf.rewind();
+ }
+
+
+ /**
+ * @param obj
+ * @return
+ */
+ public static byte[] bytes( Object obj ) {
+ if ( obj == null ) {
+ return new byte[0];
+ }
+ else if ( obj instanceof byte[] ) {
+ return ( byte[] ) obj;
+ }
+ else if ( obj instanceof Long ) {
+ return bytes( ( Long ) obj );
+ }
+ else if ( obj instanceof String ) {
+ return bytes( ( String ) obj );
+ }
+ else if ( obj instanceof UUID ) {
+ return bytes( ( UUID ) obj );
+ }
+ else if ( obj instanceof Boolean ) {
+ return bytes( ( Boolean ) obj );
+ }
+ else if ( obj instanceof Date ) {
+ return bytes( ( ( Date ) obj ).getTime() );
+ }
+ else {
+ return bytes( obj.toString() );
+ }
+ }
+
+
+ public static ByteBuffer bytebuffer( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes );
+ }
+
+
+ public static ByteBuffer bytebuffer( ByteBuffer bytes ) {
+ return bytes.duplicate();
+ }
+
+
+ public static ByteBuffer bytebuffer( Object obj ) {
+ if ( obj instanceof ByteBuffer ) {
+ return ( ( ByteBuffer ) obj ).duplicate();
+ }
+ return ByteBuffer.wrap( bytes( obj ) );
+ }
+
+
+ public static List<ByteBuffer> bytebuffers( List<?> l ) {
+ List<ByteBuffer> results = new ArrayList<ByteBuffer>( l.size() );
+ for ( Object o : l ) {
+ results.add( bytebuffer( o ) );
+ }
+ return results;
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static boolean getBoolean( byte[] bytes ) {
+ return bytes[0] != 0;
+ }
+
+
+ public static boolean getBoolean( ByteBuffer bytes ) {
+ return bytes.slice().get() != 0;
+ }
+
+
+ /**
+ * @param bytes
+ * @param offset
+ * @return
+ */
+ public static boolean getBoolean( byte[] bytes, int offset ) {
+ return bytes[offset] != 0;
+ }
+
+
+ public static boolean getBoolean( Object obj ) {
+ if ( obj instanceof Boolean ) {
+ return ( Boolean ) obj;
+ }
+ else if ( obj instanceof String ) {
+ return Boolean.parseBoolean( ( String ) obj );
+ }
+ else if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).longValue() > 0;
+ }
+
+ return false;
+ }
+
+
+ /**
+ * @param obj
+ * @return
+ */
+ public static String string( Object obj ) {
+ if ( obj instanceof String ) {
+ return ( String ) obj;
+ }
+ else if ( obj instanceof byte[] ) {
+ return string( ( byte[] ) obj );
+ }
+ else if ( obj instanceof ByteBuffer ) {
+ return string( ( ByteBuffer ) obj );
+ }
+ else if ( obj != null ) {
+ return obj.toString();
+ }
+ return null;
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static String string( byte[] bytes ) {
+ if ( bytes == null ) {
+ return null;
+ }
+ return string( bytes, 0, bytes.length, UTF8_ENCODING );
+ }
+
+
+ public static String string( ByteBuffer bytes ) {
+ if ( bytes == null ) {
+ return null;
+ }
+ return string( bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining(), UTF8_ENCODING );
+ }
+
+
+ /**
+ * @param bytes
+ * @param offset
+ * @param length
+ * @return
+ */
+ public static String string( byte[] bytes, int offset, int length ) {
+ return string( bytes, offset, length, UTF8_ENCODING );
+ }
+
+
+ /**
+ * @param bytes
+ * @param offset
+ * @param length
+ * @param encoding
+ * @return
+ */
+ public static String string( byte[] bytes, int offset, int length, String encoding ) {
+
+ if ( length <= 0 ) {
+ return "";
+ }
+
+ if ( bytes == null ) {
+ return "";
+ }
+
+ try {
+ return new String( bytes, offset, length, encoding );
+ }
+ catch ( UnsupportedEncodingException e ) {
+ // logger.log(Level.SEVERE, "UnsupportedEncodingException ", e);
+ throw new RuntimeException( e );
+ }
+ }
+
+
+ public static <T> List<String> strings( Collection<T> items ) {
+ List<String> strings = new ArrayList<String>();
+ for ( T item : items ) {
+ strings.add( string( item ) );
+ }
+ return strings;
+ }
+
+
+ /**
+ * @param bytes
+ * @param offset
+ * @return
+ */
+ public static String stringFromLong( byte[] bytes, int offset ) {
+ if ( bytes.length == 0 ) {
+ return "";
+ }
+ if ( ( bytes.length - offset ) < 8 ) {
+ throw new IllegalArgumentException( "A long is at least 8 bytes" );
+ }
+ return String.valueOf( ByteBuffer.wrap( bytes, offset, 8 ).getLong() );
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static long getLong( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes, 0, 8 ).getLong();
+ }
+
+
+ public static long getLong( ByteBuffer bytes ) {
+ return bytes.slice().getLong();
+ }
+
+
+ public static long getLong( Object obj ) {
+ if ( obj instanceof Long ) {
+ return ( Long ) obj;
+ }
+ if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).longValue();
+ }
+ if ( obj instanceof String ) {
+ return NumberUtils.toLong( ( String ) obj );
+ }
+ if ( obj instanceof Date ) {
+ return ( ( Date ) obj ).getTime();
+ }
+ if ( obj instanceof byte[] ) {
+ return getLong( ( byte[] ) obj );
+ }
+ if ( obj instanceof ByteBuffer ) {
+ return getLong( ( ByteBuffer ) obj );
+ }
+ return 0;
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static int getInt( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes, 0, 4 ).getInt();
+ }
+
+
+ public static int getInt( ByteBuffer bytes ) {
+ return bytes.slice().getInt();
+ }
+
+
+ public static int getInt( Object obj ) {
+ if ( obj instanceof Integer ) {
+ return ( Integer ) obj;
+ }
+ if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).intValue();
+ }
+ if ( obj instanceof String ) {
+ return NumberUtils.toInt( ( String ) obj );
+ }
+ if ( obj instanceof Date ) {
+ return ( int ) ( ( Date ) obj ).getTime();
+ }
+ if ( obj instanceof byte[] ) {
+ return getInt( ( byte[] ) obj );
+ }
+ if ( obj instanceof ByteBuffer ) {
+ return getInt( ( ByteBuffer ) obj );
+ }
+ return 0;
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static float getFloat( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes, 0, 4 ).getFloat();
+ }
+
+
+ public static float getFloat( ByteBuffer bytes ) {
+ return bytes.slice().getFloat();
+ }
+
+
+ public static float getFloat( Object obj ) {
+ if ( obj instanceof Float ) {
+ return ( Float ) obj;
+ }
+ if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).floatValue();
+ }
+ if ( obj instanceof String ) {
+ return NumberUtils.toFloat( ( String ) obj );
+ }
+ if ( obj instanceof Date ) {
+ return ( ( Date ) obj ).getTime();
+ }
+ if ( obj instanceof byte[] ) {
+ return getFloat( ( byte[] ) obj );
+ }
+ if ( obj instanceof ByteBuffer ) {
+ return getFloat( ( ByteBuffer ) obj );
+ }
+ return 0;
+ }
+
+
+ public static double getDouble( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes, 0, 8 ).getDouble();
+ }
+
+
+ public static double getDouble( ByteBuffer bytes ) {
+ return bytes.slice().getDouble();
+ }
+
+
+ public static double getDouble( Object obj ) {
+ if ( obj instanceof Double ) {
+ return ( Double ) obj;
+ }
+ if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).doubleValue();
+ }
+ if ( obj instanceof String ) {
+ return NumberUtils.toDouble( ( String ) obj );
+ }
+ if ( obj instanceof Date ) {
+ return ( ( Date ) obj ).getTime();
+ }
+ if ( obj instanceof byte[] ) {
+ return getDouble( ( byte[] ) obj );
+ }
+ if ( obj instanceof ByteBuffer ) {
+ return getDouble( ( ByteBuffer ) obj );
+ }
+ return 0;
+ }
+
+
+ /**
+ * @param type
+ * @param bytes
+ * @return
+ */
+ public static Object object( Class<?> type, byte[] bytes ) {
+
+ try {
+ if ( Long.class.isAssignableFrom( type ) ) {
+ return getLong( bytes );
+ }
+ else if ( UUID.class.isAssignableFrom( type ) ) {
+ return uuid( bytes );
+ }
+ else if ( String.class.isAssignableFrom( type ) ) {
+ return string( bytes );
+ }
+ else if ( Boolean.class.isAssignableFrom( type ) ) {
+ return getBoolean( bytes );
+ }
+ else if ( Integer.class.isAssignableFrom( type ) ) {
+ return getInt( bytes );
+ }
+ else if ( Double.class.isAssignableFrom( type ) ) {
+ return getDouble( bytes );
+ }
+ else if ( Float.class.isAssignableFrom( type ) ) {
+ return getFloat( bytes );
+ }
+ else if ( byte[].class.isAssignableFrom( type ) ) {
+ return bytes;
+ }
+ }
+ catch ( Exception e ) {
+ logger.error( "Unable to get object from bytes for type " + type.getName(), e );
+ }
+ return null;
+ }
+
+
+ public static Object object( Class<?> type, ByteBuffer bytes ) {
+
+ try {
+ if ( Long.class.isAssignableFrom( type ) ) {
+ return bytes.slice().getLong();
+ }
+ else if ( UUID.class.isAssignableFrom( type ) ) {
+ return uuid( bytes );
+ }
+ else if ( String.class.isAssignableFrom( type ) ) {
+ return string( bytes );
+ }
+ else if ( Boolean.class.isAssignableFrom( type ) ) {
+ return bytes.slice().get() != 0;
+ }
+ else if ( Integer.class.isAssignableFrom( type ) ) {
+ return bytes.slice().getInt();
+ }
+ else if ( Double.class.isAssignableFrom( type ) ) {
+ return bytes.slice().getDouble();
+ }
+ else if ( Float.class.isAssignableFrom( type ) ) {
+ return bytes.slice().getFloat();
+ }
+ else if ( ByteBuffer.class.isAssignableFrom( type ) ) {
+ return bytes.duplicate();
+ }
+ else if ( byte[].class.isAssignableFrom( type ) ) {
+ byte[] b = new byte[bytes.remaining()];
+ bytes.slice().get( b );
+ return b;
+ }
+ }
+ catch ( Exception e ) {
+ logger.error( "Unable to get object from bytes for type " + type.getName(), e );
+ }
+ return null;
+ }
+
+
+ /**
+ * @param bb
+ * @param bytes
+ * @param len
+ * @return
+ */
+ public static ByteBuffer appendToByteBuffer( ByteBuffer bb, byte[] bytes, int len ) {
+ if ( len > bytes.length ) {
+ int pos = bb.position();
+ bb.put( bytes );
+ bb.position( pos + len );
+ }
+ else {
+ bb.put( bytes, 0, len );
+ }
+ return bb;
+ }
+
+
+ public static Object coerce( Class<?> type, Object obj ) {
+
+ if ( obj == null ) {
+ return null;
+ }
+
+ if ( type == null ) {
+ return obj;
+ }
+
+ try {
+ if ( Long.class.isAssignableFrom( type ) ) {
+ return getLong( obj );
+ }
+ else if ( UUID.class.isAssignableFrom( type ) ) {
+ return uuid( obj );
+ }
+ else if ( String.class.isAssignableFrom( type ) ) {
+ return string( obj );
+ }
+ else if ( Boolean.class.isAssignableFrom( type ) ) {
+ return getBoolean( obj );
+ }
+ else if ( Integer.class.isAssignableFrom( type ) ) {
+ return getInt( obj );
+ }
+ else if ( Double.class.isAssignableFrom( type ) ) {
+ return getDouble( obj );
+ }
+ else if ( Float.class.isAssignableFrom( type ) ) {
+ return getFloat( obj );
+ }
+ else if ( byte[].class.isAssignableFrom( type ) ) {
+ return bytes( obj );
+ }
+ else if ( ByteBuffer.class.isAssignableFrom( type ) ) {
+ return bytebuffer( obj );
+ }
+ }
+ catch ( Exception e ) {
+ logger.error( "Unable to get object from bytes for type " + type.getName(), e );
+ }
+ return null;
+ }
+
+
+ public static Map<String, Object> coerceMap( Map<String, Class<?>> types, Map<String, Object> values ) {
+ for ( Map.Entry<String, Object> entry : values.entrySet() ) {
+ if ( types.containsKey( entry.getKey() ) ) {
+ values.put( entry.getKey(), coerce( types.get( entry.getKey() ), entry.getValue() ) );
+ }
+ }
+ return values;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/DateUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/DateUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/DateUtils.java
new file mode 100644
index 0000000..601696a
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/DateUtils.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Copyright 2010-2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+//
+// Portions copyright 2006-2009 James Murty. Please see LICENSE.txt
+// for applicable license terms and NOTICE.txt for applicable notices.
+//
+// Licensed under the Apache License, Version 2.0 (the "License").
+// You may not use this file except in compliance with the License.
+// A copy of the License is located at
+// http://aws.amazon.com/apache2.0
+// or in the "license" file accompanying this file. This file is distributed
+// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+// express or implied. See the License for the specific language governing
+// permissions and limitations under the License.
+
+package org.apache.usergrid.persistence.utils;
+
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.SimpleTimeZone;
+
+
+/**
+ * Utilities for parsing and formatting dates.
+ * <p/>
+ * Note that this class doesn't use static methods because of the synchronization issues with SimpleDateFormat. This
+ * lets synchronization be done on a per-object level, instead of on a per-class level.
+ */
+public class DateUtils {
+
+ /** ISO 8601 parser */
+ protected final SimpleDateFormat iso8601DateParser = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
+
+ /** Alternate ISO 8601 parser without fractional seconds */
+ protected final SimpleDateFormat alternateIo8601DateParser = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'" );
+
+ /** RFC 822 parser */
+ protected final SimpleDateFormat rfc822DateParser =
+ new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss z", Locale.US );
+
+
+ /** Constructs a new DateUtils object, ready to parse/format dates. */
+ public DateUtils() {
+ iso8601DateParser.setTimeZone( new SimpleTimeZone( 0, "GMT" ) );
+ rfc822DateParser.setTimeZone( new SimpleTimeZone( 0, "GMT" ) );
+ alternateIo8601DateParser.setTimeZone( new SimpleTimeZone( 0, "GMT" ) );
+ }
+
+
+ public static DateUtils instance = new DateUtils();
+
+
+ /**
+ * Formats the specified date as an ISO 8601 string.
+ *
+ * @param date The date to format.
+ *
+ * @return The ISO 8601 string representing the specified date.
+ */
+ public String formatIso8601Date( Date date ) {
+ synchronized ( iso8601DateParser ) {
+ return iso8601DateParser.format( date );
+ }
+ }
+
+
+ public String iso8601DateNow() {
+ return formatIso8601Date( new Date() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/InflectionUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/InflectionUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/InflectionUtils.java
new file mode 100644
index 0000000..6965df3
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/InflectionUtils.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+public class InflectionUtils {
+
+ public static String pluralize( Object word ) {
+ return Inflector.INSTANCE.pluralize( word );
+ }
+
+
+ public static String singularize( Object word ) {
+ return Inflector.INSTANCE.singularize( word );
+ }
+
+
+ public static boolean isPlural( Object word ) {
+ return Inflector.INSTANCE.isPlural( word );
+ }
+
+
+ public static boolean isSingular( Object word ) {
+ return Inflector.INSTANCE.isSingular( word );
+ }
+
+
+ public static String underscore( String s ) {
+ return Inflector.INSTANCE.underscore( s );
+ }
+
+
+ public static String camelCase( String lowerCaseAndUnderscoredWord, boolean uppercaseFirstLetter,
+ char... delimiterChars ) {
+ return Inflector.INSTANCE.camelCase( lowerCaseAndUnderscoredWord, uppercaseFirstLetter, delimiterChars );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Inflector.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Inflector.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Inflector.java
new file mode 100644
index 0000000..371a1b7
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Inflector.java
@@ -0,0 +1,553 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// TODO - This Class needs to go - it's LGPL Source !!!
+// ModeShape (http://www.modeshape.org)
+// See the COPYRIGHT.txt file distributed with this work for information
+// regarding copyright ownership. Some portions may be licensed
+// to Red Hat, Inc. under one or more contributor license agreements.
+// See the AUTHORS.txt file in the distribution for a full listing of
+// individual contributors.
+//
+// ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+// is licensed to you under the terms of the GNU Lesser General Public License as
+// published by the Free Software Foundation; either version 2.1 of
+// the License, or (at your option) any later version.
+//
+// ModeShape is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this software; if not, write to the Free
+// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+// 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+//
+
+package org.apache.usergrid.persistence.utils;
+
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * Transforms words to singular, plural, humanized (human readable), underscore, camel case, or ordinal form. This is
+ * inspired by the <a href="http://api.rubyonrails.org/classes/Inflector.html">Inflector</a> class in <a
+ * href="http://www.rubyonrails.org">Ruby on Rails</a>, which is distributed under the <a
+ * href="http://wiki.rubyonrails.org/rails/pages/License">Rails license</a>.
+ */
+public class Inflector {
+
+ protected static final Inflector INSTANCE = new Inflector();
+
+
+ public static Inflector getInstance() {
+ return INSTANCE;
+ }
+
+
+ protected class Rule {
+
+ protected final String expression;
+ protected final Pattern expressionPattern;
+ protected final String replacement;
+
+
+ protected Rule( String expression, String replacement ) {
+ this.expression = expression;
+ this.replacement = replacement != null ? replacement : "";
+ expressionPattern = Pattern.compile( this.expression, Pattern.CASE_INSENSITIVE );
+ }
+
+
+ /**
+ * Apply the rule against the input string, returning the modified string or null if the rule didn't apply (and
+ * no modifications were made)
+ *
+ * @param input the input string
+ *
+ * @return the modified string if this rule applied, or null if the input was not modified by this rule
+ */
+ protected String apply( String input ) {
+ Matcher matcher = expressionPattern.matcher( input );
+ if ( !matcher.find() ) {
+ return null;
+ }
+ return matcher.replaceAll( replacement );
+ }
+
+
+ @Override
+ public int hashCode() {
+ return expression.hashCode();
+ }
+
+
+ @Override
+ public boolean equals( Object obj ) {
+ if ( obj == this ) {
+ return true;
+ }
+ if ( ( obj != null ) && ( obj.getClass() == this.getClass() ) ) {
+ final Rule that = ( Rule ) obj;
+ if ( expression.equalsIgnoreCase( that.expression ) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ @Override
+ public String toString() {
+ return expression + ", " + replacement;
+ }
+ }
+
+
+ private final LinkedList<Rule> plurals = new LinkedList<Rule>();
+ private final LinkedList<Rule> singulars = new LinkedList<Rule>();
+ /**
+ * The lowercase words that are to be excluded and not processed. This map can be modified by the users via {@link
+ * #getUncountables()}.
+ */
+ private final Set<String> uncountables = new HashSet<String>();
+
+
+ public Inflector() {
+ initialize();
+ }
+
+
+ protected Inflector( Inflector original ) {
+ plurals.addAll( original.plurals );
+ singulars.addAll( original.singulars );
+ uncountables.addAll( original.uncountables );
+ }
+
+
+ @Override
+ @SuppressWarnings("all")
+ public Inflector clone() {
+ return new Inflector( this );
+ }
+
+ // ------------------------------------------------------------------------------------------------
+ // Usage functions
+ // ------------------------------------------------------------------------------------------------
+
+
+ /**
+ * Returns the plural form of the word in the string. <p> Examples: <p/>
+ * <pre>
+ * inflector.pluralize("post") #=> "posts"
+ * inflector.pluralize("octopus") #=> "octopi"
+ * inflector.pluralize("sheep") #=> "sheep"
+ * inflector.pluralize("words") #=> "words"
+ * inflector.pluralize("the blue mailman") #=> "the blue mailmen"
+ * inflector.pluralize("CamelOctopus") #=> "CamelOctopi"
+ * </pre>
+ * <p/> </p> <p> Note that if the {@link Object#toString()} is called on the supplied object, so this method works
+ * for non-strings, too. </p>
+ *
+ * @param word the word that is to be pluralized.
+ *
+ * @return the pluralized form of the word, or the word itself if it could not be pluralized
+ *
+ * @see #singularize(Object)
+ */
+ public String pluralize( Object word ) {
+ if ( word == null ) {
+ return null;
+ }
+ String wordStr = word.toString().trim();
+ if ( wordStr.length() == 0 ) {
+ return wordStr;
+ }
+ if ( isUncountable( wordStr ) ) {
+ return wordStr;
+ }
+ for ( Rule rule : plurals ) {
+ String result = rule.apply( wordStr );
+ if ( result != null ) {
+ return result;
+ }
+ }
+ return wordStr;
+ }
+
+
+ public String pluralize( Object word, int count ) {
+ if ( word == null ) {
+ return null;
+ }
+ if ( ( count == 1 ) || ( count == -1 ) ) {
+ return word.toString();
+ }
+ return pluralize( word );
+ }
+
+
+ public boolean isPlural( Object word ) {
+ if ( word == null ) {
+ return false;
+ }
+ return pluralize( word ).equals( word.toString() );
+ }
+
+
+ /**
+ * Returns the singular form of the word in the string. <p> Examples: <p/>
+ * <pre>
+ * inflector.singularize("posts") #=> "post"
+ * inflector.singularize("octopi") #=> "octopus"
+ * inflector.singularize("sheep") #=> "sheep"
+ * inflector.singularize("words") #=> "word"
+ * inflector.singularize("the blue mailmen") #=> "the blue mailman"
+ * inflector.singularize("CamelOctopi") #=> "CamelOctopus"
+ * </pre>
+ * <p/> </p> <p> Note that if the {@link Object#toString()} is called on the supplied object, so this method works
+ * for non-strings, too. </p>
+ *
+ * @param word the word that is to be pluralized.
+ *
+ * @return the pluralized form of the word, or the word itself if it could not be pluralized
+ *
+ * @see #pluralize(Object)
+ */
+ public String singularize( Object word ) {
+ if ( word == null ) {
+ return null;
+ }
+ String wordStr = word.toString().trim();
+ if ( wordStr.length() == 0 ) {
+ return wordStr;
+ }
+ if ( isUncountable( wordStr ) ) {
+ return wordStr;
+ }
+ for ( Rule rule : singulars ) {
+ String result = rule.apply( wordStr );
+ if ( result != null ) {
+ return result;
+ }
+ }
+ return wordStr;
+ }
+
+
+ public boolean isSingular( Object word ) {
+ if ( word == null ) {
+ return false;
+ }
+ return singularize( word ).equals( word.toString() );
+ }
+
+
+ /**
+ * By default, this method converts strings to UpperCamelCase. If the <code>uppercaseFirstLetter</code> argument to
+ * false, then this method produces lowerCamelCase. This method will also use any extra delimiter characters to
+ * identify word boundaries. <p> Examples: <p/>
+ * <pre>
+ * inflector.camelCase("active_record",false) #=> "activeRecord"
+ * inflector.camelCase("active_record",true) #=> "ActiveRecord"
+ * inflector.camelCase("first_name",false) #=> "firstName"
+ * inflector.camelCase("first_name",true) #=> "FirstName"
+ * inflector.camelCase("name",false) #=> "name"
+ * inflector.camelCase("name",true) #=> "Name"
+ * </pre>
+ * <p/> </p>
+ *
+ * @param lowerCaseAndUnderscoredWord the word that is to be converted to camel case
+ * @param uppercaseFirstLetter true if the first character is to be uppercased, or false if the first character is
+ * to be lowercased
+ * @param delimiterChars optional characters that are used to delimit word boundaries
+ *
+ * @return the camel case version of the word
+ *
+ * @see #underscore(String, char[])
+ */
+ public String camelCase( String lowerCaseAndUnderscoredWord, boolean uppercaseFirstLetter,
+ char... delimiterChars ) {
+ if ( lowerCaseAndUnderscoredWord == null ) {
+ return null;
+ }
+ lowerCaseAndUnderscoredWord = lowerCaseAndUnderscoredWord.trim();
+ if ( lowerCaseAndUnderscoredWord.length() == 0 ) {
+ return "";
+ }
+ if ( uppercaseFirstLetter ) {
+ String result = lowerCaseAndUnderscoredWord;
+ // Replace any extra delimiters with underscores (before the
+ // underscores are converted in the next step)...
+ if ( delimiterChars != null ) {
+ for ( char delimiterChar : delimiterChars ) {
+ result = result.replace( delimiterChar, '_' );
+ }
+ }
+
+ // Change the case at the beginning at after each underscore ...
+ return replaceAllWithUppercase( result, "(^|_)(.)", 2 );
+ }
+ if ( lowerCaseAndUnderscoredWord.length() < 2 ) {
+ return lowerCaseAndUnderscoredWord;
+ }
+ return "" + Character.toLowerCase( lowerCaseAndUnderscoredWord.charAt( 0 ) ) + camelCase(
+ lowerCaseAndUnderscoredWord, true, delimiterChars ).substring( 1 );
+ }
+
+
+ /**
+ * Makes an underscored form from the expression in the string (the reverse of the {@link #camelCase(String,
+ * boolean, char[]) camelCase} method. Also changes any characters that match the supplied delimiters into
+ * underscore. <p> Examples: <p/>
+ * <pre>
+ * inflector.underscore("activeRecord") #=> "active_record"
+ * inflector.underscore("ActiveRecord") #=> "active_record"
+ * inflector.underscore("firstName") #=> "first_name"
+ * inflector.underscore("FirstName") #=> "first_name"
+ * inflector.underscore("name") #=> "name"
+ * inflector.underscore("The.firstName") #=> "the_first_name"
+ * </pre>
+ * <p/> </p>
+ *
+ * @param camelCaseWord the camel-cased word that is to be converted;
+ * @param delimiterChars optional characters that are used to delimit word boundaries (beyond capitalization)
+ *
+ * @return a lower-cased version of the input, with separate words delimited by the underscore character.
+ */
+ public String underscore( String camelCaseWord, char... delimiterChars ) {
+ if ( camelCaseWord == null ) {
+ return null;
+ }
+ String result = camelCaseWord.trim();
+ if ( result.length() == 0 ) {
+ return "";
+ }
+ result = result.replaceAll( "([A-Z]+)([A-Z][a-z])", "$1_$2" );
+ result = result.replaceAll( "([a-z\\d])([A-Z])", "$1_$2" );
+ result = result.replace( '-', '_' );
+ if ( delimiterChars != null ) {
+ for ( char delimiterChar : delimiterChars ) {
+ result = result.replace( delimiterChar, '_' );
+ }
+ }
+ return result.toLowerCase();
+ }
+
+
+ /**
+ * Returns a copy of the input with the first character converted to uppercase and the remainder to lowercase.
+ *
+ * @param words the word to be capitalized
+ *
+ * @return the string with the first character capitalized and the remaining characters lowercased
+ */
+ public String capitalize( String words ) {
+ if ( words == null ) {
+ return null;
+ }
+ String result = words.trim();
+ if ( result.length() == 0 ) {
+ return "";
+ }
+ if ( result.length() == 1 ) {
+ return result.toUpperCase();
+ }
+ return "" + Character.toUpperCase( result.charAt( 0 ) ) + result.substring( 1 ).toLowerCase();
+ }
+
+
+ // ------------------------------------------------------------------------------------------------
+ // Management methods
+ // ------------------------------------------------------------------------------------------------
+
+
+ /**
+ * Determine whether the supplied word is considered uncountable by the {@link #pluralize(Object) pluralize} and
+ * {@link #singularize(Object) singularize} methods.
+ *
+ * @param word the word
+ *
+ * @return true if the plural and singular forms of the word are the same
+ */
+ public boolean isUncountable( String word ) {
+ if ( word == null ) {
+ return false;
+ }
+ String trimmedLower = word.trim().toLowerCase();
+ return uncountables.contains( trimmedLower );
+ }
+
+
+ /**
+ * Get the set of words that are not processed by the Inflector. The resulting map is directly modifiable.
+ *
+ * @return the set of uncountable words
+ */
+ public Set<String> getUncountables() {
+ return uncountables;
+ }
+
+
+ public void addPluralize( String rule, String replacement ) {
+ final Rule pluralizeRule = new Rule( rule, replacement );
+ plurals.addFirst( pluralizeRule );
+ }
+
+
+ public void addSingularize( String rule, String replacement ) {
+ final Rule singularizeRule = new Rule( rule, replacement );
+ singulars.addFirst( singularizeRule );
+ }
+
+
+ public void addIrregular( String singular, String plural ) {
+ if ( org.apache.commons.lang.StringUtils.isEmpty( singular ) ) {
+ throw new IllegalArgumentException( "singular rule may not be empty" );
+ }
+ if ( org.apache.commons.lang.StringUtils.isEmpty( plural ) ) {
+ throw new IllegalArgumentException( "plural rule may not be empty" );
+ }
+ String singularRemainder = singular.length() > 1 ? singular.substring( 1 ) : "";
+ String pluralRemainder = plural.length() > 1 ? plural.substring( 1 ) : "";
+ addPluralize( "(" + singular.charAt( 0 ) + ")" + singularRemainder + "$", "$1" + pluralRemainder );
+ addSingularize( "(" + plural.charAt( 0 ) + ")" + pluralRemainder + "$", "$1" + singularRemainder );
+ }
+
+
+ public void addUncountable( String... words ) {
+ if ( ( words == null ) || ( words.length == 0 ) ) {
+ return;
+ }
+ for ( String word : words ) {
+ if ( word != null ) {
+ uncountables.add( word.trim().toLowerCase() );
+ }
+ }
+ }
+
+
+ /**
+ * Utility method to replace all occurrences given by the specific backreference with its uppercased form, and
+ * remove all other backreferences. <p> The Java {@link Pattern regular expression processing} does not use the
+ * preprocessing directives <code>\l</code>, <code>\u</code>, <code>\L</code>, and <code>\U</code>. If so, such
+ * directives could be used in the replacement string to uppercase or lowercase the backreferences. For example,
+ * <code>\L1</code> would lowercase the first backreference, and <code>\u3</code> would uppercase the 3rd
+ * backreference. </p>
+ *
+ * @return the input string with the appropriate characters converted to upper-case
+ */
+ protected static String replaceAllWithUppercase( String input, String regex, int groupNumberToUppercase ) {
+ Pattern underscoreAndDotPattern = Pattern.compile( regex );
+ Matcher matcher = underscoreAndDotPattern.matcher( input );
+ StringBuffer sb = new StringBuffer();
+ while ( matcher.find() ) {
+ matcher.appendReplacement( sb, matcher.group( groupNumberToUppercase ).toUpperCase() );
+ }
+ matcher.appendTail( sb );
+ return sb.toString();
+ }
+
+
+ /** Completely remove all rules within this inflector. */
+ public void clear() {
+ uncountables.clear();
+ plurals.clear();
+ singulars.clear();
+ }
+
+
+ protected void initialize() {
+ Inflector inflect = this;
+ inflect.addPluralize( "$", "s" );
+ inflect.addPluralize( "s$", "s" );
+ inflect.addPluralize( "(ax|test)is$", "$1es" );
+ inflect.addPluralize( "(octop|vir)us$", "$1i" );
+ inflect.addPluralize( "(octop|vir)i$", "$1i" ); // already plural
+ inflect.addPluralize( "(alias|status)$", "$1es" );
+ inflect.addPluralize( "(bu)s$", "$1ses" );
+ inflect.addPluralize( "(buffal|tomat)o$", "$1oes" );
+ inflect.addPluralize( "([ti])um$", "$1a" );
+ inflect.addPluralize( "([ti])a$", "$1a" ); // already plural
+ inflect.addPluralize( "sis$", "ses" );
+ inflect.addPluralize( "(?:([^f])fe|([lr])f)$", "$1$2ves" );
+ inflect.addPluralize( "(hive)$", "$1s" );
+ inflect.addPluralize( "([^aeiouy]|qu)y$", "$1ies" );
+ inflect.addPluralize( "(x|ch|ss|sh)$", "$1es" );
+ inflect.addPluralize( "(matr|vert|ind)ix|ex$", "$1ices" );
+ inflect.addPluralize( "([m|l])ouse$", "$1ice" );
+ inflect.addPluralize( "([m|l])ice$", "$1ice" );
+ inflect.addPluralize( "^(ox)$", "$1en" );
+ inflect.addPluralize( "(quiz)$", "$1zes" );
+ // Need to check for the following words that are already pluralized:
+ inflect.addPluralize( "(people|men|children|sexes|moves|stadiums)$", "$1" ); // irregulars
+ inflect.addPluralize( "(oxen|octopi|viri|aliases|quizzes)$", "$1" ); // special
+ // rules
+
+ inflect.addSingularize( "s$", "" );
+ inflect.addSingularize( "(s|si|u)s$", "$1s" ); // '-us' and '-ss' are
+ // already singular
+ inflect.addSingularize( "(n)ews$", "$1ews" );
+ inflect.addSingularize( "([ti])a$", "$1um" );
+ inflect.addSingularize( "((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$", "$1$2sis" );
+ inflect.addSingularize( "(^analy)ses$", "$1sis" );
+ inflect.addSingularize( "(^analy)sis$", "$1sis" ); // already singular,
+ // but ends in 's'
+ inflect.addSingularize( "([^f])ves$", "$1fe" );
+ inflect.addSingularize( "(hive)s$", "$1" );
+ inflect.addSingularize( "(tive)s$", "$1" );
+ inflect.addSingularize( "([lr])ves$", "$1f" );
+ inflect.addSingularize( "([^aeiouy]|qu)ies$", "$1y" );
+ inflect.addSingularize( "(s)eries$", "$1eries" );
+ inflect.addSingularize( "(m)ovies$", "$1ovie" );
+ inflect.addSingularize( "(x|ch|ss|sh)es$", "$1" );
+ inflect.addSingularize( "([m|l])ice$", "$1ouse" );
+ inflect.addSingularize( "(bus)es$", "$1" );
+ inflect.addSingularize( "(o)es$", "$1" );
+ inflect.addSingularize( "(shoe)s$", "$1" );
+ inflect.addSingularize( "(cris|ax|test)is$", "$1is" ); // already
+ // singular, but
+ // ends in 's'
+ inflect.addSingularize( "(cris|ax|test)es$", "$1is" );
+ inflect.addSingularize( "(octop|vir)i$", "$1us" );
+ inflect.addSingularize( "(octop|vir)us$", "$1us" ); // already singular,
+ // but ends in 's'
+ inflect.addSingularize( "(alias|status)es$", "$1" );
+ inflect.addSingularize( "(alias|status)$", "$1" ); // already singular,
+ // but ends in 's'
+ inflect.addSingularize( "^(ox)en", "$1" );
+ inflect.addSingularize( "(vert|ind)ices$", "$1ex" );
+ inflect.addSingularize( "(matr)ices$", "$1ix" );
+ inflect.addSingularize( "(quiz)zes$", "$1" );
+
+ inflect.addIrregular( "person", "people" );
+ inflect.addIrregular( "man", "men" );
+ inflect.addIrregular( "child", "children" );
+ inflect.addIrregular( "sex", "sexes" );
+ inflect.addIrregular( "move", "moves" );
+ inflect.addIrregular( "stadium", "stadiums" );
+
+ inflect.addUncountable( "equipment", "information", "rice", "money", "species", "series", "fish", "sheep",
+ "data", "analytics" );
+ }
+}
[03/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/resources/sample-small.json
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/sample-small.json b/stack/corepersistence/queryindex/src/test/resources/sample-small.json
new file mode 100644
index 0000000..91f336c
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/resources/sample-small.json
@@ -0,0 +1,222 @@
+[
+ {
+ "id": 0,
+ "guid": "41a6482a-f8d5-4b28-a2f1-90b110b25167",
+ "isActive": false,
+ "balance": "$1,600.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 33,
+ "name": "Molly Fitzpatrick",
+ "gender": "female",
+ "company": "Geologix",
+ "contact": {
+ "email": "mollyfitzpatrick@geologix.com",
+ "phone": "+1 (968) 560-2206",
+ "address": "895 Karweg Place, Lookingglass, Utah, 1989"
+ },
+ "about": "Eu nisi Lorem ad exercitation enim cupidatat culpa consectetur voluptate fugiat pariatur. Irure reprehenderit est quis aliquip fugiat enim. Elit ex qui cupidatat velit nisi cillum sunt dolor eu aute duis et. Culpa anim proident veniam occaecat eiusmod non adipisicing consequat fugiat eu irure laborum. Ea est sint deserunt laboris. Enim pariatur in ut magna ipsum fugiat ullamco dolor est voluptate veniam velit.\r\n",
+ "registered": "2013-02-02T16:18:24 +05:00",
+ "latitude": 10.237003,
+ "longitude": -86.677799,
+ "tags": [
+ "sint",
+ "laboris",
+ "laboris",
+ "enim",
+ "irure",
+ "dolore",
+ "non"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Concepcion Michael"
+ },
+ {
+ "id": 1,
+ "name": "Harris Mcdonald"
+ },
+ {
+ "id": 2,
+ "name": "Marshall Cote"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 1,
+ "guid": "13158ddc-c6fe-4dc6-84ad-1a20b2bc8494",
+ "isActive": false,
+ "balance": "$3,898.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 40,
+ "name": "Tami Mccullough",
+ "gender": "female",
+ "company": "Eventex",
+ "contact": {
+ "email": "tamimccullough@eventex.com",
+ "phone": "+1 (875) 421-2839",
+ "address": "367 Orange Street, Wright, Michigan, 913"
+ },
+ "about": "Occaecat Lorem dolore in consectetur enim Lorem minim. Do eu aliqua aliquip consequat adipisicing Lorem qui reprehenderit do nisi nisi incididunt velit consequat. Aliqua anim dolor est cillum dolore et ullamco. Adipisicing dolore sunt sunt tempor nisi.\r\n",
+ "registered": "2013-06-10T03:06:40 +04:00",
+ "latitude": -38.108123,
+ "longitude": -128.352006,
+ "tags": [
+ "ipsum",
+ "magna",
+ "eu",
+ "anim",
+ "magna",
+ "nisi",
+ "nisi"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Elva Whitfield"
+ },
+ {
+ "id": 1,
+ "name": "King Waters"
+ },
+ {
+ "id": 2,
+ "name": "Sandra Rodriguez"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 2,
+ "guid": "cc4541b1-d8e3-4f2d-924f-ad1f78ca994a",
+ "isActive": false,
+ "balance": "$1,715.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 34,
+ "name": "Tina Dudley",
+ "gender": "female",
+ "company": "Reversus",
+ "contact": {
+ "email": "tinadudley@reversus.com",
+ "phone": "+1 (873) 549-2696",
+ "address": "772 Arion Place, Tibbie, Virginia, 8573"
+ },
+ "about": "Do laboris fugiat qui est mollit aliqua esse non duis ex non eiusmod consequat. Tempor eu et voluptate adipisicing. Nostrud veniam laborum officia eiusmod esse commodo culpa. Officia cupidatat officia consequat laboris duis cillum fugiat nostrud in.\r\n",
+ "registered": "1998-04-01T23:20:58 +05:00",
+ "latitude": 0.298655,
+ "longitude": -91.268836,
+ "tags": [
+ "enim",
+ "ut",
+ "elit",
+ "officia",
+ "ut",
+ "nostrud",
+ "ullamco"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Haney Spears"
+ },
+ {
+ "id": 1,
+ "name": "Erna Trevino"
+ },
+ {
+ "id": 2,
+ "name": "Trisha Vaughan"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 3,
+ "guid": "2bb6de28-5d2d-4cf6-bde0-b3cf60bf6bb3",
+ "isActive": true,
+ "balance": "$2,016.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 23,
+ "name": "Norman Hester",
+ "gender": "male",
+ "company": "Playce",
+ "contact": {
+ "email": "normanhester@playce.com",
+ "phone": "+1 (856) 431-2945",
+ "address": "406 Minna Street, Glenville, Connecticut, 3785"
+ },
+ "about": "Qui labore nostrud id occaecat culpa irure ad. Dolore non laborum occaecat occaecat ad sunt amet officia nisi in ullamco est officia. Lorem officia pariatur sit aute ea incididunt do. Consectetur id ad id mollit amet cupidatat dolor consectetur ipsum aute amet do. Reprehenderit consectetur amet esse fugiat et exercitation eiusmod. Labore nostrud sit quis sit qui id. Culpa pariatur aliquip sint magna irure occaecat officia magna sit proident pariatur.\r\n",
+ "registered": "1988-08-11T12:52:13 +04:00",
+ "latitude": -21.888779,
+ "longitude": 65.493829,
+ "tags": [
+ "Lorem",
+ "officia",
+ "nostrud",
+ "eu",
+ "do",
+ "eu",
+ "duis"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Georgina Hess"
+ },
+ {
+ "id": 1,
+ "name": "Parsons Wilson"
+ },
+ {
+ "id": 2,
+ "name": "Harmon Wise"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 4,
+ "guid": "32fedc30-8e37-4b65-abb3-8faa829f4ad3",
+ "isActive": true,
+ "balance": "$2,642.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 33,
+ "name": "Orr Byers",
+ "gender": "male",
+ "company": "Bittor",
+ "contact": {
+ "email": "orrbyers@bittor.com",
+ "phone": "+1 (997) 569-2415",
+ "address": "730 Lloyd Street, Marshall, Vermont, 3170"
+ },
+ "about": "Lorem culpa adipisicing consequat eu incididunt ullamco sunt id est. Aliquip labore ex sit culpa aliqua ex occaecat aliquip voluptate non labore culpa irure. Consequat tempor consequat laboris sint nulla commodo sit. Est velit dolor ut quis veniam aliqua amet dolore mollit labore. Magna commodo deserunt anim est velit laboris. Commodo sunt sit qui eu mollit eu esse excepteur ea sit incididunt.\r\n",
+ "registered": "1996-08-30T07:13:22 +04:00",
+ "latitude": 76.747258,
+ "longitude": -114.875056,
+ "tags": [
+ "ut",
+ "esse",
+ "reprehenderit",
+ "aute",
+ "laborum",
+ "esse",
+ "dolore"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Spencer Hurley"
+ },
+ {
+ "id": 1,
+ "name": "Adrienne Griffith"
+ },
+ {
+ "id": 2,
+ "name": "Peck Haley"
+ }
+ ],
+ "randomArrayItem": "apple"
+ }
+]
[14/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/test/resources/sample-large.json
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/test/resources/sample-large.json b/stack/corepersistence/index/src/test/resources/sample-large.json
deleted file mode 100644
index 92a7f5b..0000000
--- a/stack/corepersistence/index/src/test/resources/sample-large.json
+++ /dev/null
@@ -1,39603 +0,0 @@
-[
- {
- "id": 0,
- "guid": "600f35b5-e667-4ed1-a81b-fd8dcfbbdf0a",
- "isActive": false,
- "balance": "$1,901.00",
- "picture": "http://placehold.it/32x32",
- "age": 28,
- "name": "Bowers Oneil",
- "gender": "male",
- "company": "Senmao",
- "contact": {
- "email": "bowersoneil@senmao.com",
- "phone": "+1 (984) 481-3664",
- "address": "710 Fenimore Street, Aurora, Ohio, 9091"
- },
- "about": "Incididunt eiusmod aliquip in excepteur amet minim. Sit ad laboris reprehenderit laboris eu do ut culpa magna voluptate irure dolor. Ut ullamco deserunt do non aute minim. Incididunt excepteur voluptate excepteur consequat sit ullamco excepteur labore.\r\n",
- "registered": "1996-04-29T17:53:23 +04:00",
- "latitude": -80.49615,
- "longitude": 173.847337,
- "tags": [
- "id",
- "labore",
- "exercitation",
- "dolore",
- "et",
- "culpa",
- "eu"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Shari Hahn"
- },
- {
- "id": 1,
- "name": "Wendy Moody"
- },
- {
- "id": 2,
- "name": "Mercado Jenkins"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 1,
- "guid": "b7640d31-08a5-4c89-b2d4-2a61f7abcdf2",
- "isActive": false,
- "balance": "$1,898.00",
- "picture": "http://placehold.it/32x32",
- "age": 29,
- "name": "Valencia Mercado",
- "gender": "male",
- "company": "Surelogic",
- "contact": {
- "email": "valenciamercado@surelogic.com",
- "phone": "+1 (909) 578-3391",
- "address": "186 Highlawn Avenue, Forestburg, Montana, 2981"
- },
- "about": "Ipsum ut dolore aute do enim nostrud ad nisi non consectetur Lorem. Nostrud ex culpa commodo ad culpa sit esse consequat id. Commodo adipisicing in ut do non cillum nostrud mollit. Excepteur ipsum veniam consectetur labore magna est veniam esse. Occaecat consectetur do Lorem eiusmod laborum eiusmod. Pariatur culpa eiusmod nisi officia incididunt id.\r\n",
- "registered": "2008-09-12T22:19:23 +04:00",
- "latitude": -35.821567,
- "longitude": -153.267477,
- "tags": [
- "enim",
- "consectetur",
- "velit",
- "amet",
- "id",
- "nostrud",
- "qui"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Romero Ayers"
- },
- {
- "id": 1,
- "name": "Downs Hampton"
- },
- {
- "id": 2,
- "name": "Humphrey Henry"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 2,
- "guid": "f22b9da2-911d-447b-aa77-741a639e6039",
- "isActive": true,
- "balance": "$2,222.00",
- "picture": "http://placehold.it/32x32",
- "age": 29,
- "name": "Morgan Pierce",
- "gender": "female",
- "company": "Goko",
- "contact": {
- "email": "morganpierce@goko.com",
- "phone": "+1 (815) 565-2747",
- "address": "546 Hull Street, Loveland, Oregon, 7021"
- },
- "about": "Tempor amet cillum ea reprehenderit elit Lorem nisi do voluptate. Anim deserunt officia deserunt adipisicing ut et irure exercitation consectetur. Culpa sit elit exercitation ullamco velit ipsum incididunt. Ex aliquip do reprehenderit non ullamco exercitation non qui incididunt ea laboris. Elit occaecat nisi cupidatat elit qui nostrud in culpa dolore incididunt aute minim. Cillum magna nulla ex culpa aliqua enim eu mollit fugiat commodo excepteur qui officia. Mollit ea laborum magna amet irure eiusmod adipisicing.\r\n",
- "registered": "1999-11-19T21:04:45 +05:00",
- "latitude": 53.856352,
- "longitude": -26.088146,
- "tags": [
- "pariatur",
- "aliqua",
- "elit",
- "elit",
- "aute",
- "tempor",
- "laborum"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Patrica Pitts"
- },
- {
- "id": 1,
- "name": "Manning Torres"
- },
- {
- "id": 2,
- "name": "Salinas Landry"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 3,
- "guid": "905daf9b-b784-40e3-8f10-226abc2608ff",
- "isActive": false,
- "balance": "$1,103.00",
- "picture": "http://placehold.it/32x32",
- "age": 40,
- "name": "Kaye Baxter",
- "gender": "female",
- "company": "Biohab",
- "contact": {
- "email": "kayebaxter@biohab.com",
- "phone": "+1 (970) 460-2370",
- "address": "235 Poplar Street, Vaughn, Colorado, 365"
- },
- "about": "Proident minim velit mollit dolore dolore deserunt proident dolor cupidatat. Dolor aute culpa minim consequat laboris sit sit. Do deserunt enim consectetur deserunt velit Lorem dolore aute. Ut ad reprehenderit mollit sit pariatur qui sunt officia elit ex. Ex magna et officia nisi pariatur dolore cupidatat qui exercitation tempor. Consequat nisi minim non mollit Lorem.\r\n",
- "registered": "2003-01-16T08:17:37 +05:00",
- "latitude": 32.346743,
- "longitude": -118.107511,
- "tags": [
- "commodo",
- "adipisicing",
- "sunt",
- "do",
- "proident",
- "elit",
- "tempor"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Herman Atkinson"
- },
- {
- "id": 1,
- "name": "Naomi Harris"
- },
- {
- "id": 2,
- "name": "Bolton Sims"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 4,
- "guid": "6c31a8cf-c84a-41cc-b545-c0357c9c78cc",
- "isActive": false,
- "balance": "$1,025.00",
- "picture": "http://placehold.it/32x32",
- "age": 21,
- "name": "Lilia Kerr",
- "gender": "female",
- "company": "Proflex",
- "contact": {
- "email": "liliakerr@proflex.com",
- "phone": "+1 (813) 453-3357",
- "address": "552 Classon Avenue, Elfrida, Mississippi, 7261"
- },
- "about": "Esse eiusmod do in culpa qui commodo anim culpa elit. In incididunt consequat ad ipsum magna ullamco laborum. Elit pariatur occaecat deserunt ipsum culpa voluptate quis id eiusmod commodo. Excepteur cupidatat est qui culpa veniam dolor consectetur non laborum occaecat nostrud.\r\n",
- "registered": "1999-01-31T08:39:10 +05:00",
- "latitude": -14.813962,
- "longitude": -63.82928,
- "tags": [
- "laborum",
- "ea",
- "anim",
- "tempor",
- "aute",
- "tempor",
- "qui"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Carmela Burnett"
- },
- {
- "id": 1,
- "name": "Walter Savage"
- },
- {
- "id": 2,
- "name": "Erika Leblanc"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 5,
- "guid": "5a41803f-ffee-48d0-9754-dd21c546fea8",
- "isActive": false,
- "balance": "$1,497.00",
- "picture": "http://placehold.it/32x32",
- "age": 26,
- "name": "Ellen Smith",
- "gender": "female",
- "company": "Rubadub",
- "contact": {
- "email": "ellensmith@rubadub.com",
- "phone": "+1 (935) 564-3809",
- "address": "684 Norfolk Street, Urie, South Dakota, 8242"
- },
- "about": "Nostrud nulla incididunt aliqua non voluptate ipsum veniam. Culpa aute ipsum aliquip ad do labore esse labore fugiat ad qui. Adipisicing pariatur ut elit aliqua ea voluptate cillum non fugiat nulla consectetur cillum cupidatat magna.\r\n",
- "registered": "1989-12-31T01:17:41 +05:00",
- "latitude": -32.889744,
- "longitude": -18.163195,
- "tags": [
- "esse",
- "pariatur",
- "elit",
- "ad",
- "proident",
- "minim",
- "officia"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Frazier Wolfe"
- },
- {
- "id": 1,
- "name": "Hillary Deleon"
- },
- {
- "id": 2,
- "name": "Strong Hancock"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 6,
- "guid": "75bb1390-ad85-40ac-874c-e65f7b736ce7",
- "isActive": true,
- "balance": "$2,977.00",
- "picture": "http://placehold.it/32x32",
- "age": 39,
- "name": "Valeria Carney",
- "gender": "female",
- "company": "Webiotic",
- "contact": {
- "email": "valeriacarney@webiotic.com",
- "phone": "+1 (914) 494-3912",
- "address": "836 Whitty Lane, Lavalette, Minnesota, 6503"
- },
- "about": "Et eiusmod sit incididunt quis occaecat occaecat irure duis incididunt dolore quis. Nostrud aliquip consectetur fugiat et. Id do magna nisi esse occaecat ut excepteur magna laboris exercitation. Laboris ullamco aliquip aute sit. Cupidatat velit nulla aliqua fugiat culpa in. Veniam velit aliquip elit labore mollit Lorem labore aliquip.\r\n",
- "registered": "2007-09-29T03:51:38 +04:00",
- "latitude": 52.678155,
- "longitude": -41.807612,
- "tags": [
- "labore",
- "veniam",
- "in",
- "consequat",
- "cillum",
- "cillum",
- "enim"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Potts Santana"
- },
- {
- "id": 1,
- "name": "Ramirez Everett"
- },
- {
- "id": 2,
- "name": "Rasmussen Harrington"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 7,
- "guid": "6a870e4a-5550-447c-9615-6d059b2e0b47",
- "isActive": true,
- "balance": "$1,681.00",
- "picture": "http://placehold.it/32x32",
- "age": 30,
- "name": "Krystal Mullins",
- "gender": "female",
- "company": "Bitendrex",
- "contact": {
- "email": "krystalmullins@bitendrex.com",
- "phone": "+1 (824) 530-3509",
- "address": "782 Lott Place, Maury, Iowa, 2176"
- },
- "about": "Anim deserunt elit et ut officia sint aliqua exercitation proident sunt dolore occaecat. Sint ullamco velit magna consequat cupidatat ipsum cupidatat reprehenderit ut nostrud. Veniam ullamco proident ad id qui qui enim occaecat. Laboris in veniam deserunt dolore culpa est elit. Incididunt anim proident est esse occaecat. Exercitation non ipsum eu adipisicing do commodo consequat officia eiusmod. Labore tempor ullamco consequat velit.\r\n",
- "registered": "2003-01-13T20:07:46 +05:00",
- "latitude": -8.896934,
- "longitude": 11.939986,
- "tags": [
- "ut",
- "labore",
- "consectetur",
- "anim",
- "incididunt",
- "ut",
- "esse"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Gallagher Case"
- },
- {
- "id": 1,
- "name": "Morin Fry"
- },
- {
- "id": 2,
- "name": "Autumn Nixon"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 8,
- "guid": "85599684-8ec5-448f-83f4-3ccdd7bbd472",
- "isActive": true,
- "balance": "$2,611.00",
- "picture": "http://placehold.it/32x32",
- "age": 22,
- "name": "Ernestine Coffey",
- "gender": "female",
- "company": "Affluex",
- "contact": {
- "email": "ernestinecoffey@affluex.com",
- "phone": "+1 (850) 494-2124",
- "address": "990 Lawrence Street, Valle, Indiana, 7846"
- },
- "about": "Ipsum non cupidatat qui non labore nisi sit elit labore esse. Qui laborum laborum est Lorem quis et consectetur laboris. Aliqua sint do ea quis id velit consequat ad aute ad nostrud nulla tempor. Consequat consequat laboris nulla dolor.\r\n",
- "registered": "2001-02-21T07:05:41 +05:00",
- "latitude": 82.217467,
- "longitude": 27.389067,
- "tags": [
- "excepteur",
- "cupidatat",
- "commodo",
- "nostrud",
- "aute",
- "officia",
- "et"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Gentry Hickman"
- },
- {
- "id": 1,
- "name": "Berger Grant"
- },
- {
- "id": 2,
- "name": "Mcclain Owens"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 9,
- "guid": "e377f195-58c7-46d1-b9ff-28fd0391e222",
- "isActive": true,
- "balance": "$3,498.00",
- "picture": "http://placehold.it/32x32",
- "age": 40,
- "name": "Minerva Harrell",
- "gender": "female",
- "company": "Isis",
- "contact": {
- "email": "minervaharrell@isis.com",
- "phone": "+1 (846) 498-2864",
- "address": "843 Bath Avenue, Sanders, Alabama, 7969"
- },
- "about": "Cupidatat est elit fugiat eu non Lorem ea sunt eu Lorem. Lorem elit commodo pariatur labore velit cillum id officia anim aliquip. Proident sunt consectetur laborum ullamco nisi excepteur sit laborum. Id cillum nulla esse eiusmod non exercitation deserunt incididunt eu cupidatat sit proident labore. Do dolor culpa sunt esse esse voluptate minim eiusmod in deserunt incididunt.\r\n",
- "registered": "1994-06-05T10:31:45 +04:00",
- "latitude": 47.3984,
- "longitude": -81.830573,
- "tags": [
- "aliquip",
- "voluptate",
- "nostrud",
- "ullamco",
- "deserunt",
- "quis",
- "qui"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Boyle Davis"
- },
- {
- "id": 1,
- "name": "Cassandra Morales"
- },
- {
- "id": 2,
- "name": "Jolene Olson"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 10,
- "guid": "be892c50-2a93-4704-9e47-510ae151f104",
- "isActive": true,
- "balance": "$2,605.00",
- "picture": "http://placehold.it/32x32",
- "age": 29,
- "name": "Farmer Ryan",
- "gender": "male",
- "company": "Blurrybus",
- "contact": {
- "email": "farmerryan@blurrybus.com",
- "phone": "+1 (833) 517-3399",
- "address": "958 Bartlett Street, Grahamtown, Arkansas, 2037"
- },
- "about": "Est eu sint cillum eiusmod et non ullamco. Fugiat cillum qui consectetur consequat sit. Officia non ad qui qui qui in Lorem veniam sunt sunt adipisicing sit minim ut. Magna voluptate dolor eu aute.\r\n",
- "registered": "2011-10-22T18:04:13 +04:00",
- "latitude": -65.443981,
- "longitude": 107.936664,
- "tags": [
- "magna",
- "in",
- "et",
- "sint",
- "reprehenderit",
- "ut",
- "consequat"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Lena Macdonald"
- },
- {
- "id": 1,
- "name": "Duke Turner"
- },
- {
- "id": 2,
- "name": "Macdonald Galloway"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 11,
- "guid": "cf39ae8e-d968-48cb-b938-7c8ea7a389b8",
- "isActive": false,
- "balance": "$3,644.00",
- "picture": "http://placehold.it/32x32",
- "age": 35,
- "name": "Hunt Talley",
- "gender": "male",
- "company": "Indexia",
- "contact": {
- "email": "hunttalley@indexia.com",
- "phone": "+1 (893) 564-3122",
- "address": "843 Newkirk Avenue, Nogal, Wyoming, 945"
- },
- "about": "Voluptate nulla ex minim excepteur exercitation ullamco sunt et minim velit veniam tempor. Magna ad ipsum proident sint irure cillum non. Quis occaecat occaecat nisi aute amet labore consectetur adipisicing deserunt nisi adipisicing voluptate. Aliquip officia dolore enim cillum. Voluptate enim veniam est in dolore magna cillum laboris culpa ullamco ea laborum duis.\r\n",
- "registered": "1994-10-09T21:24:35 +04:00",
- "latitude": 10.548535,
- "longitude": -33.365903,
- "tags": [
- "dolore",
- "eiusmod",
- "officia",
- "elit",
- "consectetur",
- "mollit",
- "laboris"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Mable Gilmore"
- },
- {
- "id": 1,
- "name": "Corinne Carlson"
- },
- {
- "id": 2,
- "name": "Elnora Fuller"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 12,
- "guid": "60dbe3c9-cda1-49af-8b88-a2e61111d5af",
- "isActive": true,
- "balance": "$3,306.00",
- "picture": "http://placehold.it/32x32",
- "age": 30,
- "name": "Brooks Schultz",
- "gender": "male",
- "company": "Neteria",
- "contact": {
- "email": "brooksschultz@neteria.com",
- "phone": "+1 (956) 490-2421",
- "address": "234 Clarendon Road, Fairlee, Oklahoma, 4204"
- },
- "about": "Excepteur ea culpa in esse deserunt laboris voluptate nostrud nulla occaecat proident non occaecat occaecat. Duis nostrud sint magna ex adipisicing eu consequat deserunt tempor mollit. Sint in adipisicing proident quis reprehenderit elit tempor tempor. Exercitation ullamco ea culpa nisi. Minim reprehenderit nulla voluptate laboris eu sint ullamco proident non excepteur aute laborum sunt eu. Aliqua laboris dolor mollit sit sunt anim mollit nisi est mollit nostrud ex. Ea enim ea pariatur duis sunt velit et mollit laboris et.\r\n",
- "registered": "1997-12-23T13:36:36 +05:00",
- "latitude": 25.211469,
- "longitude": -100.269514,
- "tags": [
- "laborum",
- "commodo",
- "labore",
- "sunt",
- "aliqua",
- "est",
- "proident"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Daugherty Hatfield"
- },
- {
- "id": 1,
- "name": "Corrine Benson"
- },
- {
- "id": 2,
- "name": "Quinn Woodard"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 13,
- "guid": "489d3048-cda9-4deb-b450-e3e4d2601eb7",
- "isActive": false,
- "balance": "$2,920.00",
- "picture": "http://placehold.it/32x32",
- "age": 21,
- "name": "Mcpherson Miller",
- "gender": "male",
- "company": "Austech",
- "contact": {
- "email": "mcphersonmiller@austech.com",
- "phone": "+1 (846) 556-2757",
- "address": "123 Coffey Street, Riceville, Wisconsin, 9194"
- },
- "about": "Laboris ex sit velit tempor irure nisi ex incididunt laboris sit sint cillum. Labore dolore magna aliqua irure commodo eiusmod fugiat aute deserunt culpa sint aute dolor. Quis commodo ipsum ad Lorem elit eiusmod exercitation. Cupidatat sint duis consectetur mollit consequat qui consequat qui nisi sunt in. Mollit fugiat nulla aliqua qui. Consequat in anim cupidatat veniam cupidatat mollit do veniam occaecat. Consequat consectetur irure do esse exercitation ipsum adipisicing velit nostrud cupidatat voluptate.\r\n",
- "registered": "1997-04-13T04:16:08 +04:00",
- "latitude": -51.433761,
- "longitude": -97.834664,
- "tags": [
- "id",
- "velit",
- "labore",
- "commodo",
- "Lorem",
- "excepteur",
- "dolore"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Moran Wagner"
- },
- {
- "id": 1,
- "name": "Nielsen Koch"
- },
- {
- "id": 2,
- "name": "Lloyd Kirkland"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 14,
- "guid": "227d8254-6f18-4853-baf7-df0ead387e88",
- "isActive": true,
- "balance": "$2,774.00",
- "picture": "http://placehold.it/32x32",
- "age": 35,
- "name": "Wolfe Flowers",
- "gender": "male",
- "company": "Insurety",
- "contact": {
- "email": "wolfeflowers@insurety.com",
- "phone": "+1 (964) 435-2634",
- "address": "864 River Street, Longoria, New Jersey, 1200"
- },
- "about": "Sunt esse et ullamco minim pariatur nostrud consectetur occaecat. Ex quis elit aliqua ad. Officia ex et incididunt sit ex aliqua consectetur. Enim dolor nostrud laboris non eu Lorem excepteur tempor et mollit nulla incididunt commodo. Amet ad amet cillum laborum commodo fugiat ullamco magna. Consequat adipisicing ad voluptate ex. In incididunt eiusmod aliquip do voluptate amet esse aliqua do.\r\n",
- "registered": "1996-08-16T15:42:00 +04:00",
- "latitude": -21.688903,
- "longitude": 148.466884,
- "tags": [
- "eu",
- "dolor",
- "veniam",
- "fugiat",
- "est",
- "exercitation",
- "proident"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Peck Richards"
- },
- {
- "id": 1,
- "name": "Sharlene Meadows"
- },
- {
- "id": 2,
- "name": "Carver Mcintosh"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 15,
- "guid": "4288f9ca-b125-44c4-95ae-b1597b8d4551",
- "isActive": false,
- "balance": "$1,882.00",
- "picture": "http://placehold.it/32x32",
- "age": 38,
- "name": "Stevenson Cantrell",
- "gender": "male",
- "company": "Microluxe",
- "contact": {
- "email": "stevensoncantrell@microluxe.com",
- "phone": "+1 (813) 418-3174",
- "address": "288 Dahl Court, Chemung, Delaware, 3094"
- },
- "about": "Duis ea anim eu mollit proident dolor in occaecat anim. Dolor ullamco proident et dolor irure ad irure quis. Et exercitation minim reprehenderit aute in ullamco anim. Eu eiusmod sit do eiusmod labore eu commodo sit voluptate nostrud incididunt.\r\n",
- "registered": "1988-04-20T03:06:14 +04:00",
- "latitude": -59.191735,
- "longitude": -100.131586,
- "tags": [
- "incididunt",
- "fugiat",
- "culpa",
- "qui",
- "amet",
- "cupidatat",
- "cillum"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Rosanna Petty"
- },
- {
- "id": 1,
- "name": "Ada Bowman"
- },
- {
- "id": 2,
- "name": "Powell Salinas"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 16,
- "guid": "dfe2bc46-bc31-451b-a819-0033d886230a",
- "isActive": false,
- "balance": "$3,174.00",
- "picture": "http://placehold.it/32x32",
- "age": 24,
- "name": "Pitts Zamora",
- "gender": "male",
- "company": "Buzzworks",
- "contact": {
- "email": "pittszamora@buzzworks.com",
- "phone": "+1 (913) 434-3152",
- "address": "945 Summit Street, Alamo, North Dakota, 8966"
- },
- "about": "Reprehenderit esse qui aute incididunt et Lorem do non. Nostrud nostrud irure commodo aliqua occaecat labore sunt duis proident dolore. Magna quis mollit anim veniam velit. Minim esse sunt occaecat quis id reprehenderit occaecat. Anim eu reprehenderit esse culpa quis irure reprehenderit excepteur ad cillum reprehenderit. Dolor non laborum cillum amet aliqua proident esse tempor id amet pariatur nulla.\r\n",
- "registered": "1992-03-09T10:09:07 +05:00",
- "latitude": -86.481599,
- "longitude": -151.688114,
- "tags": [
- "esse",
- "dolore",
- "laborum",
- "Lorem",
- "laborum",
- "consequat",
- "deserunt"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Mooney Jarvis"
- },
- {
- "id": 1,
- "name": "Clemons Green"
- },
- {
- "id": 2,
- "name": "Chaney Herman"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 17,
- "guid": "72e1a2a7-0e23-4cae-9881-653fa234887c",
- "isActive": true,
- "balance": "$3,829.00",
- "picture": "http://placehold.it/32x32",
- "age": 36,
- "name": "Campos Griffith",
- "gender": "male",
- "company": "Calcu",
- "contact": {
- "email": "camposgriffith@calcu.com",
- "phone": "+1 (905) 533-3909",
- "address": "190 Jewel Street, Dundee, Idaho, 2403"
- },
- "about": "Aute exercitation incididunt cillum laboris proident Lorem. Aliquip aliqua eu labore aute voluptate cupidatat. Aliquip occaecat cupidatat ex elit anim labore consectetur fugiat cillum non voluptate et aliqua eu.\r\n",
- "registered": "1990-02-10T00:20:56 +05:00",
- "latitude": 44.283897,
- "longitude": -0.181837,
- "tags": [
- "non",
- "id",
- "nisi",
- "elit",
- "magna",
- "Lorem",
- "elit"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Lynnette Bond"
- },
- {
- "id": 1,
- "name": "Little Park"
- },
- {
- "id": 2,
- "name": "Perkins Boyer"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 18,
- "guid": "8e406e86-b4f3-49f6-80a0-f4abe9fb7c6a",
- "isActive": true,
- "balance": "$3,092.00",
- "picture": "http://placehold.it/32x32",
- "age": 23,
- "name": "Wendi Rasmussen",
- "gender": "female",
- "company": "Boink",
- "contact": {
- "email": "wendirasmussen@boink.com",
- "phone": "+1 (978) 556-3648",
- "address": "334 Lincoln Avenue, Carrsville, West Virginia, 9220"
- },
- "about": "Dolore elit commodo est ad culpa tempor amet cupidatat proident occaecat. Culpa elit cupidatat ut reprehenderit nulla et commodo id dolor. Enim in do occaecat proident cupidatat non minim occaecat irure ullamco incididunt eu aliqua. Esse voluptate eu velit laboris aute proident ad sit minim labore in adipisicing aliquip.\r\n",
- "registered": "1993-02-04T23:45:02 +05:00",
- "latitude": 58.838578,
- "longitude": -3.544895,
- "tags": [
- "incididunt",
- "consectetur",
- "ex",
- "reprehenderit",
- "eiusmod",
- "officia",
- "deserunt"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Patrice Powers"
- },
- {
- "id": 1,
- "name": "Daphne Bentley"
- },
- {
- "id": 2,
- "name": "Jennie Molina"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 19,
- "guid": "7784b16e-6e82-40fd-a6f5-3af605247d84",
- "isActive": false,
- "balance": "$1,124.00",
- "picture": "http://placehold.it/32x32",
- "age": 26,
- "name": "Nadia Brown",
- "gender": "female",
- "company": "Concility",
- "contact": {
- "email": "nadiabrown@concility.com",
- "phone": "+1 (958) 450-2930",
- "address": "225 Senator Street, Cotopaxi, Illinois, 2787"
- },
- "about": "Dolore nisi ex exercitation aliquip. Pariatur sint enim velit occaecat exercitation velit reprehenderit. Tempor aliquip amet minim quis occaecat commodo ipsum dolore. Duis ex dolor proident ad exercitation duis amet excepteur laboris aliquip. Duis laboris sint eu ut qui proident sit excepteur ullamco duis ullamco qui.\r\n",
- "registered": "1995-10-11T03:29:07 +04:00",
- "latitude": 1.539632,
- "longitude": -74.138453,
- "tags": [
- "commodo",
- "enim",
- "laborum",
- "elit",
- "sint",
- "voluptate",
- "adipisicing"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Carmen Estrada"
- },
- {
- "id": 1,
- "name": "Conrad Morton"
- },
- {
- "id": 2,
- "name": "Moss Patrick"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 20,
- "guid": "7f02bd19-f77b-4a5a-8486-df66b924927e",
- "isActive": true,
- "balance": "$2,256.00",
- "picture": "http://placehold.it/32x32",
- "age": 38,
- "name": "Petty Salazar",
- "gender": "male",
- "company": "Assurity",
- "contact": {
- "email": "pettysalazar@assurity.com",
- "phone": "+1 (942) 474-3316",
- "address": "583 Woodrow Court, Wright, North Carolina, 6644"
- },
- "about": "Id ullamco dolor sit sit incididunt officia ad amet est esse amet ex ea do. Tempor labore incididunt aliquip irure culpa nisi eiusmod consequat ea. Elit cupidatat ipsum do veniam non in duis ad dolor et. Aute ut sunt sint consectetur cillum.\r\n",
- "registered": "2005-08-19T16:51:58 +04:00",
- "latitude": -16.848101,
- "longitude": -48.295182,
- "tags": [
- "eiusmod",
- "nostrud",
- "esse",
- "deserunt",
- "proident",
- "tempor",
- "esse"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Ruth Burgess"
- },
- {
- "id": 1,
- "name": "Lynne Chavez"
- },
- {
- "id": 2,
- "name": "Maureen Mcgee"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 21,
- "guid": "5b8a612b-212b-459a-93c4-24b4a77b365b",
- "isActive": true,
- "balance": "$2,187.00",
- "picture": "http://placehold.it/32x32",
- "age": 21,
- "name": "Willis Alston",
- "gender": "male",
- "company": "Digial",
- "contact": {
- "email": "willisalston@digial.com",
- "phone": "+1 (886) 405-3691",
- "address": "249 Remsen Street, Floriston, Maryland, 9260"
- },
- "about": "Laborum deserunt occaecat pariatur elit in ad officia dolor id eu commodo ex magna ut. Magna amet id elit amet consequat. Sint qui sunt amet enim ullamco reprehenderit dolor laborum ullamco proident cillum mollit. Qui non aute Lorem mollit velit exercitation quis. Fugiat cupidatat sit ad duis nisi ipsum reprehenderit est aliqua in laborum veniam.\r\n",
- "registered": "1999-04-14T08:53:31 +04:00",
- "latitude": 35.32226,
- "longitude": 30.951607,
- "tags": [
- "ut",
- "fugiat",
- "reprehenderit",
- "laborum",
- "sunt",
- "ea",
- "culpa"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Angelique Kaufman"
- },
- {
- "id": 1,
- "name": "Candy Bright"
- },
- {
- "id": 2,
- "name": "Dudley Hoover"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 22,
- "guid": "0bf64428-0c7d-42f7-b6b5-4da22cb5d2fd",
- "isActive": true,
- "balance": "$3,157.00",
- "picture": "http://placehold.it/32x32",
- "age": 27,
- "name": "Vicky Gomez",
- "gender": "female",
- "company": "Zinca",
- "contact": {
- "email": "vickygomez@zinca.com",
- "phone": "+1 (844) 538-2119",
- "address": "974 Seigel Court, Staples, Washington, 3500"
- },
- "about": "Nostrud in et adipisicing exercitation sint id. In fugiat consequat dolor sit ea labore ipsum elit magna. Duis exercitation tempor est veniam ad deserunt esse ipsum ullamco ut cillum aute laborum duis. Commodo ut elit anim duis nostrud nisi ea ipsum. Enim irure in anim deserunt culpa ipsum ea non sunt in irure.\r\n",
- "registered": "1995-03-17T04:54:29 +05:00",
- "latitude": -65.632888,
- "longitude": -142.188912,
- "tags": [
- "aute",
- "nisi",
- "voluptate",
- "culpa",
- "et",
- "aute",
- "labore"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Sullivan Reese"
- },
- {
- "id": 1,
- "name": "Sara Adkins"
- },
- {
- "id": 2,
- "name": "Cheryl Serrano"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 23,
- "guid": "c0d4757c-334b-4185-ae6c-ce975b825c98",
- "isActive": false,
- "balance": "$3,464.00",
- "picture": "http://placehold.it/32x32",
- "age": 37,
- "name": "Janette Hurst",
- "gender": "female",
- "company": "Lovepad",
- "contact": {
- "email": "janettehurst@lovepad.com",
- "phone": "+1 (964) 488-3768",
- "address": "300 Jefferson Avenue, Sanborn, Tennessee, 8643"
- },
- "about": "Anim ut mollit cupidatat cillum mollit amet duis. Reprehenderit exercitation exercitation ea quis cupidatat ullamco do ipsum tempor nulla. Enim dolor voluptate est qui duis eu ad culpa duis velit quis ad et quis.\r\n",
- "registered": "1992-11-02T09:16:26 +05:00",
- "latitude": 80.192853,
- "longitude": 127.761747,
- "tags": [
- "commodo",
- "enim",
- "laborum",
- "ea",
- "consequat",
- "voluptate",
- "cillum"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Laura Cruz"
- },
- {
- "id": 1,
- "name": "Cotton Cervantes"
- },
- {
- "id": 2,
- "name": "Matthews Klein"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 24,
- "guid": "db1e534d-a740-4a7d-bb9c-d869b25b8fb4",
- "isActive": false,
- "balance": "$3,917.00",
- "picture": "http://placehold.it/32x32",
- "age": 34,
- "name": "Tammie Conway",
- "gender": "female",
- "company": "Escenta",
- "contact": {
- "email": "tammieconway@escenta.com",
- "phone": "+1 (990) 420-3715",
- "address": "140 Stillwell Avenue, Blairstown, Utah, 5621"
- },
- "about": "Enim dolore tempor velit sint tempor excepteur laboris. Et occaecat eu nisi ex. Do aute mollit ex anim quis commodo ex ipsum. Enim duis ut do officia mollit minim tempor dolore enim sint qui. Ut ipsum enim aliqua sunt qui. Ea ipsum enim qui do enim id elit ut.\r\n",
- "registered": "2002-12-12T08:36:42 +05:00",
- "latitude": -66.914337,
- "longitude": -3.984304,
- "tags": [
- "minim",
- "dolor",
- "est",
- "fugiat",
- "enim",
- "qui",
- "duis"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Elba Castillo"
- },
- {
- "id": 1,
- "name": "Mae Shepherd"
- },
- {
- "id": 2,
- "name": "Boyer Buckner"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 25,
- "guid": "5f5aeb4d-c03f-4e8d-b154-db544254eded",
- "isActive": false,
- "balance": "$2,948.00",
- "picture": "http://placehold.it/32x32",
- "age": 30,
- "name": "Eddie Oliver",
- "gender": "female",
- "company": "Acusage",
- "contact": {
- "email": "eddieoliver@acusage.com",
- "phone": "+1 (892) 585-3345",
- "address": "304 Adams Street, Sattley, Pennsylvania, 9979"
- },
- "about": "Aute commodo commodo ad laborum elit culpa reprehenderit tempor ad labore ex dolor ipsum. Dolore aliquip proident duis ad dolore dolore labore eiusmod pariatur enim. Tempor cupidatat eu irure ipsum anim duis ex quis labore sunt anim tempor nulla non. Adipisicing id exercitation tempor magna officia deserunt nisi ullamco.\r\n",
- "registered": "2005-01-18T11:20:19 +05:00",
- "latitude": 80.072736,
- "longitude": -81.168247,
- "tags": [
- "voluptate",
- "eiusmod",
- "irure",
- "veniam",
- "aliquip",
- "ad",
- "reprehenderit"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Annabelle Holt"
- },
- {
- "id": 1,
- "name": "Shelby Grimes"
- },
- {
- "id": 2,
- "name": "Daniels Bender"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 26,
- "guid": "2e27c341-f5d0-4d39-b6b7-7e0afc16c85f",
- "isActive": false,
- "balance": "$2,530.00",
- "picture": "http://placehold.it/32x32",
- "age": 29,
- "name": "Fannie Gamble",
- "gender": "female",
- "company": "Nebulean",
- "contact": {
- "email": "fanniegamble@nebulean.com",
- "phone": "+1 (915) 549-3646",
- "address": "154 Albemarle Road, Hanover, Alaska, 3225"
- },
- "about": "Laborum ea est esse culpa exercitation duis excepteur fugiat nulla in. Ipsum exercitation sint consequat sunt dolor fugiat veniam reprehenderit. Sint cillum eu nulla irure fugiat occaecat nulla ea qui laboris dolor ea esse. Dolore aute incididunt cupidatat eiusmod fugiat aliqua aliquip aliqua laboris. Quis est reprehenderit ipsum id. Excepteur culpa et do amet minim qui.\r\n",
- "registered": "1995-12-02T02:40:59 +05:00",
- "latitude": -39.574641,
- "longitude": 102.854115,
- "tags": [
- "sunt",
- "labore",
- "officia",
- "occaecat",
- "fugiat",
- "cillum",
- "irure"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Kirk Anthony"
- },
- {
- "id": 1,
- "name": "Terri Warner"
- },
- {
- "id": 2,
- "name": "Geneva Watkins"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 27,
- "guid": "77357b9d-64d1-4672-905e-1e4547f56e4d",
- "isActive": false,
- "balance": "$2,332.00",
- "picture": "http://placehold.it/32x32",
- "age": 33,
- "name": "Booth Wilson",
- "gender": "male",
- "company": "Bezal",
- "contact": {
- "email": "boothwilson@bezal.com",
- "phone": "+1 (969) 537-2100",
- "address": "692 Keen Court, Elbert, Missouri, 7072"
- },
- "about": "Magna tempor occaecat in pariatur est et reprehenderit ut laborum ipsum eiusmod id dolore duis. Ullamco sint excepteur est et culpa elit irure reprehenderit. Consequat aliqua Lorem minim non non velit laborum tempor eu exercitation ex. Voluptate do consectetur cupidatat ad id proident veniam ea. Quis occaecat quis eu commodo laboris consectetur nisi esse et labore velit proident.\r\n",
- "registered": "2008-11-28T06:51:17 +05:00",
- "latitude": 48.132665,
- "longitude": 168.093581,
- "tags": [
- "tempor",
- "incididunt",
- "qui",
- "aute",
- "ea",
- "eiusmod",
- "ullamco"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Sharron Ray"
- },
- {
- "id": 1,
- "name": "Robbins Buchanan"
- },
- {
- "id": 2,
- "name": "Cortez Dorsey"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 28,
- "guid": "7f1421ca-0d4f-4d93-8711-e23bc92886f0",
- "isActive": false,
- "balance": "$3,474.00",
- "picture": "http://placehold.it/32x32",
- "age": 31,
- "name": "Lowe Webster",
- "gender": "male",
- "company": "Digitalus",
- "contact": {
- "email": "lowewebster@digitalus.com",
- "phone": "+1 (952) 484-3834",
- "address": "421 Logan Street, Newcastle, Nevada, 2368"
- },
- "about": "Qui reprehenderit in proident ea irure sunt. Pariatur et est duis voluptate do ullamco non aute. In laborum duis incididunt aliqua sit aute aliquip. Tempor in consectetur officia Lorem proident dolore commodo. Eiusmod incididunt proident anim id deserunt commodo eiusmod amet commodo. Tempor adipisicing do quis quis tempor ea.\r\n",
- "registered": "1998-05-03T23:25:29 +04:00",
- "latitude": -20.168936,
- "longitude": -111.612027,
- "tags": [
- "aliqua",
- "qui",
- "eiusmod",
- "veniam",
- "aliquip",
- "mollit",
- "adipisicing"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Graham Daniels"
- },
- {
- "id": 1,
- "name": "Woods Delaney"
- },
- {
- "id": 2,
- "name": "Latoya Cannon"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 29,
- "guid": "2f1215a3-084f-40dc-aca3-5e709927a12c",
- "isActive": false,
- "balance": "$1,619.00",
- "picture": "http://placehold.it/32x32",
- "age": 27,
- "name": "Hensley Kane",
- "gender": "male",
- "company": "Harmoney",
- "contact": {
- "email": "hensleykane@harmoney.com",
- "phone": "+1 (903) 579-3262",
- "address": "853 Chapel Street, Riviera, New Hampshire, 4559"
- },
- "about": "Ullamco aliqua anim nulla in. Excepteur fugiat irure deserunt minim elit exercitation ex nulla cupidatat. Veniam dolor eu est minim est.\r\n",
- "registered": "1988-06-29T09:46:24 +04:00",
- "latitude": -50.219534,
- "longitude": -45.123064,
- "tags": [
- "officia",
- "duis",
- "est",
- "nisi",
- "tempor",
- "eu",
- "ex"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Jackie Heath"
- },
- {
- "id": 1,
- "name": "Erica Wood"
- },
- {
- "id": 2,
- "name": "Patrick Crosby"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 30,
- "guid": "e355ff04-ef86-4f69-8e16-48b8986b0685",
- "isActive": true,
- "balance": "$1,516.00",
- "picture": "http://placehold.it/32x32",
- "age": 29,
- "name": "Sanford Nguyen",
- "gender": "male",
- "company": "Rockyard",
- "contact": {
- "email": "sanfordnguyen@rockyard.com",
- "phone": "+1 (890) 438-2575",
- "address": "461 Bristol Street, Dalton, South Carolina, 5165"
- },
- "about": "Consequat exercitation culpa anim ad minim. Incididunt aliquip ad enim magna qui est nulla qui cupidatat id consequat incididunt amet. Culpa dolor laboris sunt voluptate commodo proident mollit aliqua voluptate sint anim. Amet pariatur anim voluptate adipisicing nulla est Lorem culpa esse incididunt aliqua mollit sint.\r\n",
- "registered": "1989-09-03T18:04:04 +04:00",
- "latitude": -6.779321,
- "longitude": 160.430547,
- "tags": [
- "adipisicing",
- "eiusmod",
- "ex",
- "duis",
- "veniam",
- "do",
- "sunt"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Sandra Gallagher"
- },
- {
- "id": 1,
- "name": "Mcguire Burke"
- },
- {
- "id": 2,
- "name": "Leonard Calhoun"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 31,
- "guid": "1c384a52-7e6c-4780-9e78-ccb6493d1313",
- "isActive": true,
- "balance": "$3,549.00",
- "picture": "http://placehold.it/32x32",
- "age": 25,
- "name": "Rosalie Bradshaw",
- "gender": "female",
- "company": "Elpro",
- "contact": {
- "email": "rosaliebradshaw@elpro.com",
- "phone": "+1 (913) 597-3434",
- "address": "525 Elm Place, Jenkinsville, New York, 1946"
- },
- "about": "Et labore est magna incididunt cupidatat duis quis sunt qui ut. Magna nulla Lorem exercitation proident culpa laborum fugiat dolor quis proident. Veniam esse consequat deserunt quis Lorem commodo cupidatat esse eu est Lorem aliqua. Quis mollit cupidatat mollit eiusmod cillum dolor eu. Occaecat aliquip officia non fugiat.\r\n",
- "registered": "2011-03-25T18:35:16 +04:00",
- "latitude": 0.287395,
- "longitude": 142.910656,
- "tags": [
- "amet",
- "pariatur",
- "officia",
- "reprehenderit",
- "veniam",
- "veniam",
- "commodo"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Vargas Stephens"
- },
- {
- "id": 1,
- "name": "Kendra Bryant"
- },
- {
- "id": 2,
- "name": "Gay Campos"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 32,
- "guid": "2c547391-d43f-4a31-9f7e-b80b27e90d4a",
- "isActive": true,
- "balance": "$3,972.00",
- "picture": "http://placehold.it/32x32",
- "age": 32,
- "name": "Chapman Stevens",
- "gender": "male",
- "company": "Cosmetex",
- "contact": {
- "email": "chapmanstevens@cosmetex.com",
- "phone": "+1 (801) 521-2094",
- "address": "845 Tennis Court, Veyo, Rhode Island, 2928"
- },
- "about": "Tempor aute et aute officia mollit consectetur eiusmod. Sunt duis reprehenderit quis proident eiusmod. Non pariatur cillum laboris incididunt minim anim. Do in deserunt et aliquip ipsum nisi aliqua fugiat eu. Proident veniam esse tempor eu veniam cillum veniam ad amet consequat. Magna duis deserunt mollit anim est. Labore deserunt nisi dolor excepteur id sint voluptate qui aliqua anim.\r\n",
- "registered": "2010-01-03T12:16:06 +05:00",
- "latitude": 3.477538,
- "longitude": 110.709704,
- "tags": [
- "quis",
- "sint",
- "velit",
- "anim",
- "irure",
- "officia",
- "eiusmod"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Holmes Rivas"
- },
- {
- "id": 1,
- "name": "Carroll Simon"
- },
- {
- "id": 2,
- "name": "Kimberley Cantu"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 33,
- "guid": "80040ceb-683c-4ddc-883b-a68522a9d49e",
- "isActive": true,
- "balance": "$2,117.00",
- "picture": "http://placehold.it/32x32",
- "age": 21,
- "name": "Beth Pratt",
- "gender": "female",
- "company": "Genesynk",
- "contact": {
- "email": "bethpratt@genesynk.com",
- "phone": "+1 (848) 460-3645",
- "address": "279 Milton Street, Toftrees, Connecticut, 1890"
- },
- "about": "Eu ad nulla in reprehenderit dolore. Duis velit reprehenderit eu duis quis commodo cupidatat occaecat proident aute nostrud cupidatat veniam. In ut qui mollit aute cillum aliqua et Lorem.\r\n",
- "registered": "2007-07-25T00:07:13 +04:00",
- "latitude": -59.141628,
- "longitude": 5.709463,
- "tags": [
- "aliquip",
- "duis",
- "commodo",
- "anim",
- "id",
- "qui",
- "minim"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Francesca Mcguire"
- },
- {
- "id": 1,
- "name": "Galloway Kinney"
- },
- {
- "id": 2,
- "name": "Carla Page"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 34,
- "guid": "c85c75c2-fb8c-495c-839b-21dd8f7bf1a1",
- "isActive": true,
- "balance": "$1,775.00",
- "picture": "http://placehold.it/32x32",
- "age": 24,
- "name": "Fletcher Drake",
- "gender": "male",
- "company": "Teraprene",
- "contact": {
- "email": "fletcherdrake@teraprene.com",
- "phone": "+1 (904) 518-3973",
- "address": "189 Nostrand Avenue, Dale, New Mexico, 4401"
- },
- "about": "Quis mollit irure aliqua laboris ea dolor quis do irure mollit. Cillum in sint et in anim irure id proident dolor incididunt sit. Quis mollit ullamco enim et reprehenderit cupidatat minim nulla nulla. Consequat exercitation veniam ad ullamco eiusmod minim mollit in qui irure occaecat. Officia magna nulla commodo consequat ea dolor veniam reprehenderit non ea pariatur reprehenderit nostrud. Irure amet Lorem pariatur officia et voluptate in dolore aliquip nostrud nostrud laborum. Incididunt aliqua consequat tempor aute ipsum amet quis consectetur nostrud nulla ut.\r\n",
- "registered": "2000-03-19T20:16:46 +05:00",
- "latitude": 89.026803,
- "longitude": -162.233737,
- "tags": [
- "sit",
- "eu",
- "ut",
- "consequat",
- "eu",
- "ad",
- "eu"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Bowman Flynn"
- },
- {
- "id": 1,
- "name": "Bell Maynard"
- },
- {
- "id": 2,
- "name": "Marcella Graham"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 35,
- "guid": "cdafc1f2-f3b7-4334-af81-77976eb77363",
- "isActive": false,
- "balance": "$2,580.00",
- "picture": "http://placehold.it/32x32",
- "age": 36,
- "name": "Tamera Roy",
- "gender": "female",
- "company": "Comdom",
- "contact": {
- "email": "tameraroy@comdom.com",
- "phone": "+1 (909) 501-3327",
- "address": "581 Rock Street, Worton, Vermont, 9442"
- },
- "about": "Deserunt fugiat veniam est incididunt. Do est minim esse proident anim laboris excepteur irure magna ex duis cillum consequat magna. Esse id adipisicing excepteur incididunt id commodo incididunt. Voluptate occaecat dolore nulla sint ipsum eu ut do reprehenderit exercitation. Cillum officia enim exercitation labore.\r\n",
- "registered": "2013-08-06T16:29:15 +04:00",
- "latitude": -52.622841,
- "longitude": -147.666763,
- "tags": [
- "nulla",
- "mollit",
- "fugiat",
- "enim",
- "aliqua",
- "quis",
- "eu"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Liliana Barrett"
- },
- {
- "id": 1,
- "name": "Joann Mcmahon"
- },
- {
- "id": 2,
- "name": "Georgette Mcdowell"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 36,
- "guid": "797d27ff-3483-4c56-915b-c35ac2ecb376",
- "isActive": true,
- "balance": "$3,627.00",
- "picture": "http://placehold.it/32x32",
- "age": 20,
- "name": "Ross Jacobs",
- "gender": "male",
- "company": "Aquasure",
- "contact": {
- "email": "rossjacobs@aquasure.com",
- "phone": "+1 (911) 534-3457",
- "address": "409 Harrison Place, Vowinckel, Arizona, 2136"
- },
- "about": "Incididunt occaecat exercitation ad magna dolore consectetur ea nulla aliquip. Incididunt deserunt sit aute adipisicing ex consequat esse non aliquip duis sit laboris excepteur. Velit irure tempor officia adipisicing consequat consectetur ex proident ad magna esse nisi id enim.\r\n",
- "registered": "1990-01-19T05:53:01 +05:00",
- "latitude": -44.645548,
- "longitude": 160.042416,
- "tags": [
- "commodo",
- "id",
- "dolor",
- "cupidatat",
- "laborum",
- "enim",
- "tempor"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Angela Powell"
- },
- {
- "id": 1,
- "name": "Ines Dillon"
- },
- {
- "id": 2,
- "name": "Viola Wooten"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 37,
- "guid": "34b82206-8d49-4e5e-877c-ee908e2ee54a",
- "isActive": true,
- "balance": "$2,832.00",
- "picture": "http://placehold.it/32x32",
- "age": 29,
- "name": "Holden Franklin",
- "gender": "male",
- "company": "Xanide",
- "contact": {
- "email": "holdenfranklin@xanide.com",
- "phone": "+1 (995) 518-3647",
- "address": "270 Amherst Street, Savannah, Maine, 5561"
- },
- "about": "Laborum nisi reprehenderit in cillum dolor ad anim voluptate minim. Ad ea anim laboris nisi aliqua. Adipisicing amet et ea reprehenderit enim excepteur consectetur ea qui et.\r\n",
- "registered": "1989-11-18T14:45:19 +05:00",
- "latitude": 18.000128,
- "longitude": -41.02513,
- "tags": [
- "et",
- "adipisicing",
- "occaecat",
- "nostrud",
- "et",
- "officia",
- "reprehenderit"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Nelson Raymond"
- },
- {
- "id": 1,
- "name": "Burch Hopper"
- },
- {
- "id": 2,
- "name": "Avery Hines"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 38,
- "guid": "41852bc2-daf5-469e-a1aa-3442590cc95c",
- "isActive": false,
- "balance": "$3,452.00",
- "picture": "http://placehold.it/32x32",
- "age": 24,
- "name": "Iris Santiago",
- "gender": "female",
- "company": "Digiprint",
- "contact": {
- "email": "irissantiago@digiprint.com",
- "phone": "+1 (878) 443-3417",
- "address": "501 Sumner Place, Orviston, Georgia, 1383"
- },
- "about": "Anim officia non voluptate eiusmod amet id proident minim esse et proident cillum. Labore ea qui occaecat magna labore veniam amet fugiat magna est anim amet anim. Magna velit aliquip occaecat est labore ad mollit excepteur sint veniam anim laborum fugiat labore. Esse laborum exercitation laborum cupidatat commodo officia. Ipsum mollit id exercitation Lorem tempor elit excepteur anim aliquip et mollit eu officia nisi.\r\n",
- "registered": "2004-05-10T10:04:33 +04:00",
- "latitude": -1.491802,
- "longitude": -37.508269,
- "tags": [
- "ipsum",
- "cillum",
- "laboris",
- "commodo",
- "ipsum",
- "adipisicing",
- "reprehenderit"
- ],
- "friends": [
- {
- "id": 0,
- "name": "French Hays"
- },
- {
- "id": 1,
- "name": "Judith Henderson"
- },
- {
- "id": 2,
- "name": "Guy Harper"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 39,
- "guid": "5e4aaa8c-e1c3-4322-a087-27a0ca4f9127",
- "isActive": true,
- "balance": "$3,703.00",
- "picture": "http://placehold.it/32x32",
- "age": 24,
- "name": "Frances Cobb",
- "gender": "female",
- "company": "Playce",
- "contact": {
- "email": "francescobb@playce.com",
- "phone": "+1 (828) 432-3671",
- "address": "534 Adler Place, Whitewater, Kansas, 8506"
- },
- "about": "Deserunt proident dolor labore commodo deserunt adipisicing nostrud aliquip. Consectetur Lorem elit do tempor. Non ut qui aute proident veniam tempor non duis voluptate adipisicing deserunt sunt Lorem reprehenderit. Sit minim aliquip aute in ea. Nisi nostrud eiusmod ea laboris officia culpa tempor eu anim in. Laborum cillum est consectetur mollit enim dolor et dolore ex cillum irure officia ipsum tempor.\r\n",
- "registered": "1997-07-01T07:26:13 +04:00",
- "latitude": 54.020288,
- "longitude": -132.665236,
- "tags": [
- "labore",
- "aliquip",
- "quis",
- "excepteur",
- "velit",
- "enim",
- "exercitation"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Cooke Clements"
- },
- {
- "id": 1,
- "name": "Newman Wiggins"
- },
- {
- "id": 2,
- "name": "Mccarty Horton"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 40,
- "guid": "d86dcfea-b6f9-4d1f-9367-fdd05e1b2c4e",
- "isActive": true,
- "balance": "$2,889.00",
- "picture": "http://placehold.it/32x32",
- "age": 33,
- "name": "Hayden Pugh",
- "gender": "male",
- "company": "Paprikut",
- "contact": {
- "email": "haydenpugh@paprikut.com",
- "phone": "+1 (922) 522-2096",
- "address": "286 Richardson Street, Jacumba, Michigan, 3966"
- },
- "about": "Exercitation aliqua magna tempor fugiat culpa sunt labore. Irure tempor id ex commodo commodo ut amet officia aute exercitation mollit mollit occaecat eu. Sit ullamco sit labore excepteur reprehenderit aliquip eu esse quis laborum. Enim ipsum occaecat sunt qui do laboris ullamco consectetur aliqua ipsum et. In ex quis consectetur laboris sunt minim aliqua laboris proident. Ea eu ut eu laboris duis. Dolore culpa enim aliquip non et reprehenderit ut.\r\n",
- "registered": "2000-07-10T05:40:29 +04:00",
- "latitude": 71.287534,
- "longitude": 42.215447,
- "tags": [
- "mollit",
- "exercitation",
- "occaecat",
- "duis",
- "commodo",
- "fugiat",
- "nostrud"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Leah Sheppard"
- },
- {
- "id": 1,
- "name": "Noreen Martinez"
- },
- {
- "id": 2,
- "name": "Stevens Phillips"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 41,
- "guid": "efd7d900-982a-492d-a707-7967a782567d",
- "isActive": true,
- "balance": "$2,807.00",
- "picture": "http://placehold.it/32x32",
- "age": 27,
- "name": "Cabrera Callahan",
- "gender": "male",
- "company": "Jumpstack",
- "contact": {
- "email": "cabreracallahan@jumpstack.com",
- "phone": "+1 (995) 461-3610",
- "address": "947 Butler Place, Bethany, Hawaii, 9896"
- },
- "about": "Qui ex ullamco qui sint exercitation irure nisi elit quis exercitation voluptate qui. Occaecat aute labore pariatur ut velit consequat ex consectetur sit adipisicing. Qui deserunt qui magna quis ad ex duis magna quis ex do nostrud consectetur. Dolore nostrud ut non exercitation dolor commodo esse ut do anim velit do commodo ad. Nisi minim excepteur nulla cupidatat amet ad ad. Ut veniam do culpa laboris officia ullamco quis et in ad nisi amet consequat. Occaecat proident cupidatat ea sunt do tempor nostrud occaecat nisi velit occaecat amet in enim.\r\n",
- "registered": "1991-02-26T14:57:11 +05:00",
- "latitude": -87.772592,
- "longitude": -88.680383,
- "tags": [
- "ea",
- "in",
- "ex",
- "consectetur",
- "tempor",
- "proident",
- "laboris"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Nita Cherry"
- },
- {
- "id": 1,
- "name": "Mcgee Cameron"
- },
- {
- "id": 2,
- "name": "Marilyn Price"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 42,
- "guid": "f1e73451-8ae5-4874-a86d-bd8f57c31fbf",
- "isActive": false,
- "balance": "$3,533.00",
- "picture": "http://placehold.it/32x32",
- "age": 29,
- "name": "Frieda Hull",
- "gender": "female",
- "company": "Mantrix",
- "contact": {
- "email": "friedahull@mantrix.com",
- "phone": "+1 (835) 428-3070",
- "address": "340 Ditmars Street, Williamson, Virginia, 7800"
- },
- "about": "Irure irure cupidatat elit eiusmod ea eiusmod. Do exercitation consequat mollit aute sit. Nostrud dolor enim laborum incididunt adipisicing id amet irure sit deserunt cillum ad ut eiusmod.\r\n",
- "registered": "1997-08-01T05:14:10 +04:00",
- "latitude": -35.362422,
- "longitude": 82.223451,
- "tags": [
- "ipsum",
- "aliquip",
- "et",
- "quis",
- "cillum",
- "qui",
- "veniam"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Teri Gallegos"
- },
- {
- "id": 1,
- "name": "Stella Gutierrez"
- },
- {
- "id": 2,
- "name": "Garcia Vargas"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 43,
- "guid": "869eaf17-7f10-4ddd-89c0-399b14457165",
- "isActive": true,
- "balance": "$3,417.00",
- "picture": "http://placehold.it/32x32",
- "age": 37,
- "name": "Sherri Hammond",
- "gender": "female",
- "company": "Dreamia",
- "contact": {
- "email": "sherrihammond@dreamia.com",
- "phone": "+1 (807) 566-2154",
- "address": "864 Jaffray Street, Crumpler, Louisiana, 4943"
- },
- "about": "Ea eu excepteur eiusmod non aute elit ad sit. Ut cupidatat elit ad excepteur voluptate ea dolor deserunt do culpa non pariatur in non. In fugiat ut mollit cupidatat pariatur commodo quis deserunt enim fugiat ex. Cupidatat laboris mollit esse adipisicing minim adipisicing exercitation aliqua. Elit cupidatat dolore minim id laborum. Ea ullamco nulla id reprehenderit sunt.\r\n",
- "registered": "1993-01-25T03:41:12 +05:00",
- "latitude": 12.411305,
- "longitude": -175.152748,
- "tags": [
- "sit",
- "tempor",
- "sint",
- "aliqua",
- "reprehenderit",
- "cupidatat",
- "pariatur"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Avis Potts"
- },
- {
- "id": 1,
- "name": "Johnnie Carr"
- },
- {
- "id": 2,
- "name": "Earnestine Justice"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 44,
- "guid": "061c8d75-23cb-4448-b8e4-0ae9903ce243",
- "isActive": true,
- "balance": "$3,384.00",
- "picture": "http://placehold.it/32x32",
- "age": 27,
- "name": "Kim Valdez",
- "gender": "male",
- "company": "Lotron",
- "contact": {
- "email": "kimvaldez@lotron.com",
- "phone": "+1 (948) 477-2039",
- "address": "494 Bedell Lane, Richford, Massachusetts, 7110"
- },
- "about": "Voluptate culpa minim non ipsum nulla nisi proident. Esse qui ad officia deserunt sint ad fugiat incididunt ad eiusmod cillum. Incididunt pariatur esse nisi magna cillum consectetur nulla excepteur sunt commodo fugiat enim. Fugiat elit consectetur magna eiusmod sint excepteur mollit veniam non irure exercitation aliqua sunt ipsum. Reprehenderit aliquip amet deserunt occaecat eiusmod laborum sint consequat labore nostrud sunt excepteur culpa. Esse dolore aute aute occaecat exercitation nulla. Nostrud ut cupidatat ea minim nostrud do mollit.\r\n",
- "registered": "2013-12-08T03:36:04 +05:00",
- "latitude": -18.08955,
- "longitude": -1.550904,
- "tags": [
- "incididunt",
- "fugiat",
- "Lorem",
- "laborum",
- "laboris",
- "et",
- "duis"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Magdalena Brady"
- },
- {
- "id": 1,
- "name": "Emily Mccarty"
- },
- {
- "id": 2,
- "name": "Holder Frost"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 45,
- "guid": "8932af53-3258-44a7-ab51-701667c9ba96",
- "isActive": false,
- "balance": "$3,450.00",
- "picture": "http://placehold.it/32x32",
- "age": 40,
- "name": "Glenda Langley",
- "gender": "female",
- "company": "Phuel",
- "contact": {
- "email": "glendalangley@phuel.com",
- "phone": "+1 (903) 548-3089",
- "address": "121 Vandam Street, Weeksville, Nebraska, 8425"
- },
- "about": "Voluptate duis consectetur in nisi fugiat Lorem quis. Ad culpa ex tempor quis veniam laboris amet eiusmod. Cupidatat voluptate sunt magna et. Est cupidatat veniam irure anim labore in id.\r\n",
- "registered": "2009-11-04T21:11:08 +05:00",
- "latitude": -87.668294,
- "longitude": -112.418622,
- "tags": [
- "qui",
- "Lorem",
- "minim",
- "fugiat",
- "dolor",
- "consectetur",
- "id"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Therese Mcclure"
- },
- {
- "id": 1,
- "name": "Kelley Lucas"
- },
- {
- "id": 2,
- "name": "Dunlap Bean"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 46,
- "guid": "2da8ced5-6d01-4572-b38b-d43a2fd4febb",
- "isActive": false,
- "balance": "$3,378.00",
- "picture": "http://placehold.it/32x32",
- "age": 32,
- "name": "Castillo Harding",
- "gender": "male",
- "company": "Zerbina",
- "contact": {
- "email": "castilloharding@zerbina.com",
- "phone": "+1 (914) 529-3555",
- "address": "308 Glenwood Road, Laurelton, Florida, 4041"
- },
- "about": "Nulla et excepteur ad do nostrud. Consequat id do nisi in eu voluptate laboris pariatur. Dolor velit mollit labore dolore.\r\n",
- "registered": "1998-04-26T14:22:09 +04:00",
- "latitude": -48.888699,
- "longitude": -134.191718,
- "tags": [
- "aute",
- "enim",
- "laboris",
- "reprehenderit",
- "pariatur",
- "est",
- "aliqua"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Glover Strong"
- },
- {
- "id": 1,
- "name": "Karina Terry"
- },
- {
- "id": 2,
- "name": "Brigitte Duncan"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 47,
- "guid": "4d559beb-b905-416a-9933-ebf1f4e23ccd",
- "isActive": false,
- "balance": "$1,158.00",
- "picture": "http://placehold.it/32x32",
- "age": 34,
- "name": "Velez Wallace",
- "gender": "male",
- "company": "Sulfax",
- "contact": {
- "email": "velezwallace@sulfax.com",
- "phone": "+1 (974) 585-2264",
- "address": "698 Battery Avenue, Newry, Texas, 2855"
- },
- "about": "Pariatur magna commodo in anim nisi. Dolore cillum laboris occaecat magna mollit do irure ea incididunt eiusmod sit. Minim cupidatat fugiat aliquip exercitation velit pariatur duis ipsum officia.\r\n",
- "registered": "1989-10-07T05:04:43 +04:00",
- "latitude": -50.610411,
- "longitude": -2.761224,
- "tags": [
- "esse",
- "incididunt",
- "est",
- "officia",
- "excepteur",
- "consequat",
- "fugiat"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Clarissa Shepard"
- },
- {
- "id": 1,
- "name": "Karyn Figueroa"
- },
- {
- "id": 2,
- "name": "Holly Pollard"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 48,
- "guid": "70817585-69ff-4382-8ed4-ba3dd6648bd5",
- "isActive": false,
- "balance": "$1,112.00",
- "picture": "http://placehold.it/32x32",
- "age": 29,
- "name": "Lacey Marks",
- "gender": "female",
- "company": "Twiggery",
- "contact": {
- "email": "laceymarks@twiggery.com",
- "phone": "+1 (926) 549-3368",
- "address": "106 Riverdale Avenue, Hollymead, California, 2138"
- },
- "about": "Lorem veniam voluptate laboris duis sint magna proident laboris. Ex minim sit mollit dolor est deserunt excepteur tempor nisi sunt. Esse ut aute voluptate cillum sit non deserunt ex cillum veniam. Labore proident enim cillum do. Pariatur non aliquip aute aliqua fugiat dolor.\r\n",
- "registered": "2007-06-03T20:17:07 +04:00",
- "latitude": -16.12467,
- "longitude": 102.700269,
- "tags": [
- "fugiat",
- "anim",
- "consectetur",
- "ad",
- "non",
- "sint",
- "deserunt"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Howe Slater"
- },
- {
- "id": 1,
- "name": "Hudson Hess"
- },
- {
- "id": 2,
- "name": "Hays Haynes"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 49,
- "guid": "c92187e4-a767-48be-bc1b-061574db1cfc",
- "isActive": true,
- "balance": "$1,775.00",
- "picture": "http://placehold.it/32x32",
- "age": 37,
- "name": "Middleton Cook",
- "gender": "male",
- "company": "Kiosk",
- "contact": {
- "email": "middletoncook@kiosk.com",
- "phone": "+1 (818) 432-3189",
- "address": "239 Beekman Place, Bangor, Montana, 4724"
- },
- "about": "Sit elit fugiat cillum exercitation cupidatat non cillum nulla tempor ut voluptate consequat sunt do. Ut ut nisi ex nostrud duis fugiat aliquip occaecat laborum irure proident quis sint. Ipsum aute amet minim officia sit anim cillum occaecat velit. Lorem proident id cillum mollit tempor dolore amet adipisicing duis incididunt. Deserunt in do qui et duis labore sit consequat. Velit est dolor sunt adipisicing cupidatat. Sit esse fugiat elit amet labore adipisicing exercitation qui nisi incididunt consectetur.\r\n",
- "registered": "2010-04-30T10:49:48 +04:00",
- "latitude": -53.579253,
- "longitude": 63.269635,
- "tags": [
- "ex",
- "non",
- "est",
- "officia",
- "dolor",
- "irure",
- "qui"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Pope Rojas"
- },
- {
- "id": 1,
- "name": "Graves Cooke"
- },
- {
- "id": 2,
- "name": "Mccarthy Taylor"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 50,
- "guid": "954b92fb-2ecf-4f69-b183-d27a2370697f",
- "isActive": false,
- "balance": "$3,381.00",
- "picture": "http://placehold.it/32x32",
- "age": 38,
- "name": "Carrillo Roth",
- "gender": "male",
- "company": "Soprano",
- "contact": {
- "email": "carrilloroth@soprano.com",
- "phone": "+1 (866) 480-2404",
- "address": "178 Coleridge Street, Saticoy, Oregon, 9243"
- },
- "about": "Lorem dolore do proident ea amet ex incididunt do amet commodo. Minim minim cupidatat culpa quis sint mollit irure consequat id culpa laboris veniam mollit. Commodo consectetur velit officia et et quis excepteur incididunt proident culpa pariatur.\r\n",
- "registered": "1996-05-31T06:23:13 +04:00",
- "latitude": 8.462523,
- "longitude": 31.837459,
- "tags": [
- "consequat",
- "tempor",
- "veniam",
- "excepteur",
- "Lorem",
- "eiusmod",
- "veniam"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Keller Schneider"
- },
- {
- "id": 1,
- "name": "Lessie Ochoa"
- },
- {
- "id": 2,
- "name": "Richard Snider"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 51,
- "guid": "3331c6e3-2764-44ba-931a-5762b9007c06",
- "isActive": false,
- "balance": "$2,087.00",
- "picture": "http://placehold.it/32x32",
- "age": 36,
- "name": "Monroe Goodwin",
- "gender": "male",
- "company": "Hydrocom",
- "contact": {
- "email": "monroegoodwin@hydrocom.com",
- "phone": "+1 (953) 480-3156",
- "address": "872 Taaffe Place, Shelby, New York, 480"
- },
- "about": "Labore mollit esse eu veniam nisi occaecat magna exercitation enim laboris duis nulla. Laboris cupidatat sunt ex tempor aliqua commodo excepteur aliquip elit elit. Est laboris culpa incididunt velit esse dolore est consectetur laborum incididunt est. Voluptate laboris aute id sint magna minim incididunt pariatur nostrud reprehenderit. Dolore elit commodo ipsum excepteur duis occaecat commodo mollit magna ut.\r\n",
- "registered": "1999-10-23T22:43:40 +04:00",
- "latitude": 87.514317,
- "longitude": -131.664199,
- "tags": [
- "incididunt",
- "proident",
- "amet",
- "est",
- "duis",
- "cillum",
- "qui"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Ashlee Collier"
- },
- {
- "id": 1,
- "name": "Savannah Valentine"
- },
- {
- "id": 2,
- "name": "Benita Klein"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 52,
- "guid": "a0dcd19e-1d3a-4196-9028-efde5f73e0a5",
- "isActive": false,
- "balance": "$2,062.00",
- "picture": "http://placehold.it/32x32",
- "age": 37,
- "name": "Marina Morris",
- "gender": "female",
- "company": "Zork",
- "contact": {
- "email": "marinamorris@zork.com",
- "phone": "+1 (856) 428-3606",
- "address": "435 Essex Street, Bedias, Maryland, 231"
- },
- "about": "Tempor nisi enim ipsum et laboris adipisicing consequat. Qui ut culpa cillum fugiat labore. Cupidatat consectetur pariatur dolore non velit ea dolore ullamco exercitation do reprehenderit tempor enim. Labore esse ullamco eiusmod do ipsum eiusmod commodo reprehenderit in duis nulla. Excepteur nisi consequat esse cupidatat enim eu. Deserunt voluptate aliqua velit sunt in nostrud sint elit esse.\r\n",
- "registered": "1988-09-10T08:51:01 +04:00",
- "latitude": 65.099082,
- "longitude": 162.881342,
- "tags": [
- "enim",
- "deserunt",
- "ut",
- "dolor",
- "ad",
- "nulla",
- "sit"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Monique Carrillo"
- },
- {
- "id": 1,
- "name": "Chavez Drake"
- },
- {
- "id": 2,
- "name": "Duran Goodman"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 53,
- "guid": "e093b1fd-6a6f-42fe-b2bd-66e86a87c546",
- "isActive": true,
- "balance": "$3,921.00",
- "picture": "http://placehold.it/32x32",
- "age": 20,
- "name": "Cameron Olson",
- "gender": "male",
- "company": "Verton",
- "contact": {
- "email": "cameronolson@verton.com",
- "phone": "+1 (880) 584-2467",
- "address": "146 Beacon Court, Kapowsin, Vermont, 6568"
- },
- "about": "Quis aliqua sit commodo fugiat laborum fugiat exercitation dolore ullamco laboris ad ea esse. Excepteur exercitation aute sint dolore duis officia eu nisi aliqua ullamco. Reprehenderit sunt aliquip dolore esse elit mollit magna est Lorem voluptate. Reprehenderit velit pariatur eu et excepteur ut eu aliquip proident anim ut pariatur Lorem.\r\n",
- "registered": "1994-11-06T11:20:39 +05:00",
- "latitude": -13.920139,
- "longitude": -8.277158,
- "tags": [
- "officia",
- "elit",
- "esse",
- "commodo",
- "do",
- "sint",
- "magna"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Jewell Beck"
- },
- {
- "id": 1,
- "name": "Eliza Valencia"
- },
- {
- "id": 2,
- "name": "Shelton Jones"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 54,
- "guid": "7c7b63ca-a636-4fc4-ba5e-1b3539760d80",
- "isActive": false,
- "balance": "$3,641.00",
- "picture": "http://placehold.it/32x32",
- "age": 40,
- "name": "Elvia Mcneil",
- "gender": "female",
- "company": "Mediot",
- "contact": {
- "email": "elviamcneil@mediot.com",
- "phone": "+1 (887) 542-3951",
- "address": "112 Conway Street, Riviera, Indiana, 4070"
- },
- "about": "Exercitation reprehenderit ut sunt cupidatat eu aute reprehenderit dolore Lorem ut. Commodo est dolore eiusmod tempor amet anim reprehenderit aute labore dolor mollit dolore duis incididunt. Non id enim duis ex. Cillum ea anim consectetur occaecat laborum ipsum magna aliquip cupidatat. Quis laborum in reprehenderit voluptate exercitation do Lorem incididunt laborum. Consectetur dolor incididunt id consequat.\r\n",
- "registered": "1996-09-28T17:49:54 +04:00",
- "latitude": -33.9032,
- "longitude": 124.05472,
- "tags": [
- "consequat",
- "deserunt",
- "et",
- "culpa",
- "Lorem",
- "ea",
- "amet"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Lane Lane"
- },
- {
- "id": 1,
- "name": "Marks Fulton"
- },
- {
- "id": 2,
- "name": "Sheri Newton"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 55,
- "guid": "7c65254b-9aa2-4fbb-8b34-18dcd7812ad7",
- "isActive": true,
- "balance": "$1,058.00",
- "picture": "http://placehold.it/32x32",
- "age": 28,
- "name": "Kasey Lopez",
- "gender": "female",
- "company": "Enervate",
- "contact": {
- "email": "kaseylopez@enervate.com",
- "phone": "+1 (934) 491-3787",
- "address": "250 Waldorf Court, Needmore, California, 4642"
- },
- "about": "Do nisi in pariatur amet. Cillum deserunt eiusmod cillum id cillum fugiat fugiat est labore laborum voluptate aliqua cupidatat. Ad qui dolore quis proident laboris pariatur incididunt. Magna labore fugiat excepteur aliqua aliquip quis excepteur voluptate sunt irure laborum eu ipsum eiusmod. Laborum qui sit est est. Ullamco esse aute sunt cupidatat esse excepteur elit. Ullamco commodo velit ad laborum reprehenderit nisi nostrud adipisicing.\r\n",
- "registered": "2011-03-04T19:49:25 +05:00",
- "latitude": -24.101851,
- "longitude": 72.932726,
- "tags": [
- "non",
- "sint",
- "aliquip",
- "non",
- "adipisicing",
- "non",
- "eu"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Waller Graham"
- },
- {
- "id": 1,
- "name": "Long Smith"
- },
- {
- "id": 2,
- "name": "Rosetta Villarreal"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 56,
- "guid": "799d7fa4-6e65-44e0-922e-4db7889f948c",
- "isActive": false,
- "balance": "$1,120.00",
- "picture": "http://placehold.it/32x32",
- "age": 36,
- "name": "Castillo Cooper",
- "gender": "male",
- "company": "Neurocell",
- "contact": {
- "email": "castillocooper@neurocell.com",
- "phone": "+1 (878) 430-2711",
- "address": "593 Lefferts Avenue, Draper, Washington, 2068"
- },
- "about": "Ipsum irure ullamco mollit adipisicing magna cillum voluptate. Non est consequat ad aliquip anim officia proident. Commodo anim dolore nulla voluptate veniam veniam aute. Nulla quis magna laboris voluptate consequat nostrud cillum.\r\n",
- "registered": "2008-10-13T04:25:53 +04:00",
- "latitude": 32.416458,
- "longitude": -156.838748,
- "tags": [
- "esse",
- "nulla",
- "mollit",
- "ad",
- "fugiat",
- "est",
- "ullamco"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Gilbert Sweet"
- },
- {
- "id": 1,
- "name": "Rene Stephenson"
- },
- {
- "id": 2,
- "name": "Mable Marquez"
- }
- ],
- "randomArrayItem": "cherry"
- },
- {
- "id": 57,
- "guid": "9f597ce3-dbcf-4662-9efd-187f08c9ec19",
- "isActive": false,
- "balance": "$3,687.00",
- "picture": "http://placehold.it/32x32",
- "age": 33,
- "name": "Washington Oliver",
- "gender": "male",
- "company": "Accuprint",
- "contact": {
- "email": "washingtonoliver@accuprint.com",
- "phone": "+1 (867) 544-3956",
- "address": "783 Wyckoff Avenue, Enlow, Georgia, 7254"
- },
- "about": "Cupidatat minim excepteur et magna laborum sunt. Velit labore deserunt elit consequat in dolore occaecat ut eu quis. Commodo Lorem enim sit consectetur reprehenderit consectetur. Eu culpa irure amet occaecat id qui enim consequat irure id elit. Cillum ullamco id duis dolor aute est dolore.\r\n",
- "registered": "1993-07-27T14:44:21 +04:00",
- "latitude": 79.992558,
- "longitude": 178.725427,
- "tags": [
- "ipsum",
- "et",
- "esse",
-
<TRUNCATED>
[13/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/test/resources/sample-small.json
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/test/resources/sample-small.json b/stack/corepersistence/index/src/test/resources/sample-small.json
deleted file mode 100644
index 91f336c..0000000
--- a/stack/corepersistence/index/src/test/resources/sample-small.json
+++ /dev/null
@@ -1,222 +0,0 @@
-[
- {
- "id": 0,
- "guid": "41a6482a-f8d5-4b28-a2f1-90b110b25167",
- "isActive": false,
- "balance": "$1,600.00",
- "picture": "http://placehold.it/32x32",
- "age": 33,
- "name": "Molly Fitzpatrick",
- "gender": "female",
- "company": "Geologix",
- "contact": {
- "email": "mollyfitzpatrick@geologix.com",
- "phone": "+1 (968) 560-2206",
- "address": "895 Karweg Place, Lookingglass, Utah, 1989"
- },
- "about": "Eu nisi Lorem ad exercitation enim cupidatat culpa consectetur voluptate fugiat pariatur. Irure reprehenderit est quis aliquip fugiat enim. Elit ex qui cupidatat velit nisi cillum sunt dolor eu aute duis et. Culpa anim proident veniam occaecat eiusmod non adipisicing consequat fugiat eu irure laborum. Ea est sint deserunt laboris. Enim pariatur in ut magna ipsum fugiat ullamco dolor est voluptate veniam velit.\r\n",
- "registered": "2013-02-02T16:18:24 +05:00",
- "latitude": 10.237003,
- "longitude": -86.677799,
- "tags": [
- "sint",
- "laboris",
- "laboris",
- "enim",
- "irure",
- "dolore",
- "non"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Concepcion Michael"
- },
- {
- "id": 1,
- "name": "Harris Mcdonald"
- },
- {
- "id": 2,
- "name": "Marshall Cote"
- }
- ],
- "randomArrayItem": "lemon"
- },
- {
- "id": 1,
- "guid": "13158ddc-c6fe-4dc6-84ad-1a20b2bc8494",
- "isActive": false,
- "balance": "$3,898.00",
- "picture": "http://placehold.it/32x32",
- "age": 40,
- "name": "Tami Mccullough",
- "gender": "female",
- "company": "Eventex",
- "contact": {
- "email": "tamimccullough@eventex.com",
- "phone": "+1 (875) 421-2839",
- "address": "367 Orange Street, Wright, Michigan, 913"
- },
- "about": "Occaecat Lorem dolore in consectetur enim Lorem minim. Do eu aliqua aliquip consequat adipisicing Lorem qui reprehenderit do nisi nisi incididunt velit consequat. Aliqua anim dolor est cillum dolore et ullamco. Adipisicing dolore sunt sunt tempor nisi.\r\n",
- "registered": "2013-06-10T03:06:40 +04:00",
- "latitude": -38.108123,
- "longitude": -128.352006,
- "tags": [
- "ipsum",
- "magna",
- "eu",
- "anim",
- "magna",
- "nisi",
- "nisi"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Elva Whitfield"
- },
- {
- "id": 1,
- "name": "King Waters"
- },
- {
- "id": 2,
- "name": "Sandra Rodriguez"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 2,
- "guid": "cc4541b1-d8e3-4f2d-924f-ad1f78ca994a",
- "isActive": false,
- "balance": "$1,715.00",
- "picture": "http://placehold.it/32x32",
- "age": 34,
- "name": "Tina Dudley",
- "gender": "female",
- "company": "Reversus",
- "contact": {
- "email": "tinadudley@reversus.com",
- "phone": "+1 (873) 549-2696",
- "address": "772 Arion Place, Tibbie, Virginia, 8573"
- },
- "about": "Do laboris fugiat qui est mollit aliqua esse non duis ex non eiusmod consequat. Tempor eu et voluptate adipisicing. Nostrud veniam laborum officia eiusmod esse commodo culpa. Officia cupidatat officia consequat laboris duis cillum fugiat nostrud in.\r\n",
- "registered": "1998-04-01T23:20:58 +05:00",
- "latitude": 0.298655,
- "longitude": -91.268836,
- "tags": [
- "enim",
- "ut",
- "elit",
- "officia",
- "ut",
- "nostrud",
- "ullamco"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Haney Spears"
- },
- {
- "id": 1,
- "name": "Erna Trevino"
- },
- {
- "id": 2,
- "name": "Trisha Vaughan"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 3,
- "guid": "2bb6de28-5d2d-4cf6-bde0-b3cf60bf6bb3",
- "isActive": true,
- "balance": "$2,016.00",
- "picture": "http://placehold.it/32x32",
- "age": 23,
- "name": "Norman Hester",
- "gender": "male",
- "company": "Playce",
- "contact": {
- "email": "normanhester@playce.com",
- "phone": "+1 (856) 431-2945",
- "address": "406 Minna Street, Glenville, Connecticut, 3785"
- },
- "about": "Qui labore nostrud id occaecat culpa irure ad. Dolore non laborum occaecat occaecat ad sunt amet officia nisi in ullamco est officia. Lorem officia pariatur sit aute ea incididunt do. Consectetur id ad id mollit amet cupidatat dolor consectetur ipsum aute amet do. Reprehenderit consectetur amet esse fugiat et exercitation eiusmod. Labore nostrud sit quis sit qui id. Culpa pariatur aliquip sint magna irure occaecat officia magna sit proident pariatur.\r\n",
- "registered": "1988-08-11T12:52:13 +04:00",
- "latitude": -21.888779,
- "longitude": 65.493829,
- "tags": [
- "Lorem",
- "officia",
- "nostrud",
- "eu",
- "do",
- "eu",
- "duis"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Georgina Hess"
- },
- {
- "id": 1,
- "name": "Parsons Wilson"
- },
- {
- "id": 2,
- "name": "Harmon Wise"
- }
- ],
- "randomArrayItem": "apple"
- },
- {
- "id": 4,
- "guid": "32fedc30-8e37-4b65-abb3-8faa829f4ad3",
- "isActive": true,
- "balance": "$2,642.00",
- "picture": "http://placehold.it/32x32",
- "age": 33,
- "name": "Orr Byers",
- "gender": "male",
- "company": "Bittor",
- "contact": {
- "email": "orrbyers@bittor.com",
- "phone": "+1 (997) 569-2415",
- "address": "730 Lloyd Street, Marshall, Vermont, 3170"
- },
- "about": "Lorem culpa adipisicing consequat eu incididunt ullamco sunt id est. Aliquip labore ex sit culpa aliqua ex occaecat aliquip voluptate non labore culpa irure. Consequat tempor consequat laboris sint nulla commodo sit. Est velit dolor ut quis veniam aliqua amet dolore mollit labore. Magna commodo deserunt anim est velit laboris. Commodo sunt sit qui eu mollit eu esse excepteur ea sit incididunt.\r\n",
- "registered": "1996-08-30T07:13:22 +04:00",
- "latitude": 76.747258,
- "longitude": -114.875056,
- "tags": [
- "ut",
- "esse",
- "reprehenderit",
- "aute",
- "laborum",
- "esse",
- "dolore"
- ],
- "friends": [
- {
- "id": 0,
- "name": "Spencer Hurley"
- },
- {
- "id": 1,
- "name": "Adrienne Griffith"
- },
- {
- "id": 2,
- "name": "Peck Haley"
- }
- ],
- "randomArrayItem": "apple"
- }
-]
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/query/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/query/pom.xml b/stack/corepersistence/query/pom.xml
new file mode 100644
index 0000000..d4bff43
--- /dev/null
+++ b/stack/corepersistence/query/pom.xml
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <properties>
+ <guice.version>3.0</guice.version>
+ <guicyfig.version>3.3</guicyfig.version>
+ <slf4j.version>1.7.2</slf4j.version>
+ <log4j.version>1.2.17</log4j.version>
+ <chop.version>1.0</chop.version>
+ </properties>
+
+ <parent>
+ <artifactId>persistence</artifactId>
+ <groupId>org.apache.usergrid</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <description>Module provates query for Entities via ElasticSearch</description>
+
+ <artifactId>query</artifactId>
+
+ <build>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.safehaus.chop</groupId>
+ <artifactId>chop-maven-plugin</artifactId>
+ <version>${chop.version}</version>
+
+ <!--
+ NOTE: you should be putting most of these variables into your settings.xml
+ as an automatically activated profile.
+ -->
+
+ <configuration>
+ <accessKey>${aws.s3.key}</accessKey>
+ <secretKey>${aws.s3.secret}</secretKey>
+ <availabilityZone>${availabilityZone}</availabilityZone>
+ <bucketName>${aws.s3.bucket}</bucketName>
+ <managerAppUsername>admin</managerAppUsername>
+ <managerAppPassword>${manager.app.password}</managerAppPassword>
+ <testPackageBase>org.apache.usergrid</testPackageBase>
+ <runnerSSHKeyFile>${runner.ssh.key.file}</runnerSSHKeyFile>
+ <failIfCommitNecessary>false</failIfCommitNecessary>
+ <amiID>${ami.id}</amiID>
+ <instanceType>m1.large</instanceType>
+ <resultsDirectory>${resultsDirectory}</resultsDirectory>
+ <dumpType>${dumpType}</dumpType>
+ <coldRestartTomcat>true</coldRestartTomcat>
+ <awsSecurityGroup>${security.group}</awsSecurityGroup>
+ <runnerKeyPairName>${runner.keypair.name}</runnerKeyPairName>
+ <runnerCount>6</runnerCount>
+ <securityGroupExceptions>
+ <!--
+ Add your own IP address as an exception to allow access
+ but please do this in the settings.xml file .. essentially
+ all parameters should be in the settings.xml file.
+ -->
+ <param>${myip.address}/32:24981</param>
+ <param>${myip.address}/32:22</param>
+ </securityGroupExceptions>
+ </configuration>
+ </plugin>
+
+<!-- <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <check>
+ <branchRate>85</branchRate>
+ <lineRate>85</lineRate>
+ <haltOnFailure>true</haltOnFailure>
+ <totalBranchRate>85</totalBranchRate>
+ <totalLineRate>85</totalLineRate>
+ <packageLineRate>85</packageLineRate>
+ <packageBranchRate>85</packageBranchRate>
+ </check>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>clean</goal>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>-->
+
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr3-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <configuration>
+ <outputDirectory>src/main/java</outputDirectory>
+ </configuration>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.safehaus.chop</groupId>
+ <artifactId>chop-api</artifactId>
+ <version>${chop.version}</version>
+ </dependency>
+
+ <!-- Google Guice Integration Test Injectors -->
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.elasticsearch</groupId>
+ <artifactId>elasticsearch</artifactId>
+ <version>1.0.0.RC1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.safehaus.guicyfig</groupId>
+ <artifactId>guicyfig</artifactId>
+ <version>${guicyfig.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jukito</groupId>
+ <artifactId>jukito</artifactId>
+ <version>${jukito.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- lang utils for setting uuids etc -->
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <!-- Google Guice -->
+
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <version>${guice.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>model</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.6</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-smile</artifactId>
+ <version>1.9.13</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
+ <version>3.5</version>
+ <type>jar</type>
+ </dependency>
+
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/query/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/query/src/test/resources/log4j.properties b/stack/corepersistence/query/src/test/resources/log4j.properties
new file mode 100644
index 0000000..75bbc31
--- /dev/null
+++ b/stack/corepersistence/query/src/test/resources/log4j.properties
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# for production, you should probably set the root to INFO
+# and the pattern to %c instead of %l. (%l is slower.)
+
+# output messages into a rolling log file as well as stdout
+log4j.rootLogger=INFO,stdout
+
+# stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) [%c] - %m%n
+
+log4j.category.org.apache=ERROR
+log4j.category.org.apache.usergrid=INFO
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/pom.xml b/stack/corepersistence/queryindex/pom.xml
new file mode 100644
index 0000000..87a7ebf
--- /dev/null
+++ b/stack/corepersistence/queryindex/pom.xml
@@ -0,0 +1,228 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>queryindex</name>
+ <artifactId>queryindex</artifactId>
+ <description>Module provates indexing and query of Entities via ElasticSearch</description>
+
+ <properties>
+ <guice.version>3.0</guice.version>
+ <guicyfig.version>3.3</guicyfig.version>
+ <slf4j.version>1.7.2</slf4j.version>
+ <log4j.version>1.2.17</log4j.version>
+ <chop.version>1.0</chop.version>
+ </properties>
+
+ <parent>
+ <artifactId>persistence</artifactId>
+ <groupId>org.apache.usergrid</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <build>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.safehaus.chop</groupId>
+ <artifactId>chop-maven-plugin</artifactId>
+ <version>${chop.version}</version>
+
+ <!--
+ NOTE: you should be putting most of these variables into your settings.xml
+ as an automatically activated profile.
+ -->
+
+ <configuration>
+ <accessKey>${aws.s3.key}</accessKey>
+ <secretKey>${aws.s3.secret}</secretKey>
+ <availabilityZone>${availabilityZone}</availabilityZone>
+ <bucketName>${aws.s3.bucket}</bucketName>
+ <managerAppUsername>admin</managerAppUsername>
+ <managerAppPassword>${manager.app.password}</managerAppPassword>
+ <testPackageBase>org.apache.usergrid</testPackageBase>
+ <runnerSSHKeyFile>${runner.ssh.key.file}</runnerSSHKeyFile>
+ <failIfCommitNecessary>false</failIfCommitNecessary>
+ <amiID>${ami.id}</amiID>
+ <instanceType>m1.large</instanceType>
+ <resultsDirectory>${resultsDirectory}</resultsDirectory>
+ <dumpType>${dumpType}</dumpType>
+ <coldRestartTomcat>true</coldRestartTomcat>
+ <awsSecurityGroup>${security.group}</awsSecurityGroup>
+ <runnerKeyPairName>${runner.keypair.name}</runnerKeyPairName>
+ <runnerCount>6</runnerCount>
+ <securityGroupExceptions>
+ <!--
+ Add your own IP address as an exception to allow access
+ but please do this in the settings.xml file .. essentially
+ all parameters should be in the settings.xml file.
+ -->
+ <param>${myip.address}/32:24981</param>
+ <param>${myip.address}/32:22</param>
+ </securityGroupExceptions>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <check>
+ <branchRate>85</branchRate>
+ <lineRate>85</lineRate>
+ <haltOnFailure>true</haltOnFailure>
+ <totalBranchRate>85</totalBranchRate>
+ <totalLineRate>85</totalLineRate>
+ <packageLineRate>85</packageLineRate>
+ <packageBranchRate>85</packageBranchRate>
+ </check>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>clean</goal>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>model</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>collection</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.safehaus.chop</groupId>
+ <artifactId>chop-api</artifactId>
+ <version>${chop.version}</version>
+ </dependency>
+
+ <!-- Google Guice Integration Test Injectors -->
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.elasticsearch</groupId>
+ <artifactId>elasticsearch</artifactId>
+ <version>1.0.0.RC1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.safehaus.guicyfig</groupId>
+ <artifactId>guicyfig</artifactId>
+ <version>${guicyfig.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jukito</groupId>
+ <artifactId>jukito</artifactId>
+ <version>${jukito.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- lang utils for setting uuids etc -->
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ <!-- Google Guice -->
+
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <version>${guice.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.6</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-smile</artifactId>
+ <version>1.9.13</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
+ <version>3.5</version>
+ <type>jar</type>
+ </dependency>
+
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/query/tree/QueryFilter.g
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/query/tree/QueryFilter.g b/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/query/tree/QueryFilter.g
new file mode 100644
index 0000000..c566ef9
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/query/tree/QueryFilter.g
@@ -0,0 +1,311 @@
+grammar QueryFilter;
+//NOTES: '^' denotes operator, all others in the string become operands
+
+options {
+ output=AST;
+// ASTLabelType=CommonTree;
+}
+
+@rulecatch { }
+
+
+@header {
+package org.apache.usergrid.persistence.query.tree;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.SortPredicate;
+
+}
+
+
+@members {
+ Query query = new Query();
+
+ private static final Logger logger = LoggerFactory
+ .getLogger(QueryFilterLexer.class);
+
+ @Override
+ public void emitErrorMessage(String msg) {
+ logger.info(msg);
+ }
+}
+
+
+@lexer::header {
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.usergrid.persistence.exceptions.QueryTokenException;
+
+}
+
+@lexer::members {
+
+
+
+ private static final Logger logger = LoggerFactory
+ .getLogger(QueryFilterLexer.class);
+
+
+
+
+ @Override
+ public void emitErrorMessage(String msg) {
+ logger.info(msg);
+ }
+
+ @Override
+ public void recover(RecognitionException e) {
+ //We don't want to recover, we want to re-throw to the user since they passed us invalid input
+ throw new QueryTokenException(e);
+ }
+
+
+}
+
+//these must come before ID. Otherwise lt, lte, eq, etc will be returned as id tokens
+LT : '<' | 'lt';
+
+LTE : '<=' | 'lte';
+
+EQ : '=' | 'eq';
+
+GT : '>' | 'gt';
+
+GTE : '>=' | 'gte';
+
+
+//keywords before var ids
+BOOLEAN : (TRUE|FALSE);
+
+AND : ('A'|'a')('N'|'n')('D'|'d') | '&&';
+
+OR : ('O'|'o')('R'|'r') | '||' ;
+
+NOT : ('N'|'n')('O'|'o')('T'|'t');
+
+ASC : ('A'|'a')('S'|'s')('C'|'c');
+
+DESC : ('D'|'d')('E'|'e')('S'|'s')('C'|'c');
+
+CONTAINS : ('C'|'c')('O'|'o')('N'|'n')('T'|'t')('A'|'a')('I'|'i')('N'|'n')('S'|'s');
+
+WITHIN : ('W'|'w')('I'|'i')('T'|'t')('H'|'h')('I'|'i')('N'|'n');
+
+OF : ('O'|'o')('F'|'f');
+
+UUID : HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ ;
+
+//ids and values
+ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'.'|'-')*
+ ;
+
+LONG : ('-')? '0'..'9'+
+ ;
+
+FLOAT
+ : ('-')? ( ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
+ | '.' ('0'..'9')+ EXPONENT?
+ | ('0'..'9')+ EXPONENT)
+ ;
+
+STRING
+ : '\'' ( ESC_SEQ | ~('\\'|'\'') )* '\''
+ ;
+
+
+
+WS : (' ' | '\t' | '\n' | '\r' | '\f')+ {$channel=HIDDEN;};
+
+
+
+
+
+
+
+fragment TRUE : ('T'|'t')('R'|'r')('U'|'u')('E'|'e');
+
+fragment FALSE : ('F'|'f')('A'|'a')('L'|'l')('S'|'s')('E'|'e');
+
+
+fragment
+EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
+
+fragment
+HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
+
+fragment
+ESC_SEQ
+ : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+ | UNICODE_ESC
+ | OCTAL_ESC
+ ;
+
+fragment
+OCTAL_ESC
+ : '\\' ('0'..'3') ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7')
+ ;
+
+fragment
+UNICODE_ESC
+ : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ ;
+
+
+
+
+//NE : '!=';
+
+
+
+property : ID<Property>;
+
+containsproperty : ID<ContainsProperty>;
+
+withinproperty : ID<WithinProperty>;
+
+booleanliteral: BOOLEAN<BooleanLiteral>;
+
+
+longliteral :
+ LONG<LongLiteral> ;
+
+uuidliteral :
+ UUID<UUIDLiteral>;
+
+stringliteral :
+ STRING<StringLiteral>;
+
+floatliteral :
+ FLOAT<FloatLiteral> ;
+
+//We delegate to each sub class literal so we can get each type
+value :
+ booleanliteral
+ | longliteral
+ | uuidliteral
+ | stringliteral
+ | floatliteral
+ ;
+
+
+
+//Every operand returns with the name of 'op'. This is used because all subtrees require operands,
+//this allows us to link the java code easily by using the same name as a converntion
+
+//begin search expressions
+
+//mathmatical equality operations
+equalityop :
+ property LT<LessThan>^ value
+ |property LTE<LessThanEqual>^ value
+ |property EQ<Equal>^ value
+ |property GT<GreaterThan>^ value
+ |property GTE<GreaterThanEqual>^ value
+ ;
+
+//geo location search
+locationop :
+ withinproperty WITHIN<WithinOperand>^ (floatliteral|longliteral) OF! (floatliteral|longliteral) ','! (floatliteral|longliteral);
+
+//string search
+containsop :
+ containsproperty CONTAINS<ContainsOperand>^ stringliteral;
+
+//
+operation :
+ '('! expression ')'!
+ | equalityop
+ | locationop
+ | containsop
+ ;
+
+//negations of expressions
+notexp :
+//only link if we have the not
+ NOT<NotOperand>^ operation
+ |operation
+ ;
+
+//and expressions contain operands. These should always be closer to the leaves of a tree, it allows
+//for faster result intersection sooner in the query execution
+andexp :
+ notexp (AND<AndOperand>^ notexp )*;
+
+
+//or expression should always be after AND expressions. This will give us a smaller result set to union when evaluating trees
+//also a root level expression
+expression :
+ andexp (OR<OrOperand>^ andexp )*;
+
+
+
+//end expressions
+
+//begin order clauses
+
+//direction for ordering
+direction : (ASC | DESC);
+
+//order clause
+order
+ : (property direction?){
+ String property = $property.text;
+ String direction = $direction.text;
+ query.addSort(new SortPredicate(property, direction));
+
+ };
+
+//end order clauses
+
+//Begin select clauses
+
+select_subject
+ : ID {
+
+ query.addSelect($ID.text);
+
+};
+
+
+
+select_assign
+ : target=ID ':' source=ID {
+
+ query.addSelect($target.text, $source.text);
+
+};
+
+select_expr
+ : ('*' | select_subject (',' select_subject) * | '{' select_assign (',' select_assign) * '}');
+
+//end select clauses
+
+ql returns [Query query]
+ : ('select'! select_expr!)? ('where'!? expression)? ('order by'! order! (','! order!)*)? {
+
+ if($expression.tree instanceof Operand){
+ query.setRootOperand((Operand)$expression.tree);
+ }
+
+ retval.query = query;
+
+
+};
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/QueryFilter.tokens
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/QueryFilter.tokens b/stack/corepersistence/queryindex/src/main/java/QueryFilter.tokens
new file mode 100644
index 0000000..53a0817
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/QueryFilter.tokens
@@ -0,0 +1,47 @@
+T__31=31
+T__32=32
+T__33=33
+T__34=34
+T__35=35
+T__36=36
+T__37=37
+T__38=38
+T__39=39
+T__40=40
+AND=4
+ASC=5
+BOOLEAN=6
+CONTAINS=7
+DESC=8
+EQ=9
+ESC_SEQ=10
+EXPONENT=11
+FALSE=12
+FLOAT=13
+GT=14
+GTE=15
+HEX_DIGIT=16
+ID=17
+LONG=18
+LT=19
+LTE=20
+NOT=21
+OCTAL_ESC=22
+OF=23
+OR=24
+STRING=25
+TRUE=26
+UNICODE_ESC=27
+UUID=28
+WITHIN=29
+WS=30
+'('=31
+')'=32
+'*'=33
+','=34
+':'=35
+'order by'=36
+'select'=37
+'where'=38
+'{'=39
+'}'=40
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/ApplicationAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/ApplicationAlreadyExistsException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/ApplicationAlreadyExistsException.java
new file mode 100644
index 0000000..788f9a2
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/ApplicationAlreadyExistsException.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class ApplicationAlreadyExistsException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String applicationName;
+
+
+ public ApplicationAlreadyExistsException( String applicationName ) {
+ super( "Application " + applicationName + " already exists" );
+ this.applicationName = applicationName;
+ }
+
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/DuplicateUniquePropertyExistsException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/DuplicateUniquePropertyExistsException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/DuplicateUniquePropertyExistsException.java
new file mode 100644
index 0000000..7687dea
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/DuplicateUniquePropertyExistsException.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class DuplicateUniquePropertyExistsException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+ final Object propertyValue;
+
+
+ public DuplicateUniquePropertyExistsException( String entityType, String propertyName, Object propertyValue ) {
+ super( "Entity " + entityType + " requires that property named " + propertyName + " be unique, value of "
+ + propertyValue + " exists" );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ this.propertyValue = propertyValue;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+
+ public Object getPropertyValue() {
+ return propertyValue;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/EntityNotFoundException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/EntityNotFoundException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/EntityNotFoundException.java
new file mode 100644
index 0000000..385f69b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/EntityNotFoundException.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class EntityNotFoundException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3579346096812510039L;
+
+
+ public EntityNotFoundException() {
+ super();
+ }
+
+
+ public EntityNotFoundException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public EntityNotFoundException( String message ) {
+ super( message );
+ }
+
+
+ public EntityNotFoundException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonReadException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonReadException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonReadException.java
new file mode 100644
index 0000000..1f4cb5d
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonReadException.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class JsonReadException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+
+ public JsonReadException( String msg, Throwable t ) {
+ super( msg, t );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonWriteException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonWriteException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonWriteException.java
new file mode 100644
index 0000000..22cf563
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonWriteException.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class JsonWriteException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+
+ public JsonWriteException( String msg, Throwable t ) {
+ super( msg, t );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/LockingException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/LockingException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/LockingException.java
new file mode 100644
index 0000000..7d01114
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/LockingException.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+/**
+ *
+ */
+package org.apache.usergrid.persistence.exceptions;
+
+
+/** General Exception for locking related operations. */
+public class LockingException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1630572186589575754L;
+
+
+ /**
+ *
+ */
+ public LockingException() {
+ // TODO Auto-generated constructor stub
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public LockingException( String arg0 ) {
+ super( arg0 );
+ // TODO Auto-generated constructor stub
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public LockingException( Throwable arg0 ) {
+ super( arg0 );
+ // TODO Auto-generated constructor stub
+ }
+
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public LockingException( String arg0, Throwable arg1 ) {
+ super( arg0, arg1 );
+ // TODO Auto-generated constructor stub
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java
new file mode 100644
index 0000000..793f623
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * Thrown when the user attempts to perform a "contains" operation on a field that isn't full text indexed
+ *
+ * @author tnine
+ */
+public class NoFullTextIndexException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+
+
+ public NoFullTextIndexException( String entityType, String propertyName ) {
+ super( "Entity '" + entityType + "' with property named '" + propertyName
+ + "' is not full text indexed. You cannot use the 'contains' operand on this field" );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java
new file mode 100644
index 0000000..2ee5107
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * Thrown when the user attempts to perform a "contains" operation on a field that isn't full text indexed
+ *
+ * @author tnine
+ */
+public class NoIndexException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+
+
+ public NoIndexException( String entityType, String propertyName ) {
+ super( "Entity '" + entityType + "' with property named '" + propertyName
+ + "' is not indexed. You cannot use the this field in queries." );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NotImplementedException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NotImplementedException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NotImplementedException.java
new file mode 100644
index 0000000..52ee71e
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NotImplementedException.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class NotImplementedException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ *
+ */
+ public NotImplementedException() {
+ super();
+ }
+
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public NotImplementedException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ /**
+ * @param message
+ */
+ public NotImplementedException( String message ) {
+ super( message );
+ }
+
+
+ /**
+ * @param cause
+ */
+ public NotImplementedException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java
new file mode 100644
index 0000000..dff5c8a
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class PersistenceException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ public PersistenceException() {
+ super();
+ }
+
+
+ public PersistenceException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public PersistenceException( String message ) {
+ super( message );
+ }
+
+
+ public PersistenceException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PropertyTypeConversionException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PropertyTypeConversionException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PropertyTypeConversionException.java
new file mode 100644
index 0000000..90234e5
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PropertyTypeConversionException.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class PropertyTypeConversionException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+ final Object propertyValue;
+ final Class<?> propertyType;
+
+
+ public PropertyTypeConversionException( String entityType, String propertyName, Object propertyValue,
+ Class<?> propertyType ) {
+ super( "Unable to convert property \"" + propertyName + "\" of entity \"" + entityType
+ + "\" from value of type " + propertyValue.getClass() + " to value of type " + propertyType );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ this.propertyValue = propertyValue;
+ this.propertyType = propertyType;
+ }
+
+
+ public PropertyTypeConversionException( String entityType, String propertyName, Object propertyValue,
+ Class<?> propertyType, Throwable cause ) {
+ super( "Unable to convert property \"" + propertyName + "\" of entity \"" + entityType
+ + "\" from value of type " + propertyValue.getClass() + " to value of type " + propertyType, cause );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ this.propertyValue = propertyValue;
+ this.propertyType = propertyType;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+
+ public Object getPropertyValue() {
+ return propertyValue;
+ }
+
+
+ public Class<?> getPropertyType() {
+ return propertyType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryIterationException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryIterationException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryIterationException.java
new file mode 100644
index 0000000..1acc76a
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryIterationException.java
@@ -0,0 +1,13 @@
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * Thrown when an error occurs during query iteration
+ *
+ * @author tnine
+ */
+public class QueryIterationException extends RuntimeException {
+ public QueryIterationException( final String message ) {
+ super( message );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java
new file mode 100644
index 0000000..d53144f
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * An exception thrown when a query cannot be parsed
+ *
+ * @author tnine
+ */
+public class QueryParseException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ *
+ */
+ public QueryParseException() {
+ super();
+ }
+
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public QueryParseException( String arg0, Throwable arg1 ) {
+ super( arg0, arg1 );
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueryParseException( String arg0 ) {
+ super( arg0 );
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueryParseException( Throwable arg0 ) {
+ super( arg0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java
new file mode 100644
index 0000000..72f158a
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+/**
+ * An exception thrown when a query encounters a token it doesn't recognize
+ * @author tnine
+ */
+public class QueryTokenException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+
+
+ /**
+ * @param arg0
+ */
+ public QueryTokenException( Throwable arg0 ) {
+ super( arg0 );
+ }
+
+
+ @Override
+ public String getMessage() {
+ //antlr errors or strange. We have to do this, there's no message
+ return getCause().toString();
+ }
+
+
+ @Override
+ public String getLocalizedMessage() {
+ return getMessage();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueueException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueueException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueueException.java
new file mode 100644
index 0000000..07889a6
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueueException.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+/**
+ *
+ */
+package org.apache.usergrid.persistence.exceptions;
+
+
+/** General Exception for queue related operations. */
+public class QueueException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1630572186589575754L;
+
+
+ /**
+ *
+ */
+ public QueueException() {
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueueException( String arg0 ) {
+ super( arg0 );
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueueException( Throwable arg0 ) {
+ super( arg0 );
+ }
+
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public QueueException( String arg0, Throwable arg1 ) {
+ super( arg0, arg1 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/RequiredPropertyNotFoundException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/RequiredPropertyNotFoundException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/RequiredPropertyNotFoundException.java
new file mode 100644
index 0000000..850c925
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/RequiredPropertyNotFoundException.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class RequiredPropertyNotFoundException extends PersistenceException {
+
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+
+
+ public RequiredPropertyNotFoundException( String entityType, String propertyName ) {
+ super( "Entity " + entityType + " requires a property named " + propertyName );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/TransactionNotFoundException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/TransactionNotFoundException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/TransactionNotFoundException.java
new file mode 100644
index 0000000..21bc13e
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/TransactionNotFoundException.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class TransactionNotFoundException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3579346096812510039L;
+
+
+ public TransactionNotFoundException() {
+ super();
+ }
+
+
+ public TransactionNotFoundException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public TransactionNotFoundException( String message ) {
+ super( message );
+ }
+
+
+ public TransactionNotFoundException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/UnexpectedEntityTypeException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/UnexpectedEntityTypeException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/UnexpectedEntityTypeException.java
new file mode 100644
index 0000000..7f59830
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/UnexpectedEntityTypeException.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.exceptions;
+
+
+public class UnexpectedEntityTypeException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8221919267880904834L;
+
+
+ public UnexpectedEntityTypeException() {
+ super();
+ }
+
+
+ public UnexpectedEntityTypeException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public UnexpectedEntityTypeException( String message ) {
+ super( message );
+ }
+
+
+ public UnexpectedEntityTypeException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
new file mode 100644
index 0000000..4652f81
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.persistence.index;
+
+import org.apache.usergrid.persistence.model.entity.Entity;
+
+
+/**
+ * Provides indexing of Entities within a scope.
+ */
+public interface EntityCollectionIndex {
+
+ /**
+ * Create index for Entity
+ * @param entity Entity to be indexed.
+ */
+ public void index( Entity entity );
+
+ /**
+ * Remove index of entity.
+ * @param entity Entity to be removed from index.
+ */
+ public void deindex( Entity entity );
+
+ /**
+ * Simple query interface for testing using Lucene query syntax.
+ */
+ public EntitySearchResults simpleQuery( String query, int from, int size );
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntitySearchResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntitySearchResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntitySearchResults.java
new file mode 100644
index 0000000..03e91d9
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntitySearchResults.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.persistence.index;
+
+import java.util.List;
+import java.util.UUID;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+
+/**
+ * Search results are Id and Version references to Entities.
+ */
+public class EntitySearchResults {
+ private final long count;
+ private final List<Ref> refs;
+
+ public EntitySearchResults( long count, List<Ref> refs ) {
+ this.count = count;
+ this.refs = refs;
+ }
+
+ public long count() {
+ return count;
+ }
+
+ public List<Ref> getRefs() {
+ return refs;
+ }
+
+ /**
+ * Reference to one specific version of an Entity.
+ */
+ public static final class Ref {
+ private Id id;
+ private UUID version;
+
+ public Ref( Id id, UUID version ) {
+ this.id = id;
+ this.version = version;
+ }
+ public Id getId() {
+ return id;
+ }
+ public UUID getVersion() {
+ return version;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
new file mode 100644
index 0000000..c009a66
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
@@ -0,0 +1,272 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.index.EntityCollectionIndex;
+import org.apache.usergrid.persistence.index.EntitySearchResults;
+import org.apache.usergrid.persistence.index.EntitySearchResults.Ref;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.field.ArrayField;
+import org.apache.usergrid.persistence.model.field.EntityObjectField;
+import org.apache.usergrid.persistence.model.field.Field;
+import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.SetField;
+import org.apache.usergrid.persistence.model.field.StringField;
+import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
+import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest;
+import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
+import org.elasticsearch.action.index.IndexRequestBuilder;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.AdminClient;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+import org.elasticsearch.index.query.QueryStringQueryBuilder;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.SearchHits;
+
+
+public class EntityCollectionIndexImpl implements EntityCollectionIndex {
+ private final Client client;
+ private final String index;
+ private final boolean refresh;
+ private final CollectionScope scope;
+
+ public static final String STRING_FIELD_SUFFIX = "_ug_analyzed";
+
+
+ public EntityCollectionIndexImpl( Client client, String index, CollectionScope scope, boolean refresh ) {
+ this.client = client;
+ this.index = index;
+ this.scope = scope;
+ this.refresh = refresh;
+
+ // if new index then create it
+ AdminClient admin = client.admin();
+ if ( !admin.indices().exists( new IndicesExistsRequest( index )).actionGet().isExists() ) {
+ admin.indices().prepareCreate( index ).execute().actionGet();
+ }
+
+ // if new type then create mapping
+ if ( !admin.indices().typesExists( new TypesExistsRequest(
+ new String[] {index}, scope.getName() )).actionGet().isExists()) {
+
+ try {
+ XContentBuilder mxcb = EntityCollectionIndexImpl
+ .createDoubleStringIndexMapping( jsonBuilder(), scope.getName() );
+
+ PutMappingResponse pmr = admin.indices().preparePutMapping(index)
+ .setType( scope.getName() ).setSource( mxcb ).execute().actionGet();
+
+ } catch ( IOException ex ) {
+ throw new RuntimeException("Error adding mapping for type " + scope.getName(), ex );
+ }
+ }
+ }
+
+
+ public void index( Entity entity ) {
+
+ Map<String, Object> entityAsMap = EntityCollectionIndexImpl.entityToMap( entity );
+
+ IndexRequestBuilder irb = client.prepareIndex(index, scope.getName(), createIndexId( entity ))
+ .setSource( entityAsMap )
+ .setRefresh( refresh );
+
+ // Cannot set version. As far as I can tell ES insists that initial version number is -1
+ // and that number is incremented by 1 on each update.
+ // irb = irb.setVersion( entity.getVersion().timestamp() );
+
+ IndexResponse ir = irb.execute().actionGet();
+ }
+
+
+ private String createIndexId( Entity entity ) {
+ return entity.getId().getUuid().toString() + "|"
+ + entity.getId().getType() + "|"
+ + entity.getVersion().toString();
+ }
+
+
+ public void deindex( Entity entity ) {
+ String compositeId = entity.getId().toString() + "|" + entity.getVersion().toString();
+ client.prepareDelete( index, scope.getName(), compositeId).execute().actionGet();
+ }
+
+
+ public EntitySearchResults simpleQuery( String query, int from, int size ) {
+
+ QueryStringQueryBuilder builder = new QueryStringQueryBuilder( query );
+
+ SearchResponse sr = client.prepareSearch( index ).setTypes( scope.getName() )
+ .setQuery( builder ).setFrom( from ).setSize( size ).execute().actionGet();
+
+ List<Ref> refs = new ArrayList<Ref>();
+ SearchHits hits = sr.getHits();
+
+ for ( SearchHit hit : hits.getHits() ) {
+
+ String[] idparts = hit.getId().split( "\\|" );
+ String id = idparts[0];
+ String type = idparts[1];
+ String version = idparts[2];
+
+ Ref ref = new Ref( new SimpleId( UUID.fromString(id), type), UUID.fromString(version));
+ refs.add( ref );
+ }
+
+ EntitySearchResults results = new EntitySearchResults( sr.getHits().getTotalHits(), refs );
+ return results;
+ }
+
+
+ /**
+ * Convert Entity to Map, adding version_ug_field and a {name}_ug_analyzed field for each StringField.
+ */
+ public static Map entityToMap( Entity entity ) {
+
+ Map<String, Object> entityMap = new HashMap<String, Object>();
+
+ for ( Object f : entity.getFields().toArray() ) {
+
+ if ( f instanceof ListField || f instanceof ArrayField ) {
+ Field field = (Field)f;
+ List list = (List)field.getValue();
+ entityMap.put( field.getName(),
+ new ArrayList( processCollectionForMap( list ) ) );
+
+ } else if ( f instanceof SetField ) {
+ Field field = (Field)f;
+ Set set = (Set)field.getValue();
+ entityMap.put( field.getName(),
+ new ArrayList( processCollectionForMap( set ) ) );
+
+ } else if ( f instanceof EntityObjectField ) {
+ Field field = (Field)f;
+ Entity ev = (Entity)field.getValue();
+ entityMap.put( field.getName(), entityToMap( ev ) ); // recursion
+
+ } else if ( f instanceof StringField ) {
+ Field field = (Field)f;
+ entityMap.put( field.getName(), field.getValue() );
+ entityMap.put( field.getName() + STRING_FIELD_SUFFIX, field.getValue() );
+
+ } else {
+ Field field = (Field)f;
+ entityMap.put( field.getName(), field.getValue() );
+ }
+ }
+
+ return entityMap;
+ }
+
+
+ private static Collection processCollectionForMap( Collection c ) {
+ if ( c.isEmpty() ) {
+ return c;
+ }
+ List processed = new ArrayList();
+ Object sample = c.iterator().next();
+
+ if ( sample instanceof Entity ) {
+ for ( Object o : c.toArray() ) {
+ Entity e = (Entity)o;
+ processed.add( entityToMap( e ) );
+ }
+
+ } else if ( sample instanceof List ) {
+ for ( Object o : c.toArray() ) {
+ List list = (List)o;
+ processed.add( processCollectionForMap( list ) ); // recursion;
+ }
+
+ } else if ( sample instanceof Set ) {
+ for ( Object o : c.toArray() ) {
+ Set set = (Set)o;
+ processed.add( processCollectionForMap( set ) ); // recursion;
+ }
+
+ } else {
+ for ( Object o : c.toArray() ) {
+ processed.add( o );
+ }
+ }
+ return processed;
+ }
+
+
+ /**
+ * Build mappings for data to be indexed. Setup String fields as not_analyzed and analyzed,
+ * where the analyzed field is named {name}_ug_analyzed
+ *
+ * @param builder Add JSON object to this builder.
+ * @param type ElasticSearch type of entity.
+ * @return Content builder with JSON for mapping.
+ *
+ * @throws java.io.IOException On JSON generation error.
+ */
+ public static XContentBuilder createDoubleStringIndexMapping(
+ XContentBuilder builder, String type ) throws IOException {
+
+ builder = builder
+ .startObject()
+ .startObject( type )
+ .startArray( "dynamic_templates" )
+
+ // any string with field name that ends with _ug_analyzed gets analyzed
+ .startObject()
+ .startObject( "template_1" )
+ .field( "match", "*" + STRING_FIELD_SUFFIX)
+ .field( "match_mapping_type", "string")
+ .startObject( "mapping" )
+ .field( "type", "string" )
+ .field( "index", "analyzed" )
+ .endObject()
+ .endObject()
+ .endObject()
+
+ // all other strings are not analyzed
+ .startObject()
+ .startObject( "template_2" )
+ .field( "match", "*")
+ .field( "match_mapping_type", "string")
+ .startObject( "mapping" )
+ .field( "type", "string" )
+ .field( "index", "not_analyzed" )
+ .endObject()
+ .endObject()
+ .endObject()
+
+ .endArray()
+ .endObject()
+ .endObject();
+
+ return builder;
+ }
+}
[09/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
new file mode 100644
index 0000000..40eda7b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterLexer.java
@@ -0,0 +1,2565 @@
+// $ANTLR 3.5.1 org/apache/usergrid/persistence/query/tree/QueryFilter.g 2014-02-21 08:18:25
+
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.usergrid.persistence.exceptions.QueryTokenException;
+
+
+
+import org.antlr.runtime.*;
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+
+@SuppressWarnings("all")
+public class QueryFilterLexer extends Lexer {
+ public static final int EOF=-1;
+ public static final int T__31=31;
+ public static final int T__32=32;
+ public static final int T__33=33;
+ public static final int T__34=34;
+ public static final int T__35=35;
+ public static final int T__36=36;
+ public static final int T__37=37;
+ public static final int T__38=38;
+ public static final int T__39=39;
+ public static final int T__40=40;
+ public static final int AND=4;
+ public static final int ASC=5;
+ public static final int BOOLEAN=6;
+ public static final int CONTAINS=7;
+ public static final int DESC=8;
+ public static final int EQ=9;
+ public static final int ESC_SEQ=10;
+ public static final int EXPONENT=11;
+ public static final int FALSE=12;
+ public static final int FLOAT=13;
+ public static final int GT=14;
+ public static final int GTE=15;
+ public static final int HEX_DIGIT=16;
+ public static final int ID=17;
+ public static final int LONG=18;
+ public static final int LT=19;
+ public static final int LTE=20;
+ public static final int NOT=21;
+ public static final int OCTAL_ESC=22;
+ public static final int OF=23;
+ public static final int OR=24;
+ public static final int STRING=25;
+ public static final int TRUE=26;
+ public static final int UNICODE_ESC=27;
+ public static final int UUID=28;
+ public static final int WITHIN=29;
+ public static final int WS=30;
+
+
+
+
+ private static final Logger logger = LoggerFactory
+ .getLogger(QueryFilterLexer.class);
+
+
+
+
+ @Override
+ public void emitErrorMessage(String msg) {
+ logger.info(msg);
+ }
+
+ @Override
+ public void recover(RecognitionException e) {
+ //We don't want to recover, we want to re-throw to the user since they passed us invalid input
+ throw new QueryTokenException(e);
+ }
+
+
+
+
+ // delegates
+ // delegators
+ public Lexer[] getDelegates() {
+ return new Lexer[] {};
+ }
+
+ public QueryFilterLexer() {}
+ public QueryFilterLexer(CharStream input) {
+ this(input, new RecognizerSharedState());
+ }
+ public QueryFilterLexer(CharStream input, RecognizerSharedState state) {
+ super(input,state);
+ }
+ @Override public String getGrammarFileName() { return "org/apache/usergrid/persistence/query/tree/QueryFilter.g"; }
+
+ // $ANTLR start "T__31"
+ public final void mT__31() throws RecognitionException {
+ try {
+ int _type = T__31;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:35:7: ( '(' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:35:9: '('
+ {
+ match('(');
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__31"
+
+ // $ANTLR start "T__32"
+ public final void mT__32() throws RecognitionException {
+ try {
+ int _type = T__32;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:36:7: ( ')' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:36:9: ')'
+ {
+ match(')');
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__32"
+
+ // $ANTLR start "T__33"
+ public final void mT__33() throws RecognitionException {
+ try {
+ int _type = T__33;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:37:7: ( '*' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:37:9: '*'
+ {
+ match('*');
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__33"
+
+ // $ANTLR start "T__34"
+ public final void mT__34() throws RecognitionException {
+ try {
+ int _type = T__34;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:38:7: ( ',' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:38:9: ','
+ {
+ match(',');
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__34"
+
+ // $ANTLR start "T__35"
+ public final void mT__35() throws RecognitionException {
+ try {
+ int _type = T__35;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:39:7: ( ':' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:39:9: ':'
+ {
+ match(':');
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__35"
+
+ // $ANTLR start "T__36"
+ public final void mT__36() throws RecognitionException {
+ try {
+ int _type = T__36;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:40:7: ( 'order by' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:40:9: 'order by'
+ {
+ match("order by");
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__36"
+
+ // $ANTLR start "T__37"
+ public final void mT__37() throws RecognitionException {
+ try {
+ int _type = T__37;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:41:7: ( 'select' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:41:9: 'select'
+ {
+ match("select");
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__37"
+
+ // $ANTLR start "T__38"
+ public final void mT__38() throws RecognitionException {
+ try {
+ int _type = T__38;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:42:7: ( 'where' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:42:9: 'where'
+ {
+ match("where");
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__38"
+
+ // $ANTLR start "T__39"
+ public final void mT__39() throws RecognitionException {
+ try {
+ int _type = T__39;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:43:7: ( '{' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:43:9: '{'
+ {
+ match('{');
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__39"
+
+ // $ANTLR start "T__40"
+ public final void mT__40() throws RecognitionException {
+ try {
+ int _type = T__40;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:44:7: ( '}' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:44:9: '}'
+ {
+ match('}');
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "T__40"
+
+ // $ANTLR start "LT"
+ public final void mLT() throws RecognitionException {
+ try {
+ int _type = LT;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:71:5: ( '<' | 'lt' )
+ int alt1=2;
+ int LA1_0 = input.LA(1);
+ if ( (LA1_0=='<') ) {
+ alt1=1;
+ }
+ else if ( (LA1_0=='l') ) {
+ alt1=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 1, 0, input);
+ throw nvae;
+ }
+
+ switch (alt1) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:71:7: '<'
+ {
+ match('<');
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:71:13: 'lt'
+ {
+ match("lt");
+
+ }
+ break;
+
+ }
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "LT"
+
+ // $ANTLR start "LTE"
+ public final void mLTE() throws RecognitionException {
+ try {
+ int _type = LTE;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:73:5: ( '<=' | 'lte' )
+ int alt2=2;
+ int LA2_0 = input.LA(1);
+ if ( (LA2_0=='<') ) {
+ alt2=1;
+ }
+ else if ( (LA2_0=='l') ) {
+ alt2=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 2, 0, input);
+ throw nvae;
+ }
+
+ switch (alt2) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:73:7: '<='
+ {
+ match("<=");
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:73:15: 'lte'
+ {
+ match("lte");
+
+ }
+ break;
+
+ }
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "LTE"
+
+ // $ANTLR start "EQ"
+ public final void mEQ() throws RecognitionException {
+ try {
+ int _type = EQ;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:75:5: ( '=' | 'eq' )
+ int alt3=2;
+ int LA3_0 = input.LA(1);
+ if ( (LA3_0=='=') ) {
+ alt3=1;
+ }
+ else if ( (LA3_0=='e') ) {
+ alt3=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 3, 0, input);
+ throw nvae;
+ }
+
+ switch (alt3) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:75:7: '='
+ {
+ match('=');
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:75:13: 'eq'
+ {
+ match("eq");
+
+ }
+ break;
+
+ }
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "EQ"
+
+ // $ANTLR start "GT"
+ public final void mGT() throws RecognitionException {
+ try {
+ int _type = GT;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:77:5: ( '>' | 'gt' )
+ int alt4=2;
+ int LA4_0 = input.LA(1);
+ if ( (LA4_0=='>') ) {
+ alt4=1;
+ }
+ else if ( (LA4_0=='g') ) {
+ alt4=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 4, 0, input);
+ throw nvae;
+ }
+
+ switch (alt4) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:77:7: '>'
+ {
+ match('>');
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:77:13: 'gt'
+ {
+ match("gt");
+
+ }
+ break;
+
+ }
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "GT"
+
+ // $ANTLR start "GTE"
+ public final void mGTE() throws RecognitionException {
+ try {
+ int _type = GTE;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:79:5: ( '>=' | 'gte' )
+ int alt5=2;
+ int LA5_0 = input.LA(1);
+ if ( (LA5_0=='>') ) {
+ alt5=1;
+ }
+ else if ( (LA5_0=='g') ) {
+ alt5=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 5, 0, input);
+ throw nvae;
+ }
+
+ switch (alt5) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:79:7: '>='
+ {
+ match(">=");
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:79:15: 'gte'
+ {
+ match("gte");
+
+ }
+ break;
+
+ }
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "GTE"
+
+ // $ANTLR start "BOOLEAN"
+ public final void mBOOLEAN() throws RecognitionException {
+ try {
+ int _type = BOOLEAN;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:83:9: ( ( TRUE | FALSE ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:83:11: ( TRUE | FALSE )
+ {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:83:11: ( TRUE | FALSE )
+ int alt6=2;
+ int LA6_0 = input.LA(1);
+ if ( (LA6_0=='T'||LA6_0=='t') ) {
+ alt6=1;
+ }
+ else if ( (LA6_0=='F'||LA6_0=='f') ) {
+ alt6=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 6, 0, input);
+ throw nvae;
+ }
+
+ switch (alt6) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:83:12: TRUE
+ {
+ mTRUE();
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:83:17: FALSE
+ {
+ mFALSE();
+
+ }
+ break;
+
+ }
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "BOOLEAN"
+
+ // $ANTLR start "AND"
+ public final void mAND() throws RecognitionException {
+ try {
+ int _type = AND;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:85:5: ( ( 'A' | 'a' ) ( 'N' | 'n' ) ( 'D' | 'd' ) | '&&' )
+ int alt7=2;
+ int LA7_0 = input.LA(1);
+ if ( (LA7_0=='A'||LA7_0=='a') ) {
+ alt7=1;
+ }
+ else if ( (LA7_0=='&') ) {
+ alt7=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 7, 0, input);
+ throw nvae;
+ }
+
+ switch (alt7) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:85:7: ( 'A' | 'a' ) ( 'N' | 'n' ) ( 'D' | 'd' )
+ {
+ if ( input.LA(1)=='A'||input.LA(1)=='a' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='N'||input.LA(1)=='n' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='D'||input.LA(1)=='d' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:85:37: '&&'
+ {
+ match("&&");
+
+ }
+ break;
+
+ }
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "AND"
+
+ // $ANTLR start "OR"
+ public final void mOR() throws RecognitionException {
+ try {
+ int _type = OR;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:87:5: ( ( 'O' | 'o' ) ( 'R' | 'r' ) | '||' )
+ int alt8=2;
+ int LA8_0 = input.LA(1);
+ if ( (LA8_0=='O'||LA8_0=='o') ) {
+ alt8=1;
+ }
+ else if ( (LA8_0=='|') ) {
+ alt8=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 8, 0, input);
+ throw nvae;
+ }
+
+ switch (alt8) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:87:7: ( 'O' | 'o' ) ( 'R' | 'r' )
+ {
+ if ( input.LA(1)=='O'||input.LA(1)=='o' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='R'||input.LA(1)=='r' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:87:28: '||'
+ {
+ match("||");
+
+ }
+ break;
+
+ }
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "OR"
+
+ // $ANTLR start "NOT"
+ public final void mNOT() throws RecognitionException {
+ try {
+ int _type = NOT;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:89:5: ( ( 'N' | 'n' ) ( 'O' | 'o' ) ( 'T' | 't' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:89:7: ( 'N' | 'n' ) ( 'O' | 'o' ) ( 'T' | 't' )
+ {
+ if ( input.LA(1)=='N'||input.LA(1)=='n' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='O'||input.LA(1)=='o' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='T'||input.LA(1)=='t' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "NOT"
+
+ // $ANTLR start "ASC"
+ public final void mASC() throws RecognitionException {
+ try {
+ int _type = ASC;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:91:5: ( ( 'A' | 'a' ) ( 'S' | 's' ) ( 'C' | 'c' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:91:7: ( 'A' | 'a' ) ( 'S' | 's' ) ( 'C' | 'c' )
+ {
+ if ( input.LA(1)=='A'||input.LA(1)=='a' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='S'||input.LA(1)=='s' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='C'||input.LA(1)=='c' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "ASC"
+
+ // $ANTLR start "DESC"
+ public final void mDESC() throws RecognitionException {
+ try {
+ int _type = DESC;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:93:6: ( ( 'D' | 'd' ) ( 'E' | 'e' ) ( 'S' | 's' ) ( 'C' | 'c' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:93:8: ( 'D' | 'd' ) ( 'E' | 'e' ) ( 'S' | 's' ) ( 'C' | 'c' )
+ {
+ if ( input.LA(1)=='D'||input.LA(1)=='d' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='E'||input.LA(1)=='e' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='S'||input.LA(1)=='s' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='C'||input.LA(1)=='c' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "DESC"
+
+ // $ANTLR start "CONTAINS"
+ public final void mCONTAINS() throws RecognitionException {
+ try {
+ int _type = CONTAINS;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:95:10: ( ( 'C' | 'c' ) ( 'O' | 'o' ) ( 'N' | 'n' ) ( 'T' | 't' ) ( 'A' | 'a' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'S' | 's' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:95:12: ( 'C' | 'c' ) ( 'O' | 'o' ) ( 'N' | 'n' ) ( 'T' | 't' ) ( 'A' | 'a' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'S' | 's' )
+ {
+ if ( input.LA(1)=='C'||input.LA(1)=='c' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='O'||input.LA(1)=='o' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='N'||input.LA(1)=='n' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='T'||input.LA(1)=='t' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='A'||input.LA(1)=='a' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='I'||input.LA(1)=='i' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='N'||input.LA(1)=='n' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='S'||input.LA(1)=='s' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "CONTAINS"
+
+ // $ANTLR start "WITHIN"
+ public final void mWITHIN() throws RecognitionException {
+ try {
+ int _type = WITHIN;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:97:8: ( ( 'W' | 'w' ) ( 'I' | 'i' ) ( 'T' | 't' ) ( 'H' | 'h' ) ( 'I' | 'i' ) ( 'N' | 'n' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:97:10: ( 'W' | 'w' ) ( 'I' | 'i' ) ( 'T' | 't' ) ( 'H' | 'h' ) ( 'I' | 'i' ) ( 'N' | 'n' )
+ {
+ if ( input.LA(1)=='W'||input.LA(1)=='w' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='I'||input.LA(1)=='i' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='T'||input.LA(1)=='t' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='H'||input.LA(1)=='h' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='I'||input.LA(1)=='i' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='N'||input.LA(1)=='n' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "WITHIN"
+
+ // $ANTLR start "OF"
+ public final void mOF() throws RecognitionException {
+ try {
+ int _type = OF;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:99:4: ( ( 'O' | 'o' ) ( 'F' | 'f' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:99:6: ( 'O' | 'o' ) ( 'F' | 'f' )
+ {
+ if ( input.LA(1)=='O'||input.LA(1)=='o' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='F'||input.LA(1)=='f' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "OF"
+
+ // $ANTLR start "UUID"
+ public final void mUUID() throws RecognitionException {
+ try {
+ int _type = UUID;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:101:6: ( HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:101:9: HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ {
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ match('-');
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ match('-');
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ match('-');
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ match('-');
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "UUID"
+
+ // $ANTLR start "ID"
+ public final void mID() throws RecognitionException {
+ try {
+ int _type = ID;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:112:5: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' | '.' | '-' )* )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:112:7: ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' | '.' | '-' )*
+ {
+ if ( (input.LA(1) >= 'A' && input.LA(1) <= 'Z')||input.LA(1)=='_'||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:112:31: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' | '.' | '-' )*
+ loop9:
+ while (true) {
+ int alt9=2;
+ int LA9_0 = input.LA(1);
+ if ( ((LA9_0 >= '-' && LA9_0 <= '.')||(LA9_0 >= '0' && LA9_0 <= '9')||(LA9_0 >= 'A' && LA9_0 <= 'Z')||LA9_0=='_'||(LA9_0 >= 'a' && LA9_0 <= 'z')) ) {
+ alt9=1;
+ }
+
+ switch (alt9) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( (input.LA(1) >= '-' && input.LA(1) <= '.')||(input.LA(1) >= '0' && input.LA(1) <= '9')||(input.LA(1) >= 'A' && input.LA(1) <= 'Z')||input.LA(1)=='_'||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ default :
+ break loop9;
+ }
+ }
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "ID"
+
+ // $ANTLR start "LONG"
+ public final void mLONG() throws RecognitionException {
+ try {
+ int _type = LONG;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:115:6: ( ( '-' )? ( '0' .. '9' )+ )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:115:8: ( '-' )? ( '0' .. '9' )+
+ {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:115:8: ( '-' )?
+ int alt10=2;
+ int LA10_0 = input.LA(1);
+ if ( (LA10_0=='-') ) {
+ alt10=1;
+ }
+ switch (alt10) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:115:9: '-'
+ {
+ match('-');
+ }
+ break;
+
+ }
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:115:15: ( '0' .. '9' )+
+ int cnt11=0;
+ loop11:
+ while (true) {
+ int alt11=2;
+ int LA11_0 = input.LA(1);
+ if ( ((LA11_0 >= '0' && LA11_0 <= '9')) ) {
+ alt11=1;
+ }
+
+ switch (alt11) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ default :
+ if ( cnt11 >= 1 ) break loop11;
+ EarlyExitException eee = new EarlyExitException(11, input);
+ throw eee;
+ }
+ cnt11++;
+ }
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "LONG"
+
+ // $ANTLR start "FLOAT"
+ public final void mFLOAT() throws RecognitionException {
+ try {
+ int _type = FLOAT;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:5: ( ( '-' )? ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? | '.' ( '0' .. '9' )+ ( EXPONENT )? | ( '0' .. '9' )+ EXPONENT ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:8: ( '-' )? ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? | '.' ( '0' .. '9' )+ ( EXPONENT )? | ( '0' .. '9' )+ EXPONENT )
+ {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:8: ( '-' )?
+ int alt12=2;
+ int LA12_0 = input.LA(1);
+ if ( (LA12_0=='-') ) {
+ alt12=1;
+ }
+ switch (alt12) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:9: '-'
+ {
+ match('-');
+ }
+ break;
+
+ }
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:15: ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? | '.' ( '0' .. '9' )+ ( EXPONENT )? | ( '0' .. '9' )+ EXPONENT )
+ int alt19=3;
+ alt19 = dfa19.predict(input);
+ switch (alt19) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:17: ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )?
+ {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:17: ( '0' .. '9' )+
+ int cnt13=0;
+ loop13:
+ while (true) {
+ int alt13=2;
+ int LA13_0 = input.LA(1);
+ if ( ((LA13_0 >= '0' && LA13_0 <= '9')) ) {
+ alt13=1;
+ }
+
+ switch (alt13) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ default :
+ if ( cnt13 >= 1 ) break loop13;
+ EarlyExitException eee = new EarlyExitException(13, input);
+ throw eee;
+ }
+ cnt13++;
+ }
+
+ match('.');
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:33: ( '0' .. '9' )*
+ loop14:
+ while (true) {
+ int alt14=2;
+ int LA14_0 = input.LA(1);
+ if ( ((LA14_0 >= '0' && LA14_0 <= '9')) ) {
+ alt14=1;
+ }
+
+ switch (alt14) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ default :
+ break loop14;
+ }
+ }
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:45: ( EXPONENT )?
+ int alt15=2;
+ int LA15_0 = input.LA(1);
+ if ( (LA15_0=='E'||LA15_0=='e') ) {
+ alt15=1;
+ }
+ switch (alt15) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:119:45: EXPONENT
+ {
+ mEXPONENT();
+
+ }
+ break;
+
+ }
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:120:9: '.' ( '0' .. '9' )+ ( EXPONENT )?
+ {
+ match('.');
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:120:13: ( '0' .. '9' )+
+ int cnt16=0;
+ loop16:
+ while (true) {
+ int alt16=2;
+ int LA16_0 = input.LA(1);
+ if ( ((LA16_0 >= '0' && LA16_0 <= '9')) ) {
+ alt16=1;
+ }
+
+ switch (alt16) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ default :
+ if ( cnt16 >= 1 ) break loop16;
+ EarlyExitException eee = new EarlyExitException(16, input);
+ throw eee;
+ }
+ cnt16++;
+ }
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:120:25: ( EXPONENT )?
+ int alt17=2;
+ int LA17_0 = input.LA(1);
+ if ( (LA17_0=='E'||LA17_0=='e') ) {
+ alt17=1;
+ }
+ switch (alt17) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:120:25: EXPONENT
+ {
+ mEXPONENT();
+
+ }
+ break;
+
+ }
+
+ }
+ break;
+ case 3 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:121:9: ( '0' .. '9' )+ EXPONENT
+ {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:121:9: ( '0' .. '9' )+
+ int cnt18=0;
+ loop18:
+ while (true) {
+ int alt18=2;
+ int LA18_0 = input.LA(1);
+ if ( ((LA18_0 >= '0' && LA18_0 <= '9')) ) {
+ alt18=1;
+ }
+
+ switch (alt18) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ default :
+ if ( cnt18 >= 1 ) break loop18;
+ EarlyExitException eee = new EarlyExitException(18, input);
+ throw eee;
+ }
+ cnt18++;
+ }
+
+ mEXPONENT();
+
+ }
+ break;
+
+ }
+
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "FLOAT"
+
+ // $ANTLR start "STRING"
+ public final void mSTRING() throws RecognitionException {
+ try {
+ int _type = STRING;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:125:5: ( '\\'' ( ESC_SEQ |~ ( '\\\\' | '\\'' ) )* '\\'' )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:125:8: '\\'' ( ESC_SEQ |~ ( '\\\\' | '\\'' ) )* '\\''
+ {
+ match('\'');
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:125:13: ( ESC_SEQ |~ ( '\\\\' | '\\'' ) )*
+ loop20:
+ while (true) {
+ int alt20=3;
+ int LA20_0 = input.LA(1);
+ if ( (LA20_0=='\\') ) {
+ alt20=1;
+ }
+ else if ( ((LA20_0 >= '\u0000' && LA20_0 <= '&')||(LA20_0 >= '(' && LA20_0 <= '[')||(LA20_0 >= ']' && LA20_0 <= '\uFFFF')) ) {
+ alt20=2;
+ }
+
+ switch (alt20) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:125:15: ESC_SEQ
+ {
+ mESC_SEQ();
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:125:25: ~ ( '\\\\' | '\\'' )
+ {
+ if ( (input.LA(1) >= '\u0000' && input.LA(1) <= '&')||(input.LA(1) >= '(' && input.LA(1) <= '[')||(input.LA(1) >= ']' && input.LA(1) <= '\uFFFF') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ default :
+ break loop20;
+ }
+ }
+
+ match('\'');
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "STRING"
+
+ // $ANTLR start "WS"
+ public final void mWS() throws RecognitionException {
+ try {
+ int _type = WS;
+ int _channel = DEFAULT_TOKEN_CHANNEL;
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:130:4: ( ( ' ' | '\\t' | '\\n' | '\\r' | '\\f' )+ )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:130:6: ( ' ' | '\\t' | '\\n' | '\\r' | '\\f' )+
+ {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:130:6: ( ' ' | '\\t' | '\\n' | '\\r' | '\\f' )+
+ int cnt21=0;
+ loop21:
+ while (true) {
+ int alt21=2;
+ int LA21_0 = input.LA(1);
+ if ( ((LA21_0 >= '\t' && LA21_0 <= '\n')||(LA21_0 >= '\f' && LA21_0 <= '\r')||LA21_0==' ') ) {
+ alt21=1;
+ }
+
+ switch (alt21) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( (input.LA(1) >= '\t' && input.LA(1) <= '\n')||(input.LA(1) >= '\f' && input.LA(1) <= '\r')||input.LA(1)==' ' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ default :
+ if ( cnt21 >= 1 ) break loop21;
+ EarlyExitException eee = new EarlyExitException(21, input);
+ throw eee;
+ }
+ cnt21++;
+ }
+
+ _channel=HIDDEN;
+ }
+
+ state.type = _type;
+ state.channel = _channel;
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "WS"
+
+ // $ANTLR start "TRUE"
+ public final void mTRUE() throws RecognitionException {
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:138:15: ( ( 'T' | 't' ) ( 'R' | 'r' ) ( 'U' | 'u' ) ( 'E' | 'e' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:138:17: ( 'T' | 't' ) ( 'R' | 'r' ) ( 'U' | 'u' ) ( 'E' | 'e' )
+ {
+ if ( input.LA(1)=='T'||input.LA(1)=='t' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='R'||input.LA(1)=='r' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='U'||input.LA(1)=='u' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='E'||input.LA(1)=='e' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "TRUE"
+
+ // $ANTLR start "FALSE"
+ public final void mFALSE() throws RecognitionException {
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:140:16: ( ( 'F' | 'f' ) ( 'A' | 'a' ) ( 'L' | 'l' ) ( 'S' | 's' ) ( 'E' | 'e' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:140:18: ( 'F' | 'f' ) ( 'A' | 'a' ) ( 'L' | 'l' ) ( 'S' | 's' ) ( 'E' | 'e' )
+ {
+ if ( input.LA(1)=='F'||input.LA(1)=='f' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='A'||input.LA(1)=='a' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='L'||input.LA(1)=='l' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='S'||input.LA(1)=='s' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( input.LA(1)=='E'||input.LA(1)=='e' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "FALSE"
+
+ // $ANTLR start "EXPONENT"
+ public final void mEXPONENT() throws RecognitionException {
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:145:10: ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:145:12: ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+
+ {
+ if ( input.LA(1)=='E'||input.LA(1)=='e' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:145:22: ( '+' | '-' )?
+ int alt22=2;
+ int LA22_0 = input.LA(1);
+ if ( (LA22_0=='+'||LA22_0=='-') ) {
+ alt22=1;
+ }
+ switch (alt22) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( input.LA(1)=='+'||input.LA(1)=='-' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ }
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:145:33: ( '0' .. '9' )+
+ int cnt23=0;
+ loop23:
+ while (true) {
+ int alt23=2;
+ int LA23_0 = input.LA(1);
+ if ( ((LA23_0 >= '0' && LA23_0 <= '9')) ) {
+ alt23=1;
+ }
+
+ switch (alt23) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ default :
+ if ( cnt23 >= 1 ) break loop23;
+ EarlyExitException eee = new EarlyExitException(23, input);
+ throw eee;
+ }
+ cnt23++;
+ }
+
+ }
+
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "EXPONENT"
+
+ // $ANTLR start "HEX_DIGIT"
+ public final void mHEX_DIGIT() throws RecognitionException {
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:148:11: ( ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '9')||(input.LA(1) >= 'A' && input.LA(1) <= 'F')||(input.LA(1) >= 'a' && input.LA(1) <= 'f') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "HEX_DIGIT"
+
+ // $ANTLR start "ESC_SEQ"
+ public final void mESC_SEQ() throws RecognitionException {
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:152:5: ( '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | UNICODE_ESC | OCTAL_ESC )
+ int alt24=3;
+ int LA24_0 = input.LA(1);
+ if ( (LA24_0=='\\') ) {
+ switch ( input.LA(2) ) {
+ case '\"':
+ case '\'':
+ case '\\':
+ case 'b':
+ case 'f':
+ case 'n':
+ case 'r':
+ case 't':
+ {
+ alt24=1;
+ }
+ break;
+ case 'u':
+ {
+ alt24=2;
+ }
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ {
+ alt24=3;
+ }
+ break;
+ default:
+ int nvaeMark = input.mark();
+ try {
+ input.consume();
+ NoViableAltException nvae =
+ new NoViableAltException("", 24, 1, input);
+ throw nvae;
+ } finally {
+ input.rewind(nvaeMark);
+ }
+ }
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 24, 0, input);
+ throw nvae;
+ }
+
+ switch (alt24) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:152:9: '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' )
+ {
+ match('\\');
+ if ( input.LA(1)=='\"'||input.LA(1)=='\''||input.LA(1)=='\\'||input.LA(1)=='b'||input.LA(1)=='f'||input.LA(1)=='n'||input.LA(1)=='r'||input.LA(1)=='t' ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:153:9: UNICODE_ESC
+ {
+ mUNICODE_ESC();
+
+ }
+ break;
+ case 3 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:154:9: OCTAL_ESC
+ {
+ mOCTAL_ESC();
+
+ }
+ break;
+
+ }
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "ESC_SEQ"
+
+ // $ANTLR start "OCTAL_ESC"
+ public final void mOCTAL_ESC() throws RecognitionException {
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:159:5: ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) )
+ int alt25=3;
+ int LA25_0 = input.LA(1);
+ if ( (LA25_0=='\\') ) {
+ int LA25_1 = input.LA(2);
+ if ( ((LA25_1 >= '0' && LA25_1 <= '3')) ) {
+ int LA25_2 = input.LA(3);
+ if ( ((LA25_2 >= '0' && LA25_2 <= '7')) ) {
+ int LA25_4 = input.LA(4);
+ if ( ((LA25_4 >= '0' && LA25_4 <= '7')) ) {
+ alt25=1;
+ }
+
+ else {
+ alt25=2;
+ }
+
+ }
+
+ else {
+ alt25=3;
+ }
+
+ }
+ else if ( ((LA25_1 >= '4' && LA25_1 <= '7')) ) {
+ int LA25_3 = input.LA(3);
+ if ( ((LA25_3 >= '0' && LA25_3 <= '7')) ) {
+ alt25=2;
+ }
+
+ else {
+ alt25=3;
+ }
+
+ }
+
+ else {
+ int nvaeMark = input.mark();
+ try {
+ input.consume();
+ NoViableAltException nvae =
+ new NoViableAltException("", 25, 1, input);
+ throw nvae;
+ } finally {
+ input.rewind(nvaeMark);
+ }
+ }
+
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 25, 0, input);
+ throw nvae;
+ }
+
+ switch (alt25) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:159:9: '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' )
+ {
+ match('\\');
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '3') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:160:9: '\\\\' ( '0' .. '7' ) ( '0' .. '7' )
+ {
+ match('\\');
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+ case 3 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:161:9: '\\\\' ( '0' .. '7' )
+ {
+ match('\\');
+ if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
+ input.consume();
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ recover(mse);
+ throw mse;
+ }
+ }
+ break;
+
+ }
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "OCTAL_ESC"
+
+ // $ANTLR start "UNICODE_ESC"
+ public final void mUNICODE_ESC() throws RecognitionException {
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:166:5: ( '\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:166:9: '\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ {
+ match('\\');
+ match('u');
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ mHEX_DIGIT();
+
+ }
+
+ }
+ finally {
+ // do for sure before leaving
+ }
+ }
+ // $ANTLR end "UNICODE_ESC"
+
+ @Override
+ public void mTokens() throws RecognitionException {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:8: ( T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | LT | LTE | EQ | GT | GTE | BOOLEAN | AND | OR | NOT | ASC | DESC | CONTAINS | WITHIN | OF | UUID | ID | LONG | FLOAT | STRING | WS )
+ int alt26=30;
+ alt26 = dfa26.predict(input);
+ switch (alt26) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:10: T__31
+ {
+ mT__31();
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:16: T__32
+ {
+ mT__32();
+
+ }
+ break;
+ case 3 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:22: T__33
+ {
+ mT__33();
+
+ }
+ break;
+ case 4 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:28: T__34
+ {
+ mT__34();
+
+ }
+ break;
+ case 5 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:34: T__35
+ {
+ mT__35();
+
+ }
+ break;
+ case 6 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:40: T__36
+ {
+ mT__36();
+
+ }
+ break;
+ case 7 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:46: T__37
+ {
+ mT__37();
+
+ }
+ break;
+ case 8 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:52: T__38
+ {
+ mT__38();
+
+ }
+ break;
+ case 9 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:58: T__39
+ {
+ mT__39();
+
+ }
+ break;
+ case 10 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:64: T__40
+ {
+ mT__40();
+
+ }
+ break;
+ case 11 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:70: LT
+ {
+ mLT();
+
+ }
+ break;
+ case 12 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:73: LTE
+ {
+ mLTE();
+
+ }
+ break;
+ case 13 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:77: EQ
+ {
+ mEQ();
+
+ }
+ break;
+ case 14 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:80: GT
+ {
+ mGT();
+
+ }
+ break;
+ case 15 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:83: GTE
+ {
+ mGTE();
+
+ }
+ break;
+ case 16 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:87: BOOLEAN
+ {
+ mBOOLEAN();
+
+ }
+ break;
+ case 17 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:95: AND
+ {
+ mAND();
+
+ }
+ break;
+ case 18 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:99: OR
+ {
+ mOR();
+
+ }
+ break;
+ case 19 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:102: NOT
+ {
+ mNOT();
+
+ }
+ break;
+ case 20 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:106: ASC
+ {
+ mASC();
+
+ }
+ break;
+ case 21 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:110: DESC
+ {
+ mDESC();
+
+ }
+ break;
+ case 22 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:115: CONTAINS
+ {
+ mCONTAINS();
+
+ }
+ break;
+ case 23 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:124: WITHIN
+ {
+ mWITHIN();
+
+ }
+ break;
+ case 24 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:131: OF
+ {
+ mOF();
+
+ }
+ break;
+ case 25 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:134: UUID
+ {
+ mUUID();
+
+ }
+ break;
+ case 26 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:139: ID
+ {
+ mID();
+
+ }
+ break;
+ case 27 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:142: LONG
+ {
+ mLONG();
+
+ }
+ break;
+ case 28 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:147: FLOAT
+ {
+ mFLOAT();
+
+ }
+ break;
+ case 29 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:153: STRING
+ {
+ mSTRING();
+
+ }
+ break;
+ case 30 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:1:160: WS
+ {
+ mWS();
+
+ }
+ break;
+
+ }
+ }
+
+
+ protected DFA19 dfa19 = new DFA19(this);
+ protected DFA26 dfa26 = new DFA26(this);
+ static final String DFA19_eotS =
+ "\5\uffff";
+ static final String DFA19_eofS =
+ "\5\uffff";
+ static final String DFA19_minS =
+ "\2\56\3\uffff";
+ static final String DFA19_maxS =
+ "\1\71\1\145\3\uffff";
+ static final String DFA19_acceptS =
+ "\2\uffff\1\2\1\1\1\3";
+ static final String DFA19_specialS =
+ "\5\uffff}>";
+ static final String[] DFA19_transitionS = {
+ "\1\2\1\uffff\12\1",
+ "\1\3\1\uffff\12\1\13\uffff\1\4\37\uffff\1\4",
+ "",
+ "",
+ ""
+ };
+
+ static final short[] DFA19_eot = DFA.unpackEncodedString(DFA19_eotS);
+ static final short[] DFA19_eof = DFA.unpackEncodedString(DFA19_eofS);
+ static final char[] DFA19_min = DFA.unpackEncodedStringToUnsignedChars(DFA19_minS);
+ static final char[] DFA19_max = DFA.unpackEncodedStringToUnsignedChars(DFA19_maxS);
+ static final short[] DFA19_accept = DFA.unpackEncodedString(DFA19_acceptS);
+ static final short[] DFA19_special = DFA.unpackEncodedString(DFA19_specialS);
+ static final short[][] DFA19_transition;
+
+ static {
+ int numStates = DFA19_transitionS.length;
+ DFA19_transition = new short[numStates][];
+ for (int i=0; i<numStates; i++) {
+ DFA19_transition[i] = DFA.unpackEncodedString(DFA19_transitionS[i]);
+ }
+ }
+
+ protected class DFA19 extends DFA {
+
+ public DFA19(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
+ this.decisionNumber = 19;
+ this.eot = DFA19_eot;
+ this.eof = DFA19_eof;
+ this.min = DFA19_min;
+ this.max = DFA19_max;
+ this.accept = DFA19_accept;
+ this.special = DFA19_special;
+ this.transition = DFA19_transition;
+ }
+ @Override
+ public String getDescription() {
+ return "119:15: ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? | '.' ( '0' .. '9' )+ ( EXPONENT )? | ( '0' .. '9' )+ EXPONENT )";
+ }
+ }
+
+ static final String DFA26_eotS =
+ "\6\uffff\3\35\2\uffff\1\51\1\35\1\uffff\1\35\1\56\4\35\1\uffff\1\35\1"+
+ "\uffff\5\35\1\67\5\uffff\2\26\1\75\3\35\2\uffff\1\51\1\15\1\35\2\uffff"+
+ "\1\56\7\35\1\uffff\1\67\2\uffff\1\67\1\35\1\uffff\3\35\1\50\1\35\1\55"+
+ "\2\35\1\24\1\125\1\126\2\35\1\67\1\uffff\1\37\5\35\1\141\1\35\2\uffff"+
+ "\1\143\1\35\1\67\1\uffff\1\37\2\35\1\152\2\35\1\uffff\1\141\1\uffff\1"+
+ "\35\1\67\1\uffff\1\37\1\uffff\1\161\1\uffff\1\162\2\35\1\67\1\uffff\1"+
+ "\37\2\uffff\2\35\1\67\1\uffff\1\37\1\35\1\176\1\67\1\uffff\1\37\1\35\2"+
+ "\uffff\1\35\1\37\1\35\1\37\1\35\1\37\1\35\1\37\26\35\1\72";
+ static final String DFA26_eofS =
+ "\u009f\uffff";
+ static final String DFA26_minS =
+ "\1\11\5\uffff\1\106\1\145\1\111\2\uffff\1\75\1\164\1\uffff\1\60\1\75\1"+
+ "\164\1\122\2\60\1\uffff\1\106\1\uffff\1\117\2\60\1\111\1\60\1\56\1\uffff"+
+ "\1\56\3\uffff\3\55\1\154\1\145\1\124\2\uffff\2\55\1\60\2\uffff\1\55\1"+
+ "\125\1\60\1\104\1\103\1\124\1\60\1\116\1\uffff\1\56\1\53\1\uffff\1\56"+
+ "\1\145\1\uffff\1\145\1\162\1\110\1\55\1\60\1\55\1\105\1\123\3\55\1\103"+
+ "\1\124\1\56\1\53\1\60\1\162\1\143\1\145\1\111\1\60\1\55\1\105\2\uffff"+
+ "\1\55\1\101\1\56\1\53\1\60\1\40\1\164\1\55\1\116\1\60\1\uffff\1\55\1\uffff"+
+ "\1\111\1\56\1\53\1\60\1\uffff\1\55\1\uffff\1\55\1\60\1\116\1\56\1\53\1"+
+ "\60\2\uffff\1\60\1\123\1\56\1\53\1\60\3\55\1\53\1\55\1\60\1\uffff\7\60"+
+ "\2\55\4\60\1\55\4\60\1\55\14\60\1\55";
+ static final String DFA26_maxS =
+ "\1\175\5\uffff\1\162\1\145\1\151\2\uffff\1\75\1\164\1\uffff\1\161\1\75"+
+ "\1\164\1\162\1\146\1\163\1\uffff\1\162\1\uffff\1\157\1\146\1\157\1\151"+
+ "\2\146\1\uffff\1\71\3\uffff\3\172\1\154\1\145\1\164\2\uffff\2\172\1\146"+
+ "\2\uffff\1\172\1\165\1\154\1\144\1\143\1\164\1\163\1\156\1\uffff\2\146"+
+ "\1\uffff\2\145\1\uffff\1\145\1\162\1\150\1\172\1\146\1\172\1\145\1\163"+
+ "\3\172\1\143\1\164\3\146\1\162\1\143\1\145\1\151\1\146\1\172\1\145\2\uffff"+
+ "\1\172\1\141\3\146\1\40\1\164\1\172\1\156\1\146\1\uffff\1\172\1\uffff"+
+ "\1\151\3\146\1\uffff\1\172\1\uffff\1\172\1\146\1\156\3\146\2\uffff\1\146"+
+ "\1\163\3\146\1\55\1\172\1\145\1\71\1\55\1\146\1\uffff\7\146\2\55\4\146"+
+ "\1\55\4\146\1\55\14\146\1\172";
+ static final String DFA26_acceptS =
+ "\1\uffff\1\1\1\2\1\3\1\4\1\5\3\uffff\1\11\1\12\2\uffff\1\15\6\uffff\1"+
+ "\21\1\uffff\1\22\6\uffff\1\32\1\uffff\1\34\1\35\1\36\6\uffff\1\14\1\13"+
+ "\3\uffff\1\17\1\16\10\uffff\1\33\2\uffff\1\31\2\uffff\1\30\27\uffff\1"+
+ "\24\1\23\12\uffff\1\20\1\uffff\1\25\4\uffff\1\6\1\uffff\1\10\6\uffff\1"+
+ "\7\1\27\13\uffff\1\26\40\uffff";
+ static final String DFA26_specialS =
+ "\u009f\uffff}>";
+ static final String[] DFA26_transitionS = {
+ "\2\41\1\uffff\2\41\22\uffff\1\41\5\uffff\1\24\1\40\1\1\1\2\1\3\1\uffff"+
+ "\1\4\1\36\1\37\1\uffff\12\34\1\5\1\uffff\1\13\1\15\1\17\2\uffff\1\23"+
+ "\1\33\1\31\1\30\1\33\1\22\7\35\1\27\1\25\4\35\1\21\2\35\1\32\3\35\4\uffff"+
+ "\1\35\1\uffff\1\23\1\33\1\31\1\30\1\16\1\22\1\20\4\35\1\14\1\35\1\27"+
+ "\1\6\3\35\1\7\1\21\2\35\1\10\3\35\1\11\1\26\1\12",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "\1\44\13\uffff\1\43\23\uffff\1\44\13\uffff\1\42",
+ "\1\45",
+ "\1\47\36\uffff\1\46\1\47",
+ "",
+ "",
+ "\1\50",
+ "\1\52",
+ "",
+ "\12\54\7\uffff\6\54\32\uffff\6\54\12\uffff\1\53",
+ "\1\55",
+ "\1\57",
+ "\1\60\37\uffff\1\60",
+ "\12\54\7\uffff\1\61\5\54\32\uffff\1\61\5\54",
+ "\12\54\7\uffff\6\54\7\uffff\1\62\4\uffff\1\63\15\uffff\6\54\7\uffff"+
+ "\1\62\4\uffff\1\63",
+ "",
+ "\1\44\13\uffff\1\43\23\uffff\1\44\13\uffff\1\43",
+ "",
+ "\1\64\37\uffff\1\64",
+ "\12\54\7\uffff\4\54\1\65\1\54\32\uffff\4\54\1\65\1\54",
+ "\12\54\7\uffff\6\54\10\uffff\1\66\21\uffff\6\54\10\uffff\1\66",
+ "\1\47\37\uffff\1\47",
+ "\12\54\7\uffff\6\54\32\uffff\6\54",
+ "\1\37\1\uffff\12\70\7\uffff\4\72\1\71\1\72\32\uffff\4\72\1\71\1\72",
+ "",
+ "\1\37\1\uffff\12\73",
+ "",
+ "",
+ "",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\3\35\1\74\26"+
+ "\35",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\1\76",
+ "\1\77",
+ "\1\100\37\uffff\1\100",
+ "",
+ "",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\4\35\1\101\25"+
+ "\35",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\12\102\7\uffff\6\102\32\uffff\6\102",
+ "",
+ "",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\4\35\1\103\25"+
+ "\35",
+ "\1\104\37\uffff\1\104",
+ "\12\102\7\uffff\6\102\5\uffff\1\105\24\uffff\6\102\5\uffff\1\105",
+ "\1\106\37\uffff\1\106",
+ "\1\107\37\uffff\1\107",
+ "\1\110\37\uffff\1\110",
+ "\12\102\7\uffff\6\102\14\uffff\1\111\15\uffff\6\102\14\uffff\1\111",
+ "\1\112\37\uffff\1\112",
+ "",
+ "\1\37\1\uffff\12\113\7\uffff\4\72\1\114\1\72\32\uffff\4\72\1\114\1\72",
+ "\1\37\1\uffff\1\37\2\uffff\12\115\7\uffff\6\72\32\uffff\6\72",
+ "",
+ "\1\37\1\uffff\12\73\13\uffff\1\37\37\uffff\1\37",
+ "\1\116",
+ "",
+ "\1\117",
+ "\1\120",
+ "\1\121\37\uffff\1\121",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\12\122\7\uffff\6\122\32\uffff\6\122",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\1\123\37\uffff\1\123",
+ "\1\124\37\uffff\1\124",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\1\127\37\uffff\1\127",
+ "\1\130\37\uffff\1\130",
+ "\1\37\1\uffff\12\131\7\uffff\4\72\1\132\1\72\32\uffff\4\72\1\132\1\72",
+ "\1\37\1\uffff\1\37\2\uffff\12\133\7\uffff\6\72\32\uffff\6\72",
+ "\12\133\7\uffff\6\72\32\uffff\6\72",
+ "\1\134",
+ "\1\135",
+ "\1\136",
+ "\1\137\37\uffff\1\137",
+ "\12\140\7\uffff\6\140\32\uffff\6\140",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\1\142\37\uffff\1\142",
+ "",
+ "",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\1\144\37\uffff\1\144",
+ "\1\37\1\uffff\12\145\7\uffff\4\72\1\146\1\72\32\uffff\4\72\1\146\1\72",
+ "\1\37\1\uffff\1\37\2\uffff\12\147\7\uffff\6\72\32\uffff\6\72",
+ "\12\147\7\uffff\6\72\32\uffff\6\72",
+ "\1\150",
+ "\1\151",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\1\153\37\uffff\1\153",
+ "\12\154\7\uffff\6\154\32\uffff\6\154",
+ "",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "",
+ "\1\155\37\uffff\1\155",
+ "\1\37\1\uffff\12\156\7\uffff\4\72\1\157\1\72\32\uffff\4\72\1\157\1\72",
+ "\1\37\1\uffff\1\37\2\uffff\12\160\7\uffff\6\72\32\uffff\6\72",
+ "\12\160\7\uffff\6\72\32\uffff\6\72",
+ "",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\12\163\7\uffff\6\163\32\uffff\6\163",
+ "\1\164\37\uffff\1\164",
+ "\1\37\1\uffff\12\165\7\uffff\4\72\1\166\1\72\32\uffff\4\72\1\166\1\72",
+ "\1\37\1\uffff\1\37\2\uffff\12\167\7\uffff\6\72\32\uffff\6\72",
+ "\12\167\7\uffff\6\72\32\uffff\6\72",
+ "",
+ "",
+ "\12\170\7\uffff\6\170\32\uffff\6\170",
+ "\1\171\37\uffff\1\171",
+ "\1\37\1\uffff\12\172\7\uffff\4\72\1\173\1\72\32\uffff\4\72\1\173\1\72",
+ "\1\37\1\uffff\1\37\2\uffff\12\174\7\uffff\6\72\32\uffff\6\72",
+ "\12\174\7\uffff\6\72\32\uffff\6\72",
+ "\1\175",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35",
+ "\1\72\1\37\1\uffff\12\73\13\uffff\1\37\37\uffff\1\37",
+ "\1\37\1\uffff\1\177\2\uffff\12\37",
+ "\1\72",
+ "\12\u0080\7\uffff\6\u0080\32\uffff\6\u0080",
+ "",
+ "\12\u0081\7\uffff\6\72\32\uffff\6\72",
+ "\12\u0082\7\uffff\6\u0082\32\uffff\6\u0082",
+ "\12\u0083\7\uffff\6\72\32\uffff\6\72",
+ "\12\u0084\7\uffff\6\u0084\32\uffff\6\u0084",
+ "\12\u0085\7\uffff\6\72\32\uffff\6\72",
+ "\12\u0086\7\uffff\6\u0086\32\uffff\6\u0086",
+ "\12\u0087\7\uffff\6\72\32\uffff\6\72",
+ "\1\u0088",
+ "\1\72",
+ "\12\u0089\7\uffff\6\u0089\32\uffff\6\u0089",
+ "\12\u008a\7\uffff\6\u008a\32\uffff\6\u008a",
+ "\12\u008b\7\uffff\6\u008b\32\uffff\6\u008b",
+ "\12\u008c\7\uffff\6\u008c\32\uffff\6\u008c",
+ "\1\u008d",
+ "\12\u008e\7\uffff\6\u008e\32\uffff\6\u008e",
+ "\12\u008f\7\uffff\6\u008f\32\uffff\6\u008f",
+ "\12\u0090\7\uffff\6\u0090\32\uffff\6\u0090",
+ "\12\u0091\7\uffff\6\u0091\32\uffff\6\u0091",
+ "\1\u0092",
+ "\12\u0093\7\uffff\6\u0093\32\uffff\6\u0093",
+ "\12\u0094\7\uffff\6\u0094\32\uffff\6\u0094",
+ "\12\u0095\7\uffff\6\u0095\32\uffff\6\u0095",
+ "\12\u0096\7\uffff\6\u0096\32\uffff\6\u0096",
+ "\12\u0097\7\uffff\6\u0097\32\uffff\6\u0097",
+ "\12\u0098\7\uffff\6\u0098\32\uffff\6\u0098",
+ "\12\u0099\7\uffff\6\u0099\32\uffff\6\u0099",
+ "\12\u009a\7\uffff\6\u009a\32\uffff\6\u009a",
+ "\12\u009b\7\uffff\6\u009b\32\uffff\6\u009b",
+ "\12\u009c\7\uffff\6\u009c\32\uffff\6\u009c",
+ "\12\u009d\7\uffff\6\u009d\32\uffff\6\u009d",
+ "\12\u009e\7\uffff\6\u009e\32\uffff\6\u009e",
+ "\2\35\1\uffff\12\35\7\uffff\32\35\4\uffff\1\35\1\uffff\32\35"
+ };
+
+ static final short[] DFA26_eot = DFA.unpackEncodedString(DFA26_eotS);
+ static final short[] DFA26_eof = DFA.unpackEncodedString(DFA26_eofS);
+ static final char[] DFA26_min = DFA.unpackEncodedStringToUnsignedChars(DFA26_minS);
+ static final char[] DFA26_max = DFA.unpackEncodedStringToUnsignedChars(DFA26_maxS);
+ static final short[] DFA26_accept = DFA.unpackEncodedString(DFA26_acceptS);
+ static final short[] DFA26_special = DFA.unpackEncodedString(DFA26_specialS);
+ static final short[][] DFA26_transition;
+
+ static {
+ int numStates = DFA26_transitionS.length;
+ DFA26_transition = new short[numStates][];
+ for (int i=0; i<numStates; i++) {
+ DFA26_transition[i] = DFA.unpackEncodedString(DFA26_transitionS[i]);
+ }
+ }
+
+ protected class DFA26 extends DFA {
+
+ public DFA26(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
+ this.decisionNumber = 26;
+ this.eot = DFA26_eot;
+ this.eof = DFA26_eof;
+ this.min = DFA26_min;
+ this.max = DFA26_max;
+ this.accept = DFA26_accept;
+ this.special = DFA26_special;
+ this.transition = DFA26_transition;
+ }
+ @Override
+ public String getDescription() {
+ return "1:1: Tokens : ( T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | LT | LTE | EQ | GT | GTE | BOOLEAN | AND | OR | NOT | ASC | DESC | CONTAINS | WITHIN | OF | UUID | ID | LONG | FLOAT | STRING | WS );";
+ }
+ }
+
+}
[15/21] git commit: Rename index to query index,
add working query parser code.
Posted by sn...@apache.org.
Rename index to query index, add working query parser code.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c0543f5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c0543f5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c0543f5f
Branch: refs/heads/two-dot-o
Commit: c0543f5f57731af91802cd8729b77d6bec795fe3
Parents: ba7d5ae
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Feb 21 12:31:08 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Feb 21 12:31:08 2014 -0500
----------------------------------------------------------------------
stack/corepersistence/index/pom.xml | 190 -
.../index/EntityCollectionIndex.java | 46 -
.../persistence/index/EntitySearchResults.java | 65 -
.../index/impl/EntityCollectionIndexImpl.java | 272 -
.../persistence/index/impl/IndexModule.java | 32 -
.../index/impl/ElasticSearchTest.java | 262 -
.../persistence/index/impl/EntityIndexTest.java | 306 -
.../persistence/utils/ElasticSearchRule.java | 65 -
.../index/src/test/resources/log4j.properties | 15 -
.../index/src/test/resources/sample-large.json | 39603 -----------------
.../index/src/test/resources/sample-small.json | 222 -
stack/corepersistence/query/pom.xml | 233 +
.../query/src/test/resources/log4j.properties | 30 +
stack/corepersistence/queryindex/pom.xml | 228 +
.../persistence/query/tree/QueryFilter.g | 311 +
.../queryindex/src/main/java/QueryFilter.tokens | 47 +
.../ApplicationAlreadyExistsException.java | 37 +
.../DuplicateUniquePropertyExistsException.java | 52 +
.../exceptions/EntityNotFoundException.java | 45 +
.../exceptions/JsonReadException.java | 27 +
.../exceptions/JsonWriteException.java | 27 +
.../exceptions/LockingException.java | 65 +
.../exceptions/NoFullTextIndexException.java | 50 +
.../exceptions/NoIndexException.java | 50 +
.../exceptions/NotImplementedException.java | 58 +
.../exceptions/PersistenceException.java | 45 +
.../PropertyTypeConversionException.java | 71 +
.../exceptions/QueryIterationException.java | 13 +
.../exceptions/QueryParseException.java | 63 +
.../exceptions/QueryTokenException.java | 52 +
.../persistence/exceptions/QueueException.java | 61 +
.../RequiredPropertyNotFoundException.java | 41 +
.../TransactionNotFoundException.java | 45 +
.../UnexpectedEntityTypeException.java | 45 +
.../index/EntityCollectionIndex.java | 46 +
.../persistence/index/EntitySearchResults.java | 65 +
.../index/impl/EntityCollectionIndexImpl.java | 272 +
.../persistence/index/impl/IndexModule.java | 32 +
.../persistence/query/AggregateCounter.java | 48 +
.../persistence/query/AggregateCounterSet.java | 116 +
.../persistence/query/AssociatedEntityRef.java | 21 +
.../persistence/query/CollectionRef.java | 26 +
.../persistence/query/ConnectedEntityRef.java | 22 +
.../persistence/query/ConnectionRef.java | 34 +
.../persistence/query/CounterResolution.java | 84 +
.../usergrid/persistence/query/EntityRef.java | 28 +
.../usergrid/persistence/query/Query.java | 1099 +
.../usergrid/persistence/query/QueryUtils.java | 34 +
.../usergrid/persistence/query/Results.java | 1284 +
.../persistence/query/SimpleEntityRef.java | 129 +
.../usergrid/persistence/query/ir/AllNode.java | 45 +
.../usergrid/persistence/query/ir/AndNode.java | 43 +
.../persistence/query/ir/BooleanNode.java | 48 +
.../query/ir/EmailIdentifierNode.java | 28 +
.../query/ir/NameIdentifierNode.java | 28 +
.../persistence/query/ir/NodeVisitor.java | 71 +
.../usergrid/persistence/query/ir/NotNode.java | 62 +
.../usergrid/persistence/query/ir/OrNode.java | 52 +
.../persistence/query/ir/OrderByNode.java | 84 +
.../persistence/query/ir/QueryNode.java | 28 +
.../persistence/query/ir/SearchVisitor.java | 68 +
.../query/ir/UuidIdentifierNode.java | 32 +
.../persistence/query/ir/WithinNode.java | 87 +
.../persistence/query/tree/AndOperand.java | 48 +
.../persistence/query/tree/BooleanLiteral.java | 48 +
.../persistence/query/tree/BooleanOperand.java | 48 +
.../persistence/query/tree/ContainsOperand.java | 69 +
.../query/tree/ContainsProperty.java | 57 +
.../usergrid/persistence/query/tree/Equal.java | 52 +
.../persistence/query/tree/EqualityOperand.java | 88 +
.../persistence/query/tree/FloatLiteral.java | 57 +
.../persistence/query/tree/GreaterThan.java | 52 +
.../query/tree/GreaterThanEqual.java | 56 +
.../persistence/query/tree/LessThan.java | 52 +
.../persistence/query/tree/LessThanEqual.java | 54 +
.../persistence/query/tree/Literal.java | 38 +
.../persistence/query/tree/LiteralFactory.java | 58 +
.../persistence/query/tree/LongLiteral.java | 64 +
.../persistence/query/tree/NotOperand.java | 45 +
.../persistence/query/tree/NumericLiteral.java | 24 +
.../persistence/query/tree/Operand.java | 47 +
.../persistence/query/tree/OrOperand.java | 53 +
.../persistence/query/tree/Property.java | 62 +
.../query/tree/QueryFilterLexer.java | 2565 ++
.../query/tree/QueryFilterParser.java | 2186 +
.../persistence/query/tree/QueryVisitor.java | 90 +
.../persistence/query/tree/StringLiteral.java | 82 +
.../persistence/query/tree/UUIDLiteral.java | 49 +
.../persistence/query/tree/WithinOperand.java | 111 +
.../persistence/query/tree/WithinProperty.java | 54 +
.../usergrid/persistence/utils/AESUtils.java | 83 +
.../usergrid/persistence/utils/BCrypt.java | 627 +
.../usergrid/persistence/utils/ClassUtils.java | 58 +
.../usergrid/persistence/utils/CodecUtils.java | 45 +
.../persistence/utils/ConversionUtils.java | 765 +
.../usergrid/persistence/utils/DateUtils.java | 88 +
.../persistence/utils/InflectionUtils.java | 51 +
.../usergrid/persistence/utils/Inflector.java | 553 +
.../usergrid/persistence/utils/JsonUtils.java | 329 +
.../usergrid/persistence/utils/ListUtils.java | 230 +
.../usergrid/persistence/utils/MapUtils.java | 377 +
.../usergrid/persistence/utils/NumberUtils.java | 35 +
.../persistence/utils/PasswordUtils.java | 28 +
.../usergrid/persistence/utils/StringUtils.java | 172 +
.../usergrid/persistence/utils/TimeUtils.java | 88 +
.../usergrid/persistence/utils/UUIDUtils.java | 412 +
.../usergrid/persistence/utils/Version.java | 428 +
.../persistence/utils/package-info.java | 18 +
.../index/impl/ElasticSearchTest.java | 262 +
.../persistence/index/impl/EntityIndexTest.java | 306 +
.../usergrid/persistence/query/QueryTest.java | 312 +
.../persistence/query/tree/GrammarTreeTest.java | 608 +
.../persistence/query/tree/LongLiteralTest.java | 62 +
.../query/tree/StringLiteralTest.java | 88 +
.../persistence/utils/ElasticSearchRule.java | 65 +
.../src/test/resources/log4j.properties | 15 +
.../src/test/resources/sample-large.json | 39603 +++++++++++++++++
.../src/test/resources/sample-small.json | 222 +
118 files changed, 57851 insertions(+), 41078 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/pom.xml b/stack/corepersistence/index/pom.xml
deleted file mode 100644
index 37984e8..0000000
--- a/stack/corepersistence/index/pom.xml
+++ /dev/null
@@ -1,190 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <properties>
- <guice.version>3.0</guice.version>
- <guicyfig.version>3.3</guicyfig.version>
- <slf4j.version>1.7.2</slf4j.version>
- <log4j.version>1.2.17</log4j.version>
- <chop.version>1.0</chop.version>
- </properties>
-
- <parent>
- <artifactId>persistence</artifactId>
- <groupId>org.apache.usergrid</groupId>
- <version>1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <description>Module provates indexing for Entities via ElasticSearch</description>
-
- <artifactId>index</artifactId>
-
- <build>
-
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </testResource>
- </testResources>
-
- <plugins>
-
- <plugin>
- <groupId>org.safehaus.chop</groupId>
- <artifactId>chop-maven-plugin</artifactId>
- <version>${chop.version}</version>
-
- <!--
- NOTE: you should be putting most of these variables into your settings.xml
- as an automatically activated profile.
- -->
-
- <configuration>
- <accessKey>${aws.s3.key}</accessKey>
- <secretKey>${aws.s3.secret}</secretKey>
- <availabilityZone>${availabilityZone}</availabilityZone>
- <bucketName>${aws.s3.bucket}</bucketName>
- <managerAppUsername>admin</managerAppUsername>
- <managerAppPassword>${manager.app.password}</managerAppPassword>
- <testPackageBase>org.apache.usergrid</testPackageBase>
- <runnerSSHKeyFile>${runner.ssh.key.file}</runnerSSHKeyFile>
- <failIfCommitNecessary>false</failIfCommitNecessary>
- <amiID>${ami.id}</amiID>
- <instanceType>m1.large</instanceType>
- <resultsDirectory>${resultsDirectory}</resultsDirectory>
- <dumpType>${dumpType}</dumpType>
- <coldRestartTomcat>true</coldRestartTomcat>
- <awsSecurityGroup>${security.group}</awsSecurityGroup>
- <runnerKeyPairName>${runner.keypair.name}</runnerKeyPairName>
- <runnerCount>6</runnerCount>
- <securityGroupExceptions>
- <!--
- Add your own IP address as an exception to allow access
- but please do this in the settings.xml file .. essentially
- all parameters should be in the settings.xml file.
- -->
- <param>${myip.address}/32:24981</param>
- <param>${myip.address}/32:22</param>
- </securityGroupExceptions>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <check>
- <branchRate>85</branchRate>
- <lineRate>85</lineRate>
- <haltOnFailure>true</haltOnFailure>
- <totalBranchRate>85</totalBranchRate>
- <totalLineRate>85</totalLineRate>
- <packageLineRate>85</packageLineRate>
- <packageBranchRate>85</packageBranchRate>
- </check>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>clean</goal>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>model</artifactId>
- <version>1.0-SNAPSHOT</version>
- <type>jar</type>
- </dependency>
-
- <dependency>
- <groupId>org.apache.usergrid</groupId>
- <artifactId>collection</artifactId>
- <version>1.0-SNAPSHOT</version>
- <type>jar</type>
- </dependency>
-
- <dependency>
- <groupId>org.safehaus.chop</groupId>
- <artifactId>chop-api</artifactId>
- <version>${chop.version}</version>
- </dependency>
-
- <!-- Google Guice Integration Test Injectors -->
-
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>model</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.elasticsearch</groupId>
- <artifactId>elasticsearch</artifactId>
- <version>1.0.0.RC1</version>
- </dependency>
-
- <dependency>
- <groupId>org.safehaus.guicyfig</groupId>
- <artifactId>guicyfig</artifactId>
- <version>${guicyfig.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.jukito</groupId>
- <artifactId>jukito</artifactId>
- <version>${jukito.version}</version>
- <scope>test</scope>
- </dependency>
-
- <!-- lang utils for setting uuids etc -->
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.1</version>
- </dependency>
-
- <!-- Google Guice -->
-
- <dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- <version>${guice.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
-
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${log4j.version}</version>
- </dependency>
-
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
deleted file mode 100644
index 4652f81..0000000
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.usergrid.persistence.index;
-
-import org.apache.usergrid.persistence.model.entity.Entity;
-
-
-/**
- * Provides indexing of Entities within a scope.
- */
-public interface EntityCollectionIndex {
-
- /**
- * Create index for Entity
- * @param entity Entity to be indexed.
- */
- public void index( Entity entity );
-
- /**
- * Remove index of entity.
- * @param entity Entity to be removed from index.
- */
- public void deindex( Entity entity );
-
- /**
- * Simple query interface for testing using Lucene query syntax.
- */
- public EntitySearchResults simpleQuery( String query, int from, int size );
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/EntitySearchResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/EntitySearchResults.java b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/EntitySearchResults.java
deleted file mode 100644
index 03e91d9..0000000
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/EntitySearchResults.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.usergrid.persistence.index;
-
-import java.util.List;
-import java.util.UUID;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-
-/**
- * Search results are Id and Version references to Entities.
- */
-public class EntitySearchResults {
- private final long count;
- private final List<Ref> refs;
-
- public EntitySearchResults( long count, List<Ref> refs ) {
- this.count = count;
- this.refs = refs;
- }
-
- public long count() {
- return count;
- }
-
- public List<Ref> getRefs() {
- return refs;
- }
-
- /**
- * Reference to one specific version of an Entity.
- */
- public static final class Ref {
- private Id id;
- private UUID version;
-
- public Ref( Id id, UUID version ) {
- this.id = id;
- this.version = version;
- }
- public Id getId() {
- return id;
- }
- public UUID getVersion() {
- return version;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
deleted file mode 100644
index c009a66..0000000
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexImpl.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.index.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.index.EntityCollectionIndex;
-import org.apache.usergrid.persistence.index.EntitySearchResults;
-import org.apache.usergrid.persistence.index.EntitySearchResults.Ref;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.field.ArrayField;
-import org.apache.usergrid.persistence.model.field.EntityObjectField;
-import org.apache.usergrid.persistence.model.field.Field;
-import org.apache.usergrid.persistence.model.field.ListField;
-import org.apache.usergrid.persistence.model.field.SetField;
-import org.apache.usergrid.persistence.model.field.StringField;
-import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
-import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest;
-import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
-import org.elasticsearch.action.index.IndexRequestBuilder;
-import org.elasticsearch.action.index.IndexResponse;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.AdminClient;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import org.elasticsearch.index.query.QueryStringQueryBuilder;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.search.SearchHits;
-
-
-public class EntityCollectionIndexImpl implements EntityCollectionIndex {
- private final Client client;
- private final String index;
- private final boolean refresh;
- private final CollectionScope scope;
-
- public static final String STRING_FIELD_SUFFIX = "_ug_analyzed";
-
-
- public EntityCollectionIndexImpl( Client client, String index, CollectionScope scope, boolean refresh ) {
- this.client = client;
- this.index = index;
- this.scope = scope;
- this.refresh = refresh;
-
- // if new index then create it
- AdminClient admin = client.admin();
- if ( !admin.indices().exists( new IndicesExistsRequest( index )).actionGet().isExists() ) {
- admin.indices().prepareCreate( index ).execute().actionGet();
- }
-
- // if new type then create mapping
- if ( !admin.indices().typesExists( new TypesExistsRequest(
- new String[] {index}, scope.getName() )).actionGet().isExists()) {
-
- try {
- XContentBuilder mxcb = EntityCollectionIndexImpl
- .createDoubleStringIndexMapping( jsonBuilder(), scope.getName() );
-
- PutMappingResponse pmr = admin.indices().preparePutMapping(index)
- .setType( scope.getName() ).setSource( mxcb ).execute().actionGet();
-
- } catch ( IOException ex ) {
- throw new RuntimeException("Error adding mapping for type " + scope.getName(), ex );
- }
- }
- }
-
-
- public void index( Entity entity ) {
-
- Map<String, Object> entityAsMap = EntityCollectionIndexImpl.entityToMap( entity );
-
- IndexRequestBuilder irb = client.prepareIndex(index, scope.getName(), createIndexId( entity ))
- .setSource( entityAsMap )
- .setRefresh( refresh );
-
- // Cannot set version. As far as I can tell ES insists that initial version number is -1
- // and that number is incremented by 1 on each update.
- // irb = irb.setVersion( entity.getVersion().timestamp() );
-
- IndexResponse ir = irb.execute().actionGet();
- }
-
-
- private String createIndexId( Entity entity ) {
- return entity.getId().getUuid().toString() + "|"
- + entity.getId().getType() + "|"
- + entity.getVersion().toString();
- }
-
-
- public void deindex( Entity entity ) {
- String compositeId = entity.getId().toString() + "|" + entity.getVersion().toString();
- client.prepareDelete( index, scope.getName(), compositeId).execute().actionGet();
- }
-
-
- public EntitySearchResults simpleQuery( String query, int from, int size ) {
-
- QueryStringQueryBuilder builder = new QueryStringQueryBuilder( query );
-
- SearchResponse sr = client.prepareSearch( index ).setTypes( scope.getName() )
- .setQuery( builder ).setFrom( from ).setSize( size ).execute().actionGet();
-
- List<Ref> refs = new ArrayList<Ref>();
- SearchHits hits = sr.getHits();
-
- for ( SearchHit hit : hits.getHits() ) {
-
- String[] idparts = hit.getId().split( "\\|" );
- String id = idparts[0];
- String type = idparts[1];
- String version = idparts[2];
-
- Ref ref = new Ref( new SimpleId( UUID.fromString(id), type), UUID.fromString(version));
- refs.add( ref );
- }
-
- EntitySearchResults results = new EntitySearchResults( sr.getHits().getTotalHits(), refs );
- return results;
- }
-
-
- /**
- * Convert Entity to Map, adding version_ug_field and a {name}_ug_analyzed field for each StringField.
- */
- public static Map entityToMap( Entity entity ) {
-
- Map<String, Object> entityMap = new HashMap<String, Object>();
-
- for ( Object f : entity.getFields().toArray() ) {
-
- if ( f instanceof ListField || f instanceof ArrayField ) {
- Field field = (Field)f;
- List list = (List)field.getValue();
- entityMap.put( field.getName(),
- new ArrayList( processCollectionForMap( list ) ) );
-
- } else if ( f instanceof SetField ) {
- Field field = (Field)f;
- Set set = (Set)field.getValue();
- entityMap.put( field.getName(),
- new ArrayList( processCollectionForMap( set ) ) );
-
- } else if ( f instanceof EntityObjectField ) {
- Field field = (Field)f;
- Entity ev = (Entity)field.getValue();
- entityMap.put( field.getName(), entityToMap( ev ) ); // recursion
-
- } else if ( f instanceof StringField ) {
- Field field = (Field)f;
- entityMap.put( field.getName(), field.getValue() );
- entityMap.put( field.getName() + STRING_FIELD_SUFFIX, field.getValue() );
-
- } else {
- Field field = (Field)f;
- entityMap.put( field.getName(), field.getValue() );
- }
- }
-
- return entityMap;
- }
-
-
- private static Collection processCollectionForMap( Collection c ) {
- if ( c.isEmpty() ) {
- return c;
- }
- List processed = new ArrayList();
- Object sample = c.iterator().next();
-
- if ( sample instanceof Entity ) {
- for ( Object o : c.toArray() ) {
- Entity e = (Entity)o;
- processed.add( entityToMap( e ) );
- }
-
- } else if ( sample instanceof List ) {
- for ( Object o : c.toArray() ) {
- List list = (List)o;
- processed.add( processCollectionForMap( list ) ); // recursion;
- }
-
- } else if ( sample instanceof Set ) {
- for ( Object o : c.toArray() ) {
- Set set = (Set)o;
- processed.add( processCollectionForMap( set ) ); // recursion;
- }
-
- } else {
- for ( Object o : c.toArray() ) {
- processed.add( o );
- }
- }
- return processed;
- }
-
-
- /**
- * Build mappings for data to be indexed. Setup String fields as not_analyzed and analyzed,
- * where the analyzed field is named {name}_ug_analyzed
- *
- * @param builder Add JSON object to this builder.
- * @param type ElasticSearch type of entity.
- * @return Content builder with JSON for mapping.
- *
- * @throws java.io.IOException On JSON generation error.
- */
- public static XContentBuilder createDoubleStringIndexMapping(
- XContentBuilder builder, String type ) throws IOException {
-
- builder = builder
- .startObject()
- .startObject( type )
- .startArray( "dynamic_templates" )
-
- // any string with field name that ends with _ug_analyzed gets analyzed
- .startObject()
- .startObject( "template_1" )
- .field( "match", "*" + STRING_FIELD_SUFFIX)
- .field( "match_mapping_type", "string")
- .startObject( "mapping" )
- .field( "type", "string" )
- .field( "index", "analyzed" )
- .endObject()
- .endObject()
- .endObject()
-
- // all other strings are not analyzed
- .startObject()
- .startObject( "template_2" )
- .field( "match", "*")
- .field( "match_mapping_type", "string")
- .startObject( "mapping" )
- .field( "type", "string" )
- .field( "index", "not_analyzed" )
- .endObject()
- .endObject()
- .endObject()
-
- .endArray()
- .endObject()
- .endObject();
-
- return builder;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/impl/IndexModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/impl/IndexModule.java b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/impl/IndexModule.java
deleted file mode 100644
index bda9ee9..0000000
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/impl/IndexModule.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.usergrid.persistence.index.impl;
-
-import com.google.inject.AbstractModule;
-import org.apache.usergrid.persistence.index.EntityCollectionIndex;
-
-
-public class IndexModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind( EntityCollectionIndex.class ).to( EntityCollectionIndexImpl.class );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchTest.java b/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchTest.java
deleted file mode 100644
index f6ee564..0000000
--- a/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchTest.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.usergrid.persistence.index.impl;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.usergrid.persistence.utils.ElasticSearchRule;
-import org.elasticsearch.ElasticsearchException;
-import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
-import org.elasticsearch.action.get.GetResponse;
-import org.elasticsearch.action.index.IndexResponse;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.AdminClient;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Rule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Elastic search experiments in the form of a test.
- */
-public class ElasticSearchTest {
- private static final Logger logger = LoggerFactory.getLogger( ElasticSearchTest.class );
-
- @Rule
- public ElasticSearchRule elasticSearchRule = new ElasticSearchRule();
-
- @Test
- public void testSimpleCrud() {
-
- String indexName = RandomStringUtils.randomAlphanumeric(20 ).toLowerCase();
- String collectionName = "testtype1";
- String id = RandomStringUtils.randomAlphanumeric(20 );
-
- Client client = elasticSearchRule.getClient();
-
- Map<String, Object> json = new HashMap<String, Object>();
- json.put( "user", "edward" );
- json.put( "postDate", new Date() );
- json.put( "message", "who knows if the moon’s a baloon" );
-
- // create
- IndexResponse indexResponse = client.prepareIndex(indexName, collectionName, id)
- .setSource( json ).execute().actionGet();
- assertTrue( indexResponse.isCreated() );
-
- // retrieve
- GetResponse getResponse = client.prepareGet( indexName, collectionName, id).get();
- assertEquals( "edward", getResponse.getSource().get( "user" ) );
-
- // update
- json.put( "message", "If freckles were lovely, and day was night");
- client.prepareUpdate( indexName, collectionName, id).setDoc( json ).execute().actionGet();
- getResponse = client.prepareGet( indexName, collectionName, id).get();
- assertEquals("If freckles were lovely, and day was night",
- getResponse.getSource().get( "message" ) );
-
- // update via script
- client.prepareUpdate( indexName, collectionName, id)
- .setScript( "ctx._source.message = \"coming out of a keen city in the sky\"" )
- .execute().actionGet();
- getResponse = client.prepareGet( indexName, collectionName, id).get();
- assertEquals("coming out of a keen city in the sky",
- getResponse.getSource().get( "message" ) );
-
- // delete
- client.prepareDelete(indexName, collectionName, id).execute().actionGet();
- getResponse = client.prepareGet( indexName, collectionName, id).get();
- assertFalse( getResponse.isExists() );
-
- client.close();
- }
-
-
- @Test
- public void testStringDoubleIndexDynamicMapping() throws IOException {
-
- Client client = elasticSearchRule.getClient();
-
- AdminClient admin = client.admin();
-
- String index = RandomStringUtils.randomAlphanumeric(20).toLowerCase();
- String type = "testtype";
- admin.indices().prepareCreate( index ).execute().actionGet();
-
- // add dynamic string-double index mapping
- XContentBuilder mxcb = EntityCollectionIndexImpl
- .createDoubleStringIndexMapping( jsonBuilder(), type );
- PutMappingResponse pmr = admin.indices().preparePutMapping(index)
- .setType( type ).setSource( mxcb ).execute().actionGet();
-
- indexSampleData( type, client, index );
-
- testQuery( client, index, type,
- QueryBuilders.termQuery( "name", "Orr Byers" ), 1 );
-
- // term query is exact match
- testQuery( client, index, type,
- QueryBuilders.termQuery("name", "Byers" ), 0 );
-
- // match query allows partial match
- testQuery( client, index, type,
- QueryBuilders.matchQuery( "name_ug_analyzed", "Byers" ), 1 );
-
- testQuery( client, index, type,
- QueryBuilders.termQuery( "company", "Geologix" ), 1 );
-
- testQuery( client, index, type,
- QueryBuilders.termQuery( "gender", "female" ), 3 );
-
- // query of nested object fields supported
- testQuery( client, index, type,
- QueryBuilders.termQuery( "contact.email", "orrbyers@bittor.com" ), 1 );
-
- client.close();
- }
-
-
- private void indexSampleData( String type, Client client, String index )
- throws ElasticsearchException, IOException {
-
- InputStream is = this.getClass().getResourceAsStream( "/sample-small.json" );
- ObjectMapper mapper = new ObjectMapper();
- List<Object> contacts = mapper.readValue( is, new TypeReference<List<Object>>() {} );
-
- for ( Object o : contacts ) {
- Map<String, Object> item = (Map<String, Object>)o;
- String id = item.get( "id" ).toString();
-
- XContentBuilder dxcb = ElasticSearchTest
- .prepareContentForIndexing( jsonBuilder(), type, item );
-
- IndexResponse ir = client.prepareIndex(index, type, id )
- .setSource( dxcb ).setRefresh( true ).execute().actionGet();
- }
- }
-
-
- private void testQuery( Client client, String index, String type, QueryBuilder qb, int num ) {
- SearchResponse sr = client.prepareSearch( index ).setTypes( type )
- .setQuery( qb ).setFrom( 0 ).setSize( 20 ).execute().actionGet();
- assertEquals( num, sr.getHits().getTotalHits() );
- }
-
-
- public static XContentBuilder prepareContentForIndexing( String name, XContentBuilder builder,
- String type, Map<String, Object> data ) throws IOException {
-
- if ( name != null ) {
- builder = builder.startObject( name );
- } else {
- builder = builder.startObject();
- }
- for ( String key : data.keySet() ) {
- Object value = data.get( key );
- try {
-
- if ( value instanceof Map ) {
- builder = prepareContentForIndexing(
- key, builder, type, (Map<String, Object>)data.get(key));
-
- } else if ( value instanceof List ) {
- builder = prepareContentForIndexing(key, builder, type, (List)value);
-
- } else if ( value instanceof String ) {
- builder = builder
- .field( key + "_ug_analyzed", value )
- .field( key, value );
-
- } else {
- builder = builder
- .field( key, value );
-
- }
- } catch ( Exception e ) {
- logger.error( "Error processing {} : {}", key, value, e );
- throw new RuntimeException(e);
- }
- }
- builder = builder.endObject();
- return builder;
- }
-
-
- public static XContentBuilder prepareContentForIndexing( XContentBuilder builder,
- String type, Map<String, Object> dataMap ) throws IOException {
- return prepareContentForIndexing( null, builder, type, dataMap );
- }
-
-
- public static XContentBuilder prepareContentForIndexing( String name, XContentBuilder builder,
- String type, List dataList ) throws IOException {
-
- if ( name != null ) {
- builder = builder.startArray( name );
- } else {
- builder = builder.startArray();
- }
- for ( Object o : dataList ) {
-
- if ( o instanceof Map ) {
- builder = prepareContentForIndexing( builder, type, (Map<String, Object>)o );
-
- } else if ( o instanceof List ) {
- builder = prepareContentForIndexing( builder, type, (List)o);
-
- } else {
- builder = builder.value( o );
-
- }
- }
- builder = builder.endArray();
- return builder;
- }
-
-
- public static XContentBuilder prepareContentForIndexing( XContentBuilder builder,
- String type, List dataList ) throws IOException {
- return prepareContentForIndexing( null, builder, type, dataList );
- }
-
- void log( GetResponse getResponse ) {
- logger.info( "-------------------------------------------------------------------------" );
- logger.info( "id: " + getResponse.getId() );
- logger.info( "type: " + getResponse.getType() );
- logger.info( "version: " + getResponse.getVersion() );
- logger.info( "index: " + getResponse.getIndex() );
- logger.info( "source: " + getResponse.getSourceAsString() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
deleted file mode 100644
index ee884f7..0000000
--- a/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.index.impl;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Maps;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.lang3.time.StopWatch;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.util.EntityUtils;
-import org.apache.usergrid.persistence.index.EntityCollectionIndex;
-import org.apache.usergrid.persistence.index.EntitySearchResults;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.field.BooleanField;
-import org.apache.usergrid.persistence.model.field.DoubleField;
-import org.apache.usergrid.persistence.model.field.EntityObjectField;
-import org.apache.usergrid.persistence.model.field.IntegerField;
-import org.apache.usergrid.persistence.model.field.ListField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.utils.ElasticSearchRule;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import static org.junit.Assert.assertEquals;
-import org.junit.Rule;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class EntityIndexTest {
- private static final Logger logger = LoggerFactory.getLogger( EntityIndexTest.class );
-
- @Rule
- public ElasticSearchRule elasticSearchRule = new ElasticSearchRule();
-
-
- @Test
- public void testIndex() throws IOException {
-
- Client client = elasticSearchRule.getClient();
- final CollectionScope scope = mock( CollectionScope.class );
- when( scope.getName() ).thenReturn( "contacts" );
- String index = RandomStringUtils.randomAlphanumeric(20 ).toLowerCase();
- String type = scope.getName();
-
- EntityCollectionIndex entityIndex =
- new EntityCollectionIndexImpl( client, index, scope, true );
-
- InputStream is = this.getClass().getResourceAsStream( "/sample-large.json" );
- ObjectMapper mapper = new ObjectMapper();
- List<Object> sampleJson = mapper.readValue( is, new TypeReference<List<Object>>() {} );
-
- int count = 0;
- StopWatch timer = new StopWatch();
- timer.start();
- for ( Object o : sampleJson ) {
-
- Map<String, Object> item = (Map<String, Object>)o;
-
- Entity entity = new Entity(new SimpleId(UUIDGenerator.newTimeUUID(), scope.getName()));
- entity = EntityIndexTest.mapToEntity( scope.getName(), entity, item );
- EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
-
- entityIndex.index( entity );
-
- count++;
- }
- timer.stop();
- logger.info( "Total time to index {} entries {}ms, average {}ms/entry",
- count, timer.getTime(), timer.getTime() / count );
-
- // test queries via Java API QueryBuilder
- testQueries( client, index, type );
-
- // test queries via Lucene syntax
- testQueries( entityIndex );
-
- client.close();
- }
-
-
- private void testQuery( Client client, String index, String type, QueryBuilder qb, int num ) {
-
- StopWatch timer = new StopWatch();
- timer.start();
- SearchResponse sr = client.prepareSearch( index ).setTypes( type )
- .setQuery( qb ).setFrom( 0 ).setSize( 999 ).execute().actionGet();
- timer.stop();
-
- assertEquals( num, sr.getHits().getTotalHits() );
- logger.debug( "Query1 time {}ms", timer.getTime() );
- }
-
-
- private void testQueries( Client client, String index, String type ) {
-
- testQuery( client, index, type,
- QueryBuilders.termQuery( "name", "Morgan Pierce" ), 1 );
-
- // term query is exact match
- testQuery( client, index, type,
- QueryBuilders.termQuery("name", "Pierce" ), 0 );
-
- // match query allows partial match
- testQuery( client, index, type,
- QueryBuilders.matchQuery( "name_ug_analyzed", "Pierce" ), 2 );
-
- testQuery( client, index, type,
- QueryBuilders.termQuery( "company", "Blurrybus" ), 1 );
-
- testQuery( client, index, type,
- QueryBuilders.termQuery( "gender", "female" ), 433 );
-
- // query of nested object fields supported
- testQuery( client, index, type,
- QueryBuilders.termQuery( "contact.email", "nadiabrown@concility.com" ), 1 );
- }
-
-
- private void testQuery( EntityCollectionIndex entityIndex, String query, int num ) {
-
- StopWatch timer = new StopWatch();
- timer.start();
- EntitySearchResults results = entityIndex.simpleQuery( query, 0, 999);
- timer.stop();
-
- assertEquals( num, results.count() );
- logger.debug( "Query2 time {}ms", timer.getTime() );
- }
-
-
- private void testQueries( EntityCollectionIndex entityIndex ) {
-
- testQuery( entityIndex, "name:\"Morgan Pierce\"", 1);
-
- testQuery( entityIndex, "name:\"Morgan\"", 0);
-
- testQuery( entityIndex, "name_ug_analyzed:\"Morgan\"", 1);
-
- testQuery( entityIndex, "gender:female", 433);
- }
-
-
- @Test
- public void testRemoveIndex() {
- }
-
-
- /**
- * Test of mapToEntity method, of class EntityUtils.
- */
- @Test
- public void testMapToEntityRoundTrip() throws IOException {
-
- InputStream is = this.getClass().getResourceAsStream( "/sample-large.json" );
- ObjectMapper mapper = new ObjectMapper();
- List<Object> contacts = mapper.readValue( is, new TypeReference<List<Object>>() {} );
-
- for ( Object o : contacts ) {
-
- Map<String, Object> map1 = (Map<String, Object>)o;
-
- // convert map to entity
- Entity entity1 = EntityIndexTest.mapToEntity( "testscope", map1 );
-
- // convert entity back to map
- Map map2 = EntityCollectionIndexImpl.entityToMap( entity1 );
-
- // the two maps should be the same except for the two new _ug_analyzed properties
- Map diff = Maps.difference( map1, map2 ).entriesDiffering();
- assertEquals( 2, diff.size() );
- }
- }
-
-
- public static Entity mapToEntity( String scope, Map<String, Object> item ) {
- return mapToEntity( scope, null, item );
- }
-
-
- public static Entity mapToEntity( String scope, Entity entity, Map<String, Object> map ) {
-
- if ( entity == null ) {
- entity = new Entity();
- }
-
- for ( String fieldName : map.keySet() ) {
-
- Object value = map.get( fieldName );
-
- if ( value instanceof String ) {
- entity.setField( new StringField(fieldName, (String)value ));
-
- } else if ( value instanceof Boolean ) {
- entity.setField( new BooleanField(fieldName, (Boolean)value ));
-
- } else if ( value instanceof Integer ) {
- entity.setField( new IntegerField(fieldName, (Integer)value ));
-
- } else if ( value instanceof Double ) {
- entity.setField( new DoubleField(fieldName, (Double)value ));
-
- } else if ( value instanceof Long ) {
- entity.setField( new LongField(fieldName, (Long)value ));
-
- } else if ( value instanceof List) {
- entity.setField( listToListField( scope, fieldName, (List)value ));
-
- } else if ( value instanceof Map ) {
- entity.setField( new EntityObjectField( fieldName,
- mapToEntity( scope, (Map<String, Object>)value ))); // recursion
-
- } else {
- throw new RuntimeException("Unknown type " + value.getClass().getName());
- }
- }
-
- return entity;
- }
-
-
- private static ListField listToListField( String scope, String fieldName, List list ) {
-
- if (list.isEmpty()) {
- return new ListField( fieldName );
- }
-
- Object sample = list.get(0);
-
- if ( sample instanceof Map ) {
- return new ListField<Entity>( fieldName, processListForField( scope, list ));
-
- } else if ( sample instanceof List ) {
- return new ListField<List>( fieldName, processListForField( scope, list ));
-
- } else if ( sample instanceof String ) {
- return new ListField<String>( fieldName, (List<String>)list );
-
- } else if ( sample instanceof Boolean ) {
- return new ListField<Boolean>( fieldName, (List<Boolean>)list );
-
- } else if ( sample instanceof Integer ) {
- return new ListField<Integer>( fieldName, (List<Integer>)list );
-
- } else if ( sample instanceof Double ) {
- return new ListField<Double>( fieldName, (List<Double>)list );
-
- } else if ( sample instanceof Long ) {
- return new ListField<Long>( fieldName, (List<Long>)list );
-
- } else {
- throw new RuntimeException("Unknown type " + sample.getClass().getName());
- }
- }
-
-
- private static List processListForField( String scope, List list ) {
- if ( list.isEmpty() ) {
- return list;
- }
- Object sample = list.get(0);
-
- if ( sample instanceof Map ) {
- List<Entity> newList = new ArrayList<Entity>();
- for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
- newList.add( mapToEntity( scope, map ) );
- }
- return newList;
-
- } else if ( sample instanceof List ) {
- return processListForField( scope, list ); // recursion
-
- } else {
- return list;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/utils/ElasticSearchRule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/utils/ElasticSearchRule.java b/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/utils/ElasticSearchRule.java
deleted file mode 100644
index 0068fad..0000000
--- a/stack/corepersistence/index/src/test/java/org/apache/usergrid/persistence/utils/ElasticSearchRule.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.utils;
-
-import org.apache.usergrid.persistence.collection.util.AvailablePortFinder;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.node.Node;
-import org.elasticsearch.node.NodeBuilder;
-import org.junit.rules.ExternalResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class ElasticSearchRule extends ExternalResource {
- private static final Logger log = LoggerFactory.getLogger( ElasticSearchRule.class );
-
- private Client client;
-
- @Override
- protected void after() {
- client.close();
- }
-
- @Override
- protected void before() throws Throwable {
-
- // use unique port and directory names so multiple instances of ES can run concurrently.
- int port = AvailablePortFinder.getNextAvailable(2000);
- Settings settings = ImmutableSettings.settingsBuilder()
- .put("node.http.enabled", true)
- .put("transport.tcp.port", port )
- .put("path.logs","target/elasticsearch/logs_" + port )
- .put("path.data","target/elasticsearch/data_" + port )
- .put("gateway.type", "none" )
- .put("index.store.type", "memory" )
- .put("index.number_of_shards", 1 )
- .put("index.number_of_replicas", 1).build();
-
- Node node = NodeBuilder.nodeBuilder().local(true).settings(settings).node();
- client = node.client();
- }
-
- public Client getClient() {
- return client;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/index/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/test/resources/log4j.properties b/stack/corepersistence/index/src/test/resources/log4j.properties
deleted file mode 100644
index 5d830ee..0000000
--- a/stack/corepersistence/index/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-log4j.rootLogger=INFO,stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %c{3}.%M(%L)<%t>- %m%n
-
-log4j.logger.org.safehaus.chop.plugin=DEBUG
-log4j.logger.org.safehaus.guicyfig=ERROR
-log4j.logger.org.safehaus.chop.api.store.amazon=DEBUG
-log4j.logger.org.apache.http=ERROR
-log4j.logger.com.amazonaws.request=ERROR
-
-log4j.logger.org.apache.usergrid=DEBUG
-
-log4j.logger.org.apache.usergrid.persistence.index=DEBUG
[20/21] git commit: Remove classes not needed for query parsing.
Posted by sn...@apache.org.
Remove classes not needed for query parsing.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/72329d60
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/72329d60
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/72329d60
Branch: refs/heads/two-dot-o
Commit: 72329d6022217ee046eb5e8b0bc2345a10e74a8a
Parents: c0543f5
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Feb 21 13:01:35 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Feb 21 13:01:35 2014 -0500
----------------------------------------------------------------------
.../usergrid/persistence/utils/AESUtils.java | 83 ---
.../usergrid/persistence/utils/BCrypt.java | 627 -------------------
.../usergrid/persistence/utils/CodecUtils.java | 45 --
.../usergrid/persistence/utils/DateUtils.java | 88 ---
.../persistence/utils/InflectionUtils.java | 51 --
.../usergrid/persistence/utils/Inflector.java | 553 ----------------
.../usergrid/persistence/utils/NumberUtils.java | 35 --
.../persistence/utils/PasswordUtils.java | 28 -
.../usergrid/persistence/utils/TimeUtils.java | 88 ---
.../usergrid/persistence/utils/Version.java | 428 -------------
.../persistence/utils/package-info.java | 18 -
11 files changed, 2044 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/AESUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/AESUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/AESUtils.java
deleted file mode 100644
index 8b7e6f7..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/AESUtils.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.usergrid.persistence.utils;
-
-
-import javax.crypto.Cipher;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.commons.codec.binary.Base64;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.commons.lang.StringUtils.rightPad;
-import static org.apache.commons.lang.StringUtils.substring;
-
-
-public class AESUtils {
- private static final Logger LOG = LoggerFactory.getLogger( AESUtils.class );
-
- private static byte[] linebreak = { };
- private static Cipher cipher;
- private static Base64 coder;
-
-
- static {
- try {
- cipher = Cipher.getInstance( "AES/ECB/PKCS5Padding", "SunJCE" );
- coder = new Base64( 32, linebreak, true );
- }
- catch ( Throwable t ) {
- LOG.error( "Cipher error", t );
- }
- }
-
-
- public static synchronized String encrypt( String secret, String plainText ) {
- secret = substring( rightPad( secret, 16 ), 0, 16 );
- SecretKey key = new SecretKeySpec( secret.getBytes(), "AES" );
- try {
- cipher.init( Cipher.ENCRYPT_MODE, key );
- byte[] cipherText = cipher.doFinal( plainText.getBytes() );
- return new String( coder.encode( cipherText ) );
- }
- catch ( Exception e ) {
- LOG.error( "Encryption error", e );
- }
- return null;
- }
-
-
- @SuppressWarnings("unused")
- public static synchronized String decrypt( String secret, String codedText ) {
- secret = substring( rightPad( secret, 16 ), 0, 16 );
- SecretKey key = new SecretKeySpec( secret.getBytes(), "AES" );
- byte[] encypted = coder.decode( codedText.getBytes() );
- try {
- cipher.init( Cipher.DECRYPT_MODE, key );
- byte[] decrypted = cipher.doFinal( encypted );
- return new String( decrypted );
- }
- catch ( Exception e ) {
- LOG.error( "Decryption error", e );
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/BCrypt.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/BCrypt.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/BCrypt.java
deleted file mode 100644
index 0b0e49b..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/BCrypt.java
+++ /dev/null
@@ -1,627 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.utils;
-
-//Copyright (c) 2006 Damien Miller <dj...@mindrot.org>
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-import java.io.UnsupportedEncodingException;
-import java.security.SecureRandom;
-
-
-/**
- * BCrypt implements OpenBSD-style Blowfish password hashing using the scheme described in "A Future-Adaptable Password
- * Scheme" by Niels Provos and David Mazieres.
- * <p/>
- * This password hashing system tries to thwart off-line password cracking using a computationally-intensive hashing
- * algorithm, based on Bruce Schneier's Blowfish cipher. The work factor of the algorithm is parameterised, so it can be
- * increased as computers get faster.
- * <p/>
- * Usage is really simple. To hash a password for the first time, call the hashpw method with a random salt, like this:
- * <p/>
- * <code> String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt()); <br /> </code>
- * <p/>
- * To check whether a plaintext password matches one that has been hashed previously, use the checkpw method:
- * <p/>
- * <code> if (BCrypt.checkpw(candidate_password, stored_hash))<br /> System.out.println("It
- * matches");<br /> else<br /> System.out.println("It does not match");<br /> </code>
- * <p/>
- * The gensalt() method takes an optional parameter (logRounds) that determines the computational complexity of the
- * hashing:
- * <p/>
- * <code> String strong_salt = BCrypt.gensalt(10)<br /> String stronger_salt = BCrypt.gensalt(12)<br /> </code>
- * <p/>
- * The amount of work increases exponentially (2**logRounds), so each increment is twice as much work. The default
- * logRounds is 10, and the valid range is 4 to 31.
- *
- * @version 0.2
- */
-public class BCrypt {
- private static final int BCRYPT_SALT_LEN = 16;
-
- // Blowfish parameters
- private static final int BLOWFISH_NUM_ROUNDS = 16;
-
- // Initial contents of key schedule
- private static final int[] P_orig = {
- 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, 0x452821e6,
- 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b
- };
- private static final int[] S_orig = {
- 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, 0x24a19947,
- 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
- 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, 0xc5d1b023, 0x286085f0, 0xca417918,
- 0xb8db38ef, 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
- 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af,
- 0x7c72e993, 0xb3ee1411, 0x636fbc2a, 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
- 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60,
- 0x5dec8032, 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
- 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, 0x6a51a0d2,
- 0xd8542f68, 0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
- 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, 0xe06f75d8, 0x85c12073, 0x401a449f,
- 0x56c16aa6, 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
- 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6,
- 0x409f60c4, 0x5e5c9ec2, 0x196a2463, 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
- 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39,
- 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
- 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, 0x9e5c57bb,
- 0xca6f8ca0, 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
- 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, 0x9a53e479, 0xb6f84565, 0xd28e49bc,
- 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
- 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb,
- 0xf2122b64, 0x8888b812, 0x900df01c, 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
- 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81,
- 0xd2ada8d9, 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
- 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, 0x2464369b,
- 0xf009b91e, 0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
- 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, 0xd60f573f, 0xbc9bc6e4, 0x2b60a476,
- 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
- 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0,
- 0x49a7df7d, 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29,
- 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6,
- 0xf0255dc1, 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
- 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37,
- 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, 0xd19113f9, 0x7ca92ff6,
- 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e,
- 0xa4751e41, 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
- 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f,
- 0x2e6b7124, 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, 0xec7aec3a, 0xdb851dfa,
- 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002,
- 0x133ae4dd, 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
- 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c,
- 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, 0xc6150eba, 0x94e2ea78,
- 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e,
- 0xeac31f66, 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
- 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830,
- 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, 0xeecc86bc, 0x60622ca7,
- 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5,
- 0xc021b8f7, 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
- 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb,
- 0x532e3054, 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, 0x5d4a14d9, 0xe864b7e3,
- 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d,
- 0x41cd2105, 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
- 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a,
- 0x0c55f5ea, 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, 0x7cde3759, 0xcbee7460,
- 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc,
- 0x800bcadc, 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
- 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, 0xe93d5a68,
- 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a,
- 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af, 0x70f4ddd3,
- 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
- 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2,
- 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9,
- 0xee39d7ab, 0x3b124e8b, 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7,
- 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
- 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, 0xfdf8e802,
- 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f,
- 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60, 0xdff8e8a3,
- 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
- 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f,
- 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8,
- 0x991be14c, 0xdb6e6b0d, 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92,
- 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
- 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, 0x6a124237,
- 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386,
- 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086, 0x60787bf8,
- 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
- 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3,
- 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770,
- 0x8cd55591, 0xc902de4c, 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1,
- 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
- 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, 0x9af88c27,
- 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63,
- 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188, 0x39720a3d,
- 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
- 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234,
- 0x92638212, 0x670efa8e, 0x406000e0, 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
- 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be,
- 0x6a366eb4, 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
- 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8,
- 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
- 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, 0x80e4a915, 0x87b08601, 0x9b09e6ad,
- 0x3b3ee593, 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
- 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d,
- 0x283b57cc, 0xf8d56629, 0x79132e28, 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
- 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb,
- 0x26dcf319, 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
- 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, 0xa8b6e37e,
- 0xc3293d46, 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
- 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, 0xdda26a7e, 0x3a59ff45, 0x3e350a44,
- 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
- 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428,
- 0x95983a1d, 0x06b89fb4, 0xce6ea048, 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
- 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3,
- 0xa1e8aac7, 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
- 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, 0xfae59361,
- 0xceb69ceb, 0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
- 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, 0x1b0a7441, 0x4ba3348c, 0xc5be7120,
- 0xc37632d8, 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
- 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162,
- 0x5a75ebb5, 0x6e163697, 0x88d273cc, 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
- 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c,
- 0xcd769c2b, 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
- 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869,
- 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
- };
-
- // bcrypt IV: "OrpheanBeholderScryDoubt"
- private static final int[] BF_CRYPT_CYPHERTEXT = {
- 0x4f727068, 0x65616e42, 0x65686f6c, 0x64657253, 0x63727944, 0x6f756274
- };
-
- // Table for Base64 encoding
- private static final char[] BASE64_CODE = {
- '.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
- 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
- };
-
- // Table for Base64 decoding
- private static final byte[] INDEX_64 = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, -1, -1, -1, -1, -1, -1, -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, -1, -1, -1, -1, -1, -1, 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, -1, -1, -1, -1, -1
- };
-
- // Expanded Blowfish key
- private int[] p;
- private int[] s;
-
-
- /**
- * Encode a byte array using bcrypt's slightly-modified base64 encoding scheme. Note that this is *not* compatible
- * with the standard MIME-base64 encoding.
- *
- * @param d the byte array to encode
- * @param len the number of bytes to encode
- *
- * @return base64-encoded string
- *
- * @throws IllegalArgumentException if the length is invalid
- */
- private static String encodeBase64( byte[] d, int len ) throws IllegalArgumentException {
- int off = 0;
- StringBuilder rs = new StringBuilder();
- int c1;
- int c2;
-
- if ( ( len <= 0 ) || ( len > d.length ) ) {
- throw new IllegalArgumentException( "Invalid len" );
- }
-
- while ( off < len ) {
- c1 = d[off++] & 0xff;
- rs.append( BASE64_CODE[( c1 >> 2 ) & 0x3f] );
- c1 = ( c1 & 0x03 ) << 4;
- if ( off >= len ) {
- rs.append( BASE64_CODE[c1 & 0x3f] );
- break;
- }
- c2 = d[off++] & 0xff;
- c1 |= ( c2 >> 4 ) & 0x0f;
- rs.append( BASE64_CODE[c1 & 0x3f] );
- c1 = ( c2 & 0x0f ) << 2;
- if ( off >= len ) {
- rs.append( BASE64_CODE[c1 & 0x3f] );
- break;
- }
- c2 = d[off++] & 0xff;
- c1 |= ( c2 >> 6 ) & 0x03;
- rs.append( BASE64_CODE[c1 & 0x3f] );
- rs.append( BASE64_CODE[c2 & 0x3f] );
- }
- return rs.toString();
- }
-
-
- /**
- * Look up the 3 bits base64-encoded by the specified character, range-checking againt conversion table
- *
- * @param x the base64-encoded value
- *
- * @return the decoded value of x
- */
- private static byte char64( char x ) {
- if ( ( x < 0 ) || ( x > INDEX_64.length ) ) {
- return -1;
- }
- return INDEX_64[x];
- }
-
-
- /**
- * Decode a string encoded using bcrypt's base64 scheme to a byte array. Note that this is *not* compatible with the
- * standard MIME-base64 encoding.
- *
- * @param s the string to decode
- * @param maxolen the maximum number of bytes to decode
- *
- * @return an array containing the decoded bytes
- *
- * @throws IllegalArgumentException if maxolen is invalid
- */
- private static byte[] decodeBase64( String s, int maxolen ) throws IllegalArgumentException {
- StringBuilder rs = new StringBuilder();
- int off = 0;
- int slen = s.length();
- int olen = 0;
- byte[] ret;
- byte c1;
- byte c2;
- byte c3;
- byte c4;
- byte o;
-
- if ( maxolen <= 0 ) {
- throw new IllegalArgumentException( "Invalid maxolen" );
- }
-
- while ( ( off < slen - 1 ) && ( olen < maxolen ) ) {
- c1 = char64( s.charAt( off++ ) );
- c2 = char64( s.charAt( off++ ) );
- if ( ( c1 == -1 ) || ( c2 == -1 ) ) {
- break;
- }
- o = ( byte ) ( c1 << 2 );
- o |= ( c2 & 0x30 ) >> 4;
- rs.append( ( char ) o );
- if ( ( ++olen >= maxolen ) || ( off >= slen ) ) {
- break;
- }
- c3 = char64( s.charAt( off++ ) );
- if ( c3 == -1 ) {
- break;
- }
- o = ( byte ) ( ( c2 & 0x0f ) << 4 );
- o |= ( c3 & 0x3c ) >> 2;
- rs.append( ( char ) o );
- if ( ( ++olen >= maxolen ) || ( off >= slen ) ) {
- break;
- }
- c4 = char64( s.charAt( off++ ) );
- o = ( byte ) ( ( c3 & 0x03 ) << 6 );
- o |= c4;
- rs.append( ( char ) o );
- ++olen;
- }
-
- ret = new byte[olen];
- for ( off = 0; off < olen; off++ ) {
- ret[off] = ( byte ) rs.charAt( off );
- }
- return ret;
- }
-
-
- /**
- * Blowfish encipher a single 64-bit block encoded as two 32-bit halves
- *
- * @param lr an array containing the two 32-bit half blocks
- * @param off the position in the array of the blocks
- */
- private void encipher( int[] lr, int off ) {
- int i;
- int n;
- int l = lr[off];
- int r = lr[off + 1];
-
- l ^= p[0];
- for ( i = 0; i <= BLOWFISH_NUM_ROUNDS - 2; ) {
- // Feistel substitution on left word
- n = s[( l >> 24 ) & 0xff];
- n += s[0x100 | ( ( l >> 16 ) & 0xff )];
- n ^= s[0x200 | ( ( l >> 8 ) & 0xff )];
- n += s[0x300 | ( l & 0xff )];
- r ^= n ^ p[++i];
-
- // Feistel substitution on right word
- n = s[( r >> 24 ) & 0xff];
- n += s[0x100 | ( ( r >> 16 ) & 0xff )];
- n ^= s[0x200 | ( ( r >> 8 ) & 0xff )];
- n += s[0x300 | ( r & 0xff )];
- l ^= n ^ p[++i];
- }
- lr[off] = r ^ p[BLOWFISH_NUM_ROUNDS + 1];
- lr[off + 1] = l;
- }
-
-
- /**
- * Cyclically extract a word of key material
- *
- * @param data the string to extract the data from
- * @param offp a "pointer" (as a one-entry array) to the current offset into data
- *
- * @return the next word of material from data
- */
- private static int streamtoword( byte[] data, int[] offp ) {
- int i;
- int word = 0;
- int off = offp[0];
-
- for ( i = 0; i < 4; i++ ) {
- word = ( word << 8 ) | ( data[off] & 0xff );
- off = ( off + 1 ) % data.length;
- }
-
- offp[0] = off;
- return word;
- }
-
-
- /** Initialise the Blowfish key schedule */
- private void initKey() {
- p = P_orig.clone();
- s = S_orig.clone();
- }
-
-
- /**
- * Key the Blowfish cipher
- *
- * @param key an array containing the key
- */
- private void key( byte[] key ) {
- int i;
- int[] koffp = { 0 };
- int[] lr = { 0, 0 };
- int plen = p.length;
- int slen = s.length;
-
- for ( i = 0; i < plen; i++ ) {
- p[i] = p[i] ^ streamtoword( key, koffp );
- }
-
- for ( i = 0; i < plen; i += 2 ) {
- encipher( lr, 0 );
- p[i] = lr[0];
- p[i + 1] = lr[1];
- }
-
- for ( i = 0; i < slen; i += 2 ) {
- encipher( lr, 0 );
- s[i] = lr[0];
- s[i + 1] = lr[1];
- }
- }
-
-
- /**
- * Perform the "enhanced key schedule" step described by Provos and Mazieres in "A Future-Adaptable Password Scheme"
- * http://www.openbsd.org/papers/bcrypt-paper.ps
- *
- * @param data salt information
- * @param key password information
- */
- private void ekskey( byte[] data, byte[] key ) {
- int i;
- int[] koffp = { 0 };
- int[] doffp = { 0 };
- int[] lr = { 0, 0 };
- int plen = p.length;
- int slen = s.length;
-
- for ( i = 0; i < plen; i++ ) {
- p[i] = p[i] ^ streamtoword( key, koffp );
- }
-
- for ( i = 0; i < plen; i += 2 ) {
- lr[0] ^= streamtoword( data, doffp );
- lr[1] ^= streamtoword( data, doffp );
- encipher( lr, 0 );
- p[i] = lr[0];
- p[i + 1] = lr[1];
- }
-
- for ( i = 0; i < slen; i += 2 ) {
- lr[0] ^= streamtoword( data, doffp );
- lr[1] ^= streamtoword( data, doffp );
- encipher( lr, 0 );
- s[i] = lr[0];
- s[i + 1] = lr[1];
- }
- }
-
-
- /**
- * Perform the central password hashing step in the bcrypt scheme
- *
- * @param password the password to hash
- * @param salt the binary salt to hash with the password
- * @param logRounds the binary logarithm of the number of rounds of hashing to apply
- *
- * @return an array containing the binary hashed password
- */
- private byte[] cryptRaw( byte[] password, byte[] salt, int logRounds ) {
- int rounds;
- int i;
- int j;
- int[] cdata = BF_CRYPT_CYPHERTEXT.clone();
- int clen = cdata.length;
- byte[] ret;
-
- if ( ( logRounds < 4 ) || ( logRounds > 31 ) ) {
- throw new IllegalArgumentException( "Bad number of rounds" );
- }
- rounds = 1 << logRounds;
- if ( salt.length != BCRYPT_SALT_LEN ) {
- throw new IllegalArgumentException( "Bad salt length" );
- }
-
- initKey();
- ekskey( salt, password );
- for ( i = 0; i < rounds; i++ ) {
- key( password );
- key( salt );
- }
-
- for ( i = 0; i < 64; i++ ) {
- for ( j = 0; j < ( clen >> 1 ); j++ ) {
- encipher( cdata, j << 1 );
- }
- }
-
- ret = new byte[clen * 4];
- for ( i = 0, j = 0; i < clen; i++ ) {
- ret[j++] = ( byte ) ( ( cdata[i] >> 24 ) & 0xff );
- ret[j++] = ( byte ) ( ( cdata[i] >> 16 ) & 0xff );
- ret[j++] = ( byte ) ( ( cdata[i] >> 8 ) & 0xff );
- ret[j++] = ( byte ) ( cdata[i] & 0xff );
- }
- return ret;
- }
-
-
- /**
- * Hash a password using the OpenBSD bcrypt scheme
- *
- * @param password the password to hash
- * @param salt the salt to hash with (perhaps generated using BCrypt.gensalt)
- *
- * @return the hashed password
- */
- public static String hashpw( String password, String salt ) {
- BCrypt b;
- String realSalt;
- byte[] passwordb;
- byte[] saltb;
- byte[] hashed;
- char minor = ( char ) 0;
- int rounds;
- int off;
- StringBuilder rs = new StringBuilder();
-
- if ( ( salt.charAt( 0 ) != '$' ) || ( salt.charAt( 1 ) != '2' ) ) {
- throw new IllegalArgumentException( "Invalid salt version" );
- }
- if ( salt.charAt( 2 ) == '$' ) {
- off = 3;
- }
- else {
- minor = salt.charAt( 2 );
- if ( ( minor != 'a' ) || ( salt.charAt( 3 ) != '$' ) ) {
- throw new IllegalArgumentException( "Invalid salt revision" );
- }
- off = 4;
- }
-
- // Extract number of rounds
- if ( salt.charAt( off + 2 ) > '$' ) {
- throw new IllegalArgumentException( "Missing salt rounds" );
- }
- rounds = Integer.parseInt( salt.substring( off, off + 2 ) );
-
- realSalt = salt.substring( off + 3, off + 25 );
- try {
- passwordb = ( password + ( minor >= 'a' ? "\000" : "" ) ).getBytes( "UTF-8" );
- }
- catch ( UnsupportedEncodingException uee ) {
- throw new AssertionError( "UTF-8 is not supported" );
- }
-
- saltb = decodeBase64( realSalt, BCRYPT_SALT_LEN );
-
- b = new BCrypt();
- hashed = b.cryptRaw( passwordb, saltb, rounds );
-
- rs.append( "$2" );
- if ( minor >= 'a' ) {
- rs.append( minor );
- }
- rs.append( "$" );
- if ( rounds < 10 ) {
- rs.append( "0" );
- }
- rs.append( Integer.toString( rounds ) );
- rs.append( "$" );
- rs.append( encodeBase64( saltb, saltb.length ) );
- rs.append( encodeBase64( hashed, BF_CRYPT_CYPHERTEXT.length * 4 - 1 ) );
- return rs.toString();
- }
-
-
- /**
- * Generate a salt for use with the BCrypt.hashpw() method
- *
- * @param logRounds the log2 of the number of rounds of hashing to apply - the work factor therefore increases as
- * 2**logRounds.
- * @param random an instance of SecureRandom to use
- *
- * @return an encoded salt value
- */
- public static String gensalt( int logRounds, SecureRandom random ) {
- StringBuilder rs = new StringBuilder();
- byte[] rnd = new byte[BCRYPT_SALT_LEN];
-
- random.nextBytes( rnd );
-
- rs.append( "$2a$" );
- if ( logRounds < 10 ) {
- rs.append( "0" );
- }
- rs.append( Integer.toString( logRounds ) );
- rs.append( "$" );
- rs.append( encodeBase64( rnd, rnd.length ) );
- return rs.toString();
- }
-
-
- /**
- * Generate a salt for use with the BCrypt.hashpw() method
- *
- * @param logRounds the log2 of the number of rounds of hashing to apply - the work factor therefore increases as
- * 2**logRounds.
- *
- * @return an encoded salt value
- */
- public static String gensalt( int logRounds ) {
- return gensalt( logRounds, new SecureRandom() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/CodecUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/CodecUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/CodecUtils.java
deleted file mode 100644
index f90e57e..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/CodecUtils.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.utils;
-
-
-import java.util.UUID;
-
-import org.apache.commons.codec.binary.Base64;
-
-import static org.apache.usergrid.persistence.utils.ConversionUtils.bytes;
-
-
-public class CodecUtils {
-
- public static Base64 base64 = new Base64( true );
-
-
- public static String base64( byte[] bytes ) {
- return base64.encodeToString( bytes );
- }
-
-
- public static String base64( UUID uuid ) {
- return base64.encodeToString( bytes( uuid ) );
- }
-
-
- public static String base64( String str ) {
- return Base64.encodeBase64URLSafeString( bytes( str ) );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/DateUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/DateUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/DateUtils.java
deleted file mode 100644
index 601696a..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/DateUtils.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Copyright 2010-2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
-//
-// Portions copyright 2006-2009 James Murty. Please see LICENSE.txt
-// for applicable license terms and NOTICE.txt for applicable notices.
-//
-// Licensed under the Apache License, Version 2.0 (the "License").
-// You may not use this file except in compliance with the License.
-// A copy of the License is located at
-// http://aws.amazon.com/apache2.0
-// or in the "license" file accompanying this file. This file is distributed
-// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
-
-package org.apache.usergrid.persistence.utils;
-
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.SimpleTimeZone;
-
-
-/**
- * Utilities for parsing and formatting dates.
- * <p/>
- * Note that this class doesn't use static methods because of the synchronization issues with SimpleDateFormat. This
- * lets synchronization be done on a per-object level, instead of on a per-class level.
- */
-public class DateUtils {
-
- /** ISO 8601 parser */
- protected final SimpleDateFormat iso8601DateParser = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
-
- /** Alternate ISO 8601 parser without fractional seconds */
- protected final SimpleDateFormat alternateIo8601DateParser = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'" );
-
- /** RFC 822 parser */
- protected final SimpleDateFormat rfc822DateParser =
- new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss z", Locale.US );
-
-
- /** Constructs a new DateUtils object, ready to parse/format dates. */
- public DateUtils() {
- iso8601DateParser.setTimeZone( new SimpleTimeZone( 0, "GMT" ) );
- rfc822DateParser.setTimeZone( new SimpleTimeZone( 0, "GMT" ) );
- alternateIo8601DateParser.setTimeZone( new SimpleTimeZone( 0, "GMT" ) );
- }
-
-
- public static DateUtils instance = new DateUtils();
-
-
- /**
- * Formats the specified date as an ISO 8601 string.
- *
- * @param date The date to format.
- *
- * @return The ISO 8601 string representing the specified date.
- */
- public String formatIso8601Date( Date date ) {
- synchronized ( iso8601DateParser ) {
- return iso8601DateParser.format( date );
- }
- }
-
-
- public String iso8601DateNow() {
- return formatIso8601Date( new Date() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/InflectionUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/InflectionUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/InflectionUtils.java
deleted file mode 100644
index 6965df3..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/InflectionUtils.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.utils;
-
-
-public class InflectionUtils {
-
- public static String pluralize( Object word ) {
- return Inflector.INSTANCE.pluralize( word );
- }
-
-
- public static String singularize( Object word ) {
- return Inflector.INSTANCE.singularize( word );
- }
-
-
- public static boolean isPlural( Object word ) {
- return Inflector.INSTANCE.isPlural( word );
- }
-
-
- public static boolean isSingular( Object word ) {
- return Inflector.INSTANCE.isSingular( word );
- }
-
-
- public static String underscore( String s ) {
- return Inflector.INSTANCE.underscore( s );
- }
-
-
- public static String camelCase( String lowerCaseAndUnderscoredWord, boolean uppercaseFirstLetter,
- char... delimiterChars ) {
- return Inflector.INSTANCE.camelCase( lowerCaseAndUnderscoredWord, uppercaseFirstLetter, delimiterChars );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Inflector.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Inflector.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Inflector.java
deleted file mode 100644
index 371a1b7..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Inflector.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// TODO - This Class needs to go - it's LGPL Source !!!
-// ModeShape (http://www.modeshape.org)
-// See the COPYRIGHT.txt file distributed with this work for information
-// regarding copyright ownership. Some portions may be licensed
-// to Red Hat, Inc. under one or more contributor license agreements.
-// See the AUTHORS.txt file in the distribution for a full listing of
-// individual contributors.
-//
-// ModeShape is free software. Unless otherwise indicated, all code in ModeShape
-// is licensed to you under the terms of the GNU Lesser General Public License as
-// published by the Free Software Foundation; either version 2.1 of
-// the License, or (at your option) any later version.
-//
-// ModeShape is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this software; if not, write to the Free
-// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-// 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-//
-
-package org.apache.usergrid.persistence.utils;
-
-
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-/**
- * Transforms words to singular, plural, humanized (human readable), underscore, camel case, or ordinal form. This is
- * inspired by the <a href="http://api.rubyonrails.org/classes/Inflector.html">Inflector</a> class in <a
- * href="http://www.rubyonrails.org">Ruby on Rails</a>, which is distributed under the <a
- * href="http://wiki.rubyonrails.org/rails/pages/License">Rails license</a>.
- */
-public class Inflector {
-
- protected static final Inflector INSTANCE = new Inflector();
-
-
- public static Inflector getInstance() {
- return INSTANCE;
- }
-
-
- protected class Rule {
-
- protected final String expression;
- protected final Pattern expressionPattern;
- protected final String replacement;
-
-
- protected Rule( String expression, String replacement ) {
- this.expression = expression;
- this.replacement = replacement != null ? replacement : "";
- expressionPattern = Pattern.compile( this.expression, Pattern.CASE_INSENSITIVE );
- }
-
-
- /**
- * Apply the rule against the input string, returning the modified string or null if the rule didn't apply (and
- * no modifications were made)
- *
- * @param input the input string
- *
- * @return the modified string if this rule applied, or null if the input was not modified by this rule
- */
- protected String apply( String input ) {
- Matcher matcher = expressionPattern.matcher( input );
- if ( !matcher.find() ) {
- return null;
- }
- return matcher.replaceAll( replacement );
- }
-
-
- @Override
- public int hashCode() {
- return expression.hashCode();
- }
-
-
- @Override
- public boolean equals( Object obj ) {
- if ( obj == this ) {
- return true;
- }
- if ( ( obj != null ) && ( obj.getClass() == this.getClass() ) ) {
- final Rule that = ( Rule ) obj;
- if ( expression.equalsIgnoreCase( that.expression ) ) {
- return true;
- }
- }
- return false;
- }
-
-
- @Override
- public String toString() {
- return expression + ", " + replacement;
- }
- }
-
-
- private final LinkedList<Rule> plurals = new LinkedList<Rule>();
- private final LinkedList<Rule> singulars = new LinkedList<Rule>();
- /**
- * The lowercase words that are to be excluded and not processed. This map can be modified by the users via {@link
- * #getUncountables()}.
- */
- private final Set<String> uncountables = new HashSet<String>();
-
-
- public Inflector() {
- initialize();
- }
-
-
- protected Inflector( Inflector original ) {
- plurals.addAll( original.plurals );
- singulars.addAll( original.singulars );
- uncountables.addAll( original.uncountables );
- }
-
-
- @Override
- @SuppressWarnings("all")
- public Inflector clone() {
- return new Inflector( this );
- }
-
- // ------------------------------------------------------------------------------------------------
- // Usage functions
- // ------------------------------------------------------------------------------------------------
-
-
- /**
- * Returns the plural form of the word in the string. <p> Examples: <p/>
- * <pre>
- * inflector.pluralize("post") #=> "posts"
- * inflector.pluralize("octopus") #=> "octopi"
- * inflector.pluralize("sheep") #=> "sheep"
- * inflector.pluralize("words") #=> "words"
- * inflector.pluralize("the blue mailman") #=> "the blue mailmen"
- * inflector.pluralize("CamelOctopus") #=> "CamelOctopi"
- * </pre>
- * <p/> </p> <p> Note that if the {@link Object#toString()} is called on the supplied object, so this method works
- * for non-strings, too. </p>
- *
- * @param word the word that is to be pluralized.
- *
- * @return the pluralized form of the word, or the word itself if it could not be pluralized
- *
- * @see #singularize(Object)
- */
- public String pluralize( Object word ) {
- if ( word == null ) {
- return null;
- }
- String wordStr = word.toString().trim();
- if ( wordStr.length() == 0 ) {
- return wordStr;
- }
- if ( isUncountable( wordStr ) ) {
- return wordStr;
- }
- for ( Rule rule : plurals ) {
- String result = rule.apply( wordStr );
- if ( result != null ) {
- return result;
- }
- }
- return wordStr;
- }
-
-
- public String pluralize( Object word, int count ) {
- if ( word == null ) {
- return null;
- }
- if ( ( count == 1 ) || ( count == -1 ) ) {
- return word.toString();
- }
- return pluralize( word );
- }
-
-
- public boolean isPlural( Object word ) {
- if ( word == null ) {
- return false;
- }
- return pluralize( word ).equals( word.toString() );
- }
-
-
- /**
- * Returns the singular form of the word in the string. <p> Examples: <p/>
- * <pre>
- * inflector.singularize("posts") #=> "post"
- * inflector.singularize("octopi") #=> "octopus"
- * inflector.singularize("sheep") #=> "sheep"
- * inflector.singularize("words") #=> "word"
- * inflector.singularize("the blue mailmen") #=> "the blue mailman"
- * inflector.singularize("CamelOctopi") #=> "CamelOctopus"
- * </pre>
- * <p/> </p> <p> Note that if the {@link Object#toString()} is called on the supplied object, so this method works
- * for non-strings, too. </p>
- *
- * @param word the word that is to be pluralized.
- *
- * @return the pluralized form of the word, or the word itself if it could not be pluralized
- *
- * @see #pluralize(Object)
- */
- public String singularize( Object word ) {
- if ( word == null ) {
- return null;
- }
- String wordStr = word.toString().trim();
- if ( wordStr.length() == 0 ) {
- return wordStr;
- }
- if ( isUncountable( wordStr ) ) {
- return wordStr;
- }
- for ( Rule rule : singulars ) {
- String result = rule.apply( wordStr );
- if ( result != null ) {
- return result;
- }
- }
- return wordStr;
- }
-
-
- public boolean isSingular( Object word ) {
- if ( word == null ) {
- return false;
- }
- return singularize( word ).equals( word.toString() );
- }
-
-
- /**
- * By default, this method converts strings to UpperCamelCase. If the <code>uppercaseFirstLetter</code> argument to
- * false, then this method produces lowerCamelCase. This method will also use any extra delimiter characters to
- * identify word boundaries. <p> Examples: <p/>
- * <pre>
- * inflector.camelCase("active_record",false) #=> "activeRecord"
- * inflector.camelCase("active_record",true) #=> "ActiveRecord"
- * inflector.camelCase("first_name",false) #=> "firstName"
- * inflector.camelCase("first_name",true) #=> "FirstName"
- * inflector.camelCase("name",false) #=> "name"
- * inflector.camelCase("name",true) #=> "Name"
- * </pre>
- * <p/> </p>
- *
- * @param lowerCaseAndUnderscoredWord the word that is to be converted to camel case
- * @param uppercaseFirstLetter true if the first character is to be uppercased, or false if the first character is
- * to be lowercased
- * @param delimiterChars optional characters that are used to delimit word boundaries
- *
- * @return the camel case version of the word
- *
- * @see #underscore(String, char[])
- */
- public String camelCase( String lowerCaseAndUnderscoredWord, boolean uppercaseFirstLetter,
- char... delimiterChars ) {
- if ( lowerCaseAndUnderscoredWord == null ) {
- return null;
- }
- lowerCaseAndUnderscoredWord = lowerCaseAndUnderscoredWord.trim();
- if ( lowerCaseAndUnderscoredWord.length() == 0 ) {
- return "";
- }
- if ( uppercaseFirstLetter ) {
- String result = lowerCaseAndUnderscoredWord;
- // Replace any extra delimiters with underscores (before the
- // underscores are converted in the next step)...
- if ( delimiterChars != null ) {
- for ( char delimiterChar : delimiterChars ) {
- result = result.replace( delimiterChar, '_' );
- }
- }
-
- // Change the case at the beginning at after each underscore ...
- return replaceAllWithUppercase( result, "(^|_)(.)", 2 );
- }
- if ( lowerCaseAndUnderscoredWord.length() < 2 ) {
- return lowerCaseAndUnderscoredWord;
- }
- return "" + Character.toLowerCase( lowerCaseAndUnderscoredWord.charAt( 0 ) ) + camelCase(
- lowerCaseAndUnderscoredWord, true, delimiterChars ).substring( 1 );
- }
-
-
- /**
- * Makes an underscored form from the expression in the string (the reverse of the {@link #camelCase(String,
- * boolean, char[]) camelCase} method. Also changes any characters that match the supplied delimiters into
- * underscore. <p> Examples: <p/>
- * <pre>
- * inflector.underscore("activeRecord") #=> "active_record"
- * inflector.underscore("ActiveRecord") #=> "active_record"
- * inflector.underscore("firstName") #=> "first_name"
- * inflector.underscore("FirstName") #=> "first_name"
- * inflector.underscore("name") #=> "name"
- * inflector.underscore("The.firstName") #=> "the_first_name"
- * </pre>
- * <p/> </p>
- *
- * @param camelCaseWord the camel-cased word that is to be converted;
- * @param delimiterChars optional characters that are used to delimit word boundaries (beyond capitalization)
- *
- * @return a lower-cased version of the input, with separate words delimited by the underscore character.
- */
- public String underscore( String camelCaseWord, char... delimiterChars ) {
- if ( camelCaseWord == null ) {
- return null;
- }
- String result = camelCaseWord.trim();
- if ( result.length() == 0 ) {
- return "";
- }
- result = result.replaceAll( "([A-Z]+)([A-Z][a-z])", "$1_$2" );
- result = result.replaceAll( "([a-z\\d])([A-Z])", "$1_$2" );
- result = result.replace( '-', '_' );
- if ( delimiterChars != null ) {
- for ( char delimiterChar : delimiterChars ) {
- result = result.replace( delimiterChar, '_' );
- }
- }
- return result.toLowerCase();
- }
-
-
- /**
- * Returns a copy of the input with the first character converted to uppercase and the remainder to lowercase.
- *
- * @param words the word to be capitalized
- *
- * @return the string with the first character capitalized and the remaining characters lowercased
- */
- public String capitalize( String words ) {
- if ( words == null ) {
- return null;
- }
- String result = words.trim();
- if ( result.length() == 0 ) {
- return "";
- }
- if ( result.length() == 1 ) {
- return result.toUpperCase();
- }
- return "" + Character.toUpperCase( result.charAt( 0 ) ) + result.substring( 1 ).toLowerCase();
- }
-
-
- // ------------------------------------------------------------------------------------------------
- // Management methods
- // ------------------------------------------------------------------------------------------------
-
-
- /**
- * Determine whether the supplied word is considered uncountable by the {@link #pluralize(Object) pluralize} and
- * {@link #singularize(Object) singularize} methods.
- *
- * @param word the word
- *
- * @return true if the plural and singular forms of the word are the same
- */
- public boolean isUncountable( String word ) {
- if ( word == null ) {
- return false;
- }
- String trimmedLower = word.trim().toLowerCase();
- return uncountables.contains( trimmedLower );
- }
-
-
- /**
- * Get the set of words that are not processed by the Inflector. The resulting map is directly modifiable.
- *
- * @return the set of uncountable words
- */
- public Set<String> getUncountables() {
- return uncountables;
- }
-
-
- public void addPluralize( String rule, String replacement ) {
- final Rule pluralizeRule = new Rule( rule, replacement );
- plurals.addFirst( pluralizeRule );
- }
-
-
- public void addSingularize( String rule, String replacement ) {
- final Rule singularizeRule = new Rule( rule, replacement );
- singulars.addFirst( singularizeRule );
- }
-
-
- public void addIrregular( String singular, String plural ) {
- if ( org.apache.commons.lang.StringUtils.isEmpty( singular ) ) {
- throw new IllegalArgumentException( "singular rule may not be empty" );
- }
- if ( org.apache.commons.lang.StringUtils.isEmpty( plural ) ) {
- throw new IllegalArgumentException( "plural rule may not be empty" );
- }
- String singularRemainder = singular.length() > 1 ? singular.substring( 1 ) : "";
- String pluralRemainder = plural.length() > 1 ? plural.substring( 1 ) : "";
- addPluralize( "(" + singular.charAt( 0 ) + ")" + singularRemainder + "$", "$1" + pluralRemainder );
- addSingularize( "(" + plural.charAt( 0 ) + ")" + pluralRemainder + "$", "$1" + singularRemainder );
- }
-
-
- public void addUncountable( String... words ) {
- if ( ( words == null ) || ( words.length == 0 ) ) {
- return;
- }
- for ( String word : words ) {
- if ( word != null ) {
- uncountables.add( word.trim().toLowerCase() );
- }
- }
- }
-
-
- /**
- * Utility method to replace all occurrences given by the specific backreference with its uppercased form, and
- * remove all other backreferences. <p> The Java {@link Pattern regular expression processing} does not use the
- * preprocessing directives <code>\l</code>, <code>\u</code>, <code>\L</code>, and <code>\U</code>. If so, such
- * directives could be used in the replacement string to uppercase or lowercase the backreferences. For example,
- * <code>\L1</code> would lowercase the first backreference, and <code>\u3</code> would uppercase the 3rd
- * backreference. </p>
- *
- * @return the input string with the appropriate characters converted to upper-case
- */
- protected static String replaceAllWithUppercase( String input, String regex, int groupNumberToUppercase ) {
- Pattern underscoreAndDotPattern = Pattern.compile( regex );
- Matcher matcher = underscoreAndDotPattern.matcher( input );
- StringBuffer sb = new StringBuffer();
- while ( matcher.find() ) {
- matcher.appendReplacement( sb, matcher.group( groupNumberToUppercase ).toUpperCase() );
- }
- matcher.appendTail( sb );
- return sb.toString();
- }
-
-
- /** Completely remove all rules within this inflector. */
- public void clear() {
- uncountables.clear();
- plurals.clear();
- singulars.clear();
- }
-
-
- protected void initialize() {
- Inflector inflect = this;
- inflect.addPluralize( "$", "s" );
- inflect.addPluralize( "s$", "s" );
- inflect.addPluralize( "(ax|test)is$", "$1es" );
- inflect.addPluralize( "(octop|vir)us$", "$1i" );
- inflect.addPluralize( "(octop|vir)i$", "$1i" ); // already plural
- inflect.addPluralize( "(alias|status)$", "$1es" );
- inflect.addPluralize( "(bu)s$", "$1ses" );
- inflect.addPluralize( "(buffal|tomat)o$", "$1oes" );
- inflect.addPluralize( "([ti])um$", "$1a" );
- inflect.addPluralize( "([ti])a$", "$1a" ); // already plural
- inflect.addPluralize( "sis$", "ses" );
- inflect.addPluralize( "(?:([^f])fe|([lr])f)$", "$1$2ves" );
- inflect.addPluralize( "(hive)$", "$1s" );
- inflect.addPluralize( "([^aeiouy]|qu)y$", "$1ies" );
- inflect.addPluralize( "(x|ch|ss|sh)$", "$1es" );
- inflect.addPluralize( "(matr|vert|ind)ix|ex$", "$1ices" );
- inflect.addPluralize( "([m|l])ouse$", "$1ice" );
- inflect.addPluralize( "([m|l])ice$", "$1ice" );
- inflect.addPluralize( "^(ox)$", "$1en" );
- inflect.addPluralize( "(quiz)$", "$1zes" );
- // Need to check for the following words that are already pluralized:
- inflect.addPluralize( "(people|men|children|sexes|moves|stadiums)$", "$1" ); // irregulars
- inflect.addPluralize( "(oxen|octopi|viri|aliases|quizzes)$", "$1" ); // special
- // rules
-
- inflect.addSingularize( "s$", "" );
- inflect.addSingularize( "(s|si|u)s$", "$1s" ); // '-us' and '-ss' are
- // already singular
- inflect.addSingularize( "(n)ews$", "$1ews" );
- inflect.addSingularize( "([ti])a$", "$1um" );
- inflect.addSingularize( "((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$", "$1$2sis" );
- inflect.addSingularize( "(^analy)ses$", "$1sis" );
- inflect.addSingularize( "(^analy)sis$", "$1sis" ); // already singular,
- // but ends in 's'
- inflect.addSingularize( "([^f])ves$", "$1fe" );
- inflect.addSingularize( "(hive)s$", "$1" );
- inflect.addSingularize( "(tive)s$", "$1" );
- inflect.addSingularize( "([lr])ves$", "$1f" );
- inflect.addSingularize( "([^aeiouy]|qu)ies$", "$1y" );
- inflect.addSingularize( "(s)eries$", "$1eries" );
- inflect.addSingularize( "(m)ovies$", "$1ovie" );
- inflect.addSingularize( "(x|ch|ss|sh)es$", "$1" );
- inflect.addSingularize( "([m|l])ice$", "$1ouse" );
- inflect.addSingularize( "(bus)es$", "$1" );
- inflect.addSingularize( "(o)es$", "$1" );
- inflect.addSingularize( "(shoe)s$", "$1" );
- inflect.addSingularize( "(cris|ax|test)is$", "$1is" ); // already
- // singular, but
- // ends in 's'
- inflect.addSingularize( "(cris|ax|test)es$", "$1is" );
- inflect.addSingularize( "(octop|vir)i$", "$1us" );
- inflect.addSingularize( "(octop|vir)us$", "$1us" ); // already singular,
- // but ends in 's'
- inflect.addSingularize( "(alias|status)es$", "$1" );
- inflect.addSingularize( "(alias|status)$", "$1" ); // already singular,
- // but ends in 's'
- inflect.addSingularize( "^(ox)en", "$1" );
- inflect.addSingularize( "(vert|ind)ices$", "$1ex" );
- inflect.addSingularize( "(matr)ices$", "$1ix" );
- inflect.addSingularize( "(quiz)zes$", "$1" );
-
- inflect.addIrregular( "person", "people" );
- inflect.addIrregular( "man", "men" );
- inflect.addIrregular( "child", "children" );
- inflect.addIrregular( "sex", "sexes" );
- inflect.addIrregular( "move", "moves" );
- inflect.addIrregular( "stadium", "stadiums" );
-
- inflect.addUncountable( "equipment", "information", "rice", "money", "species", "series", "fish", "sheep",
- "data", "analytics" );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/NumberUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/NumberUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/NumberUtils.java
deleted file mode 100644
index 39dfbbd..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/NumberUtils.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.utils;
-
-
-public class NumberUtils {
- public static int sign( int i ) {
- if ( i < 0 ) {
- return -1;
- }
- if ( i > 0 ) {
- return 1;
- }
- return 0;
- }
-
-
- public static long roundLong( long l, long r ) {
- return ( l / r ) * r;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/PasswordUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/PasswordUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/PasswordUtils.java
deleted file mode 100644
index a8b285d..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/PasswordUtils.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.utils;
-
-
-import org.apache.commons.codec.digest.DigestUtils;
-
-
-public class PasswordUtils {
-
- public static String mongoPassword( String username, String password ) {
- return DigestUtils.md5Hex( username + ":mongo:" + password );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/TimeUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/TimeUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/TimeUtils.java
deleted file mode 100644
index e50251f..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/TimeUtils.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.utils;
-
-
-import com.google.common.base.CharMatcher;
-import com.google.common.base.Splitter;
-
-
-public class TimeUtils {
- /**
- * Jira-style duration parser. Supported duration strings are: <ul> <li>'S': milliseconds</li> <li>'s': seconds</li>
- * <li>'m': minutes</li> <li>'h': hours</li> <li>'d': days</li> </ul>
- * <p/>
- * Durations can be compound statements in any order as long as they are separated by a ',' (comma). Eg. "1d,14h,3s"
- * to get the millisecond equivalent of one day, fourteen hours and 3 seconds.
- * <p/>
- * Numbers with no durations will be treated as raw millisecond values
- *
- * @return the number of milliseconds representing the duration
- */
- public static long millisFromDuration( String durationStr ) {
- long total = 0;
- MultiplierToken mt;
- long dur;
- for ( String val : Splitter.on( ',' ).trimResults().omitEmptyStrings().split( durationStr ) ) {
- dur = Long.parseLong( CharMatcher.DIGIT.retainFrom( val ) );
- mt = MultiplierToken.from( val.charAt( val.length() - 1 ) );
- total += ( mt.multiplier * dur );
- }
- return total;
- }
-
-
- private enum MultiplierToken {
- MILSEC_TOKEN( 'S', 1L ),
- SEC_TOKEN( 's', 1000L ),
- MIN_TOKEN( 'm', 60000L ),
- HOUR_TOKEN( 'h', 3600000L ),
- DAY_TOKEN( 'd', 86400000L );
-
- final char token;
- final long multiplier;
-
-
- MultiplierToken( char token, long multiplier ) {
- this.token = token;
- this.multiplier = multiplier;
- }
-
-
- static MultiplierToken from( char c ) {
- switch ( c ) {
- case 's':
- return SEC_TOKEN;
- case 'm':
- return MIN_TOKEN;
- case 'h':
- return HOUR_TOKEN;
- case 'd':
- return DAY_TOKEN;
- case 'S':
- return MILSEC_TOKEN;
- default:
- break;
- }
-
- if ( CharMatcher.DIGIT.matches( c ) ) {
- return MILSEC_TOKEN;
- }
- throw new IllegalArgumentException( "Duration token was not on of [S,s,m,h,d] but was " + c );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Version.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Version.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Version.java
deleted file mode 100644
index 352d6bc..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Version.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.utils;
-
-/*******************************************************************************
- * Copyright (c) 2010, Schley Andrew Kutz All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of the Schley Andrew Kutz nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- ******************************************************************************/
-
-import java.io.Serializable;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.lang.StringUtils;
-
-
-/**
- * The Version class can be used to parse a standard version string into its four components,
- * MAJOR.MINOR.BUILD.REVISION.
- */
-public class Version implements Serializable, Cloneable, Comparable<Version> {
- /** A serial version UID. */
- private static final long serialVersionUID = -4316270526722986552L;
-
- /** A pattern to match the standard version format MAJOR.MINOR.BUILD.REVISION. */
- private static final Pattern STD_VERSION_PATT =
- Pattern.compile( "^([^\\d]*?)(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:\\.(\\d+))?(.*)$" );
-
-
- /** Initialize a new Version object that is set to "0.0.0.0". */
- public Version() {
- }
-
-
- /** Everything before the version in the string that was parsed. */
- private String prefix;
-
- /** Everything after the version in the string that was parsed. */
- private String suffix;
-
- /** The String that was parsed to create this version object. */
- private String rawVersion;
-
-
- /**
- * Gets everything before the version in the string that was parsed.
- *
- * @return Everything before the version in the string that was parsed.
- */
- public String getPrefix() {
- return prefix;
- }
-
-
- /**
- * Parses a new Version object from a String.
- *
- * @param toParse The String object to parse.
- *
- * @return A new Version object.
- *
- * @throws Exception When there is an error parsing the String.
- */
- public static Version parse( String toParse ) throws Exception {
- Matcher m = STD_VERSION_PATT.matcher( toParse );
-
- if ( !m.find() ) {
- throw new Exception( String.format( "Error parsing version from '%s'", toParse ) );
- }
-
- Version v = new Version();
- v.rawVersion = toParse;
- v.prefix = m.group( 1 );
-
- if ( StringUtils.isNotEmpty( m.group( 2 ) ) ) {
- v.setMajor( m.group( 2 ) );
- }
-
- if ( StringUtils.isNotEmpty( m.group( 3 ) ) ) {
- v.setMinor( m.group( 3 ) );
- }
-
- if ( StringUtils.isNotEmpty( m.group( 4 ) ) ) {
- v.setBuild( m.group( 4 ) );
- }
-
- if ( StringUtils.isNotEmpty( m.group( 5 ) ) ) {
- v.setRevision( m.group( 5 ) );
- }
-
- v.suffix = m.group( 6 );
-
- return v;
- }
-
-
- /** The version's MAJOR component. */
- private String major = "0";
-
-
- /**
- * Sets the version's MAJOR component.
- *
- * @param toSet The version's MAJOR component.
- *
- * @throws IllegalArgumentException When a null or non-numeric value is given.
- */
- public void setMajor( String toSet ) throws IllegalArgumentException {
- if ( StringUtils.isEmpty( toSet ) ) {
- throw new IllegalArgumentException( "Argument is null" );
- }
-
- if ( !toSet.matches( "\\d+" ) ) {
- throw new IllegalArgumentException( "Argument is not numeric" );
- }
-
- if ( numberOfComponents < 1 ) {
- numberOfComponents = 1;
- }
-
- major = toSet;
- }
-
-
- /** The version's MAJOR component as an integer. */
- private int getMajorAsInt() {
- return Integer.parseInt( major );
- }
-
-
- /** The version's MINOR component. */
- private String minor = "0";
-
-
- /**
- * Sets the version's MINOR component.
- *
- * @param toSet The version's MINOR component.
- *
- * @throws IllegalArgumentException When a null or non-numeric value is given.
- */
- public void setMinor( String toSet ) throws IllegalArgumentException {
- if ( StringUtils.isEmpty( toSet ) ) {
- throw new IllegalArgumentException( "Argument is null" );
- }
-
- if ( !toSet.matches( "\\d+" ) ) {
- throw new IllegalArgumentException( "Argument is not numeric" );
- }
-
- if ( numberOfComponents < 2 ) {
- numberOfComponents = 2;
- }
-
- minor = toSet;
- }
-
-
- /** The version's MINOR component as an integer. */
- private int getMinorAsInt() {
- return Integer.parseInt( minor );
- }
-
-
- /** The version's BUILD component. */
- private String build = "0";
-
-
- /** The version's BUILD component as an integer. */
- private int getBuildAsInt() {
- return Integer.parseInt( build );
- }
-
-
- /**
- * Gets the version's BUILD component.
- *
- * @return The version's BUILD component.
- */
- public String getBuild() {
- return build;
- }
-
-
- /**
- * Sets the version's BUILD component.
- *
- * @param toSet The version's BUILD component.
- *
- * @throws IllegalArgumentException When a null or non-numeric value is given.
- */
- public void setBuild( String toSet ) throws IllegalArgumentException {
- if ( StringUtils.isEmpty( toSet ) ) {
- throw new IllegalArgumentException( "Argument is null" );
- }
-
- if ( !toSet.matches( "\\d+" ) ) {
- throw new IllegalArgumentException( "Argument is not numeric" );
- }
-
- if ( numberOfComponents < 3 ) {
- numberOfComponents = 3;
- }
-
- build = toSet;
- }
-
-
- /**
- * Sets the version's BUILD component.
- *
- * @param toSet The version's BUILD component.
- */
- public void setBuild( int toSet ) {
- setBuild( String.valueOf( toSet ) );
- }
-
-
- /** The version's REVISION component. */
- private String revision = "0";
-
-
- /** The version's REVISION component as an integer. */
- private int getRevisionAsInt() {
- return Integer.parseInt( revision );
- }
-
-
- /**
- * Sets the version's REVISION component.
- *
- * @param toSet The version's REVISION component.
- *
- * @throws IllegalArgumentException When a null or non-numeric value is given.
- */
- public void setRevision( String toSet ) throws IllegalArgumentException {
- if ( StringUtils.isEmpty( toSet ) ) {
- throw new IllegalArgumentException( "Argument is null" );
- }
-
- if ( !toSet.matches( "\\d+" ) ) {
- throw new IllegalArgumentException( "Argument is not numeric" );
- }
-
- if ( numberOfComponents < 4 ) {
- numberOfComponents = 4;
- }
-
- revision = toSet;
- }
-
-
- /**
- * The number of components that make up the version. The value will always be between 1 (inclusive) and 4
- * (inclusive).
- */
- private int numberOfComponents;
-
-
- @Override
- @SuppressWarnings("all")
- public Object clone() throws CloneNotSupportedException {
- Version v = new Version();
-
- v.rawVersion = rawVersion;
- v.prefix = prefix;
- v.suffix = suffix;
-
- v.numberOfComponents = numberOfComponents;
-
- v.major = major;
- v.minor = minor;
- v.build = build;
- v.revision = revision;
-
- return v;
- }
-
-
- @Override
- public boolean equals( Object toCompare ) {
- // Compare pointers
- if ( toCompare == this ) {
- return true;
- }
-
- // Compare types
- if ( !( toCompare instanceof Version ) ) {
- return false;
- }
-
- return compareTo( ( Version ) toCompare ) == 0;
- }
-
-
- @Override
- public int hashCode() {
- return toString().hashCode();
- }
-
-
- @Override
- public String toString() {
- return String.format( "%s.%s.%s.%s", major, minor, build, revision );
- }
-
-
- /**
- * Gets the version as a string using the specified number of components.
- *
- * @param components The number of components. Values less than 1 will be treated as 1 and values greater than 4
- * will be treated as 4.
- *
- * @return The version as a string using the specified number of components.
- */
- public String toString( int components ) {
- StringBuilder buff = new StringBuilder();
- buff.append( major );
-
- if ( components > 4 ) {
- components = 4;
- }
-
- switch ( components ) {
- case 2:
- buff.append( String.format( ".%s", minor ) );
- break;
- case 3:
- buff.append( String.format( ".%s.%s", minor, build ) );
- break;
- case 4:
- buff.append( String.format( ".%s.%s.%s", minor, build, revision ) );
- break;
- default:
- break;
- }
-
- return buff.toString();
- }
-
-
- private int compareInts( int x, int y ) {
- if ( x == y ) {
- return 0;
- }
-
- if ( x < y ) {
- return -1;
- }
-
- return 1;
- }
-
-
- @Override
- public int compareTo( Version toCompare ) {
- int result = toString().compareTo( toCompare.toString() );
-
- if ( result == 0 ) {
- return result;
- }
-
- result = compareInts( getMajorAsInt(), toCompare.getMajorAsInt() );
-
- if ( result != 0 ) {
- return result;
- }
-
- result = compareInts( getMinorAsInt(), toCompare.getMinorAsInt() );
-
- if ( result != 0 ) {
- return result;
- }
-
- result = compareInts( getBuildAsInt(), toCompare.getBuildAsInt() );
-
- if ( result != 0 ) {
- return result;
- }
-
- result = compareInts( getRevisionAsInt(), toCompare.getRevisionAsInt() );
-
- if ( result != 0 ) {
- return result;
- }
-
- return result;
- }
-}
[12/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexModule.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexModule.java
new file mode 100644
index 0000000..bda9ee9
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexModule.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.persistence.index.impl;
+
+import com.google.inject.AbstractModule;
+import org.apache.usergrid.persistence.index.EntityCollectionIndex;
+
+
+public class IndexModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind( EntityCollectionIndex.class ).to( EntityCollectionIndexImpl.class );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AggregateCounter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AggregateCounter.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AggregateCounter.java
new file mode 100644
index 0000000..ad2c0fb
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AggregateCounter.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+public class AggregateCounter {
+ private long timestamp;
+ private long value;
+
+
+ public AggregateCounter( long timestamp, long value ) {
+ this.timestamp = timestamp;
+ this.value = value;
+ }
+
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+
+ public void setTimestamp( long timestamp ) {
+ this.timestamp = timestamp;
+ }
+
+
+ public long getValue() {
+ return value;
+ }
+
+
+ public void setValue( long value ) {
+ this.value = value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AggregateCounterSet.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AggregateCounterSet.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AggregateCounterSet.java
new file mode 100644
index 0000000..a96c201
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AggregateCounterSet.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+import java.util.List;
+import java.util.UUID;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+
+public class AggregateCounterSet {
+ private String name;
+ private UUID user;
+ private UUID group;
+ private UUID queue;
+ private String category;
+ private List<AggregateCounter> values;
+
+
+ public AggregateCounterSet( String name, UUID user, UUID group, String category, List<AggregateCounter> values ) {
+ this.name = name;
+ this.user = user;
+ this.group = group;
+ this.category = category;
+ this.values = values;
+ }
+
+
+ public AggregateCounterSet( String name, UUID queue, String category, List<AggregateCounter> values ) {
+ this.name = name;
+ setQueue( queue );
+ this.category = category;
+ this.values = values;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public UUID getUser() {
+ return user;
+ }
+
+
+ public void setUser( UUID user ) {
+ this.user = user;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public UUID getGroup() {
+ return group;
+ }
+
+
+ public void setGroup( UUID group ) {
+ this.group = group;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getCategory() {
+ return category;
+ }
+
+
+ public void setCategory( String category ) {
+ this.category = category;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public String getName() {
+ return name;
+ }
+
+
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<AggregateCounter> getValues() {
+ return values;
+ }
+
+
+ public void setValues( List<AggregateCounter> values ) {
+ this.values = values;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public UUID getQueue() {
+ return queue;
+ }
+
+
+ public void setQueue( UUID queue ) {
+ this.queue = queue;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AssociatedEntityRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AssociatedEntityRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AssociatedEntityRef.java
new file mode 100644
index 0000000..d74a256
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/AssociatedEntityRef.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+public interface AssociatedEntityRef extends EntityRef {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/CollectionRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/CollectionRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/CollectionRef.java
new file mode 100644
index 0000000..0085b33
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/CollectionRef.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+public interface CollectionRef extends AssociatedEntityRef {
+
+ public EntityRef getOwnerEntity();
+
+ public String getCollectionName();
+
+ public EntityRef getItemRef();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ConnectedEntityRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ConnectedEntityRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ConnectedEntityRef.java
new file mode 100644
index 0000000..4b10cd7
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ConnectedEntityRef.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+public interface ConnectedEntityRef extends EntityRef {
+
+ public String getConnectionType();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ConnectionRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ConnectionRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ConnectionRef.java
new file mode 100644
index 0000000..5c40328
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ConnectionRef.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+import java.util.List;
+
+
+/**
+ * Connection tuple
+ *
+ * @author edanuff
+ */
+public interface ConnectionRef extends ConnectedEntityRef, AssociatedEntityRef {
+
+ public EntityRef getConnectingEntity();
+
+ public List<ConnectedEntityRef> getPairedConnections();
+
+ public ConnectedEntityRef getConnectedEntity();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/CounterResolution.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/CounterResolution.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/CounterResolution.java
new file mode 100644
index 0000000..05f7bfe
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/CounterResolution.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+public enum CounterResolution {
+ ALL( 0 ), MINUTE( 1 ), FIVE_MINUTES( 5 ), HALF_HOUR( 30 ), HOUR( 60 ), SIX_HOUR( 60 * 6 ), HALF_DAY( 60 * 12 ),
+ DAY( 60 * 24 ), WEEK( 60 * 24 * 7 ), MONTH( 60 * 24 * ( 365 / 12 ) );
+
+ private final long interval;
+
+
+ CounterResolution( long minutes ) {
+ interval = minutes * 60 * 1000;
+ }
+
+
+ public long interval() {
+ return interval;
+ }
+
+
+ public long round( long timestamp ) {
+ if ( interval == 0 ) {
+ return 1;
+ }
+ return ( timestamp / interval ) * interval;
+ }
+
+
+ public long next( long timestamp ) {
+ return round( timestamp ) + interval;
+ }
+
+
+ public static CounterResolution fromOrdinal( int i ) {
+ if ( ( i < 0 ) || ( i >= CounterResolution.values().length ) ) {
+ throw new IndexOutOfBoundsException( "Invalid ordinal" );
+ }
+ return CounterResolution.values()[i];
+ }
+
+
+ public static CounterResolution fromMinutes( int m ) {
+ m = m * 60 * 1000;
+ for ( int i = CounterResolution.values().length - 1; i >= 0; i-- ) {
+ if ( CounterResolution.values()[i].interval <= m ) {
+ return CounterResolution.values()[i];
+ }
+ }
+ return ALL;
+ }
+
+
+ public static CounterResolution fromString( String s ) {
+ if ( s == null ) {
+ return ALL;
+ }
+ try {
+ return CounterResolution.valueOf( s.toUpperCase() );
+ }
+ catch ( IllegalArgumentException e ) {
+ }
+ try {
+ return fromMinutes( Integer.valueOf( s ) );
+ }
+ catch ( NumberFormatException e ) {
+ }
+ return ALL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/EntityRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/EntityRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/EntityRef.java
new file mode 100644
index 0000000..f758afa
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/EntityRef.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+import java.util.UUID;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+
+public interface EntityRef {
+
+ public Id getId();
+
+ public UUID getVersion();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Query.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Query.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Query.java
new file mode 100644
index 0000000..51fc1dd
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Query.java
@@ -0,0 +1,1099 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.Token;
+import org.antlr.runtime.TokenRewriteStream;
+import static org.apache.commons.codec.binary.Base64.decodeBase64;
+import org.apache.commons.lang.StringUtils;
+import static org.apache.commons.lang.StringUtils.isBlank;
+import static org.apache.commons.lang.StringUtils.split;
+import org.apache.usergrid.persistence.query.Results.Level;
+import org.apache.usergrid.persistence.exceptions.QueryParseException;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.query.tree.AndOperand;
+import org.apache.usergrid.persistence.query.tree.ContainsOperand;
+import org.apache.usergrid.persistence.query.tree.Equal;
+import org.apache.usergrid.persistence.query.tree.EqualityOperand;
+import org.apache.usergrid.persistence.query.tree.GreaterThan;
+import org.apache.usergrid.persistence.query.tree.GreaterThanEqual;
+import org.apache.usergrid.persistence.query.tree.LessThan;
+import org.apache.usergrid.persistence.query.tree.LessThanEqual;
+import org.apache.usergrid.persistence.query.tree.Operand;
+import org.apache.usergrid.persistence.query.tree.QueryFilterLexer;
+import org.apache.usergrid.persistence.query.tree.QueryFilterParser;
+import static org.apache.usergrid.persistence.utils.ClassUtils.cast;
+import org.apache.usergrid.persistence.utils.JsonUtils;
+import static org.apache.usergrid.persistence.utils.ListUtils.first;
+import static org.apache.usergrid.persistence.utils.ListUtils.firstBoolean;
+import static org.apache.usergrid.persistence.utils.ListUtils.firstInteger;
+import static org.apache.usergrid.persistence.utils.ListUtils.firstLong;
+import static org.apache.usergrid.persistence.utils.ListUtils.isEmpty;
+import static org.apache.usergrid.persistence.utils.MapUtils.toMapList;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class Query {
+
+ private static final Logger logger = LoggerFactory.getLogger( Query.class );
+
+ public static final int DEFAULT_LIMIT = 10;
+
+ public static final int MAX_LIMIT = 1000;
+
+ public static final String PROPERTY_Id = "uuid";
+
+ private String type;
+ private List<SortPredicate> sortPredicates = new ArrayList<SortPredicate>();
+ private Operand rootOperand;
+ private Id startResult;
+ private String cursor;
+ private int limit = 0;
+
+ private Map<String, String> selectAssignments = new LinkedHashMap<String, String>();
+ private boolean mergeSelectResults = false;
+ private Level level = Level.ALL_PROPERTIES;
+ private String connection;
+ private List<String> permissions;
+ private boolean reversed;
+ private boolean reversedSet = false;
+ private Long startTime;
+ private Long finishTime;
+ private boolean pad;
+ private CounterResolution resolution = CounterResolution.ALL;
+ private List<Id> identifiers;
+ private String collection;
+ private String ql;
+
+
+ public Query() {
+ }
+
+
+ public Query( Query q ) {
+ if ( q != null ) {
+ type = q.type;
+ sortPredicates = q.sortPredicates != null
+ ? new ArrayList<SortPredicate>( q.sortPredicates ) : null;
+ startResult = q.startResult;
+ cursor = q.cursor;
+ limit = q.limit;
+ selectAssignments = q.selectAssignments != null
+ ? new LinkedHashMap<String, String>( q.selectAssignments ) : null;
+ mergeSelectResults = q.mergeSelectResults;
+ level = q.level;
+ connection = q.connection;
+ permissions = q.permissions != null ? new ArrayList<String>( q.permissions ) : null;
+ reversed = q.reversed;
+ reversedSet = q.reversedSet;
+ startTime = q.startTime;
+ finishTime = q.finishTime;
+ resolution = q.resolution;
+ pad = q.pad;
+ rootOperand = q.rootOperand;
+ identifiers = q.identifiers != null ? new ArrayList<Id>( q.identifiers ) : null;
+ collection = q.collection;
+ }
+ }
+
+
+ public static Query fromQL( String ql ) throws QueryParseException {
+ if ( ql == null ) {
+ return null;
+ }
+ String originalQl = ql;
+ ql = ql.trim();
+
+ String qlt = ql.toLowerCase();
+ if ( !qlt.startsWith( "select" )
+ && !qlt.startsWith( "insert" )
+ && !qlt.startsWith( "update" )
+ && !qlt.startsWith( "delete" ) ) {
+ if ( qlt.startsWith( "order by" ) ) {
+ ql = "select * " + ql;
+ }
+ else {
+ ql = "select * where " + ql;
+ }
+ }
+
+ ANTLRStringStream in = new ANTLRStringStream( qlt.trim() );
+
+ // TODO
+
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ CommonTokenStream tokens = new CommonTokenStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+ try {
+ Query q = parser.ql().query;
+ q.setQl( originalQl );
+ return q;
+ }
+ catch ( RecognitionException e ) {
+ logger.error( "Unable to parse \"{}\"", ql, e );
+
+ int index = e.index;
+ int lineNumber = e.line;
+ Token token = e.token;
+
+ String message = String.format("The query cannot be parsed. "
+ + "The token '%s' at column %d on line %d cannot be parsed",
+ token.getText(), index, lineNumber );
+
+ throw new QueryParseException( message, e );
+ }
+ }
+
+
+ private static Query newQueryIfNull( Query query ) {
+ if ( query == null ) {
+ query = new Query();
+ }
+ return query;
+ }
+
+
+ public static Query fromJsonString( String json ) throws QueryParseException {
+ Object o = JsonUtils.parse( json );
+ if ( o instanceof Map ) {
+ @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, List<String>> params =
+ cast( toMapList( ( Map ) o ) );
+ return fromQueryParams( params );
+ }
+ return null;
+ }
+
+
+ public static Query fromQueryParams(
+ Map<String, List<String>> params ) throws QueryParseException {
+
+ Query q = null;
+ CounterResolution resolution = null;
+ List<Id> identifiers = null;
+
+ String ql = QueryUtils.queryStrFrom( params );
+ String type = first( params.get( "type" ) );
+ Boolean reversed = firstBoolean( params.get( "reversed" ) );
+ String connection = first( params.get( "connection" ) );
+ //Id start = firstId( params.get( "start" ) );
+ String cursor = first( params.get( "cursor" ) );
+ Integer limit = firstInteger( params.get( "limit" ) );
+ List<String> permissions = params.get( "permission" );
+ Long startTime = firstLong( params.get( "start_time" ) );
+ Long finishTime = firstLong( params.get( "end_time" ) );
+
+ List<String> l = params.get( "resolution" );
+ if ( !isEmpty( l ) ) {
+ resolution = CounterResolution.fromString( l.get( 0 ) );
+ }
+
+ Boolean pad = firstBoolean( params.get( "pad" ) );
+
+ for ( Entry<String, List<String>> param : params.entrySet() ) {
+ Id identifier = null; // TODO Identifier.from( param.getKey() );
+ if ( ( param.getValue() == null ) || ( param.getValue().size() == 0 ) ) {
+ if ( identifier != null ) {
+ if ( identifiers == null ) {
+ identifiers = new ArrayList<Id>();
+ }
+ identifiers.add( identifier );
+ }
+ }
+ }
+
+ if ( ql != null ) {
+ q = Query.fromQL( decode( ql ) );
+ }
+
+ l = params.get( "filter" );
+
+ if ( !isEmpty( l ) ) {
+ q = newQueryIfNull( q );
+ for ( String s : l ) {
+ q.addFilter( decode( s ) );
+ }
+ }
+
+ l = params.get( "sort" );
+ if ( !isEmpty( l ) ) {
+ q = newQueryIfNull( q );
+ for ( String s : l ) {
+ q.addSort( decode( s ) );
+ }
+ }
+
+ if ( type != null ) {
+ q = newQueryIfNull( q );
+ q.setEntityType( type );
+ }
+
+ if ( connection != null ) {
+ q = newQueryIfNull( q );
+ q.setConnectionType( connection );
+ }
+
+ if ( permissions != null ) {
+ q = newQueryIfNull( q );
+ q.setPermissions( permissions );
+ }
+
+// if ( start != null ) {
+// q = newQueryIfNull( q );
+// q.setStartResult( start );
+// }
+
+ if ( cursor != null ) {
+ q = newQueryIfNull( q );
+ q.setCursor( cursor );
+ }
+
+ if ( limit != null ) {
+ q = newQueryIfNull( q );
+ q.setLimit( limit );
+ }
+
+ if ( startTime != null ) {
+ q = newQueryIfNull( q );
+ q.setStartTime( startTime );
+ }
+
+ if ( finishTime != null ) {
+ q = newQueryIfNull( q );
+ q.setFinishTime( finishTime );
+ }
+
+ if ( resolution != null ) {
+ q = newQueryIfNull( q );
+ q.setResolution( resolution );
+ }
+
+ if ( pad != null ) {
+ q = newQueryIfNull( q );
+ q.setPad( pad );
+ }
+
+ if ( identifiers != null ) {
+ q = newQueryIfNull( q );
+ q.setIdentifiers( identifiers );
+ }
+
+ if ( reversed != null ) {
+ q = newQueryIfNull( q );
+ q.setReversed( reversed );
+ }
+
+ return q;
+ }
+
+
+ public static Query searchForProperty( String propertyName, Object propertyValue ) {
+ Query q = new Query();
+ q.addEqualityFilter( propertyName, propertyValue );
+ return q;
+ }
+
+
+ public static Query findForProperty( String propertyName, Object propertyValue ) {
+ Query q = new Query();
+ q.addEqualityFilter( propertyName, propertyValue );
+ q.setLimit( 1 );
+ return q;
+ }
+
+
+ public static Query fromId( Id id ) {
+ Query q = new Query();
+ q.addIdentifier( id );
+ return q;
+ }
+
+ public boolean hasQueryPredicates() {
+ return rootOperand != null;
+ }
+
+ public Query addSort( SortPredicate sort ) {
+ if ( sort == null ) {
+ return this;
+ }
+
+ for ( SortPredicate s : sortPredicates ) {
+ if ( s.getPropertyName().equals( sort.getPropertyName() ) ) {
+ throw new QueryParseException(
+ String.format(
+ "Attempted to set sort order for %s more than once", s.getPropertyName()));
+ }
+ }
+ sortPredicates.add( sort );
+ return this;
+ }
+
+
+ @JsonIgnore
+ boolean isIdsOnly() {
+ if ( ( selectAssignments.size() == 1 ) && selectAssignments.containsKey( PROPERTY_Id ) ) {
+ level = Level.IDS;
+ return true;
+ }
+ return false;
+ }
+
+
+ private void setIdsOnly( boolean idsOnly ) {
+ if ( idsOnly ) {
+ selectAssignments = new LinkedHashMap<String, String>();
+ selectAssignments.put( PROPERTY_Id, PROPERTY_Id );
+ level = Level.IDS;
+ }
+ else if ( isIdsOnly() ) {
+ selectAssignments = new LinkedHashMap<String, String>();
+ level = Level.ALL_PROPERTIES;
+ }
+ }
+
+
+ public Level getResultsLevel() {
+ isIdsOnly();
+ return level;
+ }
+
+
+ public void setResultsLevel( Level level ) {
+ setIdsOnly( level == Level.IDS );
+ this.level = level;
+ }
+
+
+ public Query withResultsLevel( Level level ) {
+ setIdsOnly( level == Level.IDS );
+ this.level = level;
+ return this;
+ }
+
+
+ public Query withReversed( boolean reversed ) {
+ setReversed( reversed );
+ return this;
+ }
+
+
+ public String getEntityType() {
+ return type;
+ }
+
+
+ public void setEntityType( String type ) {
+ this.type = type;
+ }
+
+
+ public String getConnectionType() {
+ return connection;
+ }
+
+
+ public void setConnectionType( String connection ) {
+ this.connection = connection;
+ }
+
+
+ public List<String> getPermissions() {
+ return permissions;
+ }
+
+
+ public void setPermissions( List<String> permissions ) {
+ this.permissions = permissions;
+ }
+
+
+ public Query addSelect( String select ) {
+
+ return addSelect( select, null );
+ }
+
+
+ public Query addSelect( String select, String output ) {
+ // be paranoid with the null checks because
+ // the query parser sometimes flakes out
+ if ( select == null ) {
+ return this;
+ }
+ select = select.trim();
+
+ if ( select.equals( "*" ) ) {
+ return this;
+ }
+
+ mergeSelectResults = StringUtils.isNotEmpty( output );
+
+ if ( output == null ) {
+ output = "";
+ }
+
+ selectAssignments.put( select, output );
+
+ return this;
+ }
+
+
+ public boolean hasSelectSubjects() {
+ return !selectAssignments.isEmpty();
+ }
+
+
+ @JsonIgnore
+ public Set<String> getSelectSubjects() {
+ return selectAssignments.keySet();
+ }
+
+
+ public Map<String, String> getSelectAssignments() {
+ return selectAssignments;
+ }
+
+
+ boolean isMergeSelectResults() {
+ return mergeSelectResults;
+ }
+
+
+ public Query addSort( String propertyName ) {
+ if ( isBlank( propertyName ) ) {
+ return this;
+ }
+ propertyName = propertyName.trim();
+ if ( propertyName.indexOf( ',' ) >= 0 ) {
+ String[] propertyNames = split( propertyName, ',' );
+ for ( String s : propertyNames ) {
+ addSort( s );
+ }
+ return this;
+ }
+
+ SortDirection direction = SortDirection.ASCENDING;
+ if ( propertyName.indexOf( ' ' ) >= 0 ) {
+ String[] parts = split( propertyName, ' ' );
+ if ( parts.length > 1 ) {
+ propertyName = parts[0];
+ direction = SortDirection.find( parts[1] );
+ }
+ }
+ else if ( propertyName.startsWith( "-" ) ) {
+ propertyName = propertyName.substring( 1 );
+ direction = SortDirection.DESCENDING;
+ }
+ else if ( propertyName.startsWith( "+" ) ) {
+ propertyName = propertyName.substring( 1 );
+ direction = SortDirection.ASCENDING;
+ }
+
+ return addSort( propertyName, direction );
+ }
+
+
+ public Query addSort( String propertyName, SortDirection direction ) {
+ if ( isBlank( propertyName ) ) {
+ return this;
+ }
+ propertyName = propertyName.trim();
+ for ( SortPredicate s : sortPredicates ) {
+ if ( s.getPropertyName().equals( propertyName ) ) {
+ logger.error(
+ "Attempted to set sort order for " + s.getPropertyName() + " more than once, discarding..." );
+ return this;
+ }
+ }
+ sortPredicates.add( new SortPredicate( propertyName, direction ) );
+ return this;
+ }
+
+
+ @JsonIgnore
+ public boolean isSortSet() {
+ return !sortPredicates.isEmpty();
+ }
+
+
+ public List<SortPredicate> getSortPredicates() {
+ return sortPredicates;
+ }
+
+
+ public Query addFilter( String filter ) {
+ ANTLRStringStream in = new ANTLRStringStream( filter );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+ Operand root = null;
+ try {
+ root = parser.ql().query.getRootOperand();
+ }
+ catch ( RecognitionException e ) {
+ // todo: should we create a specific Exception for this? checked?
+ throw new RuntimeException( "Unknown operation: " + filter, e );
+ }
+
+ if ( root != null ) {
+ addClause( root );
+ }
+
+ return this;
+ }
+
+
+ /** Add a less than filter to this query. && with existing clauses */
+ public Query addLessThanFilter( String propName, Object value ) {
+ LessThan equality = new LessThan( null );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ /** Add a less than equal filter to this query. && with existing clauses */
+ public Query addLessThanEqualFilter( String propName, Object value ) {
+ LessThanEqual equality = new LessThanEqual( null );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ /** Add a equal filter to this query. && with existing clauses */
+ public Query addEqualityFilter( String propName, Object value ) {
+ Equal equality = new Equal( new ClassicToken( 0, "=" ) );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ /** Add a greater than equal filter to this query. && with existing clauses */
+ public Query addGreaterThanEqualFilter( String propName, Object value ) {
+ GreaterThanEqual equality = new GreaterThanEqual( null );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ /** Add a less than filter to this query. && with existing clauses */
+ public Query addGreaterThanFilter( String propName, Object value ) {
+ GreaterThan equality = new GreaterThan( null );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ public Query addContainsFilter( String propName, String keyword ) {
+ ContainsOperand equality = new ContainsOperand( new ClassicToken( 0, "contains" ) );
+
+ equality.setProperty( propName );
+ equality.setLiteral( keyword );
+
+ addClause( equality );
+
+ return this;
+ }
+
+
+ private void addClause( EqualityOperand equals, String propertyName, Object value ) {
+ equals.setProperty( propertyName );
+ equals.setLiteral( value );
+ addClause( equals );
+ }
+
+
+ private void addClause( Operand equals ) {
+
+ if ( rootOperand == null ) {
+ rootOperand = equals;
+ return;
+ }
+
+ AndOperand and = new AndOperand();
+ and.addChild( rootOperand );
+ and.addChild( equals );
+
+ // redirect the root to new && clause
+ rootOperand = and;
+ }
+
+
+ @JsonIgnore
+ public Operand getRootOperand() {
+ if ( rootOperand == null ) { // attempt deserialization
+ if ( ql != null ) {
+ try {
+ Query q = Query.fromQL( ql );
+ rootOperand = q.rootOperand;
+ }
+ catch ( QueryParseException e ) {
+ logger.error( "error parsing sql for rootOperand", e ); // shouldn't happen
+ }
+ }
+ }
+ return rootOperand;
+ }
+
+
+ public void setRootOperand( Operand root ) {
+ this.rootOperand = root;
+ }
+
+
+ void setStartResult( Id startResult ) {
+ this.startResult = startResult;
+ }
+
+
+ public Query withStartResult( Id startResult ) {
+ this.startResult = startResult;
+ return this;
+ }
+
+
+ public Id getStartResult() {
+ if ( ( startResult == null ) && ( cursor != null ) ) {
+ byte[] cursorBytes = decodeBase64( cursor );
+ if ( ( cursorBytes != null ) && ( cursorBytes.length == 16 ) ) {
+ startResult = null; // TODO uuid( cursorBytes );
+ }
+ }
+ return startResult;
+ }
+
+
+ public String getCursor() {
+ return cursor;
+ }
+
+
+ public void setCursor( String cursor ) {
+ this.cursor = cursor;
+ }
+
+
+ public Query withCursor( String cursor ) {
+ setCursor( cursor );
+ return this;
+ }
+
+
+ public int getLimit() {
+ return getLimit( DEFAULT_LIMIT );
+ }
+
+
+ public int getLimit( int defaultLimit ) {
+ if ( limit <= 0 ) {
+ if ( defaultLimit > 0 ) {
+ return defaultLimit;
+ }
+ else {
+ return DEFAULT_LIMIT;
+ }
+ }
+ return limit;
+ }
+
+
+ public void setLimit( int limit ) {
+
+ // TODO tnine. After users have had time to change their query limits,
+ // this needs to be uncommented and enforced.
+ // if(limit > MAX_LIMIT){
+ // throw new IllegalArgumentException(String.format("Query limit must be <= to %d", MAX_LIMIT));
+ // }
+
+ if ( limit > MAX_LIMIT ) {
+ limit = MAX_LIMIT;
+ }
+
+ this.limit = limit;
+ }
+
+
+ public Query withLimit( int limit ) {
+ setLimit( limit );
+ return this;
+ }
+
+
+ public boolean isReversed() {
+ return reversed;
+ }
+
+
+ public void setReversed( boolean reversed ) {
+ reversedSet = true;
+ this.reversed = reversed;
+ }
+
+
+ public boolean isReversedSet() {
+ return reversedSet;
+ }
+
+
+ public Long getStartTime() {
+ return startTime;
+ }
+
+
+ public void setStartTime( Long startTime ) {
+ this.startTime = startTime;
+ }
+
+
+ public Long getFinishTime() {
+ return finishTime;
+ }
+
+
+ public void setFinishTime( Long finishTime ) {
+ this.finishTime = finishTime;
+ }
+
+
+ public boolean isPad() {
+ return pad;
+ }
+
+
+ public void setPad( boolean pad ) {
+ this.pad = pad;
+ }
+
+
+ public void setResolution( CounterResolution resolution ) {
+ this.resolution = resolution;
+ }
+
+
+ public CounterResolution getResolution() {
+ return resolution;
+ }
+
+
+ public void addIdentifier( Id id ) {
+ if ( identifiers == null ) {
+ identifiers = new ArrayList<Id>();
+ }
+ identifiers.add( id );
+ }
+
+
+ void setIdentifiers( List<Id> identifiers ) {
+ this.identifiers = identifiers;
+ }
+
+
+ @Override
+ public String toString() {
+ if ( ql != null ) {
+ return ql;
+ }
+ StringBuilder s = new StringBuilder( "select " );
+ if ( selectAssignments.isEmpty() ) {
+ s.append( "*" );
+ }
+ else {
+ if ( mergeSelectResults ) {
+ s.append( "{ " );
+ boolean first = true;
+ for ( Map.Entry<String, String> select : selectAssignments.entrySet() ) {
+ if ( !first ) {
+ s.append( ", " );
+ }
+ s.append( select.getValue() ).append( " : " ).append( select.getKey() );
+ first = false;
+ }
+ s.append( " }" );
+ }
+ else {
+ boolean first = true;
+ for ( String select : selectAssignments.keySet() ) {
+ if ( !first ) {
+ s.append( ", " );
+ }
+ s.append( select );
+ first = false;
+ }
+ }
+ }
+ s.append( " from " );
+ s.append( type );
+ if ( !sortPredicates.isEmpty() ) {
+ boolean first = true;
+ s.append( " order by " );
+ for ( SortPredicate sp : sortPredicates ) {
+ if ( !first ) {
+ s.append( ", " );
+ }
+ s.append( sp );
+ first = false;
+ }
+ }
+ // if (!filterPredicates.isEmpty()) {
+ // s.append(" where ");
+ // boolean first = true;
+ // for (FilterPredicate f : filterPredicates) {
+ // if (!first) {
+ // s.append(" and ");
+ // }
+ // s.append(f.toString());
+ // first = false;
+ // }
+ // }
+ return s.toString();
+ }
+
+
+ public static enum SortDirection {
+ ASCENDING, DESCENDING;
+
+
+ public static SortDirection find( String s ) {
+ if ( s == null ) {
+ return ASCENDING;
+ }
+ s = s.toLowerCase();
+ if ( s.startsWith( "asc" ) ) {
+ return ASCENDING;
+ }
+ if ( s.startsWith( "des" ) ) {
+ return DESCENDING;
+ }
+ if ( s.equals( "+" ) ) {
+ return ASCENDING;
+ }
+ if ( s.equals( "-" ) ) {
+ return DESCENDING;
+ }
+ return ASCENDING;
+ }
+ }
+
+
+ public static final class SortPredicate implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private final String propertyName;
+ private final Query.SortDirection direction;
+
+
+ public SortPredicate( String propertyName, Query.SortDirection direction ) {
+ if ( propertyName == null ) {
+ throw new NullPointerException( "Property name was null" );
+ }
+
+ if ( direction == null ) {
+ direction = SortDirection.ASCENDING;
+ }
+
+ this.propertyName = propertyName.trim();
+ this.direction = direction;
+ }
+
+
+ public SortPredicate( String propertyName, String direction ) {
+ this( propertyName, SortDirection.find( direction ) );
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+
+ public Query.SortDirection getDirection() {
+ return direction;
+ }
+
+
+ @Override
+ public boolean equals( Object o ) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( ( o == null ) || ( super.getClass() != o.getClass() ) ) {
+ return false;
+ }
+
+ SortPredicate that = ( SortPredicate ) o;
+
+ if ( direction != that.direction ) {
+ return false;
+ }
+
+ return ( propertyName.equals( that.propertyName ) );
+ }
+
+
+ @Override
+ public int hashCode() {
+ int result = propertyName.hashCode();
+ result = ( 31 * result ) + direction.hashCode();
+ return result;
+ }
+
+
+ @Override
+ public String toString() {
+ return propertyName + ( ( direction == Query.SortDirection.DESCENDING ) ? " DESC" : "" );
+ }
+ }
+
+
+// public List<Object> getSelectionResults( Results rs ) {
+//
+// List<Entity> entities = rs.getEntities();
+// if ( entities == null ) {
+// return null;
+// }
+//
+// if ( !hasSelectSubjects() ) {
+// return cast( entities );
+// }
+//
+// List<Object> results = new ArrayList<Object>();
+//
+// for ( Entity entity : entities ) {
+// if ( isMergeSelectResults() ) {
+// boolean include = false;
+// Map<String, Object> result = new LinkedHashMap<String, Object>();
+// Map<String, String> selects = getSelectAssignments();
+// for ( Map.Entry<String, String> select : selects.entrySet() ) {
+// Object obj = JsonUtils.select( entity, select.getValue(), false );
+// if ( obj != null ) {
+// include = true;
+// }
+// result.put( select.getKey(), obj );
+// }
+// if ( include ) {
+// results.add( result );
+// }
+// }
+// else {
+// boolean include = false;
+// List<Object> result = new ArrayList<Object>();
+// Set<String> selects = getSelectSubjects();
+// for ( String select : selects ) {
+// Object obj = JsonUtils.select( entity, select );
+// if ( obj != null ) {
+// include = true;
+// }
+// result.add( obj );
+// }
+// if ( include ) {
+// results.add( result );
+// }
+// }
+// }
+//
+// if ( results.size() == 0 ) {
+// return null;
+// }
+//
+// return results;
+// }
+
+
+// public Object getSelectionResult( Results rs ) {
+// List<Object> r = getSelectionResults( rs );
+// if ( ( r != null ) && ( r.size() > 0 ) ) {
+// return r.get( 0 );
+// }
+// return null;
+// }
+
+
+ private static String decode( String input ) {
+ try {
+ return URLDecoder.decode( input, "UTF-8" );
+ }
+ catch ( UnsupportedEncodingException e ) {
+ // shouldn't happen, but just in case
+ throw new RuntimeException( e );
+ }
+ }
+
+
+ // note: very likely to be null
+ public String getCollection() {
+ return collection;
+ }
+
+
+ public void setCollection( String collection ) {
+ this.collection = collection;
+ }
+
+
+ // may be null
+ public String getQl() {
+ return ql;
+ }
+
+
+ public void setQl( String ql ) {
+ this.ql = ql;
+ }
+
+
+ public List<Id> getIdentifiers() {
+ return identifiers;
+ }
+
+
+ public String getConnection() {
+ return connection;
+ }
+
+
+ public String getType() {
+ return type;
+ }
+
+
+ public Level getLevel() {
+ return level;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/QueryUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/QueryUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/QueryUtils.java
new file mode 100644
index 0000000..42b742a
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/QueryUtils.java
@@ -0,0 +1,34 @@
+package org.apache.usergrid.persistence.query;
+
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.usergrid.persistence.utils.ListUtils;
+
+
+/**
+ * Utilities to deal with query extraction and generation
+ *
+ * @author zznate
+ */
+public class QueryUtils {
+
+ public static final String PARAM_QL = "ql";
+ public static final String PARAM_Q = "q";
+ public static final String PARAM_QUERY = "query";
+
+
+ public static String queryStrFrom( Map<String, List<String>> params ) {
+ if ( params.containsKey( PARAM_QL ) ) {
+ return ListUtils.first( params.get( PARAM_QL ) );
+ }
+ else if ( params.containsKey( PARAM_Q ) ) {
+ return ListUtils.first( params.get( PARAM_Q ) );
+ }
+ else if ( params.containsKey( PARAM_QUERY ) ) {
+ return ListUtils.first( params.get( PARAM_QUERY ) );
+ }
+ return null;
+ }
+}
[21/21] git commit: Merge branch 'two-dot-o' of
https://github.com/usergrid/usergrid into two-dot-o
Posted by sn...@apache.org.
Merge branch 'two-dot-o' of https://github.com/usergrid/usergrid into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0f5ad339
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0f5ad339
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0f5ad339
Branch: refs/heads/two-dot-o
Commit: 0f5ad3393d1a7f01fc6b93625685adbc6d6205cf
Parents: 72329d6 c27b216
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Feb 21 13:01:40 2014 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Feb 21 13:01:40 2014 -0500
----------------------------------------------------------------------
.../EntityCollectionManagerFactory.java | 2 +-
.../MultiTennantColumnFamilyDefinition.java | 47 +++++++++++++++++++-
.../collection/mvcc/stage/load/Load.java | 2 +-
.../UniqueValueSerializationStrategyImpl.java | 2 +-
.../MvccEntitySerializationStrategyImpl.java | 2 +-
.../MvccLogEntrySerializationStrategyImpl.java | 2 +-
.../EntityCollectionManagerSyncIT.java | 2 +-
.../usergrid/persistence/graph/EdgeManager.java | 2 +-
.../graph/consistency/AsyncProcessor.java | 35 +++++++++++++++
.../graph/consistency/AsyncProcessorImpl.java | 37 +++++++++++++++
.../graph/consistency/SimpleTimeoutEvent.java | 30 +++++++++++++
.../graph/consistency/TimeoutEvent.java | 18 ++++++++
.../graph/consistency/TimeoutQueue.java | 42 +++++++++++++++++
.../persistence/graph/guice/GraphModule.java | 26 +++++++++++
.../impl/EdgeMetadataSerializationImpl.java | 2 +-
.../impl/EdgeSerializationImpl.java | 2 +-
.../impl/NodeSerializationImpl.java | 2 +-
17 files changed, 244 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
[04/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/resources/sample-large.json
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/sample-large.json b/stack/corepersistence/queryindex/src/test/resources/sample-large.json
new file mode 100644
index 0000000..92a7f5b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/resources/sample-large.json
@@ -0,0 +1,39603 @@
+[
+ {
+ "id": 0,
+ "guid": "600f35b5-e667-4ed1-a81b-fd8dcfbbdf0a",
+ "isActive": false,
+ "balance": "$1,901.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 28,
+ "name": "Bowers Oneil",
+ "gender": "male",
+ "company": "Senmao",
+ "contact": {
+ "email": "bowersoneil@senmao.com",
+ "phone": "+1 (984) 481-3664",
+ "address": "710 Fenimore Street, Aurora, Ohio, 9091"
+ },
+ "about": "Incididunt eiusmod aliquip in excepteur amet minim. Sit ad laboris reprehenderit laboris eu do ut culpa magna voluptate irure dolor. Ut ullamco deserunt do non aute minim. Incididunt excepteur voluptate excepteur consequat sit ullamco excepteur labore.\r\n",
+ "registered": "1996-04-29T17:53:23 +04:00",
+ "latitude": -80.49615,
+ "longitude": 173.847337,
+ "tags": [
+ "id",
+ "labore",
+ "exercitation",
+ "dolore",
+ "et",
+ "culpa",
+ "eu"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Shari Hahn"
+ },
+ {
+ "id": 1,
+ "name": "Wendy Moody"
+ },
+ {
+ "id": 2,
+ "name": "Mercado Jenkins"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 1,
+ "guid": "b7640d31-08a5-4c89-b2d4-2a61f7abcdf2",
+ "isActive": false,
+ "balance": "$1,898.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 29,
+ "name": "Valencia Mercado",
+ "gender": "male",
+ "company": "Surelogic",
+ "contact": {
+ "email": "valenciamercado@surelogic.com",
+ "phone": "+1 (909) 578-3391",
+ "address": "186 Highlawn Avenue, Forestburg, Montana, 2981"
+ },
+ "about": "Ipsum ut dolore aute do enim nostrud ad nisi non consectetur Lorem. Nostrud ex culpa commodo ad culpa sit esse consequat id. Commodo adipisicing in ut do non cillum nostrud mollit. Excepteur ipsum veniam consectetur labore magna est veniam esse. Occaecat consectetur do Lorem eiusmod laborum eiusmod. Pariatur culpa eiusmod nisi officia incididunt id.\r\n",
+ "registered": "2008-09-12T22:19:23 +04:00",
+ "latitude": -35.821567,
+ "longitude": -153.267477,
+ "tags": [
+ "enim",
+ "consectetur",
+ "velit",
+ "amet",
+ "id",
+ "nostrud",
+ "qui"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Romero Ayers"
+ },
+ {
+ "id": 1,
+ "name": "Downs Hampton"
+ },
+ {
+ "id": 2,
+ "name": "Humphrey Henry"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 2,
+ "guid": "f22b9da2-911d-447b-aa77-741a639e6039",
+ "isActive": true,
+ "balance": "$2,222.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 29,
+ "name": "Morgan Pierce",
+ "gender": "female",
+ "company": "Goko",
+ "contact": {
+ "email": "morganpierce@goko.com",
+ "phone": "+1 (815) 565-2747",
+ "address": "546 Hull Street, Loveland, Oregon, 7021"
+ },
+ "about": "Tempor amet cillum ea reprehenderit elit Lorem nisi do voluptate. Anim deserunt officia deserunt adipisicing ut et irure exercitation consectetur. Culpa sit elit exercitation ullamco velit ipsum incididunt. Ex aliquip do reprehenderit non ullamco exercitation non qui incididunt ea laboris. Elit occaecat nisi cupidatat elit qui nostrud in culpa dolore incididunt aute minim. Cillum magna nulla ex culpa aliqua enim eu mollit fugiat commodo excepteur qui officia. Mollit ea laborum magna amet irure eiusmod adipisicing.\r\n",
+ "registered": "1999-11-19T21:04:45 +05:00",
+ "latitude": 53.856352,
+ "longitude": -26.088146,
+ "tags": [
+ "pariatur",
+ "aliqua",
+ "elit",
+ "elit",
+ "aute",
+ "tempor",
+ "laborum"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Patrica Pitts"
+ },
+ {
+ "id": 1,
+ "name": "Manning Torres"
+ },
+ {
+ "id": 2,
+ "name": "Salinas Landry"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 3,
+ "guid": "905daf9b-b784-40e3-8f10-226abc2608ff",
+ "isActive": false,
+ "balance": "$1,103.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 40,
+ "name": "Kaye Baxter",
+ "gender": "female",
+ "company": "Biohab",
+ "contact": {
+ "email": "kayebaxter@biohab.com",
+ "phone": "+1 (970) 460-2370",
+ "address": "235 Poplar Street, Vaughn, Colorado, 365"
+ },
+ "about": "Proident minim velit mollit dolore dolore deserunt proident dolor cupidatat. Dolor aute culpa minim consequat laboris sit sit. Do deserunt enim consectetur deserunt velit Lorem dolore aute. Ut ad reprehenderit mollit sit pariatur qui sunt officia elit ex. Ex magna et officia nisi pariatur dolore cupidatat qui exercitation tempor. Consequat nisi minim non mollit Lorem.\r\n",
+ "registered": "2003-01-16T08:17:37 +05:00",
+ "latitude": 32.346743,
+ "longitude": -118.107511,
+ "tags": [
+ "commodo",
+ "adipisicing",
+ "sunt",
+ "do",
+ "proident",
+ "elit",
+ "tempor"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Herman Atkinson"
+ },
+ {
+ "id": 1,
+ "name": "Naomi Harris"
+ },
+ {
+ "id": 2,
+ "name": "Bolton Sims"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 4,
+ "guid": "6c31a8cf-c84a-41cc-b545-c0357c9c78cc",
+ "isActive": false,
+ "balance": "$1,025.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 21,
+ "name": "Lilia Kerr",
+ "gender": "female",
+ "company": "Proflex",
+ "contact": {
+ "email": "liliakerr@proflex.com",
+ "phone": "+1 (813) 453-3357",
+ "address": "552 Classon Avenue, Elfrida, Mississippi, 7261"
+ },
+ "about": "Esse eiusmod do in culpa qui commodo anim culpa elit. In incididunt consequat ad ipsum magna ullamco laborum. Elit pariatur occaecat deserunt ipsum culpa voluptate quis id eiusmod commodo. Excepteur cupidatat est qui culpa veniam dolor consectetur non laborum occaecat nostrud.\r\n",
+ "registered": "1999-01-31T08:39:10 +05:00",
+ "latitude": -14.813962,
+ "longitude": -63.82928,
+ "tags": [
+ "laborum",
+ "ea",
+ "anim",
+ "tempor",
+ "aute",
+ "tempor",
+ "qui"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Carmela Burnett"
+ },
+ {
+ "id": 1,
+ "name": "Walter Savage"
+ },
+ {
+ "id": 2,
+ "name": "Erika Leblanc"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 5,
+ "guid": "5a41803f-ffee-48d0-9754-dd21c546fea8",
+ "isActive": false,
+ "balance": "$1,497.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 26,
+ "name": "Ellen Smith",
+ "gender": "female",
+ "company": "Rubadub",
+ "contact": {
+ "email": "ellensmith@rubadub.com",
+ "phone": "+1 (935) 564-3809",
+ "address": "684 Norfolk Street, Urie, South Dakota, 8242"
+ },
+ "about": "Nostrud nulla incididunt aliqua non voluptate ipsum veniam. Culpa aute ipsum aliquip ad do labore esse labore fugiat ad qui. Adipisicing pariatur ut elit aliqua ea voluptate cillum non fugiat nulla consectetur cillum cupidatat magna.\r\n",
+ "registered": "1989-12-31T01:17:41 +05:00",
+ "latitude": -32.889744,
+ "longitude": -18.163195,
+ "tags": [
+ "esse",
+ "pariatur",
+ "elit",
+ "ad",
+ "proident",
+ "minim",
+ "officia"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Frazier Wolfe"
+ },
+ {
+ "id": 1,
+ "name": "Hillary Deleon"
+ },
+ {
+ "id": 2,
+ "name": "Strong Hancock"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 6,
+ "guid": "75bb1390-ad85-40ac-874c-e65f7b736ce7",
+ "isActive": true,
+ "balance": "$2,977.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 39,
+ "name": "Valeria Carney",
+ "gender": "female",
+ "company": "Webiotic",
+ "contact": {
+ "email": "valeriacarney@webiotic.com",
+ "phone": "+1 (914) 494-3912",
+ "address": "836 Whitty Lane, Lavalette, Minnesota, 6503"
+ },
+ "about": "Et eiusmod sit incididunt quis occaecat occaecat irure duis incididunt dolore quis. Nostrud aliquip consectetur fugiat et. Id do magna nisi esse occaecat ut excepteur magna laboris exercitation. Laboris ullamco aliquip aute sit. Cupidatat velit nulla aliqua fugiat culpa in. Veniam velit aliquip elit labore mollit Lorem labore aliquip.\r\n",
+ "registered": "2007-09-29T03:51:38 +04:00",
+ "latitude": 52.678155,
+ "longitude": -41.807612,
+ "tags": [
+ "labore",
+ "veniam",
+ "in",
+ "consequat",
+ "cillum",
+ "cillum",
+ "enim"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Potts Santana"
+ },
+ {
+ "id": 1,
+ "name": "Ramirez Everett"
+ },
+ {
+ "id": 2,
+ "name": "Rasmussen Harrington"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 7,
+ "guid": "6a870e4a-5550-447c-9615-6d059b2e0b47",
+ "isActive": true,
+ "balance": "$1,681.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 30,
+ "name": "Krystal Mullins",
+ "gender": "female",
+ "company": "Bitendrex",
+ "contact": {
+ "email": "krystalmullins@bitendrex.com",
+ "phone": "+1 (824) 530-3509",
+ "address": "782 Lott Place, Maury, Iowa, 2176"
+ },
+ "about": "Anim deserunt elit et ut officia sint aliqua exercitation proident sunt dolore occaecat. Sint ullamco velit magna consequat cupidatat ipsum cupidatat reprehenderit ut nostrud. Veniam ullamco proident ad id qui qui enim occaecat. Laboris in veniam deserunt dolore culpa est elit. Incididunt anim proident est esse occaecat. Exercitation non ipsum eu adipisicing do commodo consequat officia eiusmod. Labore tempor ullamco consequat velit.\r\n",
+ "registered": "2003-01-13T20:07:46 +05:00",
+ "latitude": -8.896934,
+ "longitude": 11.939986,
+ "tags": [
+ "ut",
+ "labore",
+ "consectetur",
+ "anim",
+ "incididunt",
+ "ut",
+ "esse"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Gallagher Case"
+ },
+ {
+ "id": 1,
+ "name": "Morin Fry"
+ },
+ {
+ "id": 2,
+ "name": "Autumn Nixon"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 8,
+ "guid": "85599684-8ec5-448f-83f4-3ccdd7bbd472",
+ "isActive": true,
+ "balance": "$2,611.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 22,
+ "name": "Ernestine Coffey",
+ "gender": "female",
+ "company": "Affluex",
+ "contact": {
+ "email": "ernestinecoffey@affluex.com",
+ "phone": "+1 (850) 494-2124",
+ "address": "990 Lawrence Street, Valle, Indiana, 7846"
+ },
+ "about": "Ipsum non cupidatat qui non labore nisi sit elit labore esse. Qui laborum laborum est Lorem quis et consectetur laboris. Aliqua sint do ea quis id velit consequat ad aute ad nostrud nulla tempor. Consequat consequat laboris nulla dolor.\r\n",
+ "registered": "2001-02-21T07:05:41 +05:00",
+ "latitude": 82.217467,
+ "longitude": 27.389067,
+ "tags": [
+ "excepteur",
+ "cupidatat",
+ "commodo",
+ "nostrud",
+ "aute",
+ "officia",
+ "et"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Gentry Hickman"
+ },
+ {
+ "id": 1,
+ "name": "Berger Grant"
+ },
+ {
+ "id": 2,
+ "name": "Mcclain Owens"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 9,
+ "guid": "e377f195-58c7-46d1-b9ff-28fd0391e222",
+ "isActive": true,
+ "balance": "$3,498.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 40,
+ "name": "Minerva Harrell",
+ "gender": "female",
+ "company": "Isis",
+ "contact": {
+ "email": "minervaharrell@isis.com",
+ "phone": "+1 (846) 498-2864",
+ "address": "843 Bath Avenue, Sanders, Alabama, 7969"
+ },
+ "about": "Cupidatat est elit fugiat eu non Lorem ea sunt eu Lorem. Lorem elit commodo pariatur labore velit cillum id officia anim aliquip. Proident sunt consectetur laborum ullamco nisi excepteur sit laborum. Id cillum nulla esse eiusmod non exercitation deserunt incididunt eu cupidatat sit proident labore. Do dolor culpa sunt esse esse voluptate minim eiusmod in deserunt incididunt.\r\n",
+ "registered": "1994-06-05T10:31:45 +04:00",
+ "latitude": 47.3984,
+ "longitude": -81.830573,
+ "tags": [
+ "aliquip",
+ "voluptate",
+ "nostrud",
+ "ullamco",
+ "deserunt",
+ "quis",
+ "qui"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Boyle Davis"
+ },
+ {
+ "id": 1,
+ "name": "Cassandra Morales"
+ },
+ {
+ "id": 2,
+ "name": "Jolene Olson"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 10,
+ "guid": "be892c50-2a93-4704-9e47-510ae151f104",
+ "isActive": true,
+ "balance": "$2,605.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 29,
+ "name": "Farmer Ryan",
+ "gender": "male",
+ "company": "Blurrybus",
+ "contact": {
+ "email": "farmerryan@blurrybus.com",
+ "phone": "+1 (833) 517-3399",
+ "address": "958 Bartlett Street, Grahamtown, Arkansas, 2037"
+ },
+ "about": "Est eu sint cillum eiusmod et non ullamco. Fugiat cillum qui consectetur consequat sit. Officia non ad qui qui qui in Lorem veniam sunt sunt adipisicing sit minim ut. Magna voluptate dolor eu aute.\r\n",
+ "registered": "2011-10-22T18:04:13 +04:00",
+ "latitude": -65.443981,
+ "longitude": 107.936664,
+ "tags": [
+ "magna",
+ "in",
+ "et",
+ "sint",
+ "reprehenderit",
+ "ut",
+ "consequat"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Lena Macdonald"
+ },
+ {
+ "id": 1,
+ "name": "Duke Turner"
+ },
+ {
+ "id": 2,
+ "name": "Macdonald Galloway"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 11,
+ "guid": "cf39ae8e-d968-48cb-b938-7c8ea7a389b8",
+ "isActive": false,
+ "balance": "$3,644.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 35,
+ "name": "Hunt Talley",
+ "gender": "male",
+ "company": "Indexia",
+ "contact": {
+ "email": "hunttalley@indexia.com",
+ "phone": "+1 (893) 564-3122",
+ "address": "843 Newkirk Avenue, Nogal, Wyoming, 945"
+ },
+ "about": "Voluptate nulla ex minim excepteur exercitation ullamco sunt et minim velit veniam tempor. Magna ad ipsum proident sint irure cillum non. Quis occaecat occaecat nisi aute amet labore consectetur adipisicing deserunt nisi adipisicing voluptate. Aliquip officia dolore enim cillum. Voluptate enim veniam est in dolore magna cillum laboris culpa ullamco ea laborum duis.\r\n",
+ "registered": "1994-10-09T21:24:35 +04:00",
+ "latitude": 10.548535,
+ "longitude": -33.365903,
+ "tags": [
+ "dolore",
+ "eiusmod",
+ "officia",
+ "elit",
+ "consectetur",
+ "mollit",
+ "laboris"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Mable Gilmore"
+ },
+ {
+ "id": 1,
+ "name": "Corinne Carlson"
+ },
+ {
+ "id": 2,
+ "name": "Elnora Fuller"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 12,
+ "guid": "60dbe3c9-cda1-49af-8b88-a2e61111d5af",
+ "isActive": true,
+ "balance": "$3,306.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 30,
+ "name": "Brooks Schultz",
+ "gender": "male",
+ "company": "Neteria",
+ "contact": {
+ "email": "brooksschultz@neteria.com",
+ "phone": "+1 (956) 490-2421",
+ "address": "234 Clarendon Road, Fairlee, Oklahoma, 4204"
+ },
+ "about": "Excepteur ea culpa in esse deserunt laboris voluptate nostrud nulla occaecat proident non occaecat occaecat. Duis nostrud sint magna ex adipisicing eu consequat deserunt tempor mollit. Sint in adipisicing proident quis reprehenderit elit tempor tempor. Exercitation ullamco ea culpa nisi. Minim reprehenderit nulla voluptate laboris eu sint ullamco proident non excepteur aute laborum sunt eu. Aliqua laboris dolor mollit sit sunt anim mollit nisi est mollit nostrud ex. Ea enim ea pariatur duis sunt velit et mollit laboris et.\r\n",
+ "registered": "1997-12-23T13:36:36 +05:00",
+ "latitude": 25.211469,
+ "longitude": -100.269514,
+ "tags": [
+ "laborum",
+ "commodo",
+ "labore",
+ "sunt",
+ "aliqua",
+ "est",
+ "proident"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Daugherty Hatfield"
+ },
+ {
+ "id": 1,
+ "name": "Corrine Benson"
+ },
+ {
+ "id": 2,
+ "name": "Quinn Woodard"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 13,
+ "guid": "489d3048-cda9-4deb-b450-e3e4d2601eb7",
+ "isActive": false,
+ "balance": "$2,920.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 21,
+ "name": "Mcpherson Miller",
+ "gender": "male",
+ "company": "Austech",
+ "contact": {
+ "email": "mcphersonmiller@austech.com",
+ "phone": "+1 (846) 556-2757",
+ "address": "123 Coffey Street, Riceville, Wisconsin, 9194"
+ },
+ "about": "Laboris ex sit velit tempor irure nisi ex incididunt laboris sit sint cillum. Labore dolore magna aliqua irure commodo eiusmod fugiat aute deserunt culpa sint aute dolor. Quis commodo ipsum ad Lorem elit eiusmod exercitation. Cupidatat sint duis consectetur mollit consequat qui consequat qui nisi sunt in. Mollit fugiat nulla aliqua qui. Consequat in anim cupidatat veniam cupidatat mollit do veniam occaecat. Consequat consectetur irure do esse exercitation ipsum adipisicing velit nostrud cupidatat voluptate.\r\n",
+ "registered": "1997-04-13T04:16:08 +04:00",
+ "latitude": -51.433761,
+ "longitude": -97.834664,
+ "tags": [
+ "id",
+ "velit",
+ "labore",
+ "commodo",
+ "Lorem",
+ "excepteur",
+ "dolore"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Moran Wagner"
+ },
+ {
+ "id": 1,
+ "name": "Nielsen Koch"
+ },
+ {
+ "id": 2,
+ "name": "Lloyd Kirkland"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 14,
+ "guid": "227d8254-6f18-4853-baf7-df0ead387e88",
+ "isActive": true,
+ "balance": "$2,774.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 35,
+ "name": "Wolfe Flowers",
+ "gender": "male",
+ "company": "Insurety",
+ "contact": {
+ "email": "wolfeflowers@insurety.com",
+ "phone": "+1 (964) 435-2634",
+ "address": "864 River Street, Longoria, New Jersey, 1200"
+ },
+ "about": "Sunt esse et ullamco minim pariatur nostrud consectetur occaecat. Ex quis elit aliqua ad. Officia ex et incididunt sit ex aliqua consectetur. Enim dolor nostrud laboris non eu Lorem excepteur tempor et mollit nulla incididunt commodo. Amet ad amet cillum laborum commodo fugiat ullamco magna. Consequat adipisicing ad voluptate ex. In incididunt eiusmod aliquip do voluptate amet esse aliqua do.\r\n",
+ "registered": "1996-08-16T15:42:00 +04:00",
+ "latitude": -21.688903,
+ "longitude": 148.466884,
+ "tags": [
+ "eu",
+ "dolor",
+ "veniam",
+ "fugiat",
+ "est",
+ "exercitation",
+ "proident"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Peck Richards"
+ },
+ {
+ "id": 1,
+ "name": "Sharlene Meadows"
+ },
+ {
+ "id": 2,
+ "name": "Carver Mcintosh"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 15,
+ "guid": "4288f9ca-b125-44c4-95ae-b1597b8d4551",
+ "isActive": false,
+ "balance": "$1,882.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 38,
+ "name": "Stevenson Cantrell",
+ "gender": "male",
+ "company": "Microluxe",
+ "contact": {
+ "email": "stevensoncantrell@microluxe.com",
+ "phone": "+1 (813) 418-3174",
+ "address": "288 Dahl Court, Chemung, Delaware, 3094"
+ },
+ "about": "Duis ea anim eu mollit proident dolor in occaecat anim. Dolor ullamco proident et dolor irure ad irure quis. Et exercitation minim reprehenderit aute in ullamco anim. Eu eiusmod sit do eiusmod labore eu commodo sit voluptate nostrud incididunt.\r\n",
+ "registered": "1988-04-20T03:06:14 +04:00",
+ "latitude": -59.191735,
+ "longitude": -100.131586,
+ "tags": [
+ "incididunt",
+ "fugiat",
+ "culpa",
+ "qui",
+ "amet",
+ "cupidatat",
+ "cillum"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Rosanna Petty"
+ },
+ {
+ "id": 1,
+ "name": "Ada Bowman"
+ },
+ {
+ "id": 2,
+ "name": "Powell Salinas"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 16,
+ "guid": "dfe2bc46-bc31-451b-a819-0033d886230a",
+ "isActive": false,
+ "balance": "$3,174.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 24,
+ "name": "Pitts Zamora",
+ "gender": "male",
+ "company": "Buzzworks",
+ "contact": {
+ "email": "pittszamora@buzzworks.com",
+ "phone": "+1 (913) 434-3152",
+ "address": "945 Summit Street, Alamo, North Dakota, 8966"
+ },
+ "about": "Reprehenderit esse qui aute incididunt et Lorem do non. Nostrud nostrud irure commodo aliqua occaecat labore sunt duis proident dolore. Magna quis mollit anim veniam velit. Minim esse sunt occaecat quis id reprehenderit occaecat. Anim eu reprehenderit esse culpa quis irure reprehenderit excepteur ad cillum reprehenderit. Dolor non laborum cillum amet aliqua proident esse tempor id amet pariatur nulla.\r\n",
+ "registered": "1992-03-09T10:09:07 +05:00",
+ "latitude": -86.481599,
+ "longitude": -151.688114,
+ "tags": [
+ "esse",
+ "dolore",
+ "laborum",
+ "Lorem",
+ "laborum",
+ "consequat",
+ "deserunt"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Mooney Jarvis"
+ },
+ {
+ "id": 1,
+ "name": "Clemons Green"
+ },
+ {
+ "id": 2,
+ "name": "Chaney Herman"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 17,
+ "guid": "72e1a2a7-0e23-4cae-9881-653fa234887c",
+ "isActive": true,
+ "balance": "$3,829.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 36,
+ "name": "Campos Griffith",
+ "gender": "male",
+ "company": "Calcu",
+ "contact": {
+ "email": "camposgriffith@calcu.com",
+ "phone": "+1 (905) 533-3909",
+ "address": "190 Jewel Street, Dundee, Idaho, 2403"
+ },
+ "about": "Aute exercitation incididunt cillum laboris proident Lorem. Aliquip aliqua eu labore aute voluptate cupidatat. Aliquip occaecat cupidatat ex elit anim labore consectetur fugiat cillum non voluptate et aliqua eu.\r\n",
+ "registered": "1990-02-10T00:20:56 +05:00",
+ "latitude": 44.283897,
+ "longitude": -0.181837,
+ "tags": [
+ "non",
+ "id",
+ "nisi",
+ "elit",
+ "magna",
+ "Lorem",
+ "elit"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Lynnette Bond"
+ },
+ {
+ "id": 1,
+ "name": "Little Park"
+ },
+ {
+ "id": 2,
+ "name": "Perkins Boyer"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 18,
+ "guid": "8e406e86-b4f3-49f6-80a0-f4abe9fb7c6a",
+ "isActive": true,
+ "balance": "$3,092.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 23,
+ "name": "Wendi Rasmussen",
+ "gender": "female",
+ "company": "Boink",
+ "contact": {
+ "email": "wendirasmussen@boink.com",
+ "phone": "+1 (978) 556-3648",
+ "address": "334 Lincoln Avenue, Carrsville, West Virginia, 9220"
+ },
+ "about": "Dolore elit commodo est ad culpa tempor amet cupidatat proident occaecat. Culpa elit cupidatat ut reprehenderit nulla et commodo id dolor. Enim in do occaecat proident cupidatat non minim occaecat irure ullamco incididunt eu aliqua. Esse voluptate eu velit laboris aute proident ad sit minim labore in adipisicing aliquip.\r\n",
+ "registered": "1993-02-04T23:45:02 +05:00",
+ "latitude": 58.838578,
+ "longitude": -3.544895,
+ "tags": [
+ "incididunt",
+ "consectetur",
+ "ex",
+ "reprehenderit",
+ "eiusmod",
+ "officia",
+ "deserunt"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Patrice Powers"
+ },
+ {
+ "id": 1,
+ "name": "Daphne Bentley"
+ },
+ {
+ "id": 2,
+ "name": "Jennie Molina"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 19,
+ "guid": "7784b16e-6e82-40fd-a6f5-3af605247d84",
+ "isActive": false,
+ "balance": "$1,124.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 26,
+ "name": "Nadia Brown",
+ "gender": "female",
+ "company": "Concility",
+ "contact": {
+ "email": "nadiabrown@concility.com",
+ "phone": "+1 (958) 450-2930",
+ "address": "225 Senator Street, Cotopaxi, Illinois, 2787"
+ },
+ "about": "Dolore nisi ex exercitation aliquip. Pariatur sint enim velit occaecat exercitation velit reprehenderit. Tempor aliquip amet minim quis occaecat commodo ipsum dolore. Duis ex dolor proident ad exercitation duis amet excepteur laboris aliquip. Duis laboris sint eu ut qui proident sit excepteur ullamco duis ullamco qui.\r\n",
+ "registered": "1995-10-11T03:29:07 +04:00",
+ "latitude": 1.539632,
+ "longitude": -74.138453,
+ "tags": [
+ "commodo",
+ "enim",
+ "laborum",
+ "elit",
+ "sint",
+ "voluptate",
+ "adipisicing"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Carmen Estrada"
+ },
+ {
+ "id": 1,
+ "name": "Conrad Morton"
+ },
+ {
+ "id": 2,
+ "name": "Moss Patrick"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 20,
+ "guid": "7f02bd19-f77b-4a5a-8486-df66b924927e",
+ "isActive": true,
+ "balance": "$2,256.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 38,
+ "name": "Petty Salazar",
+ "gender": "male",
+ "company": "Assurity",
+ "contact": {
+ "email": "pettysalazar@assurity.com",
+ "phone": "+1 (942) 474-3316",
+ "address": "583 Woodrow Court, Wright, North Carolina, 6644"
+ },
+ "about": "Id ullamco dolor sit sit incididunt officia ad amet est esse amet ex ea do. Tempor labore incididunt aliquip irure culpa nisi eiusmod consequat ea. Elit cupidatat ipsum do veniam non in duis ad dolor et. Aute ut sunt sint consectetur cillum.\r\n",
+ "registered": "2005-08-19T16:51:58 +04:00",
+ "latitude": -16.848101,
+ "longitude": -48.295182,
+ "tags": [
+ "eiusmod",
+ "nostrud",
+ "esse",
+ "deserunt",
+ "proident",
+ "tempor",
+ "esse"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Ruth Burgess"
+ },
+ {
+ "id": 1,
+ "name": "Lynne Chavez"
+ },
+ {
+ "id": 2,
+ "name": "Maureen Mcgee"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 21,
+ "guid": "5b8a612b-212b-459a-93c4-24b4a77b365b",
+ "isActive": true,
+ "balance": "$2,187.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 21,
+ "name": "Willis Alston",
+ "gender": "male",
+ "company": "Digial",
+ "contact": {
+ "email": "willisalston@digial.com",
+ "phone": "+1 (886) 405-3691",
+ "address": "249 Remsen Street, Floriston, Maryland, 9260"
+ },
+ "about": "Laborum deserunt occaecat pariatur elit in ad officia dolor id eu commodo ex magna ut. Magna amet id elit amet consequat. Sint qui sunt amet enim ullamco reprehenderit dolor laborum ullamco proident cillum mollit. Qui non aute Lorem mollit velit exercitation quis. Fugiat cupidatat sit ad duis nisi ipsum reprehenderit est aliqua in laborum veniam.\r\n",
+ "registered": "1999-04-14T08:53:31 +04:00",
+ "latitude": 35.32226,
+ "longitude": 30.951607,
+ "tags": [
+ "ut",
+ "fugiat",
+ "reprehenderit",
+ "laborum",
+ "sunt",
+ "ea",
+ "culpa"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Angelique Kaufman"
+ },
+ {
+ "id": 1,
+ "name": "Candy Bright"
+ },
+ {
+ "id": 2,
+ "name": "Dudley Hoover"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 22,
+ "guid": "0bf64428-0c7d-42f7-b6b5-4da22cb5d2fd",
+ "isActive": true,
+ "balance": "$3,157.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 27,
+ "name": "Vicky Gomez",
+ "gender": "female",
+ "company": "Zinca",
+ "contact": {
+ "email": "vickygomez@zinca.com",
+ "phone": "+1 (844) 538-2119",
+ "address": "974 Seigel Court, Staples, Washington, 3500"
+ },
+ "about": "Nostrud in et adipisicing exercitation sint id. In fugiat consequat dolor sit ea labore ipsum elit magna. Duis exercitation tempor est veniam ad deserunt esse ipsum ullamco ut cillum aute laborum duis. Commodo ut elit anim duis nostrud nisi ea ipsum. Enim irure in anim deserunt culpa ipsum ea non sunt in irure.\r\n",
+ "registered": "1995-03-17T04:54:29 +05:00",
+ "latitude": -65.632888,
+ "longitude": -142.188912,
+ "tags": [
+ "aute",
+ "nisi",
+ "voluptate",
+ "culpa",
+ "et",
+ "aute",
+ "labore"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Sullivan Reese"
+ },
+ {
+ "id": 1,
+ "name": "Sara Adkins"
+ },
+ {
+ "id": 2,
+ "name": "Cheryl Serrano"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 23,
+ "guid": "c0d4757c-334b-4185-ae6c-ce975b825c98",
+ "isActive": false,
+ "balance": "$3,464.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 37,
+ "name": "Janette Hurst",
+ "gender": "female",
+ "company": "Lovepad",
+ "contact": {
+ "email": "janettehurst@lovepad.com",
+ "phone": "+1 (964) 488-3768",
+ "address": "300 Jefferson Avenue, Sanborn, Tennessee, 8643"
+ },
+ "about": "Anim ut mollit cupidatat cillum mollit amet duis. Reprehenderit exercitation exercitation ea quis cupidatat ullamco do ipsum tempor nulla. Enim dolor voluptate est qui duis eu ad culpa duis velit quis ad et quis.\r\n",
+ "registered": "1992-11-02T09:16:26 +05:00",
+ "latitude": 80.192853,
+ "longitude": 127.761747,
+ "tags": [
+ "commodo",
+ "enim",
+ "laborum",
+ "ea",
+ "consequat",
+ "voluptate",
+ "cillum"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Laura Cruz"
+ },
+ {
+ "id": 1,
+ "name": "Cotton Cervantes"
+ },
+ {
+ "id": 2,
+ "name": "Matthews Klein"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 24,
+ "guid": "db1e534d-a740-4a7d-bb9c-d869b25b8fb4",
+ "isActive": false,
+ "balance": "$3,917.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 34,
+ "name": "Tammie Conway",
+ "gender": "female",
+ "company": "Escenta",
+ "contact": {
+ "email": "tammieconway@escenta.com",
+ "phone": "+1 (990) 420-3715",
+ "address": "140 Stillwell Avenue, Blairstown, Utah, 5621"
+ },
+ "about": "Enim dolore tempor velit sint tempor excepteur laboris. Et occaecat eu nisi ex. Do aute mollit ex anim quis commodo ex ipsum. Enim duis ut do officia mollit minim tempor dolore enim sint qui. Ut ipsum enim aliqua sunt qui. Ea ipsum enim qui do enim id elit ut.\r\n",
+ "registered": "2002-12-12T08:36:42 +05:00",
+ "latitude": -66.914337,
+ "longitude": -3.984304,
+ "tags": [
+ "minim",
+ "dolor",
+ "est",
+ "fugiat",
+ "enim",
+ "qui",
+ "duis"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Elba Castillo"
+ },
+ {
+ "id": 1,
+ "name": "Mae Shepherd"
+ },
+ {
+ "id": 2,
+ "name": "Boyer Buckner"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 25,
+ "guid": "5f5aeb4d-c03f-4e8d-b154-db544254eded",
+ "isActive": false,
+ "balance": "$2,948.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 30,
+ "name": "Eddie Oliver",
+ "gender": "female",
+ "company": "Acusage",
+ "contact": {
+ "email": "eddieoliver@acusage.com",
+ "phone": "+1 (892) 585-3345",
+ "address": "304 Adams Street, Sattley, Pennsylvania, 9979"
+ },
+ "about": "Aute commodo commodo ad laborum elit culpa reprehenderit tempor ad labore ex dolor ipsum. Dolore aliquip proident duis ad dolore dolore labore eiusmod pariatur enim. Tempor cupidatat eu irure ipsum anim duis ex quis labore sunt anim tempor nulla non. Adipisicing id exercitation tempor magna officia deserunt nisi ullamco.\r\n",
+ "registered": "2005-01-18T11:20:19 +05:00",
+ "latitude": 80.072736,
+ "longitude": -81.168247,
+ "tags": [
+ "voluptate",
+ "eiusmod",
+ "irure",
+ "veniam",
+ "aliquip",
+ "ad",
+ "reprehenderit"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Annabelle Holt"
+ },
+ {
+ "id": 1,
+ "name": "Shelby Grimes"
+ },
+ {
+ "id": 2,
+ "name": "Daniels Bender"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 26,
+ "guid": "2e27c341-f5d0-4d39-b6b7-7e0afc16c85f",
+ "isActive": false,
+ "balance": "$2,530.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 29,
+ "name": "Fannie Gamble",
+ "gender": "female",
+ "company": "Nebulean",
+ "contact": {
+ "email": "fanniegamble@nebulean.com",
+ "phone": "+1 (915) 549-3646",
+ "address": "154 Albemarle Road, Hanover, Alaska, 3225"
+ },
+ "about": "Laborum ea est esse culpa exercitation duis excepteur fugiat nulla in. Ipsum exercitation sint consequat sunt dolor fugiat veniam reprehenderit. Sint cillum eu nulla irure fugiat occaecat nulla ea qui laboris dolor ea esse. Dolore aute incididunt cupidatat eiusmod fugiat aliqua aliquip aliqua laboris. Quis est reprehenderit ipsum id. Excepteur culpa et do amet minim qui.\r\n",
+ "registered": "1995-12-02T02:40:59 +05:00",
+ "latitude": -39.574641,
+ "longitude": 102.854115,
+ "tags": [
+ "sunt",
+ "labore",
+ "officia",
+ "occaecat",
+ "fugiat",
+ "cillum",
+ "irure"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Kirk Anthony"
+ },
+ {
+ "id": 1,
+ "name": "Terri Warner"
+ },
+ {
+ "id": 2,
+ "name": "Geneva Watkins"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 27,
+ "guid": "77357b9d-64d1-4672-905e-1e4547f56e4d",
+ "isActive": false,
+ "balance": "$2,332.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 33,
+ "name": "Booth Wilson",
+ "gender": "male",
+ "company": "Bezal",
+ "contact": {
+ "email": "boothwilson@bezal.com",
+ "phone": "+1 (969) 537-2100",
+ "address": "692 Keen Court, Elbert, Missouri, 7072"
+ },
+ "about": "Magna tempor occaecat in pariatur est et reprehenderit ut laborum ipsum eiusmod id dolore duis. Ullamco sint excepteur est et culpa elit irure reprehenderit. Consequat aliqua Lorem minim non non velit laborum tempor eu exercitation ex. Voluptate do consectetur cupidatat ad id proident veniam ea. Quis occaecat quis eu commodo laboris consectetur nisi esse et labore velit proident.\r\n",
+ "registered": "2008-11-28T06:51:17 +05:00",
+ "latitude": 48.132665,
+ "longitude": 168.093581,
+ "tags": [
+ "tempor",
+ "incididunt",
+ "qui",
+ "aute",
+ "ea",
+ "eiusmod",
+ "ullamco"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Sharron Ray"
+ },
+ {
+ "id": 1,
+ "name": "Robbins Buchanan"
+ },
+ {
+ "id": 2,
+ "name": "Cortez Dorsey"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 28,
+ "guid": "7f1421ca-0d4f-4d93-8711-e23bc92886f0",
+ "isActive": false,
+ "balance": "$3,474.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 31,
+ "name": "Lowe Webster",
+ "gender": "male",
+ "company": "Digitalus",
+ "contact": {
+ "email": "lowewebster@digitalus.com",
+ "phone": "+1 (952) 484-3834",
+ "address": "421 Logan Street, Newcastle, Nevada, 2368"
+ },
+ "about": "Qui reprehenderit in proident ea irure sunt. Pariatur et est duis voluptate do ullamco non aute. In laborum duis incididunt aliqua sit aute aliquip. Tempor in consectetur officia Lorem proident dolore commodo. Eiusmod incididunt proident anim id deserunt commodo eiusmod amet commodo. Tempor adipisicing do quis quis tempor ea.\r\n",
+ "registered": "1998-05-03T23:25:29 +04:00",
+ "latitude": -20.168936,
+ "longitude": -111.612027,
+ "tags": [
+ "aliqua",
+ "qui",
+ "eiusmod",
+ "veniam",
+ "aliquip",
+ "mollit",
+ "adipisicing"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Graham Daniels"
+ },
+ {
+ "id": 1,
+ "name": "Woods Delaney"
+ },
+ {
+ "id": 2,
+ "name": "Latoya Cannon"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 29,
+ "guid": "2f1215a3-084f-40dc-aca3-5e709927a12c",
+ "isActive": false,
+ "balance": "$1,619.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 27,
+ "name": "Hensley Kane",
+ "gender": "male",
+ "company": "Harmoney",
+ "contact": {
+ "email": "hensleykane@harmoney.com",
+ "phone": "+1 (903) 579-3262",
+ "address": "853 Chapel Street, Riviera, New Hampshire, 4559"
+ },
+ "about": "Ullamco aliqua anim nulla in. Excepteur fugiat irure deserunt minim elit exercitation ex nulla cupidatat. Veniam dolor eu est minim est.\r\n",
+ "registered": "1988-06-29T09:46:24 +04:00",
+ "latitude": -50.219534,
+ "longitude": -45.123064,
+ "tags": [
+ "officia",
+ "duis",
+ "est",
+ "nisi",
+ "tempor",
+ "eu",
+ "ex"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Jackie Heath"
+ },
+ {
+ "id": 1,
+ "name": "Erica Wood"
+ },
+ {
+ "id": 2,
+ "name": "Patrick Crosby"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 30,
+ "guid": "e355ff04-ef86-4f69-8e16-48b8986b0685",
+ "isActive": true,
+ "balance": "$1,516.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 29,
+ "name": "Sanford Nguyen",
+ "gender": "male",
+ "company": "Rockyard",
+ "contact": {
+ "email": "sanfordnguyen@rockyard.com",
+ "phone": "+1 (890) 438-2575",
+ "address": "461 Bristol Street, Dalton, South Carolina, 5165"
+ },
+ "about": "Consequat exercitation culpa anim ad minim. Incididunt aliquip ad enim magna qui est nulla qui cupidatat id consequat incididunt amet. Culpa dolor laboris sunt voluptate commodo proident mollit aliqua voluptate sint anim. Amet pariatur anim voluptate adipisicing nulla est Lorem culpa esse incididunt aliqua mollit sint.\r\n",
+ "registered": "1989-09-03T18:04:04 +04:00",
+ "latitude": -6.779321,
+ "longitude": 160.430547,
+ "tags": [
+ "adipisicing",
+ "eiusmod",
+ "ex",
+ "duis",
+ "veniam",
+ "do",
+ "sunt"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Sandra Gallagher"
+ },
+ {
+ "id": 1,
+ "name": "Mcguire Burke"
+ },
+ {
+ "id": 2,
+ "name": "Leonard Calhoun"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 31,
+ "guid": "1c384a52-7e6c-4780-9e78-ccb6493d1313",
+ "isActive": true,
+ "balance": "$3,549.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 25,
+ "name": "Rosalie Bradshaw",
+ "gender": "female",
+ "company": "Elpro",
+ "contact": {
+ "email": "rosaliebradshaw@elpro.com",
+ "phone": "+1 (913) 597-3434",
+ "address": "525 Elm Place, Jenkinsville, New York, 1946"
+ },
+ "about": "Et labore est magna incididunt cupidatat duis quis sunt qui ut. Magna nulla Lorem exercitation proident culpa laborum fugiat dolor quis proident. Veniam esse consequat deserunt quis Lorem commodo cupidatat esse eu est Lorem aliqua. Quis mollit cupidatat mollit eiusmod cillum dolor eu. Occaecat aliquip officia non fugiat.\r\n",
+ "registered": "2011-03-25T18:35:16 +04:00",
+ "latitude": 0.287395,
+ "longitude": 142.910656,
+ "tags": [
+ "amet",
+ "pariatur",
+ "officia",
+ "reprehenderit",
+ "veniam",
+ "veniam",
+ "commodo"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Vargas Stephens"
+ },
+ {
+ "id": 1,
+ "name": "Kendra Bryant"
+ },
+ {
+ "id": 2,
+ "name": "Gay Campos"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 32,
+ "guid": "2c547391-d43f-4a31-9f7e-b80b27e90d4a",
+ "isActive": true,
+ "balance": "$3,972.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 32,
+ "name": "Chapman Stevens",
+ "gender": "male",
+ "company": "Cosmetex",
+ "contact": {
+ "email": "chapmanstevens@cosmetex.com",
+ "phone": "+1 (801) 521-2094",
+ "address": "845 Tennis Court, Veyo, Rhode Island, 2928"
+ },
+ "about": "Tempor aute et aute officia mollit consectetur eiusmod. Sunt duis reprehenderit quis proident eiusmod. Non pariatur cillum laboris incididunt minim anim. Do in deserunt et aliquip ipsum nisi aliqua fugiat eu. Proident veniam esse tempor eu veniam cillum veniam ad amet consequat. Magna duis deserunt mollit anim est. Labore deserunt nisi dolor excepteur id sint voluptate qui aliqua anim.\r\n",
+ "registered": "2010-01-03T12:16:06 +05:00",
+ "latitude": 3.477538,
+ "longitude": 110.709704,
+ "tags": [
+ "quis",
+ "sint",
+ "velit",
+ "anim",
+ "irure",
+ "officia",
+ "eiusmod"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Holmes Rivas"
+ },
+ {
+ "id": 1,
+ "name": "Carroll Simon"
+ },
+ {
+ "id": 2,
+ "name": "Kimberley Cantu"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 33,
+ "guid": "80040ceb-683c-4ddc-883b-a68522a9d49e",
+ "isActive": true,
+ "balance": "$2,117.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 21,
+ "name": "Beth Pratt",
+ "gender": "female",
+ "company": "Genesynk",
+ "contact": {
+ "email": "bethpratt@genesynk.com",
+ "phone": "+1 (848) 460-3645",
+ "address": "279 Milton Street, Toftrees, Connecticut, 1890"
+ },
+ "about": "Eu ad nulla in reprehenderit dolore. Duis velit reprehenderit eu duis quis commodo cupidatat occaecat proident aute nostrud cupidatat veniam. In ut qui mollit aute cillum aliqua et Lorem.\r\n",
+ "registered": "2007-07-25T00:07:13 +04:00",
+ "latitude": -59.141628,
+ "longitude": 5.709463,
+ "tags": [
+ "aliquip",
+ "duis",
+ "commodo",
+ "anim",
+ "id",
+ "qui",
+ "minim"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Francesca Mcguire"
+ },
+ {
+ "id": 1,
+ "name": "Galloway Kinney"
+ },
+ {
+ "id": 2,
+ "name": "Carla Page"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 34,
+ "guid": "c85c75c2-fb8c-495c-839b-21dd8f7bf1a1",
+ "isActive": true,
+ "balance": "$1,775.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 24,
+ "name": "Fletcher Drake",
+ "gender": "male",
+ "company": "Teraprene",
+ "contact": {
+ "email": "fletcherdrake@teraprene.com",
+ "phone": "+1 (904) 518-3973",
+ "address": "189 Nostrand Avenue, Dale, New Mexico, 4401"
+ },
+ "about": "Quis mollit irure aliqua laboris ea dolor quis do irure mollit. Cillum in sint et in anim irure id proident dolor incididunt sit. Quis mollit ullamco enim et reprehenderit cupidatat minim nulla nulla. Consequat exercitation veniam ad ullamco eiusmod minim mollit in qui irure occaecat. Officia magna nulla commodo consequat ea dolor veniam reprehenderit non ea pariatur reprehenderit nostrud. Irure amet Lorem pariatur officia et voluptate in dolore aliquip nostrud nostrud laborum. Incididunt aliqua consequat tempor aute ipsum amet quis consectetur nostrud nulla ut.\r\n",
+ "registered": "2000-03-19T20:16:46 +05:00",
+ "latitude": 89.026803,
+ "longitude": -162.233737,
+ "tags": [
+ "sit",
+ "eu",
+ "ut",
+ "consequat",
+ "eu",
+ "ad",
+ "eu"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Bowman Flynn"
+ },
+ {
+ "id": 1,
+ "name": "Bell Maynard"
+ },
+ {
+ "id": 2,
+ "name": "Marcella Graham"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 35,
+ "guid": "cdafc1f2-f3b7-4334-af81-77976eb77363",
+ "isActive": false,
+ "balance": "$2,580.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 36,
+ "name": "Tamera Roy",
+ "gender": "female",
+ "company": "Comdom",
+ "contact": {
+ "email": "tameraroy@comdom.com",
+ "phone": "+1 (909) 501-3327",
+ "address": "581 Rock Street, Worton, Vermont, 9442"
+ },
+ "about": "Deserunt fugiat veniam est incididunt. Do est minim esse proident anim laboris excepteur irure magna ex duis cillum consequat magna. Esse id adipisicing excepteur incididunt id commodo incididunt. Voluptate occaecat dolore nulla sint ipsum eu ut do reprehenderit exercitation. Cillum officia enim exercitation labore.\r\n",
+ "registered": "2013-08-06T16:29:15 +04:00",
+ "latitude": -52.622841,
+ "longitude": -147.666763,
+ "tags": [
+ "nulla",
+ "mollit",
+ "fugiat",
+ "enim",
+ "aliqua",
+ "quis",
+ "eu"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Liliana Barrett"
+ },
+ {
+ "id": 1,
+ "name": "Joann Mcmahon"
+ },
+ {
+ "id": 2,
+ "name": "Georgette Mcdowell"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 36,
+ "guid": "797d27ff-3483-4c56-915b-c35ac2ecb376",
+ "isActive": true,
+ "balance": "$3,627.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 20,
+ "name": "Ross Jacobs",
+ "gender": "male",
+ "company": "Aquasure",
+ "contact": {
+ "email": "rossjacobs@aquasure.com",
+ "phone": "+1 (911) 534-3457",
+ "address": "409 Harrison Place, Vowinckel, Arizona, 2136"
+ },
+ "about": "Incididunt occaecat exercitation ad magna dolore consectetur ea nulla aliquip. Incididunt deserunt sit aute adipisicing ex consequat esse non aliquip duis sit laboris excepteur. Velit irure tempor officia adipisicing consequat consectetur ex proident ad magna esse nisi id enim.\r\n",
+ "registered": "1990-01-19T05:53:01 +05:00",
+ "latitude": -44.645548,
+ "longitude": 160.042416,
+ "tags": [
+ "commodo",
+ "id",
+ "dolor",
+ "cupidatat",
+ "laborum",
+ "enim",
+ "tempor"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Angela Powell"
+ },
+ {
+ "id": 1,
+ "name": "Ines Dillon"
+ },
+ {
+ "id": 2,
+ "name": "Viola Wooten"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 37,
+ "guid": "34b82206-8d49-4e5e-877c-ee908e2ee54a",
+ "isActive": true,
+ "balance": "$2,832.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 29,
+ "name": "Holden Franklin",
+ "gender": "male",
+ "company": "Xanide",
+ "contact": {
+ "email": "holdenfranklin@xanide.com",
+ "phone": "+1 (995) 518-3647",
+ "address": "270 Amherst Street, Savannah, Maine, 5561"
+ },
+ "about": "Laborum nisi reprehenderit in cillum dolor ad anim voluptate minim. Ad ea anim laboris nisi aliqua. Adipisicing amet et ea reprehenderit enim excepteur consectetur ea qui et.\r\n",
+ "registered": "1989-11-18T14:45:19 +05:00",
+ "latitude": 18.000128,
+ "longitude": -41.02513,
+ "tags": [
+ "et",
+ "adipisicing",
+ "occaecat",
+ "nostrud",
+ "et",
+ "officia",
+ "reprehenderit"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Nelson Raymond"
+ },
+ {
+ "id": 1,
+ "name": "Burch Hopper"
+ },
+ {
+ "id": 2,
+ "name": "Avery Hines"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 38,
+ "guid": "41852bc2-daf5-469e-a1aa-3442590cc95c",
+ "isActive": false,
+ "balance": "$3,452.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 24,
+ "name": "Iris Santiago",
+ "gender": "female",
+ "company": "Digiprint",
+ "contact": {
+ "email": "irissantiago@digiprint.com",
+ "phone": "+1 (878) 443-3417",
+ "address": "501 Sumner Place, Orviston, Georgia, 1383"
+ },
+ "about": "Anim officia non voluptate eiusmod amet id proident minim esse et proident cillum. Labore ea qui occaecat magna labore veniam amet fugiat magna est anim amet anim. Magna velit aliquip occaecat est labore ad mollit excepteur sint veniam anim laborum fugiat labore. Esse laborum exercitation laborum cupidatat commodo officia. Ipsum mollit id exercitation Lorem tempor elit excepteur anim aliquip et mollit eu officia nisi.\r\n",
+ "registered": "2004-05-10T10:04:33 +04:00",
+ "latitude": -1.491802,
+ "longitude": -37.508269,
+ "tags": [
+ "ipsum",
+ "cillum",
+ "laboris",
+ "commodo",
+ "ipsum",
+ "adipisicing",
+ "reprehenderit"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "French Hays"
+ },
+ {
+ "id": 1,
+ "name": "Judith Henderson"
+ },
+ {
+ "id": 2,
+ "name": "Guy Harper"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 39,
+ "guid": "5e4aaa8c-e1c3-4322-a087-27a0ca4f9127",
+ "isActive": true,
+ "balance": "$3,703.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 24,
+ "name": "Frances Cobb",
+ "gender": "female",
+ "company": "Playce",
+ "contact": {
+ "email": "francescobb@playce.com",
+ "phone": "+1 (828) 432-3671",
+ "address": "534 Adler Place, Whitewater, Kansas, 8506"
+ },
+ "about": "Deserunt proident dolor labore commodo deserunt adipisicing nostrud aliquip. Consectetur Lorem elit do tempor. Non ut qui aute proident veniam tempor non duis voluptate adipisicing deserunt sunt Lorem reprehenderit. Sit minim aliquip aute in ea. Nisi nostrud eiusmod ea laboris officia culpa tempor eu anim in. Laborum cillum est consectetur mollit enim dolor et dolore ex cillum irure officia ipsum tempor.\r\n",
+ "registered": "1997-07-01T07:26:13 +04:00",
+ "latitude": 54.020288,
+ "longitude": -132.665236,
+ "tags": [
+ "labore",
+ "aliquip",
+ "quis",
+ "excepteur",
+ "velit",
+ "enim",
+ "exercitation"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Cooke Clements"
+ },
+ {
+ "id": 1,
+ "name": "Newman Wiggins"
+ },
+ {
+ "id": 2,
+ "name": "Mccarty Horton"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 40,
+ "guid": "d86dcfea-b6f9-4d1f-9367-fdd05e1b2c4e",
+ "isActive": true,
+ "balance": "$2,889.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 33,
+ "name": "Hayden Pugh",
+ "gender": "male",
+ "company": "Paprikut",
+ "contact": {
+ "email": "haydenpugh@paprikut.com",
+ "phone": "+1 (922) 522-2096",
+ "address": "286 Richardson Street, Jacumba, Michigan, 3966"
+ },
+ "about": "Exercitation aliqua magna tempor fugiat culpa sunt labore. Irure tempor id ex commodo commodo ut amet officia aute exercitation mollit mollit occaecat eu. Sit ullamco sit labore excepteur reprehenderit aliquip eu esse quis laborum. Enim ipsum occaecat sunt qui do laboris ullamco consectetur aliqua ipsum et. In ex quis consectetur laboris sunt minim aliqua laboris proident. Ea eu ut eu laboris duis. Dolore culpa enim aliquip non et reprehenderit ut.\r\n",
+ "registered": "2000-07-10T05:40:29 +04:00",
+ "latitude": 71.287534,
+ "longitude": 42.215447,
+ "tags": [
+ "mollit",
+ "exercitation",
+ "occaecat",
+ "duis",
+ "commodo",
+ "fugiat",
+ "nostrud"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Leah Sheppard"
+ },
+ {
+ "id": 1,
+ "name": "Noreen Martinez"
+ },
+ {
+ "id": 2,
+ "name": "Stevens Phillips"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 41,
+ "guid": "efd7d900-982a-492d-a707-7967a782567d",
+ "isActive": true,
+ "balance": "$2,807.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 27,
+ "name": "Cabrera Callahan",
+ "gender": "male",
+ "company": "Jumpstack",
+ "contact": {
+ "email": "cabreracallahan@jumpstack.com",
+ "phone": "+1 (995) 461-3610",
+ "address": "947 Butler Place, Bethany, Hawaii, 9896"
+ },
+ "about": "Qui ex ullamco qui sint exercitation irure nisi elit quis exercitation voluptate qui. Occaecat aute labore pariatur ut velit consequat ex consectetur sit adipisicing. Qui deserunt qui magna quis ad ex duis magna quis ex do nostrud consectetur. Dolore nostrud ut non exercitation dolor commodo esse ut do anim velit do commodo ad. Nisi minim excepteur nulla cupidatat amet ad ad. Ut veniam do culpa laboris officia ullamco quis et in ad nisi amet consequat. Occaecat proident cupidatat ea sunt do tempor nostrud occaecat nisi velit occaecat amet in enim.\r\n",
+ "registered": "1991-02-26T14:57:11 +05:00",
+ "latitude": -87.772592,
+ "longitude": -88.680383,
+ "tags": [
+ "ea",
+ "in",
+ "ex",
+ "consectetur",
+ "tempor",
+ "proident",
+ "laboris"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Nita Cherry"
+ },
+ {
+ "id": 1,
+ "name": "Mcgee Cameron"
+ },
+ {
+ "id": 2,
+ "name": "Marilyn Price"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 42,
+ "guid": "f1e73451-8ae5-4874-a86d-bd8f57c31fbf",
+ "isActive": false,
+ "balance": "$3,533.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 29,
+ "name": "Frieda Hull",
+ "gender": "female",
+ "company": "Mantrix",
+ "contact": {
+ "email": "friedahull@mantrix.com",
+ "phone": "+1 (835) 428-3070",
+ "address": "340 Ditmars Street, Williamson, Virginia, 7800"
+ },
+ "about": "Irure irure cupidatat elit eiusmod ea eiusmod. Do exercitation consequat mollit aute sit. Nostrud dolor enim laborum incididunt adipisicing id amet irure sit deserunt cillum ad ut eiusmod.\r\n",
+ "registered": "1997-08-01T05:14:10 +04:00",
+ "latitude": -35.362422,
+ "longitude": 82.223451,
+ "tags": [
+ "ipsum",
+ "aliquip",
+ "et",
+ "quis",
+ "cillum",
+ "qui",
+ "veniam"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Teri Gallegos"
+ },
+ {
+ "id": 1,
+ "name": "Stella Gutierrez"
+ },
+ {
+ "id": 2,
+ "name": "Garcia Vargas"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 43,
+ "guid": "869eaf17-7f10-4ddd-89c0-399b14457165",
+ "isActive": true,
+ "balance": "$3,417.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 37,
+ "name": "Sherri Hammond",
+ "gender": "female",
+ "company": "Dreamia",
+ "contact": {
+ "email": "sherrihammond@dreamia.com",
+ "phone": "+1 (807) 566-2154",
+ "address": "864 Jaffray Street, Crumpler, Louisiana, 4943"
+ },
+ "about": "Ea eu excepteur eiusmod non aute elit ad sit. Ut cupidatat elit ad excepteur voluptate ea dolor deserunt do culpa non pariatur in non. In fugiat ut mollit cupidatat pariatur commodo quis deserunt enim fugiat ex. Cupidatat laboris mollit esse adipisicing minim adipisicing exercitation aliqua. Elit cupidatat dolore minim id laborum. Ea ullamco nulla id reprehenderit sunt.\r\n",
+ "registered": "1993-01-25T03:41:12 +05:00",
+ "latitude": 12.411305,
+ "longitude": -175.152748,
+ "tags": [
+ "sit",
+ "tempor",
+ "sint",
+ "aliqua",
+ "reprehenderit",
+ "cupidatat",
+ "pariatur"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Avis Potts"
+ },
+ {
+ "id": 1,
+ "name": "Johnnie Carr"
+ },
+ {
+ "id": 2,
+ "name": "Earnestine Justice"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 44,
+ "guid": "061c8d75-23cb-4448-b8e4-0ae9903ce243",
+ "isActive": true,
+ "balance": "$3,384.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 27,
+ "name": "Kim Valdez",
+ "gender": "male",
+ "company": "Lotron",
+ "contact": {
+ "email": "kimvaldez@lotron.com",
+ "phone": "+1 (948) 477-2039",
+ "address": "494 Bedell Lane, Richford, Massachusetts, 7110"
+ },
+ "about": "Voluptate culpa minim non ipsum nulla nisi proident. Esse qui ad officia deserunt sint ad fugiat incididunt ad eiusmod cillum. Incididunt pariatur esse nisi magna cillum consectetur nulla excepteur sunt commodo fugiat enim. Fugiat elit consectetur magna eiusmod sint excepteur mollit veniam non irure exercitation aliqua sunt ipsum. Reprehenderit aliquip amet deserunt occaecat eiusmod laborum sint consequat labore nostrud sunt excepteur culpa. Esse dolore aute aute occaecat exercitation nulla. Nostrud ut cupidatat ea minim nostrud do mollit.\r\n",
+ "registered": "2013-12-08T03:36:04 +05:00",
+ "latitude": -18.08955,
+ "longitude": -1.550904,
+ "tags": [
+ "incididunt",
+ "fugiat",
+ "Lorem",
+ "laborum",
+ "laboris",
+ "et",
+ "duis"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Magdalena Brady"
+ },
+ {
+ "id": 1,
+ "name": "Emily Mccarty"
+ },
+ {
+ "id": 2,
+ "name": "Holder Frost"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 45,
+ "guid": "8932af53-3258-44a7-ab51-701667c9ba96",
+ "isActive": false,
+ "balance": "$3,450.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 40,
+ "name": "Glenda Langley",
+ "gender": "female",
+ "company": "Phuel",
+ "contact": {
+ "email": "glendalangley@phuel.com",
+ "phone": "+1 (903) 548-3089",
+ "address": "121 Vandam Street, Weeksville, Nebraska, 8425"
+ },
+ "about": "Voluptate duis consectetur in nisi fugiat Lorem quis. Ad culpa ex tempor quis veniam laboris amet eiusmod. Cupidatat voluptate sunt magna et. Est cupidatat veniam irure anim labore in id.\r\n",
+ "registered": "2009-11-04T21:11:08 +05:00",
+ "latitude": -87.668294,
+ "longitude": -112.418622,
+ "tags": [
+ "qui",
+ "Lorem",
+ "minim",
+ "fugiat",
+ "dolor",
+ "consectetur",
+ "id"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Therese Mcclure"
+ },
+ {
+ "id": 1,
+ "name": "Kelley Lucas"
+ },
+ {
+ "id": 2,
+ "name": "Dunlap Bean"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 46,
+ "guid": "2da8ced5-6d01-4572-b38b-d43a2fd4febb",
+ "isActive": false,
+ "balance": "$3,378.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 32,
+ "name": "Castillo Harding",
+ "gender": "male",
+ "company": "Zerbina",
+ "contact": {
+ "email": "castilloharding@zerbina.com",
+ "phone": "+1 (914) 529-3555",
+ "address": "308 Glenwood Road, Laurelton, Florida, 4041"
+ },
+ "about": "Nulla et excepteur ad do nostrud. Consequat id do nisi in eu voluptate laboris pariatur. Dolor velit mollit labore dolore.\r\n",
+ "registered": "1998-04-26T14:22:09 +04:00",
+ "latitude": -48.888699,
+ "longitude": -134.191718,
+ "tags": [
+ "aute",
+ "enim",
+ "laboris",
+ "reprehenderit",
+ "pariatur",
+ "est",
+ "aliqua"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Glover Strong"
+ },
+ {
+ "id": 1,
+ "name": "Karina Terry"
+ },
+ {
+ "id": 2,
+ "name": "Brigitte Duncan"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 47,
+ "guid": "4d559beb-b905-416a-9933-ebf1f4e23ccd",
+ "isActive": false,
+ "balance": "$1,158.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 34,
+ "name": "Velez Wallace",
+ "gender": "male",
+ "company": "Sulfax",
+ "contact": {
+ "email": "velezwallace@sulfax.com",
+ "phone": "+1 (974) 585-2264",
+ "address": "698 Battery Avenue, Newry, Texas, 2855"
+ },
+ "about": "Pariatur magna commodo in anim nisi. Dolore cillum laboris occaecat magna mollit do irure ea incididunt eiusmod sit. Minim cupidatat fugiat aliquip exercitation velit pariatur duis ipsum officia.\r\n",
+ "registered": "1989-10-07T05:04:43 +04:00",
+ "latitude": -50.610411,
+ "longitude": -2.761224,
+ "tags": [
+ "esse",
+ "incididunt",
+ "est",
+ "officia",
+ "excepteur",
+ "consequat",
+ "fugiat"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Clarissa Shepard"
+ },
+ {
+ "id": 1,
+ "name": "Karyn Figueroa"
+ },
+ {
+ "id": 2,
+ "name": "Holly Pollard"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 48,
+ "guid": "70817585-69ff-4382-8ed4-ba3dd6648bd5",
+ "isActive": false,
+ "balance": "$1,112.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 29,
+ "name": "Lacey Marks",
+ "gender": "female",
+ "company": "Twiggery",
+ "contact": {
+ "email": "laceymarks@twiggery.com",
+ "phone": "+1 (926) 549-3368",
+ "address": "106 Riverdale Avenue, Hollymead, California, 2138"
+ },
+ "about": "Lorem veniam voluptate laboris duis sint magna proident laboris. Ex minim sit mollit dolor est deserunt excepteur tempor nisi sunt. Esse ut aute voluptate cillum sit non deserunt ex cillum veniam. Labore proident enim cillum do. Pariatur non aliquip aute aliqua fugiat dolor.\r\n",
+ "registered": "2007-06-03T20:17:07 +04:00",
+ "latitude": -16.12467,
+ "longitude": 102.700269,
+ "tags": [
+ "fugiat",
+ "anim",
+ "consectetur",
+ "ad",
+ "non",
+ "sint",
+ "deserunt"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Howe Slater"
+ },
+ {
+ "id": 1,
+ "name": "Hudson Hess"
+ },
+ {
+ "id": 2,
+ "name": "Hays Haynes"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 49,
+ "guid": "c92187e4-a767-48be-bc1b-061574db1cfc",
+ "isActive": true,
+ "balance": "$1,775.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 37,
+ "name": "Middleton Cook",
+ "gender": "male",
+ "company": "Kiosk",
+ "contact": {
+ "email": "middletoncook@kiosk.com",
+ "phone": "+1 (818) 432-3189",
+ "address": "239 Beekman Place, Bangor, Montana, 4724"
+ },
+ "about": "Sit elit fugiat cillum exercitation cupidatat non cillum nulla tempor ut voluptate consequat sunt do. Ut ut nisi ex nostrud duis fugiat aliquip occaecat laborum irure proident quis sint. Ipsum aute amet minim officia sit anim cillum occaecat velit. Lorem proident id cillum mollit tempor dolore amet adipisicing duis incididunt. Deserunt in do qui et duis labore sit consequat. Velit est dolor sunt adipisicing cupidatat. Sit esse fugiat elit amet labore adipisicing exercitation qui nisi incididunt consectetur.\r\n",
+ "registered": "2010-04-30T10:49:48 +04:00",
+ "latitude": -53.579253,
+ "longitude": 63.269635,
+ "tags": [
+ "ex",
+ "non",
+ "est",
+ "officia",
+ "dolor",
+ "irure",
+ "qui"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Pope Rojas"
+ },
+ {
+ "id": 1,
+ "name": "Graves Cooke"
+ },
+ {
+ "id": 2,
+ "name": "Mccarthy Taylor"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 50,
+ "guid": "954b92fb-2ecf-4f69-b183-d27a2370697f",
+ "isActive": false,
+ "balance": "$3,381.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 38,
+ "name": "Carrillo Roth",
+ "gender": "male",
+ "company": "Soprano",
+ "contact": {
+ "email": "carrilloroth@soprano.com",
+ "phone": "+1 (866) 480-2404",
+ "address": "178 Coleridge Street, Saticoy, Oregon, 9243"
+ },
+ "about": "Lorem dolore do proident ea amet ex incididunt do amet commodo. Minim minim cupidatat culpa quis sint mollit irure consequat id culpa laboris veniam mollit. Commodo consectetur velit officia et et quis excepteur incididunt proident culpa pariatur.\r\n",
+ "registered": "1996-05-31T06:23:13 +04:00",
+ "latitude": 8.462523,
+ "longitude": 31.837459,
+ "tags": [
+ "consequat",
+ "tempor",
+ "veniam",
+ "excepteur",
+ "Lorem",
+ "eiusmod",
+ "veniam"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Keller Schneider"
+ },
+ {
+ "id": 1,
+ "name": "Lessie Ochoa"
+ },
+ {
+ "id": 2,
+ "name": "Richard Snider"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 51,
+ "guid": "3331c6e3-2764-44ba-931a-5762b9007c06",
+ "isActive": false,
+ "balance": "$2,087.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 36,
+ "name": "Monroe Goodwin",
+ "gender": "male",
+ "company": "Hydrocom",
+ "contact": {
+ "email": "monroegoodwin@hydrocom.com",
+ "phone": "+1 (953) 480-3156",
+ "address": "872 Taaffe Place, Shelby, New York, 480"
+ },
+ "about": "Labore mollit esse eu veniam nisi occaecat magna exercitation enim laboris duis nulla. Laboris cupidatat sunt ex tempor aliqua commodo excepteur aliquip elit elit. Est laboris culpa incididunt velit esse dolore est consectetur laborum incididunt est. Voluptate laboris aute id sint magna minim incididunt pariatur nostrud reprehenderit. Dolore elit commodo ipsum excepteur duis occaecat commodo mollit magna ut.\r\n",
+ "registered": "1999-10-23T22:43:40 +04:00",
+ "latitude": 87.514317,
+ "longitude": -131.664199,
+ "tags": [
+ "incididunt",
+ "proident",
+ "amet",
+ "est",
+ "duis",
+ "cillum",
+ "qui"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Ashlee Collier"
+ },
+ {
+ "id": 1,
+ "name": "Savannah Valentine"
+ },
+ {
+ "id": 2,
+ "name": "Benita Klein"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 52,
+ "guid": "a0dcd19e-1d3a-4196-9028-efde5f73e0a5",
+ "isActive": false,
+ "balance": "$2,062.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 37,
+ "name": "Marina Morris",
+ "gender": "female",
+ "company": "Zork",
+ "contact": {
+ "email": "marinamorris@zork.com",
+ "phone": "+1 (856) 428-3606",
+ "address": "435 Essex Street, Bedias, Maryland, 231"
+ },
+ "about": "Tempor nisi enim ipsum et laboris adipisicing consequat. Qui ut culpa cillum fugiat labore. Cupidatat consectetur pariatur dolore non velit ea dolore ullamco exercitation do reprehenderit tempor enim. Labore esse ullamco eiusmod do ipsum eiusmod commodo reprehenderit in duis nulla. Excepteur nisi consequat esse cupidatat enim eu. Deserunt voluptate aliqua velit sunt in nostrud sint elit esse.\r\n",
+ "registered": "1988-09-10T08:51:01 +04:00",
+ "latitude": 65.099082,
+ "longitude": 162.881342,
+ "tags": [
+ "enim",
+ "deserunt",
+ "ut",
+ "dolor",
+ "ad",
+ "nulla",
+ "sit"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Monique Carrillo"
+ },
+ {
+ "id": 1,
+ "name": "Chavez Drake"
+ },
+ {
+ "id": 2,
+ "name": "Duran Goodman"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 53,
+ "guid": "e093b1fd-6a6f-42fe-b2bd-66e86a87c546",
+ "isActive": true,
+ "balance": "$3,921.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 20,
+ "name": "Cameron Olson",
+ "gender": "male",
+ "company": "Verton",
+ "contact": {
+ "email": "cameronolson@verton.com",
+ "phone": "+1 (880) 584-2467",
+ "address": "146 Beacon Court, Kapowsin, Vermont, 6568"
+ },
+ "about": "Quis aliqua sit commodo fugiat laborum fugiat exercitation dolore ullamco laboris ad ea esse. Excepteur exercitation aute sint dolore duis officia eu nisi aliqua ullamco. Reprehenderit sunt aliquip dolore esse elit mollit magna est Lorem voluptate. Reprehenderit velit pariatur eu et excepteur ut eu aliquip proident anim ut pariatur Lorem.\r\n",
+ "registered": "1994-11-06T11:20:39 +05:00",
+ "latitude": -13.920139,
+ "longitude": -8.277158,
+ "tags": [
+ "officia",
+ "elit",
+ "esse",
+ "commodo",
+ "do",
+ "sint",
+ "magna"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Jewell Beck"
+ },
+ {
+ "id": 1,
+ "name": "Eliza Valencia"
+ },
+ {
+ "id": 2,
+ "name": "Shelton Jones"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 54,
+ "guid": "7c7b63ca-a636-4fc4-ba5e-1b3539760d80",
+ "isActive": false,
+ "balance": "$3,641.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 40,
+ "name": "Elvia Mcneil",
+ "gender": "female",
+ "company": "Mediot",
+ "contact": {
+ "email": "elviamcneil@mediot.com",
+ "phone": "+1 (887) 542-3951",
+ "address": "112 Conway Street, Riviera, Indiana, 4070"
+ },
+ "about": "Exercitation reprehenderit ut sunt cupidatat eu aute reprehenderit dolore Lorem ut. Commodo est dolore eiusmod tempor amet anim reprehenderit aute labore dolor mollit dolore duis incididunt. Non id enim duis ex. Cillum ea anim consectetur occaecat laborum ipsum magna aliquip cupidatat. Quis laborum in reprehenderit voluptate exercitation do Lorem incididunt laborum. Consectetur dolor incididunt id consequat.\r\n",
+ "registered": "1996-09-28T17:49:54 +04:00",
+ "latitude": -33.9032,
+ "longitude": 124.05472,
+ "tags": [
+ "consequat",
+ "deserunt",
+ "et",
+ "culpa",
+ "Lorem",
+ "ea",
+ "amet"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Lane Lane"
+ },
+ {
+ "id": 1,
+ "name": "Marks Fulton"
+ },
+ {
+ "id": 2,
+ "name": "Sheri Newton"
+ }
+ ],
+ "randomArrayItem": "apple"
+ },
+ {
+ "id": 55,
+ "guid": "7c65254b-9aa2-4fbb-8b34-18dcd7812ad7",
+ "isActive": true,
+ "balance": "$1,058.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 28,
+ "name": "Kasey Lopez",
+ "gender": "female",
+ "company": "Enervate",
+ "contact": {
+ "email": "kaseylopez@enervate.com",
+ "phone": "+1 (934) 491-3787",
+ "address": "250 Waldorf Court, Needmore, California, 4642"
+ },
+ "about": "Do nisi in pariatur amet. Cillum deserunt eiusmod cillum id cillum fugiat fugiat est labore laborum voluptate aliqua cupidatat. Ad qui dolore quis proident laboris pariatur incididunt. Magna labore fugiat excepteur aliqua aliquip quis excepteur voluptate sunt irure laborum eu ipsum eiusmod. Laborum qui sit est est. Ullamco esse aute sunt cupidatat esse excepteur elit. Ullamco commodo velit ad laborum reprehenderit nisi nostrud adipisicing.\r\n",
+ "registered": "2011-03-04T19:49:25 +05:00",
+ "latitude": -24.101851,
+ "longitude": 72.932726,
+ "tags": [
+ "non",
+ "sint",
+ "aliquip",
+ "non",
+ "adipisicing",
+ "non",
+ "eu"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Waller Graham"
+ },
+ {
+ "id": 1,
+ "name": "Long Smith"
+ },
+ {
+ "id": 2,
+ "name": "Rosetta Villarreal"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "id": 56,
+ "guid": "799d7fa4-6e65-44e0-922e-4db7889f948c",
+ "isActive": false,
+ "balance": "$1,120.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 36,
+ "name": "Castillo Cooper",
+ "gender": "male",
+ "company": "Neurocell",
+ "contact": {
+ "email": "castillocooper@neurocell.com",
+ "phone": "+1 (878) 430-2711",
+ "address": "593 Lefferts Avenue, Draper, Washington, 2068"
+ },
+ "about": "Ipsum irure ullamco mollit adipisicing magna cillum voluptate. Non est consequat ad aliquip anim officia proident. Commodo anim dolore nulla voluptate veniam veniam aute. Nulla quis magna laboris voluptate consequat nostrud cillum.\r\n",
+ "registered": "2008-10-13T04:25:53 +04:00",
+ "latitude": 32.416458,
+ "longitude": -156.838748,
+ "tags": [
+ "esse",
+ "nulla",
+ "mollit",
+ "ad",
+ "fugiat",
+ "est",
+ "ullamco"
+ ],
+ "friends": [
+ {
+ "id": 0,
+ "name": "Gilbert Sweet"
+ },
+ {
+ "id": 1,
+ "name": "Rene Stephenson"
+ },
+ {
+ "id": 2,
+ "name": "Mable Marquez"
+ }
+ ],
+ "randomArrayItem": "cherry"
+ },
+ {
+ "id": 57,
+ "guid": "9f597ce3-dbcf-4662-9efd-187f08c9ec19",
+ "isActive": false,
+ "balance": "$3,687.00",
+ "picture": "http://placehold.it/32x32",
+ "age": 33,
+ "name": "Washington Oliver",
+ "gender": "male",
+ "company": "Accuprint",
+ "contact": {
+ "email": "washingtonoliver@accuprint.com",
+ "phone": "+1 (867) 544-3956",
+ "address": "783 Wyckoff Avenue, Enlow, Georgia, 7254"
+ },
+ "about": "Cupidatat minim excepteur et magna laborum sunt. Velit labore deserunt elit consequat in dolore occaecat ut eu quis. Commodo Lorem enim sit consectetur reprehenderit consectetur. Eu culpa irure amet occaecat id qui enim consequat irure id elit. Cillum ullamco id duis dolor aute est dolore.\r\n",
+ "registered": "1993-07-27T14:44:21 +04:00",
+ "latitude": 79.992558,
+ "longitude": 178.725427,
+ "tags": [
+ "ipsum",
+ "et",
+
<TRUNCATED>
[08/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
new file mode 100644
index 0000000..a54816e
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryFilterParser.java
@@ -0,0 +1,2186 @@
+// $ANTLR 3.5.1 org/apache/usergrid/persistence/query/tree/QueryFilter.g 2014-02-21 08:18:25
+
+package org.apache.usergrid.persistence.query.tree;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.Query.SortPredicate;
+
+
+
+import org.antlr.runtime.*;
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.antlr.runtime.tree.*;
+
+
+@SuppressWarnings("all")
+public class QueryFilterParser extends Parser {
+ public static final String[] tokenNames = new String[] {
+ "<invalid>", "<EOR>", "<DOWN>", "<UP>", "AND", "ASC", "BOOLEAN", "CONTAINS",
+ "DESC", "EQ", "ESC_SEQ", "EXPONENT", "FALSE", "FLOAT", "GT", "GTE", "HEX_DIGIT",
+ "ID", "LONG", "LT", "LTE", "NOT", "OCTAL_ESC", "OF", "OR", "STRING", "TRUE",
+ "UNICODE_ESC", "UUID", "WITHIN", "WS", "'('", "')'", "'*'", "','", "':'",
+ "'order by'", "'select'", "'where'", "'{'", "'}'"
+ };
+ public static final int EOF=-1;
+ public static final int T__31=31;
+ public static final int T__32=32;
+ public static final int T__33=33;
+ public static final int T__34=34;
+ public static final int T__35=35;
+ public static final int T__36=36;
+ public static final int T__37=37;
+ public static final int T__38=38;
+ public static final int T__39=39;
+ public static final int T__40=40;
+ public static final int AND=4;
+ public static final int ASC=5;
+ public static final int BOOLEAN=6;
+ public static final int CONTAINS=7;
+ public static final int DESC=8;
+ public static final int EQ=9;
+ public static final int ESC_SEQ=10;
+ public static final int EXPONENT=11;
+ public static final int FALSE=12;
+ public static final int FLOAT=13;
+ public static final int GT=14;
+ public static final int GTE=15;
+ public static final int HEX_DIGIT=16;
+ public static final int ID=17;
+ public static final int LONG=18;
+ public static final int LT=19;
+ public static final int LTE=20;
+ public static final int NOT=21;
+ public static final int OCTAL_ESC=22;
+ public static final int OF=23;
+ public static final int OR=24;
+ public static final int STRING=25;
+ public static final int TRUE=26;
+ public static final int UNICODE_ESC=27;
+ public static final int UUID=28;
+ public static final int WITHIN=29;
+ public static final int WS=30;
+
+ // delegates
+ public Parser[] getDelegates() {
+ return new Parser[] {};
+ }
+
+ // delegators
+
+
+ public QueryFilterParser(TokenStream input) {
+ this(input, new RecognizerSharedState());
+ }
+ public QueryFilterParser(TokenStream input, RecognizerSharedState state) {
+ super(input, state);
+ }
+
+ protected TreeAdaptor adaptor = new CommonTreeAdaptor();
+
+ public void setTreeAdaptor(TreeAdaptor adaptor) {
+ this.adaptor = adaptor;
+ }
+ public TreeAdaptor getTreeAdaptor() {
+ return adaptor;
+ }
+ @Override public String[] getTokenNames() { return QueryFilterParser.tokenNames; }
+ @Override public String getGrammarFileName() { return "org/apache/usergrid/persistence/query/tree/QueryFilter.g"; }
+
+
+ Query query = new Query();
+
+ private static final Logger logger = LoggerFactory
+ .getLogger(QueryFilterLexer.class);
+
+ @Override
+ public void emitErrorMessage(String msg) {
+ logger.info(msg);
+ }
+
+
+ public static class property_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "property"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:175:1: property : ID ;
+ public final QueryFilterParser.property_return property() throws RecognitionException {
+ QueryFilterParser.property_return retval = new QueryFilterParser.property_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token ID1=null;
+
+ Object ID1_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:175:10: ( ID )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:175:12: ID
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ ID1=(Token)match(input,ID,FOLLOW_ID_in_property991);
+ ID1_tree = new Property(ID1) ;
+ adaptor.addChild(root_0, ID1_tree);
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "property"
+
+
+ public static class containsproperty_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "containsproperty"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:177:1: containsproperty : ID ;
+ public final QueryFilterParser.containsproperty_return containsproperty() throws RecognitionException {
+ QueryFilterParser.containsproperty_return retval = new QueryFilterParser.containsproperty_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token ID2=null;
+
+ Object ID2_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:177:18: ( ID )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:177:20: ID
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ ID2=(Token)match(input,ID,FOLLOW_ID_in_containsproperty1002);
+ ID2_tree = new ContainsProperty(ID2) ;
+ adaptor.addChild(root_0, ID2_tree);
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "containsproperty"
+
+
+ public static class withinproperty_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "withinproperty"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:179:1: withinproperty : ID ;
+ public final QueryFilterParser.withinproperty_return withinproperty() throws RecognitionException {
+ QueryFilterParser.withinproperty_return retval = new QueryFilterParser.withinproperty_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token ID3=null;
+
+ Object ID3_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:179:16: ( ID )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:179:18: ID
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ ID3=(Token)match(input,ID,FOLLOW_ID_in_withinproperty1013);
+ ID3_tree = new WithinProperty(ID3) ;
+ adaptor.addChild(root_0, ID3_tree);
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "withinproperty"
+
+
+ public static class booleanliteral_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "booleanliteral"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:181:1: booleanliteral : BOOLEAN ;
+ public final QueryFilterParser.booleanliteral_return booleanliteral() throws RecognitionException {
+ QueryFilterParser.booleanliteral_return retval = new QueryFilterParser.booleanliteral_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token BOOLEAN4=null;
+
+ Object BOOLEAN4_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:181:15: ( BOOLEAN )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:181:17: BOOLEAN
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ BOOLEAN4=(Token)match(input,BOOLEAN,FOLLOW_BOOLEAN_in_booleanliteral1024);
+ BOOLEAN4_tree = new BooleanLiteral(BOOLEAN4) ;
+ adaptor.addChild(root_0, BOOLEAN4_tree);
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "booleanliteral"
+
+
+ public static class longliteral_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "longliteral"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:184:1: longliteral : LONG ;
+ public final QueryFilterParser.longliteral_return longliteral() throws RecognitionException {
+ QueryFilterParser.longliteral_return retval = new QueryFilterParser.longliteral_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token LONG5=null;
+
+ Object LONG5_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:184:13: ( LONG )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:185:3: LONG
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ LONG5=(Token)match(input,LONG,FOLLOW_LONG_in_longliteral1038);
+ LONG5_tree = new LongLiteral(LONG5) ;
+ adaptor.addChild(root_0, LONG5_tree);
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "longliteral"
+
+
+ public static class uuidliteral_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "uuidliteral"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:187:1: uuidliteral : UUID ;
+ public final QueryFilterParser.uuidliteral_return uuidliteral() throws RecognitionException {
+ QueryFilterParser.uuidliteral_return retval = new QueryFilterParser.uuidliteral_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token UUID6=null;
+
+ Object UUID6_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:187:13: ( UUID )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:188:3: UUID
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ UUID6=(Token)match(input,UUID,FOLLOW_UUID_in_uuidliteral1052);
+ UUID6_tree = new UUIDLiteral(UUID6) ;
+ adaptor.addChild(root_0, UUID6_tree);
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "uuidliteral"
+
+
+ public static class stringliteral_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "stringliteral"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:190:1: stringliteral : STRING ;
+ public final QueryFilterParser.stringliteral_return stringliteral() throws RecognitionException {
+ QueryFilterParser.stringliteral_return retval = new QueryFilterParser.stringliteral_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token STRING7=null;
+
+ Object STRING7_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:190:15: ( STRING )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:191:3: STRING
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ STRING7=(Token)match(input,STRING,FOLLOW_STRING_in_stringliteral1065);
+ STRING7_tree = new StringLiteral(STRING7) ;
+ adaptor.addChild(root_0, STRING7_tree);
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "stringliteral"
+
+
+ public static class floatliteral_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "floatliteral"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:193:1: floatliteral : FLOAT ;
+ public final QueryFilterParser.floatliteral_return floatliteral() throws RecognitionException {
+ QueryFilterParser.floatliteral_return retval = new QueryFilterParser.floatliteral_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token FLOAT8=null;
+
+ Object FLOAT8_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:193:14: ( FLOAT )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:194:3: FLOAT
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ FLOAT8=(Token)match(input,FLOAT,FOLLOW_FLOAT_in_floatliteral1080);
+ FLOAT8_tree = new FloatLiteral(FLOAT8) ;
+ adaptor.addChild(root_0, FLOAT8_tree);
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "floatliteral"
+
+
+ public static class value_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "value"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:197:1: value : ( booleanliteral | longliteral | uuidliteral | stringliteral | floatliteral );
+ public final QueryFilterParser.value_return value() throws RecognitionException {
+ QueryFilterParser.value_return retval = new QueryFilterParser.value_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ ParserRuleReturnScope booleanliteral9 =null;
+ ParserRuleReturnScope longliteral10 =null;
+ ParserRuleReturnScope uuidliteral11 =null;
+ ParserRuleReturnScope stringliteral12 =null;
+ ParserRuleReturnScope floatliteral13 =null;
+
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:197:7: ( booleanliteral | longliteral | uuidliteral | stringliteral | floatliteral )
+ int alt1=5;
+ switch ( input.LA(1) ) {
+ case BOOLEAN:
+ {
+ alt1=1;
+ }
+ break;
+ case LONG:
+ {
+ alt1=2;
+ }
+ break;
+ case UUID:
+ {
+ alt1=3;
+ }
+ break;
+ case STRING:
+ {
+ alt1=4;
+ }
+ break;
+ case FLOAT:
+ {
+ alt1=5;
+ }
+ break;
+ default:
+ NoViableAltException nvae =
+ new NoViableAltException("", 1, 0, input);
+ throw nvae;
+ }
+ switch (alt1) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:198:3: booleanliteral
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_booleanliteral_in_value1096);
+ booleanliteral9=booleanliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, booleanliteral9.getTree());
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:199:5: longliteral
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_longliteral_in_value1102);
+ longliteral10=longliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, longliteral10.getTree());
+
+ }
+ break;
+ case 3 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:200:5: uuidliteral
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_uuidliteral_in_value1108);
+ uuidliteral11=uuidliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, uuidliteral11.getTree());
+
+ }
+ break;
+ case 4 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:201:5: stringliteral
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_stringliteral_in_value1114);
+ stringliteral12=stringliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, stringliteral12.getTree());
+
+ }
+ break;
+ case 5 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:202:5: floatliteral
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_floatliteral_in_value1120);
+ floatliteral13=floatliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, floatliteral13.getTree());
+
+ }
+ break;
+
+ }
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "value"
+
+
+ public static class equalityop_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "equalityop"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:213:1: equalityop : ( property LT ^ value | property LTE ^ value | property EQ ^ value | property GT ^ value | property GTE ^ value );
+ public final QueryFilterParser.equalityop_return equalityop() throws RecognitionException {
+ QueryFilterParser.equalityop_return retval = new QueryFilterParser.equalityop_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token LT15=null;
+ Token LTE18=null;
+ Token EQ21=null;
+ Token GT24=null;
+ Token GTE27=null;
+ ParserRuleReturnScope property14 =null;
+ ParserRuleReturnScope value16 =null;
+ ParserRuleReturnScope property17 =null;
+ ParserRuleReturnScope value19 =null;
+ ParserRuleReturnScope property20 =null;
+ ParserRuleReturnScope value22 =null;
+ ParserRuleReturnScope property23 =null;
+ ParserRuleReturnScope value25 =null;
+ ParserRuleReturnScope property26 =null;
+ ParserRuleReturnScope value28 =null;
+
+ Object LT15_tree=null;
+ Object LTE18_tree=null;
+ Object EQ21_tree=null;
+ Object GT24_tree=null;
+ Object GTE27_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:213:12: ( property LT ^ value | property LTE ^ value | property EQ ^ value | property GT ^ value | property GTE ^ value )
+ int alt2=5;
+ int LA2_0 = input.LA(1);
+ if ( (LA2_0==ID) ) {
+ switch ( input.LA(2) ) {
+ case LT:
+ {
+ alt2=1;
+ }
+ break;
+ case LTE:
+ {
+ alt2=2;
+ }
+ break;
+ case EQ:
+ {
+ alt2=3;
+ }
+ break;
+ case GT:
+ {
+ alt2=4;
+ }
+ break;
+ case GTE:
+ {
+ alt2=5;
+ }
+ break;
+ default:
+ int nvaeMark = input.mark();
+ try {
+ input.consume();
+ NoViableAltException nvae =
+ new NoViableAltException("", 2, 1, input);
+ throw nvae;
+ } finally {
+ input.rewind(nvaeMark);
+ }
+ }
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 2, 0, input);
+ throw nvae;
+ }
+
+ switch (alt2) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:214:3: property LT ^ value
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_property_in_equalityop1145);
+ property14=property();
+ state._fsp--;
+
+ adaptor.addChild(root_0, property14.getTree());
+
+ LT15=(Token)match(input,LT,FOLLOW_LT_in_equalityop1147);
+ LT15_tree = new LessThan(LT15) ;
+ root_0 = (Object)adaptor.becomeRoot(LT15_tree, root_0);
+
+ pushFollow(FOLLOW_value_in_equalityop1153);
+ value16=value();
+ state._fsp--;
+
+ adaptor.addChild(root_0, value16.getTree());
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:215:4: property LTE ^ value
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_property_in_equalityop1158);
+ property17=property();
+ state._fsp--;
+
+ adaptor.addChild(root_0, property17.getTree());
+
+ LTE18=(Token)match(input,LTE,FOLLOW_LTE_in_equalityop1160);
+ LTE18_tree = new LessThanEqual(LTE18) ;
+ root_0 = (Object)adaptor.becomeRoot(LTE18_tree, root_0);
+
+ pushFollow(FOLLOW_value_in_equalityop1166);
+ value19=value();
+ state._fsp--;
+
+ adaptor.addChild(root_0, value19.getTree());
+
+ }
+ break;
+ case 3 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:216:4: property EQ ^ value
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_property_in_equalityop1171);
+ property20=property();
+ state._fsp--;
+
+ adaptor.addChild(root_0, property20.getTree());
+
+ EQ21=(Token)match(input,EQ,FOLLOW_EQ_in_equalityop1173);
+ EQ21_tree = new Equal(EQ21) ;
+ root_0 = (Object)adaptor.becomeRoot(EQ21_tree, root_0);
+
+ pushFollow(FOLLOW_value_in_equalityop1179);
+ value22=value();
+ state._fsp--;
+
+ adaptor.addChild(root_0, value22.getTree());
+
+ }
+ break;
+ case 4 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:217:4: property GT ^ value
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_property_in_equalityop1184);
+ property23=property();
+ state._fsp--;
+
+ adaptor.addChild(root_0, property23.getTree());
+
+ GT24=(Token)match(input,GT,FOLLOW_GT_in_equalityop1186);
+ GT24_tree = new GreaterThan(GT24) ;
+ root_0 = (Object)adaptor.becomeRoot(GT24_tree, root_0);
+
+ pushFollow(FOLLOW_value_in_equalityop1192);
+ value25=value();
+ state._fsp--;
+
+ adaptor.addChild(root_0, value25.getTree());
+
+ }
+ break;
+ case 5 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:218:4: property GTE ^ value
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_property_in_equalityop1197);
+ property26=property();
+ state._fsp--;
+
+ adaptor.addChild(root_0, property26.getTree());
+
+ GTE27=(Token)match(input,GTE,FOLLOW_GTE_in_equalityop1199);
+ GTE27_tree = new GreaterThanEqual(GTE27) ;
+ root_0 = (Object)adaptor.becomeRoot(GTE27_tree, root_0);
+
+ pushFollow(FOLLOW_value_in_equalityop1205);
+ value28=value();
+ state._fsp--;
+
+ adaptor.addChild(root_0, value28.getTree());
+
+ }
+ break;
+
+ }
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "equalityop"
+
+
+ public static class locationop_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "locationop"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:222:1: locationop : withinproperty WITHIN ^ ( floatliteral | longliteral ) OF ! ( floatliteral | longliteral ) ',' ! ( floatliteral | longliteral ) ;
+ public final QueryFilterParser.locationop_return locationop() throws RecognitionException {
+ QueryFilterParser.locationop_return retval = new QueryFilterParser.locationop_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token WITHIN30=null;
+ Token OF33=null;
+ Token char_literal36=null;
+ ParserRuleReturnScope withinproperty29 =null;
+ ParserRuleReturnScope floatliteral31 =null;
+ ParserRuleReturnScope longliteral32 =null;
+ ParserRuleReturnScope floatliteral34 =null;
+ ParserRuleReturnScope longliteral35 =null;
+ ParserRuleReturnScope floatliteral37 =null;
+ ParserRuleReturnScope longliteral38 =null;
+
+ Object WITHIN30_tree=null;
+ Object OF33_tree=null;
+ Object char_literal36_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:222:12: ( withinproperty WITHIN ^ ( floatliteral | longliteral ) OF ! ( floatliteral | longliteral ) ',' ! ( floatliteral | longliteral ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:3: withinproperty WITHIN ^ ( floatliteral | longliteral ) OF ! ( floatliteral | longliteral ) ',' ! ( floatliteral | longliteral )
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_withinproperty_in_locationop1220);
+ withinproperty29=withinproperty();
+ state._fsp--;
+
+ adaptor.addChild(root_0, withinproperty29.getTree());
+
+ WITHIN30=(Token)match(input,WITHIN,FOLLOW_WITHIN_in_locationop1222);
+ WITHIN30_tree = new WithinOperand(WITHIN30) ;
+ root_0 = (Object)adaptor.becomeRoot(WITHIN30_tree, root_0);
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:41: ( floatliteral | longliteral )
+ int alt3=2;
+ int LA3_0 = input.LA(1);
+ if ( (LA3_0==FLOAT) ) {
+ alt3=1;
+ }
+ else if ( (LA3_0==LONG) ) {
+ alt3=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 3, 0, input);
+ throw nvae;
+ }
+
+ switch (alt3) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:42: floatliteral
+ {
+ pushFollow(FOLLOW_floatliteral_in_locationop1229);
+ floatliteral31=floatliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, floatliteral31.getTree());
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:55: longliteral
+ {
+ pushFollow(FOLLOW_longliteral_in_locationop1231);
+ longliteral32=longliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, longliteral32.getTree());
+
+ }
+ break;
+
+ }
+
+ OF33=(Token)match(input,OF,FOLLOW_OF_in_locationop1234);
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:72: ( floatliteral | longliteral )
+ int alt4=2;
+ int LA4_0 = input.LA(1);
+ if ( (LA4_0==FLOAT) ) {
+ alt4=1;
+ }
+ else if ( (LA4_0==LONG) ) {
+ alt4=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 4, 0, input);
+ throw nvae;
+ }
+
+ switch (alt4) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:73: floatliteral
+ {
+ pushFollow(FOLLOW_floatliteral_in_locationop1238);
+ floatliteral34=floatliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, floatliteral34.getTree());
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:86: longliteral
+ {
+ pushFollow(FOLLOW_longliteral_in_locationop1240);
+ longliteral35=longliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, longliteral35.getTree());
+
+ }
+ break;
+
+ }
+
+ char_literal36=(Token)match(input,34,FOLLOW_34_in_locationop1243);
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:104: ( floatliteral | longliteral )
+ int alt5=2;
+ int LA5_0 = input.LA(1);
+ if ( (LA5_0==FLOAT) ) {
+ alt5=1;
+ }
+ else if ( (LA5_0==LONG) ) {
+ alt5=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 5, 0, input);
+ throw nvae;
+ }
+
+ switch (alt5) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:105: floatliteral
+ {
+ pushFollow(FOLLOW_floatliteral_in_locationop1247);
+ floatliteral37=floatliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, floatliteral37.getTree());
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:223:118: longliteral
+ {
+ pushFollow(FOLLOW_longliteral_in_locationop1249);
+ longliteral38=longliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, longliteral38.getTree());
+
+ }
+ break;
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "locationop"
+
+
+ public static class containsop_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "containsop"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:226:1: containsop : containsproperty CONTAINS ^ stringliteral ;
+ public final QueryFilterParser.containsop_return containsop() throws RecognitionException {
+ QueryFilterParser.containsop_return retval = new QueryFilterParser.containsop_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token CONTAINS40=null;
+ ParserRuleReturnScope containsproperty39 =null;
+ ParserRuleReturnScope stringliteral41 =null;
+
+ Object CONTAINS40_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:226:12: ( containsproperty CONTAINS ^ stringliteral )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:227:3: containsproperty CONTAINS ^ stringliteral
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_containsproperty_in_containsop1263);
+ containsproperty39=containsproperty();
+ state._fsp--;
+
+ adaptor.addChild(root_0, containsproperty39.getTree());
+
+ CONTAINS40=(Token)match(input,CONTAINS,FOLLOW_CONTAINS_in_containsop1265);
+ CONTAINS40_tree = new ContainsOperand(CONTAINS40) ;
+ root_0 = (Object)adaptor.becomeRoot(CONTAINS40_tree, root_0);
+
+ pushFollow(FOLLOW_stringliteral_in_containsop1271);
+ stringliteral41=stringliteral();
+ state._fsp--;
+
+ adaptor.addChild(root_0, stringliteral41.getTree());
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "containsop"
+
+
+ public static class operation_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "operation"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:230:1: operation : ( '(' ! expression ')' !| equalityop | locationop | containsop );
+ public final QueryFilterParser.operation_return operation() throws RecognitionException {
+ QueryFilterParser.operation_return retval = new QueryFilterParser.operation_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token char_literal42=null;
+ Token char_literal44=null;
+ ParserRuleReturnScope expression43 =null;
+ ParserRuleReturnScope equalityop45 =null;
+ ParserRuleReturnScope locationop46 =null;
+ ParserRuleReturnScope containsop47 =null;
+
+ Object char_literal42_tree=null;
+ Object char_literal44_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:230:11: ( '(' ! expression ')' !| equalityop | locationop | containsop )
+ int alt6=4;
+ int LA6_0 = input.LA(1);
+ if ( (LA6_0==31) ) {
+ alt6=1;
+ }
+ else if ( (LA6_0==ID) ) {
+ switch ( input.LA(2) ) {
+ case EQ:
+ case GT:
+ case GTE:
+ case LT:
+ case LTE:
+ {
+ alt6=2;
+ }
+ break;
+ case WITHIN:
+ {
+ alt6=3;
+ }
+ break;
+ case CONTAINS:
+ {
+ alt6=4;
+ }
+ break;
+ default:
+ int nvaeMark = input.mark();
+ try {
+ input.consume();
+ NoViableAltException nvae =
+ new NoViableAltException("", 6, 2, input);
+ throw nvae;
+ } finally {
+ input.rewind(nvaeMark);
+ }
+ }
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 6, 0, input);
+ throw nvae;
+ }
+
+ switch (alt6) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:231:2: '(' ! expression ')' !
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ char_literal42=(Token)match(input,31,FOLLOW_31_in_operation1281);
+ pushFollow(FOLLOW_expression_in_operation1284);
+ expression43=expression();
+ state._fsp--;
+
+ adaptor.addChild(root_0, expression43.getTree());
+
+ char_literal44=(Token)match(input,32,FOLLOW_32_in_operation1286);
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:232:6: equalityop
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_equalityop_in_operation1294);
+ equalityop45=equalityop();
+ state._fsp--;
+
+ adaptor.addChild(root_0, equalityop45.getTree());
+
+ }
+ break;
+ case 3 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:233:6: locationop
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_locationop_in_operation1302);
+ locationop46=locationop();
+ state._fsp--;
+
+ adaptor.addChild(root_0, locationop46.getTree());
+
+ }
+ break;
+ case 4 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:234:6: containsop
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_containsop_in_operation1310);
+ containsop47=containsop();
+ state._fsp--;
+
+ adaptor.addChild(root_0, containsop47.getTree());
+
+ }
+ break;
+
+ }
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "operation"
+
+
+ public static class notexp_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "notexp"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:238:1: notexp : ( NOT ^ operation | operation );
+ public final QueryFilterParser.notexp_return notexp() throws RecognitionException {
+ QueryFilterParser.notexp_return retval = new QueryFilterParser.notexp_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token NOT48=null;
+ ParserRuleReturnScope operation49 =null;
+ ParserRuleReturnScope operation50 =null;
+
+ Object NOT48_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:238:8: ( NOT ^ operation | operation )
+ int alt7=2;
+ int LA7_0 = input.LA(1);
+ if ( (LA7_0==NOT) ) {
+ alt7=1;
+ }
+ else if ( (LA7_0==ID||LA7_0==31) ) {
+ alt7=2;
+ }
+
+ else {
+ NoViableAltException nvae =
+ new NoViableAltException("", 7, 0, input);
+ throw nvae;
+ }
+
+ switch (alt7) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:240:2: NOT ^ operation
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ NOT48=(Token)match(input,NOT,FOLLOW_NOT_in_notexp1326);
+ NOT48_tree = new NotOperand(NOT48) ;
+ root_0 = (Object)adaptor.becomeRoot(NOT48_tree, root_0);
+
+ pushFollow(FOLLOW_operation_in_notexp1332);
+ operation49=operation();
+ state._fsp--;
+
+ adaptor.addChild(root_0, operation49.getTree());
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:241:3: operation
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_operation_in_notexp1338);
+ operation50=operation();
+ state._fsp--;
+
+ adaptor.addChild(root_0, operation50.getTree());
+
+ }
+ break;
+
+ }
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "notexp"
+
+
+ public static class andexp_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "andexp"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:246:1: andexp : notexp ( AND ^ notexp )* ;
+ public final QueryFilterParser.andexp_return andexp() throws RecognitionException {
+ QueryFilterParser.andexp_return retval = new QueryFilterParser.andexp_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token AND52=null;
+ ParserRuleReturnScope notexp51 =null;
+ ParserRuleReturnScope notexp53 =null;
+
+ Object AND52_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:246:8: ( notexp ( AND ^ notexp )* )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:247:2: notexp ( AND ^ notexp )*
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_notexp_in_andexp1352);
+ notexp51=notexp();
+ state._fsp--;
+
+ adaptor.addChild(root_0, notexp51.getTree());
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:247:9: ( AND ^ notexp )*
+ loop8:
+ while (true) {
+ int alt8=2;
+ int LA8_0 = input.LA(1);
+ if ( (LA8_0==AND) ) {
+ alt8=1;
+ }
+
+ switch (alt8) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:247:10: AND ^ notexp
+ {
+ AND52=(Token)match(input,AND,FOLLOW_AND_in_andexp1355);
+ AND52_tree = new AndOperand(AND52) ;
+ root_0 = (Object)adaptor.becomeRoot(AND52_tree, root_0);
+
+ pushFollow(FOLLOW_notexp_in_andexp1361);
+ notexp53=notexp();
+ state._fsp--;
+
+ adaptor.addChild(root_0, notexp53.getTree());
+
+ }
+ break;
+
+ default :
+ break loop8;
+ }
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "andexp"
+
+
+ public static class expression_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "expression"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:252:1: expression : andexp ( OR ^ andexp )* ;
+ public final QueryFilterParser.expression_return expression() throws RecognitionException {
+ QueryFilterParser.expression_return retval = new QueryFilterParser.expression_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token OR55=null;
+ ParserRuleReturnScope andexp54 =null;
+ ParserRuleReturnScope andexp56 =null;
+
+ Object OR55_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:252:12: ( andexp ( OR ^ andexp )* )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:253:2: andexp ( OR ^ andexp )*
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ pushFollow(FOLLOW_andexp_in_expression1378);
+ andexp54=andexp();
+ state._fsp--;
+
+ adaptor.addChild(root_0, andexp54.getTree());
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:253:9: ( OR ^ andexp )*
+ loop9:
+ while (true) {
+ int alt9=2;
+ int LA9_0 = input.LA(1);
+ if ( (LA9_0==OR) ) {
+ alt9=1;
+ }
+
+ switch (alt9) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:253:10: OR ^ andexp
+ {
+ OR55=(Token)match(input,OR,FOLLOW_OR_in_expression1381);
+ OR55_tree = new OrOperand(OR55) ;
+ root_0 = (Object)adaptor.becomeRoot(OR55_tree, root_0);
+
+ pushFollow(FOLLOW_andexp_in_expression1387);
+ andexp56=andexp();
+ state._fsp--;
+
+ adaptor.addChild(root_0, andexp56.getTree());
+
+ }
+ break;
+
+ default :
+ break loop9;
+ }
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "expression"
+
+
+ public static class direction_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "direction"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:262:1: direction : ( ASC | DESC ) ;
+ public final QueryFilterParser.direction_return direction() throws RecognitionException {
+ QueryFilterParser.direction_return retval = new QueryFilterParser.direction_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token set57=null;
+
+ Object set57_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:262:12: ( ( ASC | DESC ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ set57=input.LT(1);
+ if ( input.LA(1)==ASC||input.LA(1)==DESC ) {
+ input.consume();
+ adaptor.addChild(root_0, (Object)adaptor.create(set57));
+ state.errorRecovery=false;
+ }
+ else {
+ MismatchedSetException mse = new MismatchedSetException(null,input);
+ throw mse;
+ }
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "direction"
+
+
+ public static class order_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "order"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:265:1: order : ( property ( direction )? ) ;
+ public final QueryFilterParser.order_return order() throws RecognitionException {
+ QueryFilterParser.order_return retval = new QueryFilterParser.order_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ ParserRuleReturnScope property58 =null;
+ ParserRuleReturnScope direction59 =null;
+
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:266:3: ( ( property ( direction )? ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:266:5: ( property ( direction )? )
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:266:5: ( property ( direction )? )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:266:6: property ( direction )?
+ {
+ pushFollow(FOLLOW_property_in_order1424);
+ property58=property();
+ state._fsp--;
+
+ adaptor.addChild(root_0, property58.getTree());
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:266:15: ( direction )?
+ int alt10=2;
+ int LA10_0 = input.LA(1);
+ if ( (LA10_0==ASC||LA10_0==DESC) ) {
+ alt10=1;
+ }
+ switch (alt10) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:266:15: direction
+ {
+ pushFollow(FOLLOW_direction_in_order1426);
+ direction59=direction();
+ state._fsp--;
+
+ adaptor.addChild(root_0, direction59.getTree());
+
+ }
+ break;
+
+ }
+
+ }
+
+
+ String property = (property58!=null?input.toString(property58.start,property58.stop):null);
+ String direction = (direction59!=null?input.toString(direction59.start,direction59.stop):null);
+ query.addSort(new SortPredicate(property, direction));
+
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "order"
+
+
+ public static class select_subject_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "select_subject"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:277:1: select_subject : ID ;
+ public final QueryFilterParser.select_subject_return select_subject() throws RecognitionException {
+ QueryFilterParser.select_subject_return retval = new QueryFilterParser.select_subject_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token ID60=null;
+
+ Object ID60_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:278:3: ( ID )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:278:5: ID
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ ID60=(Token)match(input,ID,FOLLOW_ID_in_select_subject1445);
+ ID60_tree = (Object)adaptor.create(ID60);
+ adaptor.addChild(root_0, ID60_tree);
+
+
+
+ query.addSelect((ID60!=null?ID60.getText():null));
+
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "select_subject"
+
+
+ public static class select_assign_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "select_assign"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:286:1: select_assign : target= ID ':' source= ID ;
+ public final QueryFilterParser.select_assign_return select_assign() throws RecognitionException {
+ QueryFilterParser.select_assign_return retval = new QueryFilterParser.select_assign_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token target=null;
+ Token source=null;
+ Token char_literal61=null;
+
+ Object target_tree=null;
+ Object source_tree=null;
+ Object char_literal61_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:287:3: (target= ID ':' source= ID )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:287:5: target= ID ':' source= ID
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ target=(Token)match(input,ID,FOLLOW_ID_in_select_assign1462);
+ target_tree = (Object)adaptor.create(target);
+ adaptor.addChild(root_0, target_tree);
+
+ char_literal61=(Token)match(input,35,FOLLOW_35_in_select_assign1464);
+ char_literal61_tree = (Object)adaptor.create(char_literal61);
+ adaptor.addChild(root_0, char_literal61_tree);
+
+ source=(Token)match(input,ID,FOLLOW_ID_in_select_assign1468);
+ source_tree = (Object)adaptor.create(source);
+ adaptor.addChild(root_0, source_tree);
+
+
+
+ query.addSelect((target!=null?target.getText():null), (source!=null?source.getText():null));
+
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "select_assign"
+
+
+ public static class select_expr_return extends ParserRuleReturnScope {
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "select_expr"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:293:1: select_expr : ( '*' | select_subject ( ',' select_subject )* | '{' select_assign ( ',' select_assign )* '}' ) ;
+ public final QueryFilterParser.select_expr_return select_expr() throws RecognitionException {
+ QueryFilterParser.select_expr_return retval = new QueryFilterParser.select_expr_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token char_literal62=null;
+ Token char_literal64=null;
+ Token char_literal66=null;
+ Token char_literal68=null;
+ Token char_literal70=null;
+ ParserRuleReturnScope select_subject63 =null;
+ ParserRuleReturnScope select_subject65 =null;
+ ParserRuleReturnScope select_assign67 =null;
+ ParserRuleReturnScope select_assign69 =null;
+
+ Object char_literal62_tree=null;
+ Object char_literal64_tree=null;
+ Object char_literal66_tree=null;
+ Object char_literal68_tree=null;
+ Object char_literal70_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:3: ( ( '*' | select_subject ( ',' select_subject )* | '{' select_assign ( ',' select_assign )* '}' ) )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:5: ( '*' | select_subject ( ',' select_subject )* | '{' select_assign ( ',' select_assign )* '}' )
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:5: ( '*' | select_subject ( ',' select_subject )* | '{' select_assign ( ',' select_assign )* '}' )
+ int alt13=3;
+ switch ( input.LA(1) ) {
+ case 33:
+ {
+ alt13=1;
+ }
+ break;
+ case ID:
+ {
+ alt13=2;
+ }
+ break;
+ case 39:
+ {
+ alt13=3;
+ }
+ break;
+ default:
+ NoViableAltException nvae =
+ new NoViableAltException("", 13, 0, input);
+ throw nvae;
+ }
+ switch (alt13) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:6: '*'
+ {
+ char_literal62=(Token)match(input,33,FOLLOW_33_in_select_expr1482);
+ char_literal62_tree = (Object)adaptor.create(char_literal62);
+ adaptor.addChild(root_0, char_literal62_tree);
+
+ }
+ break;
+ case 2 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:12: select_subject ( ',' select_subject )*
+ {
+ pushFollow(FOLLOW_select_subject_in_select_expr1486);
+ select_subject63=select_subject();
+ state._fsp--;
+
+ adaptor.addChild(root_0, select_subject63.getTree());
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:27: ( ',' select_subject )*
+ loop11:
+ while (true) {
+ int alt11=2;
+ int LA11_0 = input.LA(1);
+ if ( (LA11_0==34) ) {
+ alt11=1;
+ }
+
+ switch (alt11) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:28: ',' select_subject
+ {
+ char_literal64=(Token)match(input,34,FOLLOW_34_in_select_expr1489);
+ char_literal64_tree = (Object)adaptor.create(char_literal64);
+ adaptor.addChild(root_0, char_literal64_tree);
+
+ pushFollow(FOLLOW_select_subject_in_select_expr1491);
+ select_subject65=select_subject();
+ state._fsp--;
+
+ adaptor.addChild(root_0, select_subject65.getTree());
+
+ }
+ break;
+
+ default :
+ break loop11;
+ }
+ }
+
+ }
+ break;
+ case 3 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:52: '{' select_assign ( ',' select_assign )* '}'
+ {
+ char_literal66=(Token)match(input,39,FOLLOW_39_in_select_expr1498);
+ char_literal66_tree = (Object)adaptor.create(char_literal66);
+ adaptor.addChild(root_0, char_literal66_tree);
+
+ pushFollow(FOLLOW_select_assign_in_select_expr1500);
+ select_assign67=select_assign();
+ state._fsp--;
+
+ adaptor.addChild(root_0, select_assign67.getTree());
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:70: ( ',' select_assign )*
+ loop12:
+ while (true) {
+ int alt12=2;
+ int LA12_0 = input.LA(1);
+ if ( (LA12_0==34) ) {
+ alt12=1;
+ }
+
+ switch (alt12) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:294:71: ',' select_assign
+ {
+ char_literal68=(Token)match(input,34,FOLLOW_34_in_select_expr1503);
+ char_literal68_tree = (Object)adaptor.create(char_literal68);
+ adaptor.addChild(root_0, char_literal68_tree);
+
+ pushFollow(FOLLOW_select_assign_in_select_expr1505);
+ select_assign69=select_assign();
+ state._fsp--;
+
+ adaptor.addChild(root_0, select_assign69.getTree());
+
+ }
+ break;
+
+ default :
+ break loop12;
+ }
+ }
+
+ char_literal70=(Token)match(input,40,FOLLOW_40_in_select_expr1510);
+ char_literal70_tree = (Object)adaptor.create(char_literal70);
+ adaptor.addChild(root_0, char_literal70_tree);
+
+ }
+ break;
+
+ }
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "select_expr"
+
+
+ public static class ql_return extends ParserRuleReturnScope {
+ public Query query;
+ Object tree;
+ @Override
+ public Object getTree() { return tree; }
+ };
+
+
+ // $ANTLR start "ql"
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:298:1: ql returns [Query query] : ( 'select' ! select_expr !)? ( ( 'where' !)? expression )? ( 'order by' ! order ! ( ',' ! order !)* )? ;
+ public final QueryFilterParser.ql_return ql() throws RecognitionException {
+ QueryFilterParser.ql_return retval = new QueryFilterParser.ql_return();
+ retval.start = input.LT(1);
+
+ Object root_0 = null;
+
+ Token string_literal71=null;
+ Token string_literal73=null;
+ Token string_literal75=null;
+ Token char_literal77=null;
+ ParserRuleReturnScope select_expr72 =null;
+ ParserRuleReturnScope expression74 =null;
+ ParserRuleReturnScope order76 =null;
+ ParserRuleReturnScope order78 =null;
+
+ Object string_literal71_tree=null;
+ Object string_literal73_tree=null;
+ Object string_literal75_tree=null;
+ Object char_literal77_tree=null;
+
+ try {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:3: ( ( 'select' ! select_expr !)? ( ( 'where' !)? expression )? ( 'order by' ! order ! ( ',' ! order !)* )? )
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:5: ( 'select' ! select_expr !)? ( ( 'where' !)? expression )? ( 'order by' ! order ! ( ',' ! order !)* )?
+ {
+ root_0 = (Object)adaptor.nil();
+
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:5: ( 'select' ! select_expr !)?
+ int alt14=2;
+ int LA14_0 = input.LA(1);
+ if ( (LA14_0==37) ) {
+ alt14=1;
+ }
+ switch (alt14) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:6: 'select' ! select_expr !
+ {
+ string_literal71=(Token)match(input,37,FOLLOW_37_in_ql1533);
+ pushFollow(FOLLOW_select_expr_in_ql1536);
+ select_expr72=select_expr();
+ state._fsp--;
+
+ }
+ break;
+
+ }
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:31: ( ( 'where' !)? expression )?
+ int alt16=2;
+ int LA16_0 = input.LA(1);
+ if ( (LA16_0==ID||LA16_0==NOT||LA16_0==31||LA16_0==38) ) {
+ alt16=1;
+ }
+ switch (alt16) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:32: ( 'where' !)? expression
+ {
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:39: ( 'where' !)?
+ int alt15=2;
+ int LA15_0 = input.LA(1);
+ if ( (LA15_0==38) ) {
+ alt15=1;
+ }
+ switch (alt15) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:39: 'where' !
+ {
+ string_literal73=(Token)match(input,38,FOLLOW_38_in_ql1542);
+ }
+ break;
+
+ }
+
+ pushFollow(FOLLOW_expression_in_ql1546);
+ expression74=expression();
+ state._fsp--;
+
+ adaptor.addChild(root_0, expression74.getTree());
+
+ }
+ break;
+
+ }
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:55: ( 'order by' ! order ! ( ',' ! order !)* )?
+ int alt18=2;
+ int LA18_0 = input.LA(1);
+ if ( (LA18_0==36) ) {
+ alt18=1;
+ }
+ switch (alt18) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:56: 'order by' ! order ! ( ',' ! order !)*
+ {
+ string_literal75=(Token)match(input,36,FOLLOW_36_in_ql1551);
+ pushFollow(FOLLOW_order_in_ql1554);
+ order76=order();
+ state._fsp--;
+
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:75: ( ',' ! order !)*
+ loop17:
+ while (true) {
+ int alt17=2;
+ int LA17_0 = input.LA(1);
+ if ( (LA17_0==34) ) {
+ alt17=1;
+ }
+
+ switch (alt17) {
+ case 1 :
+ // org/apache/usergrid/persistence/query/tree/QueryFilter.g:299:76: ',' ! order !
+ {
+ char_literal77=(Token)match(input,34,FOLLOW_34_in_ql1558);
+ pushFollow(FOLLOW_order_in_ql1561);
+ order78=order();
+ state._fsp--;
+
+ }
+ break;
+
+ default :
+ break loop17;
+ }
+ }
+
+ }
+ break;
+
+ }
+
+
+
+ if((expression74!=null?((Object)expression74.getTree()):null) instanceof Operand){
+ query.setRootOperand((Operand)(expression74!=null?((Object)expression74.getTree()):null));
+ }
+
+ retval.query = query;
+
+
+
+ }
+
+ retval.stop = input.LT(-1);
+
+ retval.tree = (Object)adaptor.rulePostProcessing(root_0);
+ adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
+
+ }
+
+ finally {
+ // do for sure before leaving
+ }
+ return retval;
+ }
+ // $ANTLR end "ql"
+
+ // Delegated rules
+
+
+
+ public static final BitSet FOLLOW_ID_in_property991 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_ID_in_containsproperty1002 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_ID_in_withinproperty1013 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_BOOLEAN_in_booleanliteral1024 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_LONG_in_longliteral1038 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_UUID_in_uuidliteral1052 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_STRING_in_stringliteral1065 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_FLOAT_in_floatliteral1080 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_booleanliteral_in_value1096 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_longliteral_in_value1102 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_uuidliteral_in_value1108 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_stringliteral_in_value1114 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_floatliteral_in_value1120 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_property_in_equalityop1145 = new BitSet(new long[]{0x0000000000080000L});
+ public static final BitSet FOLLOW_LT_in_equalityop1147 = new BitSet(new long[]{0x0000000012042040L});
+ public static final BitSet FOLLOW_value_in_equalityop1153 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_property_in_equalityop1158 = new BitSet(new long[]{0x0000000000100000L});
+ public static final BitSet FOLLOW_LTE_in_equalityop1160 = new BitSet(new long[]{0x0000000012042040L});
+ public static final BitSet FOLLOW_value_in_equalityop1166 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_property_in_equalityop1171 = new BitSet(new long[]{0x0000000000000200L});
+ public static final BitSet FOLLOW_EQ_in_equalityop1173 = new BitSet(new long[]{0x0000000012042040L});
+ public static final BitSet FOLLOW_value_in_equalityop1179 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_property_in_equalityop1184 = new BitSet(new long[]{0x0000000000004000L});
+ public static final BitSet FOLLOW_GT_in_equalityop1186 = new BitSet(new long[]{0x0000000012042040L});
+ public static final BitSet FOLLOW_value_in_equalityop1192 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_property_in_equalityop1197 = new BitSet(new long[]{0x0000000000008000L});
+ public static final BitSet FOLLOW_GTE_in_equalityop1199 = new BitSet(new long[]{0x0000000012042040L});
+ public static final BitSet FOLLOW_value_in_equalityop1205 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_withinproperty_in_locationop1220 = new BitSet(new long[]{0x0000000020000000L});
+ public static final BitSet FOLLOW_WITHIN_in_locationop1222 = new BitSet(new long[]{0x0000000000042000L});
+ public static final BitSet FOLLOW_floatliteral_in_locationop1229 = new BitSet(new long[]{0x0000000000800000L});
+ public static final BitSet FOLLOW_longliteral_in_locationop1231 = new BitSet(new long[]{0x0000000000800000L});
+ public static final BitSet FOLLOW_OF_in_locationop1234 = new BitSet(new long[]{0x0000000000042000L});
+ public static final BitSet FOLLOW_floatliteral_in_locationop1238 = new BitSet(new long[]{0x0000000400000000L});
+ public static final BitSet FOLLOW_longliteral_in_locationop1240 = new BitSet(new long[]{0x0000000400000000L});
+ public static final BitSet FOLLOW_34_in_locationop1243 = new BitSet(new long[]{0x0000000000042000L});
+ public static final BitSet FOLLOW_floatliteral_in_locationop1247 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_longliteral_in_locationop1249 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_containsproperty_in_containsop1263 = new BitSet(new long[]{0x0000000000000080L});
+ public static final BitSet FOLLOW_CONTAINS_in_containsop1265 = new BitSet(new long[]{0x0000000002000000L});
+ public static final BitSet FOLLOW_stringliteral_in_containsop1271 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_31_in_operation1281 = new BitSet(new long[]{0x0000000080220000L});
+ public static final BitSet FOLLOW_expression_in_operation1284 = new BitSet(new long[]{0x0000000100000000L});
+ public static final BitSet FOLLOW_32_in_operation1286 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_equalityop_in_operation1294 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_locationop_in_operation1302 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_containsop_in_operation1310 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_NOT_in_notexp1326 = new BitSet(new long[]{0x0000000080020000L});
+ public static final BitSet FOLLOW_operation_in_notexp1332 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_operation_in_notexp1338 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_notexp_in_andexp1352 = new BitSet(new long[]{0x0000000000000012L});
+ public static final BitSet FOLLOW_AND_in_andexp1355 = new BitSet(new long[]{0x0000000080220000L});
+ public static final BitSet FOLLOW_notexp_in_andexp1361 = new BitSet(new long[]{0x0000000000000012L});
+ public static final BitSet FOLLOW_andexp_in_expression1378 = new BitSet(new long[]{0x0000000001000002L});
+ public static final BitSet FOLLOW_OR_in_expression1381 = new BitSet(new long[]{0x0000000080220000L});
+ public static final BitSet FOLLOW_andexp_in_expression1387 = new BitSet(new long[]{0x0000000001000002L});
+ public static final BitSet FOLLOW_property_in_order1424 = new BitSet(new long[]{0x0000000000000122L});
+ public static final BitSet FOLLOW_direction_in_order1426 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_ID_in_select_subject1445 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_ID_in_select_assign1462 = new BitSet(new long[]{0x0000000800000000L});
+ public static final BitSet FOLLOW_35_in_select_assign1464 = new BitSet(new long[]{0x0000000000020000L});
+ public static final BitSet FOLLOW_ID_in_select_assign1468 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_33_in_select_expr1482 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_select_subject_in_select_expr1486 = new BitSet(new long[]{0x0000000400000002L});
+ public static final BitSet FOLLOW_34_in_select_expr1489 = new BitSet(new long[]{0x0000000000020000L});
+ public static final BitSet FOLLOW_select_subject_in_select_expr1491 = new BitSet(new long[]{0x0000000400000002L});
+ public static final BitSet FOLLOW_39_in_select_expr1498 = new BitSet(new long[]{0x0000000000020000L});
+ public static final BitSet FOLLOW_select_assign_in_select_expr1500 = new BitSet(new long[]{0x0000010400000000L});
+ public static final BitSet FOLLOW_34_in_select_expr1503 = new BitSet(new long[]{0x0000000000020000L});
+ public static final BitSet FOLLOW_select_assign_in_select_expr1505 = new BitSet(new long[]{0x0000010400000000L});
+ public static final BitSet FOLLOW_40_in_select_expr1510 = new BitSet(new long[]{0x0000000000000002L});
+ public static final BitSet FOLLOW_37_in_ql1533 = new BitSet(new long[]{0x0000008200020000L});
+ public static final BitSet FOLLOW_select_expr_in_ql1536 = new BitSet(new long[]{0x0000005080220002L});
+ public static final BitSet FOLLOW_38_in_ql1542 = new BitSet(new long[]{0x0000000080220000L});
+ public static final BitSet FOLLOW_expression_in_ql1546 = new BitSet(new long[]{0x0000001000000002L});
+ public static final BitSet FOLLOW_36_in_ql1551 = new BitSet(new long[]{0x0000000000020000L});
+ public static final BitSet FOLLOW_order_in_ql1554 = new BitSet(new long[]{0x0000000400000002L});
+ public static final BitSet FOLLOW_34_in_ql1558 = new BitSet(new long[]{0x0000000000020000L});
+ public static final BitSet FOLLOW_order_in_ql1561 = new BitSet(new long[]{0x0000000400000002L});
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryVisitor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryVisitor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryVisitor.java
new file mode 100644
index 0000000..63d549b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryVisitor.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.apache.usergrid.persistence.exceptions.NoFullTextIndexException;
+import org.apache.usergrid.persistence.exceptions.NoIndexException;
+import org.apache.usergrid.persistence.exceptions.PersistenceException;
+
+
+/**
+ * Interface for visiting nodes in our AST as we produce
+ *
+ * @author tnine
+ */
+public interface QueryVisitor {
+
+ /**
+ *
+ * @param op
+ * @throws PersistenceException
+ */
+ public void visit( AndOperand op ) throws PersistenceException;
+
+ /**
+ * @param op
+ * @throws PersistenceException
+ */
+ public void visit( OrOperand op ) throws PersistenceException;
+
+ /**
+ * @param op
+ * @throws PersistenceException
+ */
+ public void visit( NotOperand op ) throws PersistenceException;
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( LessThan op ) throws NoIndexException;
+
+ /**
+ * @param op
+ * @throws NoFullTextIndexException
+ */
+ public void visit( ContainsOperand op ) throws NoFullTextIndexException;
+
+ /**
+ * @param op
+ */
+ public void visit( WithinOperand op );
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( LessThanEqual op ) throws NoIndexException;
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( Equal op ) throws NoIndexException;
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( GreaterThan op ) throws NoIndexException;
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( GreaterThanEqual op ) throws NoIndexException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/StringLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/StringLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/StringLiteral.java
new file mode 100644
index 0000000..a7ada85
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/StringLiteral.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+import static org.apache.commons.lang.StringUtils.removeEnd;
+
+
+/** @author tnine */
+public class StringLiteral extends Literal<String> {
+
+ private String value;
+ private String finishValue;
+
+
+ /**
+ * @param t
+ */
+ public StringLiteral( Token t ) {
+ super( t );
+ String newValue = t.getText();
+ newValue = newValue.substring( 1, newValue.length() - 1 );
+
+ parseValue( newValue );
+ }
+
+
+ public StringLiteral( String value ) {
+ super( new ClassicToken( 0, value ) );
+ parseValue( value );
+ }
+
+
+ /** Parse the value and set the optional end value */
+ private void parseValue( String value ) {
+
+ this.value = value.trim().toLowerCase();
+
+ if ( "*".equals( value ) ) {
+ this.value = null;
+ this.finishValue = null;
+ return;
+ }
+
+ if ( value != null && value.endsWith( "*" ) ) {
+ this.value = removeEnd( value.toString(), "*" );
+
+ finishValue = this.value + "\uFFFF";
+ }
+ // set the end value to the same as the start value
+ else {
+ finishValue = value;
+ }
+ }
+
+
+ /** If this were a string literal */
+ public String getEndValue() {
+ return this.finishValue;
+ }
+
+
+ public String getValue() {
+ return this.value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/UUIDLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/UUIDLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/UUIDLiteral.java
new file mode 100644
index 0000000..5c6c90d
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/UUIDLiteral.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import java.util.UUID;
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class UUIDLiteral extends Literal<UUID> {
+
+ private UUID value;
+
+
+ /**
+ * @param t
+ */
+ public UUIDLiteral( Token t ) {
+ super( t );
+ value = UUID.fromString( t.getText() );
+ }
+
+
+ public UUIDLiteral( UUID value ) {
+ super( new ClassicToken( 0, String.valueOf( value ) ) );
+ this.value = value;
+ }
+
+
+ public UUID getValue() {
+ return this.value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinOperand.java
new file mode 100644
index 0000000..1891c25
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinOperand.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class WithinOperand extends Operand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public WithinOperand( Token t ) {
+ super( t );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) {
+ visitor.visit( this );
+ }
+
+
+ /**
+ * @param propName
+ */
+ public void setProperty( String propName ) {
+ setChild( 0, new WithinProperty( propName ) );
+ }
+
+
+ /**
+ * @param distance
+ */
+ public void setDistance( float distance ) {
+ setChild( 1, new FloatLiteral( distance ) );
+ }
+
+
+ /**
+ * @param lattitude
+ */
+ public void setLattitude( float lattitude ) {
+ setChild( 2, new FloatLiteral( lattitude ) );
+ }
+
+
+ /**
+ * @param longitude
+ */
+ public void setLongitude( float longitude ) {
+ setChild( 3, new FloatLiteral( longitude ) );
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public WithinProperty getProperty() {
+ return ( WithinProperty ) this.children.get( 0 );
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public NumericLiteral getDistance() {
+ return ( NumericLiteral ) this.children.get( 1 );
+ }
+
+
+ /**
+ * @return
+ */
+ public NumericLiteral getLattitude() {
+ return ( NumericLiteral ) this.children.get( 2 );
+ }
+
+
+ /**
+ * @return
+ */
+ public NumericLiteral getLongitude() {
+ return ( NumericLiteral ) this.children.get( 3 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinProperty.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinProperty.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinProperty.java
new file mode 100644
index 0000000..7a340ab
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinProperty.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/**
+ * A property
+ *
+ * @author tnine
+ */
+public class WithinProperty extends Property {
+
+ private String indexedName = null;
+
+
+ public WithinProperty( Token t ) {
+ super( t );
+ this.indexedName = String.format( "%s.coordinates", super.getValue() );
+ }
+
+
+ public WithinProperty( String property ) {
+ this( new ClassicToken( 0, property ) );
+ }
+
+
+ /** Get the */
+ public String getIndexedName() {
+ return this.indexedName;
+ }
+
+
+ /** @return the property */
+ public WithinProperty getProperty() {
+ return ( WithinProperty ) this.children.get( 0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/AESUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/AESUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/AESUtils.java
new file mode 100644
index 0000000..8b7e6f7
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/AESUtils.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.persistence.utils;
+
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.apache.commons.codec.binary.Base64;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.commons.lang.StringUtils.rightPad;
+import static org.apache.commons.lang.StringUtils.substring;
+
+
+public class AESUtils {
+ private static final Logger LOG = LoggerFactory.getLogger( AESUtils.class );
+
+ private static byte[] linebreak = { };
+ private static Cipher cipher;
+ private static Base64 coder;
+
+
+ static {
+ try {
+ cipher = Cipher.getInstance( "AES/ECB/PKCS5Padding", "SunJCE" );
+ coder = new Base64( 32, linebreak, true );
+ }
+ catch ( Throwable t ) {
+ LOG.error( "Cipher error", t );
+ }
+ }
+
+
+ public static synchronized String encrypt( String secret, String plainText ) {
+ secret = substring( rightPad( secret, 16 ), 0, 16 );
+ SecretKey key = new SecretKeySpec( secret.getBytes(), "AES" );
+ try {
+ cipher.init( Cipher.ENCRYPT_MODE, key );
+ byte[] cipherText = cipher.doFinal( plainText.getBytes() );
+ return new String( coder.encode( cipherText ) );
+ }
+ catch ( Exception e ) {
+ LOG.error( "Encryption error", e );
+ }
+ return null;
+ }
+
+
+ @SuppressWarnings("unused")
+ public static synchronized String decrypt( String secret, String codedText ) {
+ secret = substring( rightPad( secret, 16 ), 0, 16 );
+ SecretKey key = new SecretKeySpec( secret.getBytes(), "AES" );
+ byte[] encypted = coder.decode( codedText.getBytes() );
+ try {
+ cipher.init( Cipher.DECRYPT_MODE, key );
+ byte[] decrypted = cipher.doFinal( encypted );
+ return new String( decrypted );
+ }
+ catch ( Exception e ) {
+ LOG.error( "Decryption error", e );
+ }
+ return null;
+ }
+}
[11/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
new file mode 100644
index 0000000..aab3f79
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
@@ -0,0 +1,1284 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.apache.usergrid.persistence.query.ir.SearchVisitor;
+import static org.apache.usergrid.persistence.query.SimpleEntityRef.ref;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+
+@XmlRootElement
+public class Results implements Iterable<Entity> {
+
+
+ public enum Level {
+ IDS, REFS, CORE_PROPERTIES, ALL_PROPERTIES, LINKED_PROPERTIES
+ }
+
+
+ Level level = Level.IDS;
+ Id id;
+ List<Id> ids;
+ Set<Id> idSet;
+
+ EntityRef ref;
+ List<EntityRef> refs;
+ Map<Id, EntityRef> refsMap;
+ Map<String, List<EntityRef>> refsByType;
+
+ Entity entity;
+ List<Entity> entities;
+ Map<Id, Entity> entitiesMap;
+ Map<String, List<Entity>> entitiesByType;
+
+ List<ConnectionRef> connections;
+ boolean forwardConnections = true;
+
+ List<AggregateCounterSet> counters;
+
+ Set<String> types;
+
+ Map<Id, Map<String, Object>> metadata;
+ boolean metadataMerged = true;
+
+ Id nextResult;
+ String cursor;
+
+ Query query;
+ Object data;
+ String dataName;
+
+ private SearchVisitor searchVisitor;
+
+
+ public Results() {
+ }
+
+
+ public Results( Results r ) {
+ if ( r != null ) {
+ level = r.level;
+
+ id = r.id;
+ ids = r.ids;
+ idSet = r.idSet;
+
+ ref = r.ref;
+ refs = r.refs;
+ refsMap = r.refsMap;
+ refsByType = r.refsByType;
+
+ entity = r.entity;
+ entities = r.entities;
+ entitiesMap = r.entitiesMap;
+ entitiesByType = r.entitiesByType;
+
+ connections = r.connections;
+ forwardConnections = r.forwardConnections;
+
+ counters = r.counters;
+
+ types = r.types;
+
+ metadata = r.metadata;
+ metadataMerged = r.metadataMerged;
+
+ nextResult = r.nextResult;
+ cursor = r.cursor;
+
+ query = r.query;
+ data = r.data;
+ dataName = r.dataName;
+ }
+ }
+
+
+ public void init() {
+ level = Level.IDS;
+
+ id = null;
+ ids = null;
+ idSet = null;
+
+ ref = null;
+ refs = null;
+ refsMap = null;
+ refsByType = null;
+
+ entity = null;
+ entities = null;
+ entitiesMap = null;
+ entitiesByType = null;
+
+ connections = null;
+ forwardConnections = true;
+
+ counters = null;
+
+ types = null;
+
+ // metadata = null;
+ metadataMerged = false;
+
+ query = null;
+ data = null;
+ dataName = null;
+ }
+
+
+ public static Results fromIdList( List<Id> l ) {
+ Results r = new Results();
+ r.setIds( l );
+ return r;
+ }
+
+
+ public static Results fromIdList( List<Id> l, String type ) {
+ if ( type == null ) {
+ return fromIdList( l );
+ }
+ List<EntityRef> refs = new ArrayList<EntityRef>();
+ for ( Id u : l ) {
+ refs.add( ref( u ) );
+ }
+ Results r = new Results();
+ r.setRefs( refs );
+ return r;
+ }
+
+
+ public static Results fromId( Id id ) {
+ Results r = new Results();
+ if ( id != null ) {
+ List<Id> l = new ArrayList<Id>();
+ l.add( id );
+ r.setIds( l );
+ }
+ return r;
+ }
+
+
+ public static Results fromRefList( List<EntityRef> l ) {
+ Results r = new Results();
+ r.setRefs( l );
+ return r;
+ }
+
+
+// public static Results fromEntities( List<? extends Entity> l ) {
+// Results r = new Results();
+// r.setEntities( l );
+// return r;
+// }
+
+
+ public static Results fromEntity( Entity e ) {
+ Results r = new Results();
+ r.setEntity( e );
+ return r;
+ }
+
+
+ public static Results fromRef( EntityRef ref ) {
+ if ( ref instanceof Entity ) {
+ return fromEntity( ( Entity ) ref );
+ }
+ Results r = new Results();
+ r.setRef( ref );
+ return r;
+ }
+
+
+// public static Results fromData( Object obj ) {
+// Results r = new Results();
+// r.setData( obj );
+// return r;
+// }
+//
+//
+// public static Results fromCounters( AggregateCounterSet counters ) {
+// Results r = new Results();
+// List<AggregateCounterSet> l = new ArrayList<AggregateCounterSet>();
+// l.add( counters );
+// r.setCounters( l );
+// return r;
+// }
+//
+//
+// public static Results fromCounters( List<AggregateCounterSet> counters ) {
+// Results r = new Results();
+// r.setCounters( counters );
+// return r;
+// }
+//
+//
+// @SuppressWarnings("unchecked")
+// public static Results fromConnections( List<? extends ConnectionRef> connections ) {
+// Results r = new Results();
+// r.setConnections( ( List<ConnectionRef> ) connections, true );
+// return r;
+// }
+//
+//
+// @SuppressWarnings("unchecked")
+// public static Results fromConnections( List<? extends ConnectionRef> connections, boolean forward ) {
+// Results r = new Results();
+// r.setConnections( ( List<ConnectionRef> ) connections, forward );
+// return r;
+// }
+
+
+ public Level getLevel() {
+ return level;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Query getQuery() {
+ return query;
+ }
+
+
+ public void setQuery( Query query ) {
+ this.query = query;
+ }
+
+
+ public Results withQuery( Query query ) {
+ this.query = query;
+ return this;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Id getId() {
+ if ( id != null ) {
+ return id;
+ }
+ if ( entity != null ) {
+ id = entity.getId();
+ return id;
+ }
+ if ( ( ids != null ) && ( ids.size() > 0 ) ) {
+ id = ids.get( 0 );
+ return id;
+ }
+ if ( ( entities != null ) && ( entities.size() > 0 ) ) {
+ entity = entities.get( 0 );
+ id = entity.getId();
+ return id;
+ }
+ if ( ( refs != null ) && ( refs.size() > 0 ) ) {
+ EntityRef ref = refs.get( 0 );
+ id = ref.getId();
+ }
+ return id;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<Id> getIds() {
+ if ( ids != null ) {
+ return ids;
+ }
+ /*
+ * if (connectionTypeAndEntityTypeToEntityIdMap != null) { ids = new
+ * ArrayList<Id>(); Set<Id> entitySet = new LinkedHashSet<Id>();
+ * for (String ctype : connectionTypeAndEntityTypeToEntityIdMap
+ * .keySet()) { Map<String, List<Id>> m =
+ * connectionTypeAndEntityTypeToEntityIdMap .get(ctype); for (String
+ * etype : m.keySet()) { List<Id> l = m.get(etype); for (Id id : l)
+ * { if (!entitySet.contains(id)) { ids.add(id); } } } } return ids; }
+ */
+ if ( connections != null ) {
+ ids = new ArrayList<Id>();
+ for ( ConnectionRef connection : connections ) {
+ if ( forwardConnections ) {
+ ConnectedEntityRef c = connection.getConnectedEntity();
+ if ( c != null ) {
+ ids.add( c.getId() );
+ }
+ }
+ else {
+ EntityRef c = connection.getConnectingEntity();
+ if ( c != null ) {
+ ids.add( c.getId() );
+ }
+ }
+ }
+ return ids;
+ }
+ if ( ( entities != null )
+ /* || (connectionTypeAndEntityTypeToEntityMap != null) */ ) {
+ // getEntities();
+ ids = new ArrayList<Id>();
+ for ( Entity entity : entities ) {
+ ids.add( entity.getId() );
+ }
+ return ids;
+ }
+ if ( refs != null ) {
+ ids = new ArrayList<Id>();
+ for ( EntityRef ref : refs ) {
+ ids.add( ref.getId() );
+ }
+ return ids;
+ }
+ if ( id != null ) {
+ ids = new ArrayList<Id>();
+ ids.add( id );
+ return ids;
+ }
+ if ( entity != null ) {
+ ids = new ArrayList<Id>();
+ ids.add( entity.getId() );
+ return ids;
+ }
+ return new ArrayList<Id>();
+ }
+
+
+ public void setIds( List<Id> resultsIds ) {
+ init();
+ ids = resultsIds;
+ level = Level.IDS;
+ }
+
+
+ public Results withIds( List<Id> resultsIds ) {
+ setIds( resultsIds );
+ return this;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Set<Id> getIdSet() {
+ if ( idSet != null ) {
+ return idSet;
+ }
+ getIds();
+ if ( ids != null ) {
+ idSet = new LinkedHashSet<Id>();
+ idSet.addAll( ids );
+ return idSet;
+ }
+ return new LinkedHashSet<Id>();
+ }
+
+
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// @SuppressWarnings("unchecked")
+// public List<EntityRef> getRefs() {
+// if ( refs != null ) {
+// return refs;
+// }
+// List<?> l = getEntities();
+// if ( ( l != null ) && ( l.size() > 0 ) ) {
+// return ( List<EntityRef> ) l;
+// }
+// if ( connections != null ) {
+// refs = new ArrayList<EntityRef>();
+// for ( ConnectionRef connection : connections ) {
+// if ( forwardConnections ) {
+// ConnectedEntityRef c = connection.getConnectedEntity();
+// if ( c != null ) {
+// refs.add( c );
+// }
+// }
+// else {
+// EntityRef c = connection.getConnectingEntity();
+// if ( c != null ) {
+// refs.add( c );
+// }
+// }
+// }
+// return refs;
+// }
+// if ( ref != null ) {
+// refs = new ArrayList<EntityRef>();
+// refs.add( ref );
+// return refs;
+// }
+// return new ArrayList<EntityRef>();
+// }
+
+
+ public void setRefs( List<EntityRef> resultsRefs ) {
+ init();
+ refs = resultsRefs;
+ level = Level.REFS;
+ }
+
+
+ public Results withRefs( List<EntityRef> resultsRefs ) {
+ setRefs( resultsRefs );
+ return this;
+ }
+
+
+ public void setRef( EntityRef ref ) {
+ init();
+ this.ref = ref;
+ level = Level.REFS;
+ }
+
+
+ public Results withRef( EntityRef ref ) {
+ setRef( ref );
+ return this;
+ }
+
+
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public EntityRef getRef() {
+// if ( ref != null ) {
+// return ref;
+// }
+// Entity e = getEntity();
+// if ( e != null ) {
+// return ref( e.getId(), e.getVersion() );
+// }
+// Id u = getId();
+// if ( u != null ) {
+// return ref( u );
+// }
+// return null;
+// }
+
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public Map<Id, EntityRef> getRefsMap() {
+// if ( refsMap != null ) {
+// return refsMap;
+// }
+// getEntitiesMap();
+// if ( entitiesMap != null ) {
+// refsMap = cast( entitiesMap );
+// return refsMap;
+// }
+// getRefs();
+// if ( refs != null ) {
+// refsMap = new LinkedHashMap<Id, EntityRef>();
+// for ( EntityRef ref : refs ) {
+// refsMap.put( ref.getId(), ref );
+// }
+// }
+// return refsMap;
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public Entity getEntity() {
+// mergeEntitiesWithMetadata();
+// if ( entity != null ) {
+// return entity;
+// }
+// if ( ( entities != null ) && ( entities.size() > 0 ) ) {
+// entity = entities.get( 0 );
+// return entity;
+// }
+// return null;
+// }
+
+
+ public void setEntity( Entity resultEntity ) {
+ init();
+ entity = resultEntity;
+ level = Level.CORE_PROPERTIES;
+ }
+
+
+ public Results withEntity( Entity resultEntity ) {
+ setEntity( resultEntity );
+ return this;
+ }
+
+
+ public Iterator<Id> idIterator() {
+ List<Id> l = getIds();
+ if ( l != null ) {
+ return l.iterator();
+ }
+ return ( new ArrayList<Id>( 0 ) ).iterator();
+ }
+
+
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public List<Entity> getEntities() {
+// mergeEntitiesWithMetadata();
+// if ( entities != null ) {
+// return entities;
+// }
+// /*
+// * if (connectionTypeAndEntityTypeToEntityMap != null) { entities = new
+// * ArrayList<Entity>(); Map<Id, Entity> eMap = new LinkedHashMap<Id,
+// * Entity>(); for (String ctype :
+// * connectionTypeAndEntityTypeToEntityMap.keySet()) { Map<String,
+// * List<Entity>> m = connectionTypeAndEntityTypeToEntityMap .get(ctype);
+// * for (String etype : m.keySet()) { List<Entity> l = m.get(etype); for
+// * (Entity e : l) { if (!eMap.containsKey(e.getUuid())) { entities.add(e);
+// * eMap.put(e.getUuid(), e); } } } } return entities; }
+// */
+// if ( entity != null ) {
+// entities = new ArrayList<Entity>();
+// entities.add( entity );
+// return entities;
+// }
+// return new ArrayList<Entity>();
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public Map<Id, Entity> getEntitiesMap() {
+// if ( entitiesMap != null ) {
+// return entitiesMap;
+// }
+// if ( entities != null ) {
+// entitiesMap = new LinkedHashMap<Id, Entity>();
+// for ( Entity entity : entities ) {
+// entitiesMap.put( entity.getId(), entity );
+// }
+// }
+// return entitiesMap;
+// }
+//
+//
+// public List<EntityRef> getEntityRefsByType( String type ) {
+// if ( entitiesByType != null ) {
+// return refsByType.get( type );
+// }
+// List<EntityRef> l = cast( getEntitiesByType( type ) );
+// if ( l != null ) {
+// return l;
+// }
+// getRefs();
+// if ( refs == null ) {
+// return null;
+// }
+// refsByType = new LinkedHashMap<String, List<EntityRef>>();
+// for ( Entity entity : entities ) {
+// l = refsByType.get( entity.getId().getType() );
+// if ( l == null ) {
+// l = new ArrayList<EntityRef>();
+// refsByType.put( entity.getId().getType(), l );
+// }
+// l.add( entity );
+// }
+// return l;
+// }
+//
+//
+// public List<Entity> getEntitiesByType( String type ) {
+// if ( entitiesByType != null ) {
+// return entitiesByType.get( type );
+// }
+// getEntities();
+// if ( entities == null ) {
+// return null;
+// }
+// List<Entity> l = null;
+// entitiesByType = new LinkedHashMap<String, List<Entity>>();
+// for ( Entity entity : entities ) {
+// l = entitiesByType.get( entity.getType() );
+// if ( l == null ) {
+// l = new ArrayList<Entity>();
+// entitiesByType.put( entity.getType(), l );
+// }
+// l.add( entity );
+// }
+// return l;
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public Set<String> getTypes() {
+// if ( types != null ) {
+// return types;
+// }
+// getEntityRefsByType( "entity" );
+// if ( entitiesByType != null ) {
+// types = entitiesByType.keySet();
+// }
+// else if ( refsByType != null ) {
+// types = refsByType.keySet();
+// }
+// return types;
+// }
+//
+//
+// public void merge( Results results ) {
+// getEntitiesMap();
+// results.getEntitiesMap();
+// if ( entitiesMap != null || results.entitiesMap != null ) {
+//
+// level = Level.ALL_PROPERTIES;
+//
+// // do nothing, nothing to union
+// if ( entitiesMap != null && results.entitiesMap == null ) {
+// return;
+// // other side has the results, assign and return
+// }
+// else if ( entitiesMap == null && results.entitiesMap != null ) {
+// entities = results.entities;
+// return;
+// }
+//
+// entitiesMap.putAll( results.entitiesMap );
+// entities = new ArrayList<Entity>( entitiesMap.values() );
+//
+// return;
+// }
+//
+// getRefsMap();
+// results.getRefsMap();
+// if ( ( refsMap != null ) || ( results.refsMap != null ) ) {
+//
+// level = Level.REFS;
+//
+// // do nothing, nothing to union
+// if ( refsMap != null && results.refsMap == null ) {
+// return;
+// // other side has the results, assign and return
+// }
+// else if ( refsMap == null && results.refsMap != null ) {
+// refs = results.refs;
+// return;
+// }
+//
+// refsMap.putAll( results.refsMap );
+// refs = new ArrayList<EntityRef>( refsMap.values() );
+//
+// return;
+// }
+//
+// getIdSet();
+// results.getIdSet();
+// if ( ( idSet != null ) && ( results.idSet != null ) ) {
+//
+// level = Level.IDS;
+//
+// // do nothing, nothing to union
+// if ( idSet != null && results.idSet == null ) {
+// return;
+// // other side has the results, assign and return
+// }
+// else if ( idSet == null && results.idSet != null ) {
+// ids = results.ids;
+// return;
+// }
+//
+// idSet.addAll( results.idSet );
+// ids = new ArrayList<Id>( idSet );
+//
+// return;
+// }
+// }
+//
+//
+// /** Remove the passed in results from the current results */
+// public void subtract( Results results ) {
+// getEntitiesMap();
+// results.getEntitiesMap();
+//
+// if ( ( entitiesMap != null ) && ( results.entitiesMap != null ) ) {
+// Map<Id, Entity> newMap = new LinkedHashMap<Id, Entity>();
+// for ( Map.Entry<Id, Entity> e : entitiesMap.entrySet() ) {
+// if ( !results.entitiesMap.containsKey( e.getKey() ) ) {
+// newMap.put( e.getKey(), e.getValue() );
+// }
+// }
+// entitiesMap = newMap;
+// entities = new ArrayList<Entity>( entitiesMap.values() );
+// level = Level.ALL_PROPERTIES;
+// return;
+// }
+//
+// getRefsMap();
+// results.getRefsMap();
+// if ( ( refsMap != null ) && ( results.refsMap != null ) ) {
+// Map<Id, EntityRef> newMap = new LinkedHashMap<Id, EntityRef>();
+// for ( Map.Entry<Id, EntityRef> e : refsMap.entrySet() ) {
+// if ( !results.refsMap.containsKey( e.getKey() ) ) {
+// newMap.put( e.getKey(), e.getValue() );
+// }
+// }
+// refsMap = newMap;
+// refs = new ArrayList<EntityRef>( refsMap.values() );
+// level = Level.REFS;
+// return;
+// }
+//
+// getIdSet();
+// results.getIdSet();
+// if ( ( idSet != null ) && ( results.idSet != null ) ) {
+// Set<Id> newSet = new LinkedHashSet<Id>();
+// for ( Id uuid : idSet ) {
+// if ( !results.idSet.contains( uuid ) ) {
+// newSet.add( uuid );
+// }
+// }
+// idSet = newSet;
+// ids = new ArrayList<Id>( idSet );
+// level = Level.IDS;
+// return;
+// }
+// }
+//
+//
+// /** Perform an intersection of the 2 results */
+// public void and( Results results ) {
+// getEntitiesMap();
+// results.getEntitiesMap();
+//
+// if ( ( entitiesMap != null ) && ( results.entitiesMap != null ) ) {
+// Map<Id, Entity> newMap = new LinkedHashMap<Id, Entity>();
+// for ( Map.Entry<Id, Entity> e : entitiesMap.entrySet() ) {
+// if ( results.entitiesMap.containsKey( e.getKey() ) ) {
+// newMap.put( e.getKey(), e.getValue() );
+// }
+// }
+// entitiesMap = newMap;
+// entities = new ArrayList<Entity>( entitiesMap.values() );
+// level = Level.ALL_PROPERTIES;
+// return;
+// }
+//
+// getRefsMap();
+// results.getRefsMap();
+// if ( ( refsMap != null ) && ( results.refsMap != null ) ) {
+// Map<Id, EntityRef> newMap = new LinkedHashMap<Id, EntityRef>();
+// for ( Map.Entry<Id, EntityRef> e : refsMap.entrySet() ) {
+// if ( results.refsMap.containsKey( e.getKey() ) ) {
+// newMap.put( e.getKey(), e.getValue() );
+// }
+// }
+// refsMap = newMap;
+// refs = new ArrayList<EntityRef>( refsMap.values() );
+// level = Level.REFS;
+// ids = null;
+// return;
+// }
+//
+// getIdSet();
+// results.getIdSet();
+// if ( ( idSet != null ) && ( results.idSet != null ) ) {
+// Set<Id> newSet = new LinkedHashSet<Id>();
+// for ( Id uuid : idSet ) {
+// if ( results.idSet.contains( uuid ) ) {
+// newSet.add( uuid );
+// }
+// }
+// idSet = newSet;
+// ids = new ArrayList<Id>( idSet );
+// level = Level.IDS;
+// return;
+// }
+//
+// // should be empty
+// init();
+// }
+//
+//
+// public void replace( Entity entity ) {
+// entitiesMap = null;
+// if ( ( this.entity != null ) && ( this.entity.getUuid().equals( entity.getUuid() ) ) ) {
+// this.entity = entity;
+// }
+// if ( entities != null ) {
+// ListIterator<Entity> i = entities.listIterator();
+// while ( i.hasNext() ) {
+// Entity e = i.next();
+// if ( e.getUuid().equals( entity.getUuid() ) ) {
+// i.set( entity );
+// }
+// }
+// }
+// }
+//
+//
+// public Results startingFrom( Id entityId ) {
+// if ( entities != null ) {
+// for ( int i = 0; i < entities.size(); i++ ) {
+// Entity entity = entities.get( i );
+// if ( entityId.equals( entity.getUuid() ) ) {
+// if ( i == 0 ) {
+// return this;
+// }
+// return Results.fromEntities( entities.subList( i, entities.size() ) );
+// }
+// }
+// }
+// if ( refs != null ) {
+// for ( int i = 0; i < refs.size(); i++ ) {
+// EntityRef entityRef = refs.get( i );
+// if ( entityId.equals( entityRef.getUuid() ) ) {
+// if ( i == 0 ) {
+// return this;
+// }
+// return Results.fromRefList( refs.subList( i, refs.size() ) );
+// }
+// }
+// }
+// if ( ids != null ) {
+// for ( int i = 0; i < ids.size(); i++ ) {
+// Id uuid = ids.get( i );
+// if ( entityId.equals( uuid ) ) {
+// if ( i == 0 ) {
+// return this;
+// }
+// return Results.fromIdList( ids.subList( i, ids.size() ) );
+// }
+// }
+// }
+// return this;
+// }
+//
+//
+// @SuppressWarnings("unchecked")
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public <E extends Entity> List<E> getList() {
+// List<Entity> l = getEntities();
+// return ( List<E> ) l;
+// }
+//
+//
+// public <E extends Entity> Iterator<E> iterator( Class<E> cls ) {
+// List<E> l = getList();
+// if ( l != null ) {
+// return l.iterator();
+// }
+// return ( new ArrayList<E>( 0 ) ).iterator();
+// }
+//
+
+ @Override
+ public Iterator<Entity> iterator() {
+ List<Entity> l = null; // getEntities();
+ if ( l != null ) {
+ return l.iterator();
+ }
+ return ( new ArrayList<Entity>( 0 ) ).iterator();
+ }
+
+//
+// public Results findForProperty( String propertyName, Object propertyValue ) {
+// return findForProperty( propertyName, propertyValue, 1 );
+// }
+//
+//
+// public Results findForProperty( String propertyName, Object propertyValue, int count ) {
+// if ( propertyValue == null ) {
+// return new Results();
+// }
+// List<Entity> l = getEntities();
+// if ( l == null ) {
+// return new Results();
+// }
+// List<Entity> found = new ArrayList<Entity>();
+// for ( Entity e : l ) {
+// if ( propertyValue.equals( e.getProperty( propertyName ) ) ) {
+// found.add( e );
+// if ( ( count > 0 ) && ( found.size() == count ) ) {
+// break;
+// }
+// }
+// }
+// return Results.fromEntities( found );
+// }
+//
+//
+// @SuppressWarnings("unchecked")
+// public void setEntities( List<? extends Entity> resultsEntities ) {
+// init();
+// entities = ( List<Entity> ) resultsEntities;
+// level = Level.CORE_PROPERTIES;
+// }
+//
+//
+// public Results withEntities( List<? extends Entity> resultsEntities ) {
+// setEntities( resultsEntities );
+// return this;
+// }
+//
+//
+// public boolean hasConnections() {
+// return connections != null;
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public List<ConnectionRef> getConnections() {
+// return connections;
+// }
+//
+//
+// private void setConnections( List<ConnectionRef> connections, boolean forwardConnections ) {
+// init();
+// this.connections = connections;
+// this.forwardConnections = forwardConnections;
+// level = Level.REFS;
+// for ( ConnectionRef connection : connections ) {
+// if ( forwardConnections ) {
+// this.setMetadata( connection.getConnectedEntity().getUuid(), "connection",
+// connection.getConnectionType() );
+// }
+// else {
+// this.setMetadata( connection.getConnectingEntity().getUuid(), "connection",
+// connection.getConnectionType() );
+// }
+// }
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public Object getObject() {
+// if ( data != null ) {
+// return data;
+// }
+// if ( entities != null ) {
+// return entities;
+// }
+// if ( ids != null ) {
+// return ids;
+// }
+// if ( entity != null ) {
+// return entity;
+// }
+// if ( id != null ) {
+// return id;
+// }
+// if ( counters != null ) {
+// return counters;
+// }
+// return null;
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public String getObjectName() {
+// if ( dataName != null ) {
+// return dataName;
+// }
+// if ( entities != null ) {
+// return "entities";
+// }
+// if ( ids != null ) {
+// return "ids";
+// }
+// if ( entity != null ) {
+// return "entity";
+// }
+// if ( id != null ) {
+// return "id";
+// }
+// return null;
+// }
+//
+//
+// public void setDataName( String dataName ) {
+// this.dataName = dataName;
+// }
+//
+//
+// public Results withDataName( String dataName ) {
+// this.dataName = dataName;
+// return this;
+// }
+//
+//
+// public boolean hasData() {
+// return data != null;
+// }
+//
+//
+// public void setData( Object data ) {
+// this.data = data;
+// }
+//
+//
+// public Results withData( Object data ) {
+// this.data = data;
+// return this;
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public Object getData() {
+// return data;
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public List<AggregateCounterSet> getCounters() {
+// return counters;
+// }
+//
+//
+// public void setCounters( List<AggregateCounterSet> counters ) {
+// this.counters = counters;
+// }
+//
+//
+// public Results withCounters( List<AggregateCounterSet> counters ) {
+// this.counters = counters;
+// return this;
+// }
+//
+//
+// public int size() {
+// if ( entities != null ) {
+// return entities.size();
+// }
+// if ( refs != null ) {
+// return refs.size();
+// }
+// if ( ids != null ) {
+// return ids.size();
+// }
+// if ( entity != null ) {
+// return 1;
+// }
+// if ( ref != null ) {
+// return 1;
+// }
+// if ( id != null ) {
+// return 1;
+// }
+// return 0;
+// }
+//
+//
+// public boolean isEmpty() {
+// return size() == 0;
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public Id getNextResult() {
+// return nextResult;
+// }
+//
+//
+// public Results excludeCursorMetadataAttribute() {
+// if ( metadata != null ) {
+// for ( Entry<Id, Map<String, Object>> entry : metadata.entrySet() ) {
+// Map<String, Object> map = entry.getValue();
+// if ( map != null ) {
+// map.remove( Schema.PROPERTY_CURSOR );
+// }
+// }
+// }
+// return new Results( this );
+// }
+//
+//
+// public Results trim( int count ) {
+// if ( count == 0 ) {
+// return this;
+// }
+//
+// int size = size();
+// if ( size <= count ) {
+// return this;
+// }
+//
+// List<Id> ids = getIds();
+// Id nextResult = null;
+// String cursor = null;
+// if ( ids.size() > count ) {
+// nextResult = ids.get( count );
+// ids = ids.subList( 0, count );
+// if ( metadata != null ) {
+// cursor = StringUtils.toString( MapUtils.getMapMap( metadata, nextResult, "cursor" ) );
+// }
+// if ( cursor == null ) {
+// cursor = encodeBase64URLSafeString( bytes( nextResult ) );
+// }
+// }
+//
+// Results r = new Results( this );
+// if ( r.entities != null ) {
+// r.entities = r.entities.subList( 0, count );
+// }
+// if ( r.refs != null ) {
+// r.refs = r.refs.subList( 0, count );
+// }
+// if ( r.ids != null ) {
+// r.ids = r.ids.subList( 0, count );
+// }
+// r.setNextResult( nextResult );
+// r.setCursor( cursor );
+//
+// return r;
+// }
+//
+//
+// public boolean hasMoreResults() {
+// return nextResult != null;
+// }
+//
+//
+// public void setNextResult( Id nextResult ) {
+// this.nextResult = nextResult;
+// }
+//
+//
+// public Results withNextResult( Id nextResult ) {
+// this.nextResult = nextResult;
+// return this;
+// }
+//
+//
+// @JsonSerialize(include = Inclusion.NON_NULL)
+// public String getCursor() {
+// return cursor;
+// }
+//
+//
+// public boolean hasCursor() {
+// return cursor != null && cursor.length() > 0;
+// }
+//
+//
+// public void setCursor( String cursor ) {
+// this.cursor = cursor;
+// }
+//
+//
+// public Results withCursor( String cursor ) {
+// this.cursor = cursor;
+// return this;
+// }
+//
+//
+// public void setMetadata( Id id, String name, Object value ) {
+// if ( metadata == null ) {
+// metadata = new LinkedHashMap<Id, Map<String, Object>>();
+// }
+// Map<String, Object> entityMetadata = metadata.get( id );
+// if ( entityMetadata == null ) {
+// entityMetadata = new LinkedHashMap<String, Object>();
+// metadata.put( id, entityMetadata );
+// }
+// entityMetadata.put( name, value );
+// metadataMerged = false;
+// // updateIndex(id, name, value);
+// }
+//
+//
+// public Results withMetadata( Id id, String name, Object value ) {
+// setMetadata( id, name, value );
+// return this;
+// }
+//
+//
+// public void setMetadata( Id id, Map<String, Object> data ) {
+// if ( metadata == null ) {
+// metadata = new LinkedHashMap<Id, Map<String, Object>>();
+// }
+// Map<String, Object> entityMetadata = metadata.get( id );
+// if ( entityMetadata == null ) {
+// entityMetadata = new LinkedHashMap<String, Object>();
+// metadata.put( id, entityMetadata );
+// }
+// entityMetadata.putAll( data );
+// metadataMerged = false;
+// /*
+// * for (Entry<String, Object> m : data.entrySet()) { updateIndex(id,
+// * m.getKey(), m.getValue()); }
+// */
+// }
+//
+//
+// public Results withMetadata( Id id, Map<String, Object> data ) {
+// setMetadata( id, data );
+// return this;
+// }
+//
+//
+// public void setMetadata( Map<Id, Map<String, Object>> metadata ) {
+// this.metadata = metadata;
+// }
+//
+//
+// public Results withMetadata( Map<Id, Map<String, Object>> metadata ) {
+// this.metadata = metadata;
+// return this;
+// }
+//
+//
+// public void mergeEntitiesWithMetadata() {
+// if ( metadataMerged ) {
+// return;
+// }
+// if ( metadata == null ) {
+// return;
+// }
+// metadataMerged = true;
+// getEntities();
+// if ( entities != null ) {
+// for ( Entity entity : entities ) {
+// entity.clearMetadata();
+// Map<String, Object> entityMetadata = metadata.get( entity.getUuid() );
+// if ( entityMetadata != null ) {
+// entity.mergeMetadata( entityMetadata );
+// }
+// }
+// }
+// }
+//
+//
+// protected QueryProcessor getQueryProcessor() {
+// return queryProcessor;
+// }
+//
+//
+// public void setQueryProcessor( QueryProcessor queryProcessor ) {
+// this.queryProcessor = queryProcessor;
+// }
+//
+//
+// public void setSearchVisitor( SearchVisitor searchVisitor ) {
+// this.searchVisitor = searchVisitor;
+// }
+//
+//
+// /** uses cursor to get next batch of Results (returns null if no cursor) */
+// public Results getNextPageResults() throws Exception {
+// if ( !hasCursor() ) {
+// return null;
+// }
+//
+// Query q = new Query( query );
+// q.setCursor( getCursor() );
+// queryProcessor.setQuery( q );
+//
+// return queryProcessor.getResults( searchVisitor );
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/SimpleEntityRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/SimpleEntityRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/SimpleEntityRef.java
new file mode 100644
index 0000000..57d1d4b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/SimpleEntityRef.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+import java.util.UUID;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+
+public class SimpleEntityRef implements EntityRef {
+
+ private final Id id;
+
+ private final UUID version;
+
+
+ public SimpleEntityRef( Id id, UUID version ) {
+ this.id = id;
+ this.version = version;
+ }
+
+
+ public SimpleEntityRef( EntityRef entityRef ) {
+ this.id = entityRef.getId();
+ this.version = entityRef.getVersion();
+ }
+
+
+ public static EntityRef ref() {
+ return new SimpleEntityRef( null, null );
+ }
+
+ public static EntityRef ref( Id id ) {
+ return new SimpleEntityRef( id, null );
+ }
+
+ public static EntityRef ref( Id id, UUID version ) {
+ return new SimpleEntityRef( id, version );
+ }
+
+
+ public static EntityRef ref( EntityRef ref ) {
+ return new SimpleEntityRef( ref );
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( id == null ) ? 0 : id.hashCode() );
+ result = prime * result + ( ( version == null ) ? 0 : version.hashCode() );
+ return result;
+ }
+
+
+ @Override
+ public boolean equals( Object obj ) {
+ if ( this == obj ) {
+ return true;
+ }
+ if ( obj == null ) {
+ return false;
+ }
+ if ( getClass() != obj.getClass() ) {
+ return false;
+ }
+ SimpleEntityRef other = ( SimpleEntityRef ) obj;
+ if ( id == null ) {
+ if ( other.id != null ) {
+ return false;
+ }
+ }
+ else if ( !id.equals( other.id ) ) {
+ return false;
+ }
+ if ( version == null ) {
+ if ( other.version != null ) {
+ return false;
+ }
+ }
+ else if ( !version.equals( other.version ) ) {
+ return false;
+ }
+ return true;
+ }
+
+
+ @Override
+ public String toString() {
+ return id.toString() + "|" + version.toString();
+ }
+
+ public static Id getId( EntityRef ref ) {
+ if ( ref == null ) {
+ return null;
+ }
+ return ref.getId();
+ }
+
+
+ public static String getType( EntityRef ref ) {
+ if ( ref == null ) {
+ return null;
+ }
+ return ref.getId().getType();
+ }
+
+ public Id getId() {
+ return id;
+ }
+
+ public UUID getVersion() {
+ return version;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/AllNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/AllNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/AllNode.java
new file mode 100644
index 0000000..e408552
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/AllNode.java
@@ -0,0 +1,45 @@
+package org.apache.usergrid.persistence.query.ir;
+
+
+/**
+ * Used to represent a "select all". This will iterate over the entities by UUID
+ *
+ * @author tnine
+ */
+public class AllNode extends QueryNode {
+
+
+ private final boolean forceKeepFirst;
+
+
+ /**
+ * Note that the slice isn't used on select, but is used when creating cursors
+ *
+ * @param id. The unique numeric id for this node
+ * @param forceKeepFirst True if we don't allow the iterator to skip the first result, regardless of cursor state.
+ * Used for startUUID paging
+ */
+ public AllNode( int id, boolean forceKeepFirst ) {
+ this.forceKeepFirst = forceKeepFirst;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.ir.QueryNode#visit(org.apache.usergrid.persistence.query.ir.NodeVisitor)
+ */
+ @Override
+ public void visit( NodeVisitor visitor ) throws Exception {
+ visitor.visit( this );
+ }
+
+
+ @Override
+ public String toString() {
+ return "AllNode";
+ }
+
+ /** @return the skipFirstMatch */
+ public boolean isForceKeepFirst() {
+ return forceKeepFirst;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/AndNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/AndNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/AndNode.java
new file mode 100644
index 0000000..3e889b2
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/AndNode.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.ir;
+
+
+/**
+ * Node where the results need intersected. Used instead of a SliceNode when one of the children is an operation other
+ * than slices. I.E OR, NOT etc
+ *
+ * @author tnine
+ */
+public class AndNode extends BooleanNode {
+
+ /**
+ * @param left
+ * @param right
+ */
+ public AndNode( QueryNode left, QueryNode right ) {
+ super( left, right );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.ir.QueryNode#visit(org.apache.usergrid.persistence.query.ir.NodeVisitor)
+ */
+ @Override
+ public void visit( NodeVisitor visitor ) throws Exception {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/BooleanNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/BooleanNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/BooleanNode.java
new file mode 100644
index 0000000..e4eb813
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/BooleanNode.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.ir;
+
+
+/** @author tnine */
+public abstract class BooleanNode extends QueryNode {
+
+ protected QueryNode left;
+ protected QueryNode right;
+
+
+ public BooleanNode( QueryNode left, QueryNode right ) {
+ this.left = left;
+ this.right = right;
+ }
+
+
+ /** @return the left */
+ public QueryNode getLeft() {
+ return left;
+ }
+
+
+ /** @return the right */
+ public QueryNode getRight() {
+ return right;
+ }
+
+
+ @Override
+ public String toString() {
+ return "BooleanNode [left=" + left + ", right=" + right + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/EmailIdentifierNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/EmailIdentifierNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/EmailIdentifierNode.java
new file mode 100644
index 0000000..ef95d1a
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/EmailIdentifierNode.java
@@ -0,0 +1,28 @@
+package org.apache.usergrid.persistence.query.ir;
+
+
+/**
+ * Class to represent a UUID based Identifier query
+ *
+ * @author tnine
+ */
+public class EmailIdentifierNode extends QueryNode {
+
+ private final String identifier;
+
+
+ public EmailIdentifierNode( String identifier ) {
+ this.identifier = identifier;
+ }
+
+
+ @Override
+ public void visit( NodeVisitor visitor ) throws Exception {
+ visitor.visit( this );
+ }
+
+
+ public String getIdentifier() {
+ return identifier;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NameIdentifierNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NameIdentifierNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NameIdentifierNode.java
new file mode 100644
index 0000000..9b6f2e0
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NameIdentifierNode.java
@@ -0,0 +1,28 @@
+package org.apache.usergrid.persistence.query.ir;
+
+
+/**
+ * Class to represent a UUID based Identifier query
+ *
+ * @author tnine
+ */
+public class NameIdentifierNode extends QueryNode {
+
+ private final String name;
+
+
+ public NameIdentifierNode( String name ) {
+ this.name = name;
+ }
+
+
+ @Override
+ public void visit( NodeVisitor visitor ) throws Exception {
+ visitor.visit( this );
+ }
+
+
+ public String getName() {
+ return name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NodeVisitor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NodeVisitor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NodeVisitor.java
new file mode 100644
index 0000000..2cad64e
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NodeVisitor.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.ir;
+
+
+/** @author tnine */
+public interface NodeVisitor {
+
+ /**
+ *
+ * @param node
+ * @throws Exception
+ */
+ public void visit( AndNode node ) throws Exception;
+
+ /**
+ *
+ * @param node
+ * @throws Exception
+ */
+ public void visit( NotNode node ) throws Exception;
+
+ /**
+ *
+ * @param node
+ * @throws Exception
+ */
+ public void visit( OrNode node ) throws Exception;
+
+ /**
+ *
+ * @param node
+ * @throws Exception
+ */
+ public void visit( WithinNode node ) throws Exception;
+
+ /**
+ *
+ * @param node
+ * @throws Exception
+ */
+ public void visit( AllNode node ) throws Exception;
+
+ /** Visit the name identifier node */
+ public void visit( NameIdentifierNode nameIdentifierNode ) throws Exception;
+
+ /** Visit the uuid identifier node */
+ public void visit( UuidIdentifierNode uuidIdentifierNode );
+
+ /**
+ * @param orderByNode
+ * @throws Exception
+ */
+ public void visit( OrderByNode orderByNode ) throws Exception;
+
+ /** Visit the email id node */
+ public void visit( EmailIdentifierNode emailIdentifierNode ) throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NotNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NotNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NotNode.java
new file mode 100644
index 0000000..e8d037d
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/NotNode.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.ir;
+
+
+/** @author tnine */
+public class NotNode extends QueryNode {
+
+ protected QueryNode subtractNode, keepNode;
+
+
+ /** @param keepNode may be null if there are parents to this */
+ public NotNode( QueryNode subtractNode, QueryNode keepNode ) {
+ this.subtractNode = subtractNode;
+ this.keepNode = keepNode;
+// throw new RuntimeException( "I'm a not node" );
+ }
+
+
+ /** @return the child */
+ public QueryNode getSubtractNode() {
+ return subtractNode;
+ }
+
+
+ /** @return the all */
+ public QueryNode getKeepNode() {
+ return keepNode;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.ir.QueryNode#visit(org.apache.usergrid.persistence
+ * .query.ir.NodeVisitor)
+ */
+ @Override
+ public void visit( NodeVisitor visitor ) throws Exception {
+ visitor.visit( this );
+ }
+
+
+ @Override
+ public String toString() {
+ return "NotNode [child=" + subtractNode + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/OrNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/OrNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/OrNode.java
new file mode 100644
index 0000000..2ce0b65
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/OrNode.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.ir;
+
+
+/**
+ * @author tnine
+ */
+public class OrNode extends BooleanNode {
+
+ private final int id;
+
+
+ /**
+ * @param left
+ * @param right
+ */
+ public OrNode( QueryNode left, QueryNode right, int id ) {
+ super( left, right );
+ this.id = id;
+ }
+
+
+ /**
+ * Get the context id
+ */
+ public int getId() {
+ return this.id;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.ir.QueryNode#visit(org.apache.usergrid.persistence.query.ir.NodeVisitor)
+ */
+ @Override
+ public void visit( NodeVisitor visitor ) throws Exception {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/OrderByNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/OrderByNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/OrderByNode.java
new file mode 100644
index 0000000..c3ae763
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/OrderByNode.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.ir;
+
+
+import java.util.List;
+
+import org.apache.usergrid.persistence.query.Query.SortPredicate;
+
+
+/**
+ * Intermediate representation of ordering operations
+ *
+ * @author tnine
+ */
+public class OrderByNode extends QueryNode {
+
+
+ private final List<SortPredicate> secondarySorts;
+ private final QueryNode queryOperations;
+
+
+ /**
+ * @param firstPredicate The first predicate that is in the order by statement
+ * @param secondarySorts Any subsequent terms
+ * @param queryOperations The subtree for boolean evaluation
+ */
+ public OrderByNode( List<SortPredicate> secondarySorts, QueryNode queryOperations ) {
+ this.secondarySorts = secondarySorts;
+ this.queryOperations = queryOperations;
+ }
+
+
+ /** @return the sorts */
+ public List<SortPredicate> getSecondarySorts() {
+ return secondarySorts;
+ }
+
+
+ public QueryNode getQueryOperations() {
+ return queryOperations;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.ir.QueryNode#visit(org.apache.usergrid.persistence
+ * .query.ir.NodeVisitor)
+ */
+ @Override
+ public void visit( NodeVisitor visitor ) throws Exception {
+ visitor.visit( this );
+ }
+
+
+ /** Return true if this order has secondary sorts */
+ public boolean hasSecondarySorts() {
+ return secondarySorts != null && secondarySorts.size() > 0;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "OrderByNode [sorts=" + secondarySorts + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/QueryNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/QueryNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/QueryNode.java
new file mode 100644
index 0000000..f6881f0
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/QueryNode.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.ir;
+
+
+/**
+ * The visit the node
+ *
+ * @author tnine
+ */
+public abstract class QueryNode {
+
+ /** Visit this node */
+ public abstract void visit( NodeVisitor visitor ) throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/SearchVisitor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/SearchVisitor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/SearchVisitor.java
new file mode 100644
index 0000000..f040119
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/SearchVisitor.java
@@ -0,0 +1,68 @@
+package org.apache.usergrid.persistence.query.ir;
+
+import org.apache.usergrid.persistence.query.Query;
+
+/**
+ * Simple search visitor that builds query string.
+ */
+public abstract class SearchVisitor implements NodeVisitor {
+ protected final Query query;
+
+
+ public SearchVisitor( Query query ) {
+ this.query = query;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.usergrid.persistence.query.ir.NodeVisitor#visit(org.apache.usergrid.
+ * persistence.query.ir.AndNode)
+ */
+ @Override
+ public void visit( AndNode node ) throws Exception {
+ node.getLeft().visit( this );
+ node.getRight().visit( this );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.usergrid.persistence.query.ir.NodeVisitor#visit(org.apache.usergrid.
+ * persistence.query.ir.NotNode)
+ */
+ @Override
+ public void visit( NotNode node ) throws Exception {
+ node.getSubtractNode().visit( this );
+ node.getKeepNode().visit( this );
+
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.usergrid.persistence.query.ir.NodeVisitor#visit(org.apache.usergrid.
+ * persistence.query.ir.OrNode)
+ */
+ @Override
+ public void visit( OrNode node ) throws Exception {
+ node.getLeft().visit( this );
+ node.getRight().visit( this );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.ir.NodeVisitor#visit(org.apache.usergrid.persistence
+ * .query.ir.OrderByNode)
+ */
+ @Override
+ public void visit( OrderByNode orderByNode ) throws Exception {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/UuidIdentifierNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/UuidIdentifierNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/UuidIdentifierNode.java
new file mode 100644
index 0000000..ce7ffa8
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/UuidIdentifierNode.java
@@ -0,0 +1,32 @@
+package org.apache.usergrid.persistence.query.ir;
+
+
+import java.util.UUID;
+
+
+/**
+ * Class to represent a UUID based Identifier query
+ *
+ * @author tnine
+ */
+public class UuidIdentifierNode extends QueryNode {
+
+
+ private final UUID uuid;
+
+
+ public UuidIdentifierNode( UUID uuid ) {
+ this.uuid = uuid;
+ }
+
+
+ @Override
+ public void visit( NodeVisitor visitor ) throws Exception {
+ visitor.visit( this );
+ }
+
+
+ public UUID getUuid() {
+ return uuid;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/WithinNode.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/WithinNode.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/WithinNode.java
new file mode 100644
index 0000000..c44caf9
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/ir/WithinNode.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.ir;
+
+
+/**
+ * Intermediate represnetation of the within operator
+ *
+ * @author tnine
+ */
+public class WithinNode extends QueryNode {
+
+ private final String propertyName;
+ private final float distance;
+ private final float lattitude;
+ private final float longitude;
+
+
+ /**
+ * @param propertyName
+ * @param distance
+ * @param lattitude
+ * @param longitude
+ */
+ public WithinNode( String propertyName, float distance, float lattitude, float longitude, int nodeId ) {
+ this.propertyName = propertyName;
+ this.distance = distance;
+ this.lattitude = lattitude;
+ this.longitude = longitude;
+ }
+
+
+ /** @return the propertyName */
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+
+ /** @return the distance */
+ public float getDistance() {
+ return distance;
+ }
+
+
+ /** @return the lattitude */
+ public float getLattitude() {
+ return lattitude;
+ }
+
+
+ /** @return the longitude */
+ public float getLongitude() {
+ return longitude;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.ir.QueryNode#visit(org.apache.usergrid.persistence
+ * .query.ir.NodeVisitor)
+ */
+ @Override
+ public void visit( NodeVisitor visitor ) throws Exception {
+ visitor.visit( this );
+ }
+
+
+ @Override
+ public String toString() {
+ return "WithinNode [propertyName=" + propertyName + ", distance=" + distance + ", lattitude=" + lattitude
+ + ", longitude=" + longitude + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/AndOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/AndOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/AndOperand.java
new file mode 100644
index 0000000..e4c82ed
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/AndOperand.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.exceptions.PersistenceException;
+
+
+/** @author tnine */
+public class AndOperand extends BooleanOperand {
+
+ public AndOperand() {
+ super( new CommonToken( 0, "and" ) );
+ }
+
+
+ public AndOperand( Token t ) {
+ super( t );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws PersistenceException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanLiteral.java
new file mode 100644
index 0000000..e624e25
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanLiteral.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class BooleanLiteral extends Literal<Boolean> {
+
+ private boolean value;
+
+
+ /**
+ * @param t
+ */
+ protected BooleanLiteral( Token t ) {
+ super( t );
+ value = Boolean.valueOf( t.getText() );
+ }
+
+
+ /** The boolean literal */
+ public BooleanLiteral( boolean value ) {
+ super( new ClassicToken( 0, String.valueOf( value ) ) );
+ this.value = value;
+ }
+
+
+ public Boolean getValue() {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanOperand.java
new file mode 100644
index 0000000..ecf5451
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanOperand.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.Token;
+
+
+/**
+ * A base class for any equality expression. Expressions must have a property and a value. Examples are >=, >, =, <,
+ * <=,
+ *
+ * @author tnine
+ */
+public abstract class BooleanOperand extends Operand {
+
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public BooleanOperand( Token t ) {
+ super( t );
+ }
+
+
+ public Operand getLeft() {
+ return ( Operand ) this.children.get( 0 );
+ }
+
+
+ public Operand getRight() {
+ return ( Operand ) this.children.get( 1 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsOperand.java
new file mode 100644
index 0000000..aa75a1e
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsOperand.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.exceptions.PersistenceException;
+
+
+/** @author tnine */
+public class ContainsOperand extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public ContainsOperand( Token t ) {
+ super( t );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws PersistenceException {
+ visitor.visit( this );
+ }
+
+
+ public StringLiteral getString() {
+ return ( StringLiteral ) getLiteral();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.EqualityOperand#newProperty(java.lang.String)
+ */
+ @Override
+ protected Property newProperty( String name ) {
+ return new ContainsProperty( name );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.EqualityOperand#getProperty()
+ */
+ @Override
+ public ContainsProperty getProperty() {
+ return ( ContainsProperty ) this.children.get( 0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsProperty.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsProperty.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsProperty.java
new file mode 100644
index 0000000..1e35af6
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsProperty.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/**
+ * A property for full text searching that requires special renaming
+ *
+ * @author tnine
+ */
+public class ContainsProperty extends Property {
+
+ private String indexedName = null;
+
+
+ public ContainsProperty( Token t ) {
+ super( t );
+ this.indexedName = String.format( "%s.keywords", super.getValue() );
+ }
+
+
+ public ContainsProperty( String property ) {
+ this( new ClassicToken( 0, property ) );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.Property#getIndexedValue()
+ */
+ @Override
+ public String getIndexedValue() {
+ return this.indexedName;
+ }
+
+
+ /** @return the property */
+ public ContainsProperty getProperty() {
+ return ( ContainsProperty ) this.children.get( 0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Equal.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Equal.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Equal.java
new file mode 100644
index 0000000..d4d4406
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Equal.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class Equal extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public Equal( Token t ) {
+ super( t );
+ }
+
+
+ public Equal() {
+ super( new ClassicToken( 0, "=" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/EqualityOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/EqualityOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/EqualityOperand.java
new file mode 100644
index 0000000..1e3cbc9
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/EqualityOperand.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.Token;
+
+
+/**
+ * A base class for any equality expression. Expressions must have a property and a value. Examples are >=, >, =, <,
+ * <=,
+ *
+ * @author tnine
+ */
+public abstract class EqualityOperand extends Operand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public EqualityOperand( Token t ) {
+ super( t );
+ }
+
+
+ public EqualityOperand( String propName, Literal<?> value ) {
+ super( null );
+ }
+
+
+ /** Set the property on this operand */
+ public void setProperty( String name ) {
+ setAtIndex( 0, newProperty( name ) );
+ }
+
+
+ /** Get the property to set into the equality. Allows subclasses to override the type */
+ protected Property newProperty( String name ) {
+ return new Property( name );
+ }
+
+
+ /** Set the literal on this operand from the given value */
+ public void setLiteral( Object value ) {
+ setAtIndex( 1, LiteralFactory.getLiteral( value ) );
+ }
+
+
+ /** Set the child at the specified index. If it doesn't exist, it's added until it does */
+ @SuppressWarnings("unchecked")
+ private void setAtIndex( int index, Literal<?> value ) {
+
+ if ( children == null ) {
+ children = createChildrenList();
+ }
+
+ while ( children.size() - 1 < index ) {
+ children.add( null );
+ }
+
+ setChild( index, value );
+ }
+
+
+ /** @return the property */
+ public Property getProperty() {
+ return ( Property ) this.children.get( 0 );
+ }
+
+
+ /** @return the literal */
+ public Literal<?> getLiteral() {
+ return ( Literal<?> ) this.children.get( 1 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/FloatLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/FloatLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/FloatLiteral.java
new file mode 100644
index 0000000..6363234
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/FloatLiteral.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class FloatLiteral extends Literal<Float> implements NumericLiteral {
+
+ private float value;
+
+
+ /**
+ * @param t
+ */
+ public FloatLiteral( Token t ) {
+ super( t );
+ value = Float.valueOf( t.getText() );
+ }
+
+
+ public FloatLiteral( float f ) {
+ super( new ClassicToken( 0, String.valueOf( f ) ) );
+ value = f;
+ }
+
+
+ /** @return the value */
+ public Float getValue() {
+ return value;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.NumericLiteral#getFloatValue()
+ */
+ @Override
+ public float getFloatValue() {
+ return value;
+ }
+}
[16/21] git commit: Merge pull request #58 from shawnfeldman/master
Posted by sn...@apache.org.
Merge pull request #58 from shawnfeldman/master
fix forgot password and remove google analytics
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9aff385f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9aff385f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9aff385f
Branch: refs/heads/master
Commit: 9aff385f50cc3af1b60082882dcef442eeefbb6e
Parents: 57f0a94 47bce9d
Author: Rod Simpson <ro...@rodsimpson.com>
Authored: Fri Feb 21 10:38:33 2014 -0700
Committer: Rod Simpson <ro...@rodsimpson.com>
Committed: Fri Feb 21 10:38:33 2014 -0700
----------------------------------------------------------------------
portal/config.js | 15 ---------------
portal/js/login/forgot-password-controller.js | 6 ++++--
2 files changed, 4 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
[19/21] Remove classes not needed for query parsing.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72329d60/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/package-info.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/package-info.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/package-info.java
deleted file mode 100644
index b22445d..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.usergrid.persistence.utils;
[05/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
new file mode 100644
index 0000000..ee884f7
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -0,0 +1,306 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.impl;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.time.StopWatch;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.util.EntityUtils;
+import org.apache.usergrid.persistence.index.EntityCollectionIndex;
+import org.apache.usergrid.persistence.index.EntitySearchResults;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.field.BooleanField;
+import org.apache.usergrid.persistence.model.field.DoubleField;
+import org.apache.usergrid.persistence.model.field.EntityObjectField;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.StringField;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.persistence.utils.ElasticSearchRule;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import static org.junit.Assert.assertEquals;
+import org.junit.Rule;
+import org.junit.Test;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class EntityIndexTest {
+ private static final Logger logger = LoggerFactory.getLogger( EntityIndexTest.class );
+
+ @Rule
+ public ElasticSearchRule elasticSearchRule = new ElasticSearchRule();
+
+
+ @Test
+ public void testIndex() throws IOException {
+
+ Client client = elasticSearchRule.getClient();
+ final CollectionScope scope = mock( CollectionScope.class );
+ when( scope.getName() ).thenReturn( "contacts" );
+ String index = RandomStringUtils.randomAlphanumeric(20 ).toLowerCase();
+ String type = scope.getName();
+
+ EntityCollectionIndex entityIndex =
+ new EntityCollectionIndexImpl( client, index, scope, true );
+
+ InputStream is = this.getClass().getResourceAsStream( "/sample-large.json" );
+ ObjectMapper mapper = new ObjectMapper();
+ List<Object> sampleJson = mapper.readValue( is, new TypeReference<List<Object>>() {} );
+
+ int count = 0;
+ StopWatch timer = new StopWatch();
+ timer.start();
+ for ( Object o : sampleJson ) {
+
+ Map<String, Object> item = (Map<String, Object>)o;
+
+ Entity entity = new Entity(new SimpleId(UUIDGenerator.newTimeUUID(), scope.getName()));
+ entity = EntityIndexTest.mapToEntity( scope.getName(), entity, item );
+ EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
+
+ entityIndex.index( entity );
+
+ count++;
+ }
+ timer.stop();
+ logger.info( "Total time to index {} entries {}ms, average {}ms/entry",
+ count, timer.getTime(), timer.getTime() / count );
+
+ // test queries via Java API QueryBuilder
+ testQueries( client, index, type );
+
+ // test queries via Lucene syntax
+ testQueries( entityIndex );
+
+ client.close();
+ }
+
+
+ private void testQuery( Client client, String index, String type, QueryBuilder qb, int num ) {
+
+ StopWatch timer = new StopWatch();
+ timer.start();
+ SearchResponse sr = client.prepareSearch( index ).setTypes( type )
+ .setQuery( qb ).setFrom( 0 ).setSize( 999 ).execute().actionGet();
+ timer.stop();
+
+ assertEquals( num, sr.getHits().getTotalHits() );
+ logger.debug( "Query1 time {}ms", timer.getTime() );
+ }
+
+
+ private void testQueries( Client client, String index, String type ) {
+
+ testQuery( client, index, type,
+ QueryBuilders.termQuery( "name", "Morgan Pierce" ), 1 );
+
+ // term query is exact match
+ testQuery( client, index, type,
+ QueryBuilders.termQuery("name", "Pierce" ), 0 );
+
+ // match query allows partial match
+ testQuery( client, index, type,
+ QueryBuilders.matchQuery( "name_ug_analyzed", "Pierce" ), 2 );
+
+ testQuery( client, index, type,
+ QueryBuilders.termQuery( "company", "Blurrybus" ), 1 );
+
+ testQuery( client, index, type,
+ QueryBuilders.termQuery( "gender", "female" ), 433 );
+
+ // query of nested object fields supported
+ testQuery( client, index, type,
+ QueryBuilders.termQuery( "contact.email", "nadiabrown@concility.com" ), 1 );
+ }
+
+
+ private void testQuery( EntityCollectionIndex entityIndex, String query, int num ) {
+
+ StopWatch timer = new StopWatch();
+ timer.start();
+ EntitySearchResults results = entityIndex.simpleQuery( query, 0, 999);
+ timer.stop();
+
+ assertEquals( num, results.count() );
+ logger.debug( "Query2 time {}ms", timer.getTime() );
+ }
+
+
+ private void testQueries( EntityCollectionIndex entityIndex ) {
+
+ testQuery( entityIndex, "name:\"Morgan Pierce\"", 1);
+
+ testQuery( entityIndex, "name:\"Morgan\"", 0);
+
+ testQuery( entityIndex, "name_ug_analyzed:\"Morgan\"", 1);
+
+ testQuery( entityIndex, "gender:female", 433);
+ }
+
+
+ @Test
+ public void testRemoveIndex() {
+ }
+
+
+ /**
+ * Test of mapToEntity method, of class EntityUtils.
+ */
+ @Test
+ public void testMapToEntityRoundTrip() throws IOException {
+
+ InputStream is = this.getClass().getResourceAsStream( "/sample-large.json" );
+ ObjectMapper mapper = new ObjectMapper();
+ List<Object> contacts = mapper.readValue( is, new TypeReference<List<Object>>() {} );
+
+ for ( Object o : contacts ) {
+
+ Map<String, Object> map1 = (Map<String, Object>)o;
+
+ // convert map to entity
+ Entity entity1 = EntityIndexTest.mapToEntity( "testscope", map1 );
+
+ // convert entity back to map
+ Map map2 = EntityCollectionIndexImpl.entityToMap( entity1 );
+
+ // the two maps should be the same except for the two new _ug_analyzed properties
+ Map diff = Maps.difference( map1, map2 ).entriesDiffering();
+ assertEquals( 2, diff.size() );
+ }
+ }
+
+
+ public static Entity mapToEntity( String scope, Map<String, Object> item ) {
+ return mapToEntity( scope, null, item );
+ }
+
+
+ public static Entity mapToEntity( String scope, Entity entity, Map<String, Object> map ) {
+
+ if ( entity == null ) {
+ entity = new Entity();
+ }
+
+ for ( String fieldName : map.keySet() ) {
+
+ Object value = map.get( fieldName );
+
+ if ( value instanceof String ) {
+ entity.setField( new StringField(fieldName, (String)value ));
+
+ } else if ( value instanceof Boolean ) {
+ entity.setField( new BooleanField(fieldName, (Boolean)value ));
+
+ } else if ( value instanceof Integer ) {
+ entity.setField( new IntegerField(fieldName, (Integer)value ));
+
+ } else if ( value instanceof Double ) {
+ entity.setField( new DoubleField(fieldName, (Double)value ));
+
+ } else if ( value instanceof Long ) {
+ entity.setField( new LongField(fieldName, (Long)value ));
+
+ } else if ( value instanceof List) {
+ entity.setField( listToListField( scope, fieldName, (List)value ));
+
+ } else if ( value instanceof Map ) {
+ entity.setField( new EntityObjectField( fieldName,
+ mapToEntity( scope, (Map<String, Object>)value ))); // recursion
+
+ } else {
+ throw new RuntimeException("Unknown type " + value.getClass().getName());
+ }
+ }
+
+ return entity;
+ }
+
+
+ private static ListField listToListField( String scope, String fieldName, List list ) {
+
+ if (list.isEmpty()) {
+ return new ListField( fieldName );
+ }
+
+ Object sample = list.get(0);
+
+ if ( sample instanceof Map ) {
+ return new ListField<Entity>( fieldName, processListForField( scope, list ));
+
+ } else if ( sample instanceof List ) {
+ return new ListField<List>( fieldName, processListForField( scope, list ));
+
+ } else if ( sample instanceof String ) {
+ return new ListField<String>( fieldName, (List<String>)list );
+
+ } else if ( sample instanceof Boolean ) {
+ return new ListField<Boolean>( fieldName, (List<Boolean>)list );
+
+ } else if ( sample instanceof Integer ) {
+ return new ListField<Integer>( fieldName, (List<Integer>)list );
+
+ } else if ( sample instanceof Double ) {
+ return new ListField<Double>( fieldName, (List<Double>)list );
+
+ } else if ( sample instanceof Long ) {
+ return new ListField<Long>( fieldName, (List<Long>)list );
+
+ } else {
+ throw new RuntimeException("Unknown type " + sample.getClass().getName());
+ }
+ }
+
+
+ private static List processListForField( String scope, List list ) {
+ if ( list.isEmpty() ) {
+ return list;
+ }
+ Object sample = list.get(0);
+
+ if ( sample instanceof Map ) {
+ List<Entity> newList = new ArrayList<Entity>();
+ for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
+ newList.add( mapToEntity( scope, map ) );
+ }
+ return newList;
+
+ } else if ( sample instanceof List ) {
+ return processListForField( scope, list ); // recursion
+
+ } else {
+ return list;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
new file mode 100644
index 0000000..fa46f4c
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query;
+
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.usergrid.persistence.query.Query.SortDirection;
+import org.apache.usergrid.persistence.query.Query.SortPredicate;
+import org.apache.usergrid.persistence.exceptions.QueryParseException;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.tree.AndOperand;
+import org.apache.usergrid.persistence.query.tree.ContainsOperand;
+import org.apache.usergrid.persistence.query.tree.Equal;
+import org.apache.usergrid.persistence.query.tree.FloatLiteral;
+import org.apache.usergrid.persistence.query.tree.GreaterThan;
+import org.apache.usergrid.persistence.query.tree.GreaterThanEqual;
+import org.apache.usergrid.persistence.query.tree.LessThan;
+import org.apache.usergrid.persistence.query.tree.LessThanEqual;
+import org.apache.usergrid.persistence.query.tree.LongLiteral;
+import org.apache.usergrid.persistence.query.tree.NotOperand;
+import org.apache.usergrid.persistence.query.tree.StringLiteral;
+import org.apache.usergrid.persistence.query.tree.WithinOperand;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+
+//@Concurrent()
+public class QueryTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger( QueryTest.class );
+
+
+ @Test
+ public void testQueryTree() throws Exception {
+ LOG.info( "testQuery" );
+
+ Query q = new Query();
+
+ try {
+ q.addFilter( "blah" );
+ fail( "'blah' shouldn't be a valid operation." );
+ }
+ catch ( RuntimeException e ) {
+ // this is correct
+ }
+
+ q.addFilter( "a=5" );
+ q.addFilter( "b='hello'" );
+ q.addFilter( "c < 7" );
+ q.addFilter( "d gt 5" );
+ // q.addFilter("e in 5,6");
+ q.addFilter( "f = 6.0" );
+ q.addFilter( "g = .05" );
+ q.addFilter( "loc within .05 of 5.0,6.0" );
+ q.addFilter( "not h eq 4" );
+
+ AndOperand and = ( AndOperand ) q.getRootOperand();
+
+ NotOperand not = ( NotOperand ) and.getRight();
+ Equal equal = ( Equal ) not.getOperation();
+ assertEquals( "h", equal.getProperty().getValue() );
+ assertEquals( 4.0f, ( ( LongLiteral ) equal.getLiteral() ).getValue(), 0 );
+
+ and = ( AndOperand ) and.getLeft();
+ WithinOperand op = ( WithinOperand ) and.getRight();
+
+ assertEquals( "loc", op.getProperty().getValue() );
+ assertEquals( .05f, op.getDistance().getFloatValue(), 0 );
+ assertEquals( 5f, op.getLattitude().getFloatValue(), 0 );
+ assertEquals( 6f, op.getLongitude().getFloatValue(), 0 );
+
+ and = ( AndOperand ) and.getLeft();
+ equal = ( Equal ) and.getRight();
+
+ assertEquals( "g", equal.getProperty().getValue() );
+ assertEquals( .05f, ( ( FloatLiteral ) equal.getLiteral() ).getValue(), 0 );
+
+ and = ( AndOperand ) and.getLeft();
+ equal = ( Equal ) and.getRight();
+
+ assertEquals( "f", equal.getProperty().getValue() );
+ assertEquals( 6.0f, ( ( FloatLiteral ) equal.getLiteral() ).getValue(), 0 );
+
+ and = ( AndOperand ) and.getLeft();
+ GreaterThan gt = ( GreaterThan ) and.getRight();
+
+ assertEquals( "d", gt.getProperty().getValue() );
+ assertEquals( 5, ( ( LongLiteral ) gt.getLiteral() ).getValue(), 0 );
+
+ and = ( AndOperand ) and.getLeft();
+ LessThan lt = ( LessThan ) and.getRight();
+
+ assertEquals( "c", lt.getProperty().getValue() );
+ assertEquals( 7, ( ( LongLiteral ) lt.getLiteral() ).getValue(), 0 );
+
+ and = ( AndOperand ) and.getLeft();
+ equal = ( Equal ) and.getRight();
+
+ assertEquals( "b", equal.getProperty().getValue() );
+ assertEquals( "hello", ( ( StringLiteral ) equal.getLiteral() ).getValue() );
+
+ equal = ( Equal ) and.getLeft();
+
+ assertEquals( "a", equal.getProperty().getValue() );
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+ }
+
+
+ @Test
+ public void testCodeEquals() {
+ Query query = new Query();
+ query.addEqualityFilter( "foo", "bar" );
+
+ Equal equal = ( Equal ) query.getRootOperand();
+
+ assertEquals( "foo", equal.getProperty().getValue() );
+ assertEquals( "bar", equal.getLiteral().getValue() );
+ }
+
+
+ @Test
+ public void testCodeLessThan() {
+ Query query = new Query();
+ query.addLessThanFilter( "foo", 5 );
+
+ LessThan equal = ( LessThan ) query.getRootOperand();
+
+ assertEquals( "foo", equal.getProperty().getValue() );
+ assertEquals( 5l, equal.getLiteral().getValue() );
+ }
+
+
+ @Test
+ public void testCodeLessThanEqual() {
+ Query query = new Query();
+ query.addLessThanEqualFilter( "foo", 5 );
+
+ LessThanEqual equal = ( LessThanEqual ) query.getRootOperand();
+
+ assertEquals( "foo", equal.getProperty().getValue() );
+ assertEquals( 5l, equal.getLiteral().getValue() );
+ }
+
+
+ @Test
+ public void testCodeGreaterThan() {
+ Query query = new Query();
+ query.addGreaterThanFilter( "foo", 5 );
+
+ GreaterThan equal = ( GreaterThan ) query.getRootOperand();
+
+ assertEquals( "foo", equal.getProperty().getValue() );
+ assertEquals( 5l, equal.getLiteral().getValue() );
+ }
+
+
+ @Test
+ public void testCodeGreaterThanEqual() {
+ Query query = new Query();
+ query.addGreaterThanEqualFilter( "foo", 5 );
+
+ GreaterThanEqual equal = ( GreaterThanEqual ) query.getRootOperand();
+
+ assertEquals( "foo", equal.getProperty().getValue() );
+ assertEquals( 5l, equal.getLiteral().getValue() );
+ }
+
+
+ @Test
+ public void testFromJson() throws QueryParseException {
+ String s = "{\"filter\":\"a contains 'ed'\"}";
+ Query q = Query.fromJsonString( s );
+ assertNotNull( q );
+
+ ContainsOperand contains = ( ContainsOperand ) q.getRootOperand();
+
+ assertEquals( "a", contains.getProperty().getValue() );
+ assertEquals( "ed", contains.getString().getValue() );
+ }
+
+
+ @Test
+ public void testCompoundQueryWithNot() throws QueryParseException {
+ String s = "name contains 'm' and not name contains 'grover'";
+ Query q = Query.fromQL( s );
+ assertNotNull( q );
+
+ AndOperand and = ( AndOperand ) q.getRootOperand();
+
+ ContainsOperand contains = ( ContainsOperand ) and.getLeft();
+ assertEquals( "name", contains.getProperty().getValue() );
+ assertEquals( "m", contains.getString().getValue() );
+
+ NotOperand not = ( NotOperand ) and.getRight();
+ contains = ( ContainsOperand ) not.getOperation();
+ assertEquals( "name", contains.getProperty().getValue() );
+ assertEquals( "grover", contains.getString().getValue() );
+ }
+
+
+ @Test
+ public void badGrammar() throws QueryParseException {
+ // from isn't allowed
+ String s = "select * from where name = 'bob'";
+
+ String error = null;
+
+ try {
+ Query.fromQL( s );
+ }
+ catch ( QueryParseException qpe ) {
+ error = qpe.getMessage();
+ }
+ assertNotNull( error );
+ assertTrue( error.startsWith("The query cannot be parsed") );
+ }
+
+
+ @Test
+ public void testTruncation() {
+
+ Query query = new Query();
+ query.setLimit( Query.MAX_LIMIT * 2 );
+
+ assertEquals( Query.MAX_LIMIT, query.getLimit() );
+ }
+
+
+ @Test
+ public void testTruncationFromParams() throws QueryParseException {
+
+ HashMap<String, List<String>> params = new HashMap<String, List<String>>();
+
+ params.put( "limit", Collections.singletonList( "2000" ) );
+
+ Query query = Query.fromQueryParams( params );
+
+ assertEquals( Query.MAX_LIMIT, query.getLimit() );
+ }
+
+
+ @Test
+ public void badOrderByBadGrammar() throws QueryParseException {
+ // from isn't allowed
+ String s = "select * where name = 'bob' order by";
+
+ String error = null;
+
+ try {
+ Query.fromQL( s );
+ }
+ catch ( QueryParseException qpe ) {
+ error = qpe.getMessage();
+ }
+
+ assertEquals( "The query cannot be parsed. The token '<EOF>' at column 13 on line 1 cannot be parsed", error );
+ }
+
+
+ @Test
+ public void badOrderByGrammarAsc() throws QueryParseException {
+ // from isn't allowed
+ String s = "select * where name = 'bob' order by name asc";
+
+ Query q = Query.fromQL( s );
+
+ List<SortPredicate> sorts = q.getSortPredicates();
+
+ assertEquals( 1, sorts.size() );
+
+ assertEquals( "name", sorts.get( 0 ).getPropertyName() );
+ assertEquals( SortDirection.ASCENDING, sorts.get( 0 ).getDirection() );
+ }
+
+
+ @Test
+ public void badOrderByGrammarDesc() throws QueryParseException {
+ // from isn't allowed
+ String s = "select * where name = 'bob' order by name desc";
+
+ Query q = Query.fromQL( s );
+
+ List<SortPredicate> sorts = q.getSortPredicates();
+
+ assertEquals( 1, sorts.size() );
+
+ assertEquals( "name", sorts.get( 0 ).getPropertyName() );
+ assertEquals( SortDirection.DESCENDING, sorts.get( 0 ).getDirection() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
new file mode 100644
index 0000000..10324d1
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
@@ -0,0 +1,608 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenRewriteStream;
+import org.junit.Test;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.exceptions.QueryParseException;
+import org.apache.usergrid.persistence.query.ir.OrNode;
+
+import antlr.NoViableAltException;
+import org.apache.usergrid.persistence.query.tree.AndOperand;
+import org.apache.usergrid.persistence.query.tree.ContainsOperand;
+import org.apache.usergrid.persistence.query.tree.Equal;
+import org.apache.usergrid.persistence.query.tree.GreaterThan;
+import org.apache.usergrid.persistence.query.tree.GreaterThanEqual;
+import org.apache.usergrid.persistence.query.tree.LessThan;
+import org.apache.usergrid.persistence.query.tree.LessThanEqual;
+import org.apache.usergrid.persistence.query.tree.LongLiteral;
+import org.apache.usergrid.persistence.query.tree.NotOperand;
+import org.apache.usergrid.persistence.query.tree.Operand;
+import org.apache.usergrid.persistence.query.tree.OrOperand;
+import org.apache.usergrid.persistence.query.tree.QueryFilterLexer;
+import org.apache.usergrid.persistence.query.tree.QueryFilterParser;
+import org.apache.usergrid.persistence.query.tree.StringLiteral;
+import org.apache.usergrid.persistence.query.tree.UUIDLiteral;
+import org.apache.usergrid.persistence.query.tree.WithinOperand;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+
+/** @author tnine */
+public class GrammarTreeTest {
+
+ /** Simple test that constructs and AST from the ANTLR generated files */
+ @Test
+ public void equality() throws RecognitionException {
+
+ String queryString = "select * where a = 5";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Operand root = query.getRootOperand();
+
+ Equal equal = ( Equal ) root;
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+ }
+
+
+ /** Simple test that constructs and AST from the ANTLR generated files */
+ @Test
+ public void lessThan() throws RecognitionException {
+
+ String queryString = "select * where a < 5";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Operand root = query.getRootOperand();
+
+ LessThan equal = ( LessThan ) root;
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+
+ // TODO Todd fix this.
+
+ queryString = "select * where a lt 5";
+
+ in = new ANTLRStringStream( queryString );
+ lexer = new QueryFilterLexer( in );
+ tokens = new TokenRewriteStream( lexer );
+ parser = new QueryFilterParser( tokens );
+
+ query = parser.ql().query;
+
+ root = query.getRootOperand();
+
+ equal = ( LessThan ) root;
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+ }
+
+
+ /** Simple test that constructs and AST from the ANTLR generated files */
+ @Test
+ public void lessThanEqual() throws RecognitionException {
+
+ String queryString = "select * where a <= 5";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Operand root = query.getRootOperand();
+
+ LessThanEqual equal = ( LessThanEqual ) root;
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+
+ queryString = "select * where a lte 5";
+
+ in = new ANTLRStringStream( queryString );
+ lexer = new QueryFilterLexer( in );
+ tokens = new TokenRewriteStream( lexer );
+ parser = new QueryFilterParser( tokens );
+
+ query = parser.ql().query;
+
+ root = query.getRootOperand();
+
+ equal = ( LessThanEqual ) root;
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+ }
+
+
+ /** Simple test that constructs and AST from the ANTLR generated files */
+ @Test
+ public void greaterThan() throws RecognitionException {
+
+ String queryString = "select * where a > 5";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Operand root = query.getRootOperand();
+
+ GreaterThan equal = ( GreaterThan ) root;
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+
+ queryString = "select * where a gt 5";
+
+ in = new ANTLRStringStream( queryString );
+ lexer = new QueryFilterLexer( in );
+ tokens = new TokenRewriteStream( lexer );
+ parser = new QueryFilterParser( tokens );
+
+ query = parser.ql().query;
+
+ root = query.getRootOperand();
+
+ equal = ( GreaterThan ) root;
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+ }
+
+
+ /** Simple test that constructs and AST from the ANTLR generated files */
+ @Test
+ public void greaterThanEqual() throws RecognitionException {
+
+ String queryString = "select * where a >= 5";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Operand root = query.getRootOperand();
+
+ GreaterThanEqual equal = ( GreaterThanEqual ) root;
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+
+ queryString = "select * where a gte 5";
+
+ in = new ANTLRStringStream( queryString );
+ lexer = new QueryFilterLexer( in );
+ tokens = new TokenRewriteStream( lexer );
+ parser = new QueryFilterParser( tokens );
+
+ query = parser.ql().query;
+
+ root = query.getRootOperand();
+
+ equal = ( GreaterThanEqual ) root;
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 5, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+ }
+
+
+ /** Test basic && expression */
+ @Test
+ public void andExpression() throws RecognitionException {
+
+ String queryString = "select * where a = 1 and b > 2";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Operand root = query.getRootOperand();
+
+ AndOperand and = ( AndOperand ) root;
+
+ Equal equal = ( Equal ) and.getLeft();
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 1, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+
+ GreaterThan greater = ( GreaterThan ) and.getRight();
+
+ assertEquals( "b", greater.getProperty().getValue() );
+ assertEquals( 2, ( ( LongLiteral ) greater.getLiteral() ).getValue().intValue() );
+ }
+
+
+ /** Test basic || expression */
+ @Test
+ public void orExpression() throws RecognitionException {
+
+ String queryString = "select * where a = 1 or b > 2";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Operand root = query.getRootOperand();
+
+ OrOperand and = ( OrOperand ) root;
+
+ Equal equal = ( Equal ) and.getLeft();
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 1, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+
+ GreaterThan greater = ( GreaterThan ) and.getRight();
+
+ assertEquals( "b", greater.getProperty().getValue() );
+ assertEquals( 2, ( ( LongLiteral ) greater.getLiteral() ).getValue().intValue() );
+ }
+
+
+ /** Test basic not expression */
+ @Test
+ public void notExpression() throws RecognitionException {
+
+ String queryString = "select * where not a = 1";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Operand root = query.getRootOperand();
+
+ NotOperand not = ( NotOperand ) root;
+
+ Equal equal = ( Equal ) not.getOperation();
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 1, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+ }
+
+
+ /** Test basic not expression */
+ @Test
+ public void complexExpression() throws RecognitionException {
+
+ String queryString = "select * where not a = 1";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Operand root = query.getRootOperand();
+
+ NotOperand not = ( NotOperand ) root;
+
+ Equal equal = ( Equal ) not.getOperation();
+
+ assertEquals( "a", equal.getProperty().getValue() );
+
+ assertEquals( 1, ( ( LongLiteral ) equal.getLiteral() ).getValue().intValue() );
+ }
+
+
+ /** Test basic || expression */
+ @Test
+ public void selectAll() throws RecognitionException {
+
+ String queryString = "select * where a = 1 or b > 2";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Set<String> identifiers = query.getSelectSubjects();
+
+ assertEquals( 0, identifiers.size() );
+ }
+
+
+ @Test
+ public void selectGeo() throws RecognitionException {
+ String queryString = "select * where a within .1 of -40.343666, 175.630917";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ WithinOperand operand = ( WithinOperand ) query.getRootOperand();
+
+ assertEquals( "a", operand.getProperty().getValue() );
+ assertEquals( .1f, operand.getDistance().getFloatValue(), 0 );
+ assertEquals( -40.343666f, operand.getLattitude().getFloatValue(), 0 );
+ assertEquals( 175.630917f, operand.getLongitude().getFloatValue(), 0 );
+ }
+
+
+ @Test
+ public void selectGeoWithInt() throws RecognitionException {
+ String queryString = "select * where a within 1 of -40.343666, 175.630917";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ WithinOperand operand = ( WithinOperand ) query.getRootOperand();
+
+ assertEquals( "a", operand.getProperty().getValue() );
+ assertEquals( 1, operand.getDistance().getFloatValue(), 0 );
+ assertEquals( -40.343666f, operand.getLattitude().getFloatValue(), 0 );
+ assertEquals( 175.630917f, operand.getLongitude().getFloatValue(), 0 );
+ }
+
+
+ @Test
+ public void selectDistance() throws RecognitionException {
+ String queryString = "select * where a contains 'foo'";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ ContainsOperand operand = ( ContainsOperand ) query.getRootOperand();
+
+ assertEquals( "a", operand.getProperty().getValue() );
+ assertEquals( "foo", operand.getString().getValue() );
+ }
+
+
+ @Test
+ public void selectField() throws RecognitionException {
+
+ String queryString = "select c where a = 1 or b > 2";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Set<String> identifiers = query.getSelectSubjects();
+
+ assertTrue( identifiers.contains( "c" ) );
+ }
+
+
+ @Test
+ public void selectRename() throws RecognitionException {
+
+ String queryString = "select {source:target} where a = 1 or b > 2";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Map<String, String> identifiers = query.getSelectAssignments();
+
+ assertEquals( "target", identifiers.get( "source" ) );
+ }
+
+
+ @Test
+ public void containsOr() throws Exception {
+ String queryString = "select * where keywords contains 'hot' or title contains 'hot'";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ OrOperand rootNode = ( OrOperand ) query.getRootOperand();
+
+ assertNotNull( rootNode );
+
+ ContainsOperand left = ( ContainsOperand ) rootNode.getLeft();
+
+ assertEquals( "keywords", left.getProperty().getValue() );
+
+ assertEquals( "hot", left.getString().getValue() );
+ assertEquals( "hot", left.getString().getEndValue() );
+
+ ContainsOperand right = ( ContainsOperand ) rootNode.getRight();
+
+ assertEquals( "title", right.getProperty().getValue() );
+
+ assertEquals( "hot", right.getString().getValue() );
+ assertEquals( "hot", right.getString().getEndValue() );
+ }
+
+
+ @Test
+ public void stringLower() throws Exception {
+ String queryString = "select * where title = 'Hot'";
+
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Equal rootNode = ( Equal ) query.getRootOperand();
+
+ assertEquals( "title", rootNode.getProperty().getValue() );
+ assertEquals( "hot", ( ( StringLiteral ) rootNode.getLiteral() ).getValue() );
+ }
+
+
+ @Test
+ public void nestedBooleanLogic() throws Exception {
+ String queryString = "select * where field1 = 'foo' AND (field2 = 'bar' OR field2 = 'baz')";
+
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ AndOperand rootNode = ( AndOperand ) query.getRootOperand();
+
+ //left should be field1
+ Equal field1Equal = ( Equal ) rootNode.getLeft();
+
+ assertEquals( "field1", field1Equal.getProperty().getValue() );
+ assertEquals( "foo", ( ( StringLiteral ) field1Equal.getLiteral() ).getValue() );
+
+
+ OrOperand orNode = ( OrOperand ) rootNode.getRight();
+
+ Equal field2Bar = ( Equal ) orNode.getLeft();
+ Equal field2Baz = ( Equal ) orNode.getRight();
+
+ assertEquals( "field2", field2Bar.getProperty().getValue() );
+ assertEquals( "bar", ( ( StringLiteral ) field2Bar.getLiteral() ).getValue() );
+
+ assertEquals( "field2", field2Baz.getProperty().getValue() );
+ assertEquals( "baz", ( ( StringLiteral ) field2Baz.getLiteral() ).getValue() );
+ }
+
+
+ @Test
+ public void uuidParse() throws RecognitionException {
+ String queryString = "select * where title = c6ee8a1c-3ef4-11e2-8861-02e81adcf3d0";
+
+ ANTLRStringStream in = new ANTLRStringStream( queryString );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ Query query = parser.ql().query;
+
+ Equal rootNode = ( Equal ) query.getRootOperand();
+
+ assertEquals( "title", rootNode.getProperty().getValue() );
+ assertEquals( UUID.fromString( "c6ee8a1c-3ef4-11e2-8861-02e81adcf3d0" ),
+ ( ( UUIDLiteral ) rootNode.getLiteral() ).getValue() );
+ }
+
+
+ @Test
+ public void badOrderByGrammar() throws QueryParseException {
+ // from isn't allowed
+ String s = "select * where name = 'bob' order by";
+
+ String error = null;
+
+ try {
+ Query.fromQL( s );
+ }
+ catch ( QueryParseException qpe ) {
+ error = qpe.getMessage();
+ }
+
+ assertEquals( "The query cannot be parsed. The token '<EOF>' " + "at column 13 on line 1 cannot be parsed",
+ error );
+ }
+
+ @Test
+ public void badOperand() throws QueryParseException {
+ // from isn't allowed
+ String s = "select * where name != 'bob'";
+
+ String error = null;
+
+ try {
+ Query.fromQL( s );
+ fail("should throw an exception");
+ }
+ catch ( RuntimeException qpe ) {
+ error = qpe.getMessage();
+ }
+
+ assertEquals( "NoViableAltException('!'@[1:1: Tokens : ( T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | LT | LTE | EQ | GT | GTE | BOOLEAN | AND | OR | NOT | ASC | DESC | CONTAINS | WITHIN | OF | UUID | ID | LONG | FLOAT | STRING | WS );])",
+ error );
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/LongLiteralTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/LongLiteralTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/LongLiteralTest.java
new file mode 100644
index 0000000..b2e2eba
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/LongLiteralTest.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.apache.usergrid.persistence.query.tree.LongLiteral;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+
+/** @author tnine */
+public class LongLiteralTest {
+
+
+ /**
+ * Test method for {@link org.apache.usergrid.persistence.query.tree.LongLiteral#IntegerLiteral(org.antlr.runtime
+ * .Token)}.
+ */
+ @Test
+ public void longMin() {
+
+ long value = Long.MIN_VALUE;
+
+ String stringVal = String.valueOf( value );
+
+ LongLiteral literal = new LongLiteral( new CommonToken( 0, stringVal ) );
+
+ assertEquals( value, literal.getValue().longValue() );
+ }
+
+
+ /**
+ * Test method for {@link org.apache.usergrid.persistence.query.tree.LongLiteral#IntegerLiteral(org.antlr.runtime
+ * .Token)}.
+ */
+ @Test
+ public void longMax() {
+
+ long value = Long.MAX_VALUE;
+
+ String stringVal = String.valueOf( value );
+
+ LongLiteral literal = new LongLiteral( new CommonToken( 0, stringVal ) );
+
+ assertEquals( value, literal.getValue().longValue() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/StringLiteralTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/StringLiteralTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/StringLiteralTest.java
new file mode 100644
index 0000000..56ef54d
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/StringLiteralTest.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.apache.usergrid.persistence.query.tree.StringLiteral;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+
+/** @author tnine */
+public class StringLiteralTest {
+
+ @Test
+ public void exactToken() {
+
+ StringLiteral literal = new StringLiteral( new CommonToken( 0, "'value'" ) );
+
+ assertEquals( "value", literal.getValue() );
+ assertEquals( "value", literal.getEndValue() );
+ }
+
+
+ @Test
+ public void exactString() {
+
+ StringLiteral literal = new StringLiteral( "value" );
+
+ assertEquals( "value", literal.getValue() );
+ assertEquals( "value", literal.getEndValue() );
+ }
+
+
+ @Test
+ public void wildcardToken() {
+
+ StringLiteral literal = new StringLiteral( new CommonToken( 0, "'*'" ) );
+
+ assertNull( literal.getValue() );
+ assertNull( literal.getEndValue() );
+ }
+
+
+ @Test
+ public void wildcardString() {
+
+ StringLiteral literal = new StringLiteral( "*" );
+
+ assertNull( literal.getValue() );
+ assertNull( literal.getEndValue() );
+ }
+
+
+ @Test
+ public void wildcardEndToken() {
+
+ StringLiteral literal = new StringLiteral( new CommonToken( 0, "'value*'" ) );
+
+ assertEquals( "value", literal.getValue() );
+ assertEquals( "value\uffff", literal.getEndValue() );
+ }
+
+
+ @Test
+ public void wildcardEndString() {
+
+ StringLiteral literal = new StringLiteral( "value*" );
+
+ assertEquals( "value", literal.getValue() );
+ assertEquals( "value\uffff", literal.getEndValue() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/utils/ElasticSearchRule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/utils/ElasticSearchRule.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/utils/ElasticSearchRule.java
new file mode 100644
index 0000000..0068fad
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/utils/ElasticSearchRule.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.utils;
+
+import org.apache.usergrid.persistence.collection.util.AvailablePortFinder;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.settings.ImmutableSettings;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.node.Node;
+import org.elasticsearch.node.NodeBuilder;
+import org.junit.rules.ExternalResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ElasticSearchRule extends ExternalResource {
+ private static final Logger log = LoggerFactory.getLogger( ElasticSearchRule.class );
+
+ private Client client;
+
+ @Override
+ protected void after() {
+ client.close();
+ }
+
+ @Override
+ protected void before() throws Throwable {
+
+ // use unique port and directory names so multiple instances of ES can run concurrently.
+ int port = AvailablePortFinder.getNextAvailable(2000);
+ Settings settings = ImmutableSettings.settingsBuilder()
+ .put("node.http.enabled", true)
+ .put("transport.tcp.port", port )
+ .put("path.logs","target/elasticsearch/logs_" + port )
+ .put("path.data","target/elasticsearch/data_" + port )
+ .put("gateway.type", "none" )
+ .put("index.store.type", "memory" )
+ .put("index.number_of_shards", 1 )
+ .put("index.number_of_replicas", 1).build();
+
+ Node node = NodeBuilder.nodeBuilder().local(true).settings(settings).node();
+ client = node.client();
+ }
+
+ public Client getClient() {
+ return client;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/log4j.properties b/stack/corepersistence/queryindex/src/test/resources/log4j.properties
new file mode 100644
index 0000000..5d830ee
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/resources/log4j.properties
@@ -0,0 +1,15 @@
+log4j.rootLogger=INFO,stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %c{3}.%M(%L)<%t>- %m%n
+
+log4j.logger.org.safehaus.chop.plugin=DEBUG
+log4j.logger.org.safehaus.guicyfig=ERROR
+log4j.logger.org.safehaus.chop.api.store.amazon=DEBUG
+log4j.logger.org.apache.http=ERROR
+log4j.logger.com.amazonaws.request=ERROR
+
+log4j.logger.org.apache.usergrid=DEBUG
+
+log4j.logger.org.apache.usergrid.persistence.index=DEBUG
[06/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/JsonUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/JsonUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/JsonUtils.java
new file mode 100644
index 0000000..fe26403
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/JsonUtils.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import java.io.File;
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.usergrid.persistence.exceptions.JsonReadException;
+import org.apache.usergrid.persistence.exceptions.JsonWriteException;
+//import org.apache.usergrid.persistence.Entity;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.io.JsonStringEncoder;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig.Feature;
+import org.codehaus.jackson.smile.SmileFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.commons.lang.StringUtils.substringAfter;
+
+import static org.apache.usergrid.persistence.utils.StringUtils.stringOrSubstringBeforeFirst;
+
+
+public class JsonUtils {
+
+ private static final Logger LOG = LoggerFactory.getLogger( JsonUtils.class );
+
+ static ObjectMapper mapper = new ObjectMapper();
+
+ static SmileFactory smile = new SmileFactory();
+
+ static ObjectMapper smileMapper = new ObjectMapper( smile );
+
+ private static ObjectMapper indentObjectMapper = new ObjectMapper();
+
+
+ static {
+ indentObjectMapper.getSerializationConfig().set( Feature.INDENT_OUTPUT, true );
+ }
+
+
+ /** Converts object to JSON string, throws runtime exception JsonWriteException on failure. */
+ public static String mapToJsonString( Object obj ) {
+ try {
+ return mapper.writeValueAsString( obj );
+ }
+ catch ( Throwable t ) {
+ LOG.debug( "Error generating JSON", t );
+ throw new JsonWriteException( "Error generating JSON", t );
+ }
+ }
+
+
+ /** Converts object to JSON string, throws runtime exception JsonWriteException on failure. */
+ public static String mapToFormattedJsonString( Object obj ) {
+ try {
+ return indentObjectMapper.writeValueAsString( obj );
+ }
+ catch ( Throwable t ) {
+ LOG.debug( "Error generating JSON", t );
+ throw new JsonWriteException( "Error generating JSON", t );
+ }
+ }
+
+
+ /** Parses JSON string and returns object, throws runtime exception JsonReadException on failure. */
+ public static Object parse( String json ) {
+ try {
+ return mapper.readValue( json, Object.class );
+ }
+ catch ( Throwable t ) {
+ LOG.debug( "Error parsing JSON", t );
+ throw new JsonReadException( "Error parsing JSON", t );
+ }
+ }
+
+
+ public static String quoteString( String s ) {
+ JsonStringEncoder encoder = new JsonStringEncoder();
+ return new String( encoder.quoteAsUTF8( s ) );
+ }
+
+
+ public static ByteBuffer toByteBuffer( Object obj ) {
+ if ( obj == null ) {
+ return null;
+ }
+
+ byte[] bytes = null;
+ try {
+ bytes = smileMapper.writeValueAsBytes( obj );
+ }
+ catch ( Exception e ) {
+ LOG.error( "Error getting SMILE bytes", e );
+ }
+ if ( bytes != null ) {
+ return ByteBuffer.wrap( bytes );
+ }
+ return null;
+ }
+
+
+ public static Object fromByteBuffer( ByteBuffer byteBuffer ) {
+ return fromByteBuffer( byteBuffer, Object.class );
+ }
+
+
+ public static Object fromByteBuffer( ByteBuffer byteBuffer, Class<?> clazz ) {
+ if ( ( byteBuffer == null ) || !byteBuffer.hasRemaining() ) {
+ return null;
+ }
+ if ( clazz == null ) {
+ clazz = Object.class;
+ }
+
+ Object obj = null;
+ try {
+ obj = smileMapper.readValue( byteBuffer.array(), byteBuffer.arrayOffset() + byteBuffer.position(),
+ byteBuffer.remaining(), clazz );
+ }
+ catch ( Exception e ) {
+ LOG.error( "Error parsing SMILE bytes", e );
+ }
+ return obj;
+ }
+
+
+ public static JsonNode toJsonNode( Object obj ) {
+ if ( obj == null ) {
+ return null;
+ }
+ return mapper.convertValue( obj, JsonNode.class );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, Object> toJsonMap( Object obj ) {
+ if ( obj == null ) {
+ return null;
+ }
+
+ return ( Map<String, Object> ) mapper.convertValue( obj, Map.class );
+ }
+
+
+ private static UUID tryConvertToUUID( Object o ) {
+ if ( o instanceof String ) {
+ String s = ( String ) o;
+ if ( s.length() == 36 ) {
+ try {
+ return UUID.fromString( s );
+ }
+ catch ( IllegalArgumentException e ) {
+ LOG.warn( "Argument to UUID.fromString({}) was invalid.", s, e );
+ }
+ }
+ }
+ return null;
+ }
+
+
+ public static Object normalizeJsonTree( Object obj ) {
+ if ( obj instanceof Map ) {
+ @SuppressWarnings("unchecked") Map<Object, Object> m = ( Map<Object, Object> ) obj;
+ Object o;
+ UUID uuid;
+ for ( Object k : m.keySet() ) {
+ if ( k instanceof String && ( ( String ) k ).equalsIgnoreCase( "name" ) ) {
+ continue;
+ }
+
+ o = m.get( k );
+ uuid = tryConvertToUUID( o );
+ if ( uuid != null ) {
+ m.put( k, uuid );
+ }
+ else if ( o instanceof Integer ) {
+ m.put( k, ( ( Integer ) o ).longValue() );
+ }
+ else if ( o instanceof BigInteger ) {
+ m.put( k, ( ( BigInteger ) o ).longValue() );
+ }
+ }
+ }
+ else if ( obj instanceof List ) {
+ @SuppressWarnings("unchecked") List<Object> l = ( List<Object> ) obj;
+ Object o;
+ UUID uuid;
+ for ( int i = 0; i < l.size(); i++ ) {
+ o = l.get( i );
+ uuid = tryConvertToUUID( o );
+ if ( uuid != null ) {
+ l.set( i, uuid );
+ }
+ else if ( ( o instanceof Map ) || ( o instanceof List ) ) {
+ normalizeJsonTree( o );
+ }
+ else if ( o instanceof Integer ) {
+ l.set( i, ( ( Integer ) o ).longValue() );
+ }
+ else if ( o instanceof BigInteger ) {
+ l.set( i, ( ( BigInteger ) o ).longValue() );
+ }
+ }
+ }
+ else if ( obj instanceof String ) {
+ UUID uuid = tryConvertToUUID( obj );
+ if ( uuid != null ) {
+ return uuid;
+ }
+ }
+ else if ( obj instanceof Integer ) {
+ return ( ( Integer ) obj ).longValue();
+ }
+ else if ( obj instanceof BigInteger ) {
+ return ( ( BigInteger ) obj ).longValue();
+ }
+ else if ( obj instanceof JsonNode ) {
+ return mapper.convertValue( obj, Object.class );
+ }
+ return obj;
+ }
+
+
+// public static Object select( Object obj, String path ) {
+// return select( obj, path, false );
+// }
+//
+//
+// public static Object select( Object obj, String path, boolean buildResultTree ) {
+//
+// if ( obj == null ) {
+// return null;
+// }
+//
+// if ( org.apache.commons.lang.StringUtils.isBlank( path ) ) {
+// return obj;
+// }
+//
+// String segment = stringOrSubstringBeforeFirst( path, '.' );
+// String remaining = substringAfter( path, "." );
+//
+// if ( obj instanceof Map ) {
+// Map<?, ?> map = ( Map<?, ?> ) obj;
+// Object child = map.get( segment );
+// Object result = select( child, remaining, buildResultTree );
+// if ( result != null ) {
+// if ( buildResultTree ) {
+// Map<Object, Object> results = new LinkedHashMap<Object, Object>();
+// results.put( segment, result );
+// return results;
+// }
+// else {
+// return result;
+// }
+// }
+// return null;
+// }
+// if ( obj instanceof List ) {
+// List<Object> results = new ArrayList<Object>();
+// List<?> list = ( List<?> ) obj;
+// for ( Object i : list ) {
+// Object result = select( i, path, buildResultTree );
+// if ( result != null ) {
+// results.add( result );
+// }
+// }
+// if ( !results.isEmpty() ) {
+// return results;
+// }
+// return null;
+// }
+//
+// if ( obj instanceof Entity ) {
+// Object child = ( ( Entity ) obj ).getProperty( segment );
+// Object result = select( child, remaining, buildResultTree );
+// if ( result != null ) {
+// if ( buildResultTree ) {
+// Map<Object, Object> results = new LinkedHashMap<Object, Object>();
+// results.put( segment, result );
+// return results;
+// }
+// else {
+// return result;
+// }
+// }
+// else {
+// return result;
+// }
+// }
+//
+// return obj;
+// }
+
+
+ public static Object loadFromFilesystem( String filename ) {
+ Object json = null;
+ try {
+ File file = new File( filename );
+ json = mapper.readValue( file, Object.class );
+ }
+ catch ( Exception e ) {
+ LOG.error( "Error loading JSON", e );
+ }
+ return json;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ListUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ListUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ListUtils.java
new file mode 100644
index 0000000..8ca5056
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/ListUtils.java
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.commons.lang.math.NumberUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ListUtils extends org.apache.commons.collections.ListUtils {
+ private static final Logger LOG = LoggerFactory.getLogger( ListUtils.class );
+
+
+ public static <A> A first( List<A> list ) {
+ if ( list == null ) {
+ return null;
+ }
+ if ( list.size() == 0 ) {
+ return null;
+ }
+ return list.get( 0 );
+ }
+
+
+ public static <A> A last( List<A> list ) {
+ if ( list == null ) {
+ return null;
+ }
+ if ( list.size() == 0 ) {
+ return null;
+ }
+ return list.get( list.size() - 1 );
+ }
+
+
+ public static <A> Integer firstInteger( List<A> list ) {
+ A a = first( list );
+ if ( a == null ) {
+ return null;
+ }
+
+ if ( a instanceof Integer ) {
+ return ( Integer ) a;
+ }
+
+ try {
+ return NumberUtils.toInt( ( String ) a );
+ }
+ catch ( Exception e ) {
+ LOG.warn( "Could not convert list item {} to int", a, e );
+ }
+ return null;
+ }
+
+
+ public static <A> Long firstLong( List<A> list ) {
+ A a = first( list );
+ if ( a == null ) {
+ return null;
+ }
+
+ if ( a instanceof Long ) {
+ return ( Long ) a;
+ }
+
+ try {
+ return NumberUtils.toLong( ( String ) a );
+ }
+ catch ( Exception e ) {
+ LOG.warn( "Could not convert list item {} to long", a, e );
+ }
+ return null;
+ }
+
+
+ public static <A> Boolean firstBoolean( List<A> list ) {
+ A a = first( list );
+ if ( a == null ) {
+ return null;
+ }
+
+ if ( a instanceof Boolean ) {
+ return ( Boolean ) a;
+ }
+
+ try {
+ return Boolean.parseBoolean( ( String ) a );
+ }
+ catch ( Exception e ) {
+ LOG.warn( "Could not convert list item {} to boolean", a, e );
+ }
+ return null;
+ }
+
+
+ public static <A> UUID firstUuid( List<A> list ) {
+ A i = first( list );
+ if ( i == null ) {
+ return null;
+ }
+
+ if ( i instanceof UUID ) {
+ return ( UUID ) i;
+ }
+
+ try {
+ return UUIDUtils.tryGetUUID( ( String ) i );
+ }
+ catch ( Exception e ) {
+ LOG.warn( "Could not convert list item {} to UUID", i, e );
+ }
+ return null;
+ }
+
+
+ public static boolean isEmpty( List<?> list ) {
+ return ( list == null ) || ( list.size() == 0 );
+ }
+
+
+ public static <T> List<T> dequeueCopy( List<T> list ) {
+ if ( !isEmpty( list ) ) {
+ list = list.subList( 1, list.size() );
+ }
+ return list;
+ }
+
+
+ public static <T> List<T> initCopy( List<T> list ) {
+ if ( !isEmpty( list ) ) {
+ list = new ArrayList<T>( list );
+ }
+ else {
+ list = new ArrayList<T>();
+ }
+ return list;
+ }
+
+
+ public static <T> T dequeue( List<T> list ) {
+ if ( !isEmpty( list ) ) {
+ return list.remove( 0 );
+ }
+ return null;
+ }
+
+
+ public static <T> List<T> queue( List<T> list, T item ) {
+ if ( list == null ) {
+ list = new ArrayList<T>();
+ }
+ list.add( item );
+ return list;
+ }
+
+
+ public static <T> List<T> requeue( List<T> list, T item ) {
+ if ( list == null ) {
+ list = new ArrayList<T>();
+ }
+ list.add( 0, item );
+ return list;
+ }
+
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public static List<?> flatten( Collection<?> l ) {
+ boolean hasCollection = false;
+ for ( Object o : l ) {
+ if ( o instanceof Collection ) {
+ hasCollection = true;
+ break;
+ }
+ }
+ if ( !hasCollection && ( l instanceof List ) ) {
+ return ( List<?> ) l;
+ }
+ List newList = new ArrayList();
+ for ( Object o : l ) {
+ if ( o instanceof List ) {
+ newList.addAll( flatten( ( List ) o ) );
+ }
+ else {
+ newList.add( o );
+ }
+ }
+ return newList;
+ }
+
+
+ public static boolean anyNull( List<?> l ) {
+ for ( Object o : l ) {
+ if ( o == null ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public static boolean anyNull( Object... objects ) {
+ for ( Object o : objects ) {
+ if ( o == null ) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/MapUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/MapUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/MapUtils.java
new file mode 100644
index 0000000..a9c4200
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/MapUtils.java
@@ -0,0 +1,377 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
+import static org.apache.usergrid.persistence.utils.ClassUtils.cast;
+
+
+public class MapUtils extends org.apache.commons.collections.MapUtils {
+
+ public static <A, B> void addMapSet( Map<A, Set<B>> map, A a, B b ) {
+ addMapSet( map, false, a, b );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <A, B> void addMapSet( Map<A, Set<B>> map, boolean ignoreCase, A a, B b ) {
+
+ Set<B> setB = map.get( a );
+ if ( setB == null ) {
+ if ( ignoreCase && ( b instanceof String ) ) {
+ setB = ( Set<B> ) new TreeSet<String>( String.CASE_INSENSITIVE_ORDER );
+ }
+ else {
+ setB = new LinkedHashSet<B>();
+ }
+ map.put( a, setB );
+ }
+ setB.add( b );
+ }
+
+
+ public static <A, B, C> void addMapMapSet( Map<A, Map<B, Set<C>>> map, A a, B b, C c ) {
+ addMapMapSet( map, false, a, b, c );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <A, B, C> void addMapMapSet( Map<A, Map<B, Set<C>>> map, boolean ignoreCase, A a, B b, C c ) {
+
+ Map<B, Set<C>> mapB = map.get( a );
+ if ( mapB == null ) {
+ if ( ignoreCase && ( b instanceof String ) ) {
+ mapB = ( Map<B, Set<C>> ) new TreeMap<String, Set<C>>( String.CASE_INSENSITIVE_ORDER );
+ }
+ else {
+ mapB = new LinkedHashMap<B, Set<C>>();
+ }
+ map.put( a, mapB );
+ }
+ addMapSet( mapB, ignoreCase, b, c );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <A, B, C, D> void addMapMapMapSet( Map<A, Map<B, Map<C, Set<D>>>> map, boolean ignoreCase, A a, B b,
+ C c, D d ) {
+ Map<B, Map<C, Set<D>>> mapB = map.get( a );
+ if ( mapB == null ) {
+ if ( ignoreCase && ( b instanceof String ) ) {
+ mapB = ( Map<B, Map<C, Set<D>>> ) new TreeMap<String, Map<C, Set<D>>>( String.CASE_INSENSITIVE_ORDER );
+ }
+ else {
+ mapB = new LinkedHashMap<B, Map<C, Set<D>>>();
+ }
+ map.put( a, mapB );
+ }
+ addMapMapSet( mapB, ignoreCase, b, c, d );
+ }
+
+
+ public static <A, B, C> C getMapMap( Map<A, Map<B, C>> map, A a, B b ) {
+
+ Map<B, C> mapB = map.get( a );
+ if ( mapB == null ) {
+ return null;
+ }
+ return mapB.get( b );
+ }
+
+
+ public static <A, B> void addMapList( Map<A, List<B>> map, A a, B b ) {
+
+ List<B> listB = map.get( a );
+ if ( listB == null ) {
+ listB = new ArrayList<B>();
+ map.put( a, listB );
+ }
+ listB.add( b );
+ }
+
+
+ public static <A, B> void addListToMapList( Map<A, List<B>> map, A a, List<B> b ) {
+
+ List<B> listB = map.get( a );
+ if ( listB == null ) {
+ listB = new ArrayList<B>();
+ map.put( a, listB );
+ }
+ listB.addAll( b );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <K, V> V getValue( Map<K, ?> map, K k ) {
+ V v = null;
+ try {
+ v = ( V ) map.get( k );
+ }
+ catch ( ClassCastException e ) {
+ //LOG.war( "Map value {} was not the expected class", map.get( k ), e );
+ }
+
+ return v;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <K, V> Map<?, ?> map( Object... objects ) {
+ Map<K, V> map = new LinkedHashMap<K, V>();
+ int i = 0;
+ while ( i < objects.length ) {
+ if ( objects[i] instanceof Map.Entry ) {
+ Map.Entry<K, V> entry = ( Entry<K, V> ) objects[i];
+ map.put( entry.getKey(), entry.getValue() );
+ i++;
+ }
+ else if ( objects[i] instanceof Map ) {
+ map.putAll( ( Map<? extends K, ? extends V> ) objects[i] );
+ i++;
+ }
+ else if ( i < ( objects.length - 1 ) ) {
+ K k = ( K ) objects[i];
+ V v = ( V ) objects[i + 1];
+ map.put( k, v );
+ i += 2;
+ }
+ else {
+ break;
+ }
+ }
+ return map;
+ }
+
+
+ private static class SimpleMapEntry<K, V> implements Map.Entry<K, V> {
+
+ private final K k;
+ private V v;
+
+
+ public SimpleMapEntry( K k, V v ) {
+ this.k = k;
+ this.v = v;
+ }
+
+
+ @Override
+ public K getKey() {
+ return k;
+ }
+
+
+ @Override
+ public V getValue() {
+ return v;
+ }
+
+
+ @Override
+ public V setValue( V v ) {
+ V oldV = this.v;
+ this.v = v;
+ return oldV;
+ }
+ }
+
+
+ public static <K, V> Map.Entry<K, V> entry( K k, V v ) {
+ return new SimpleMapEntry<K, V>( k, v );
+ }
+
+
+ public static <K, V> K getFirstKey( Map<K, V> map ) {
+ if ( map == null ) {
+ return null;
+ }
+ Entry<K, V> e = map.entrySet().iterator().next();
+ if ( e != null ) {
+ return e.getKey();
+ }
+ return null;
+ }
+
+
+ public static <V> Map<String, V> filter( Map<String, V> map, String prefix, boolean removePrefix ) {
+ Map<String, V> filteredMap = new LinkedHashMap<String, V>();
+ for ( Entry<String, V> entry : map.entrySet() ) {
+ if ( entry.getKey().startsWith( prefix ) ) {
+ if ( removePrefix ) {
+ filteredMap.put( entry.getKey().substring( prefix.length() ), entry.getValue() );
+ }
+ else {
+ filteredMap.put( entry.getKey(), entry.getValue() );
+ }
+ }
+ }
+ return filteredMap;
+ }
+
+
+ public static <V> Map<String, V> filter( Map<String, V> map, String prefix ) {
+ return filter( map, prefix, false );
+ }
+
+
+ public static Properties filter( Properties properties, String prefix, boolean removePrefix ) {
+ Properties filteredProperties = new Properties();
+ for ( Entry<String, String> entry : asMap( properties ).entrySet() ) {
+ if ( entry.getKey().startsWith( prefix ) ) {
+ if ( removePrefix ) {
+ filteredProperties.put( entry.getKey().substring( prefix.length() ), entry.getValue() );
+ }
+ else {
+ filteredProperties.put( entry.getKey(), entry.getValue() );
+ }
+ }
+ }
+ return filteredProperties;
+ }
+
+
+ public static Properties filter( Properties properties, String prefix ) {
+ return filter( properties, prefix, false );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, String> asMap( Properties properties ) {
+ return cast( properties );
+ }
+
+
+ public static <S, T> HashMapBuilder<S, T> hashMap( S key, T value ) {
+ return new HashMapBuilder<S, T>().map( key, value );
+ }
+
+
+ public static class HashMapBuilder<S, T> extends HashMap<S, T> {
+ private static final long serialVersionUID = 1L;
+
+
+ public HashMapBuilder() {
+ }
+
+
+ public HashMapBuilder<S, T> map( S key, T value ) {
+ put( key, value );
+ return this;
+ }
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, List<?>> toMapList( Map<String, ?> m ) {
+ Map<String, List<Object>> mapList = new LinkedHashMap<String, List<Object>>();
+
+ for ( Entry<String, ?> e : m.entrySet() ) {
+ if ( e.getValue() instanceof List ) {
+ addListToMapList( mapList, e.getKey(), ( List<Object> ) e.getValue() );
+ }
+ else {
+ addMapList( mapList, e.getKey(), e.getValue() );
+ }
+ }
+
+ return cast( mapList );
+ }
+
+
+ public static Map<String, ?> putPath( String path, Object value ) {
+ return putPath( null, path, value );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, ?> putPath( Map<String, ?> map, String path, Object value ) {
+
+ if ( map == null ) {
+ map = new HashMap<String, Object>();
+ }
+
+ int i = path.indexOf( '.' );
+ if ( i < 0 ) {
+ ( ( Map<String, Object> ) map ).put( path, value );
+ return map;
+ }
+ String segment = path.substring( 0, i ).trim();
+ if ( isNotBlank( segment ) ) {
+ Object o = map.get( segment );
+ if ( ( o != null ) && ( !( o instanceof Map ) ) ) {
+ return map;
+ }
+ Map<String, Object> subMap = ( Map<String, Object> ) o;
+ if ( subMap == null ) {
+ subMap = new HashMap<String, Object>();
+ ( ( Map<String, Object> ) map ).put( segment, subMap );
+ }
+ String subPath = path.substring( i + 1 );
+ if ( isNotBlank( subPath ) ) {
+ putPath( subMap, subPath, value );
+ }
+ }
+
+ return map;
+ }
+
+
+ public static <K, V> Map<K, V> emptyMapWithKeys( Map<K, V> map ) {
+ Map<K, V> newMap = new HashMap<K, V>();
+
+ for ( K k : map.keySet() ) {
+ newMap.put( k, null );
+ }
+
+ return newMap;
+ }
+
+
+ public static boolean hasKeys( Map<?, ?> map, String... keys ) {
+ if ( map == null ) {
+ return false;
+ }
+ for ( String key : keys ) {
+ if ( !map.containsKey( key ) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ public static boolean hasKeys( Map<?, ?> map, Set<String> keys ) {
+ if ( map == null ) {
+ return false;
+ }
+ return map.keySet().containsAll( keys );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/NumberUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/NumberUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/NumberUtils.java
new file mode 100644
index 0000000..39dfbbd
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/NumberUtils.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+public class NumberUtils {
+ public static int sign( int i ) {
+ if ( i < 0 ) {
+ return -1;
+ }
+ if ( i > 0 ) {
+ return 1;
+ }
+ return 0;
+ }
+
+
+ public static long roundLong( long l, long r ) {
+ return ( l / r ) * r;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/PasswordUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/PasswordUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/PasswordUtils.java
new file mode 100644
index 0000000..a8b285d
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/PasswordUtils.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import org.apache.commons.codec.digest.DigestUtils;
+
+
+public class PasswordUtils {
+
+ public static String mongoPassword( String username, String password ) {
+ return DigestUtils.md5Hex( username + ":mongo:" + password );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/StringUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/StringUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/StringUtils.java
new file mode 100644
index 0000000..34a25ca
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/StringUtils.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import java.util.Arrays;
+
+import org.apache.commons.io.IOUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.usergrid.persistence.utils.ConversionUtils.string;
+
+
+public class StringUtils extends org.apache.commons.lang.StringUtils {
+
+ private static final Logger LOG = LoggerFactory.getLogger( StringUtils.class );
+
+
+ public static Object lower( Object obj ) {
+ if ( !( obj instanceof String ) ) {
+ return obj;
+ }
+ return ( ( String ) obj ).toLowerCase();
+ }
+
+
+ public static String stringOrSubstringAfterLast( String str, char c ) {
+ if ( str == null ) {
+ return null;
+ }
+ int i = str.lastIndexOf( c );
+ if ( i != -1 ) {
+ return str.substring( i + 1 );
+ }
+ return str;
+ }
+
+
+ public static String stringOrSubstringBeforeLast( String str, char c ) {
+ if ( str == null ) {
+ return null;
+ }
+ int i = str.lastIndexOf( c );
+ if ( i != -1 ) {
+ return str.substring( 0, i );
+ }
+ return str;
+ }
+
+
+ public static String stringOrSubstringBeforeFirst( String str, char c ) {
+ if ( str == null ) {
+ return null;
+ }
+ int i = str.indexOf( c );
+ if ( i != -1 ) {
+ return str.substring( 0, i );
+ }
+ return str;
+ }
+
+
+ public static String stringOrSubstringAfterFirst( String str, char c ) {
+ if ( str == null ) {
+ return null;
+ }
+ int i = str.indexOf( c );
+ if ( i != -1 ) {
+ return str.substring( i + 1 );
+ }
+ return str;
+ }
+
+
+ public static String compactWhitespace( String str ) {
+ if ( str == null ) {
+ return null;
+ }
+ boolean prevWS = false;
+ StringBuilder builder = new StringBuilder();
+ for ( int i = 0; i < str.length(); i++ ) {
+ char c = str.charAt( i );
+ if ( Character.isWhitespace( c ) ) {
+ if ( !prevWS ) {
+ builder.append( ' ' );
+ }
+ prevWS = true;
+ }
+ else {
+ prevWS = false;
+ builder.append( c );
+ }
+ }
+ return builder.toString().trim();
+ }
+
+
+ /** @return new string with replace applied */
+ public static String replaceAll( String source, String find, String replace ) {
+ if ( source == null ) {
+ return null;
+ }
+ while ( true ) {
+ String old = source;
+ source = source.replaceAll( find, replace );
+ if ( source.equals( old ) ) {
+ return source;
+ }
+ }
+ }
+
+
+ public static String toString( Object obj ) {
+ return string( obj );
+ }
+
+
+ public static String toStringFormat( Object obj, String format ) {
+ if ( obj != null ) {
+ if ( format != null ) {
+ if ( obj.getClass().isArray() ) {
+ return String.format( format, Arrays.toString( ( Object[] ) obj ) );
+ }
+ return String.format( format, string( obj ) );
+ }
+ else {
+ return string( obj );
+ }
+ }
+ return "";
+ }
+
+
+ public static boolean isString( Object obj ) {
+ return obj instanceof String;
+ }
+
+
+ public static boolean isStringOrNull( Object obj ) {
+ if ( obj == null ) {
+ return true;
+ }
+ return obj instanceof String;
+ }
+
+
+ public static String readClasspathFileAsString( String filePath ) {
+ try {
+ return IOUtils.toString( StringUtils.class.getResourceAsStream( filePath ) );
+ }
+ catch ( Exception e ) {
+ LOG.error( "Error getting file from classpath: " + filePath, e );
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/TimeUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/TimeUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/TimeUtils.java
new file mode 100644
index 0000000..e50251f
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/TimeUtils.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import com.google.common.base.CharMatcher;
+import com.google.common.base.Splitter;
+
+
+public class TimeUtils {
+ /**
+ * Jira-style duration parser. Supported duration strings are: <ul> <li>'S': milliseconds</li> <li>'s': seconds</li>
+ * <li>'m': minutes</li> <li>'h': hours</li> <li>'d': days</li> </ul>
+ * <p/>
+ * Durations can be compound statements in any order as long as they are separated by a ',' (comma). Eg. "1d,14h,3s"
+ * to get the millisecond equivalent of one day, fourteen hours and 3 seconds.
+ * <p/>
+ * Numbers with no durations will be treated as raw millisecond values
+ *
+ * @return the number of milliseconds representing the duration
+ */
+ public static long millisFromDuration( String durationStr ) {
+ long total = 0;
+ MultiplierToken mt;
+ long dur;
+ for ( String val : Splitter.on( ',' ).trimResults().omitEmptyStrings().split( durationStr ) ) {
+ dur = Long.parseLong( CharMatcher.DIGIT.retainFrom( val ) );
+ mt = MultiplierToken.from( val.charAt( val.length() - 1 ) );
+ total += ( mt.multiplier * dur );
+ }
+ return total;
+ }
+
+
+ private enum MultiplierToken {
+ MILSEC_TOKEN( 'S', 1L ),
+ SEC_TOKEN( 's', 1000L ),
+ MIN_TOKEN( 'm', 60000L ),
+ HOUR_TOKEN( 'h', 3600000L ),
+ DAY_TOKEN( 'd', 86400000L );
+
+ final char token;
+ final long multiplier;
+
+
+ MultiplierToken( char token, long multiplier ) {
+ this.token = token;
+ this.multiplier = multiplier;
+ }
+
+
+ static MultiplierToken from( char c ) {
+ switch ( c ) {
+ case 's':
+ return SEC_TOKEN;
+ case 'm':
+ return MIN_TOKEN;
+ case 'h':
+ return HOUR_TOKEN;
+ case 'd':
+ return DAY_TOKEN;
+ case 'S':
+ return MILSEC_TOKEN;
+ default:
+ break;
+ }
+
+ if ( CharMatcher.DIGIT.matches( c ) ) {
+ return MILSEC_TOKEN;
+ }
+ throw new IllegalArgumentException( "Duration token was not on of [S,s,m,h,d] but was " + c );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/UUIDUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/UUIDUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/UUIDUtils.java
new file mode 100644
index 0000000..0363cd6
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/UUIDUtils.java
@@ -0,0 +1,412 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.fasterxml.uuid.EthernetAddress;
+import com.fasterxml.uuid.UUIDComparator;
+
+import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_HI;
+import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_LO;
+import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_MID;
+import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_SEQUENCE;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.commons.codec.binary.Base64.decodeBase64;
+import static org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString;
+
+import static org.apache.usergrid.persistence.utils.ConversionUtils.bytes;
+import static org.apache.usergrid.persistence.utils.ConversionUtils.uuid;
+
+
+public class UUIDUtils {
+ private static final Logger LOG = LoggerFactory.getLogger( UUIDUtils.class );
+ private static final int[] MICROS = new int[1000];
+
+
+ static {
+ for ( int x = 0; x < 1000; x++ ) {
+ MICROS[x] = x * 10;
+ }
+ }
+
+
+ private static ReentrantLock tsLock = new ReentrantLock( true );
+
+ public static final UUID MIN_TIME_UUID = UUID.fromString( "00000000-0000-1000-8000-000000000000" );
+
+ public static final UUID MAX_TIME_UUID = UUID.fromString( "ffffffff-ffff-1fff-bfff-ffffffffffff" );
+
+ public static final UUID ZERO_UUID = new UUID( 0, 0 );
+
+ private static long timestampMillisNow = System.currentTimeMillis();
+
+ private static AtomicInteger currentMicrosPoint = new AtomicInteger( 0 );
+ private static AtomicInteger customMicrosPointer = new AtomicInteger( 0 );
+
+
+ /**
+ * Return the "next" UUID in micro second resolution. <b>WARNING</b>: this is designed to return the next unique
+ * timestamped UUID for this JVM. Depending on velocity of the call, this method may block internally to insure that
+ * "now" is kept in sync with the UUIDs being generated by this call.
+ * <p/>
+ * In other words, we will intentionally burn CPU insuring that this method is not executed more than 10k -1 times
+ * per millisecond and guarantee that those microseconds held within are sequential.
+ * <p/>
+ * If we did not do this, you would get <b>timestamp collision</b> even though the UUIDs will technically be
+ * 'unique.'
+ */
+ public static java.util.UUID newTimeUUID() {
+ // get & inc counter, but roll on 1k (because we divide by 10 on retrieval)
+ // if count + currentMicro > 1k, block and roll
+ tsLock.lock();
+ long ts = System.currentTimeMillis();
+ if ( ts > timestampMillisNow ) {
+ timestampMillisNow = ts;
+ currentMicrosPoint.set( 0 );
+ }
+ int pointer = currentMicrosPoint.getAndIncrement();
+ try {
+ if ( pointer > 990 ) {
+ TimeUnit.MILLISECONDS.sleep( 1L );
+ }
+ }
+ catch ( Exception ex ) {
+ ex.printStackTrace();
+ }
+ finally {
+ tsLock.unlock();
+ }
+ return newTimeUUID( ts, MICROS[pointer] );
+ }
+
+
+ private static final long KCLOCK_OFFSET = 0x01b21dd213814000L;
+ private static final long KCLOCK_MULTIPLIER_L = 10000L;
+
+ private static final Random CLOCK_SEQ_RANDOM = new Random();
+
+
+ // 14 bits of randomness
+ private static int getRandomClockSequence() {
+ return CLOCK_SEQ_RANDOM.nextInt() & 0x3FFF;
+ }
+
+
+ private static void setTimestamp( long timestamp, byte[] uuidBytes, int clockSeq, int timeOffset ) {
+
+ timestamp *= KCLOCK_MULTIPLIER_L;
+ timestamp += KCLOCK_OFFSET;
+ timestamp += timeOffset;
+
+ // Set random clock sequence
+ uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] = ( byte ) ( clockSeq >> 8 );
+ uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE + 1] = ( byte ) clockSeq;
+
+ // Set variant
+ uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] &= 0x3F;
+ uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] |= 0x80;
+ setTime( uuidBytes, timestamp );
+ }
+
+
+ @SuppressWarnings("all")
+ private static void setTime( byte[] uuidBytes, long timestamp ) {
+
+ // Time fields aren't nicely split across the UUID, so can't just
+ // linearly dump the stamp:
+ int clockHi = ( int ) ( timestamp >>> 32 );
+ int clockLo = ( int ) timestamp;
+
+ uuidBytes[BYTE_OFFSET_CLOCK_HI] = ( byte ) ( clockHi >>> 24 );
+ uuidBytes[BYTE_OFFSET_CLOCK_HI + 1] = ( byte ) ( clockHi >>> 16 );
+ uuidBytes[BYTE_OFFSET_CLOCK_MID] = ( byte ) ( clockHi >>> 8 );
+ uuidBytes[BYTE_OFFSET_CLOCK_MID + 1] = ( byte ) clockHi;
+
+ uuidBytes[BYTE_OFFSET_CLOCK_LO] = ( byte ) ( clockLo >>> 24 );
+ uuidBytes[BYTE_OFFSET_CLOCK_LO + 1] = ( byte ) ( clockLo >>> 16 );
+ uuidBytes[BYTE_OFFSET_CLOCK_LO + 2] = ( byte ) ( clockLo >>> 8 );
+ uuidBytes[BYTE_OFFSET_CLOCK_LO + 3] = ( byte ) clockLo;
+
+ // Set version
+ uuidBytes[BYTE_OFFSET_CLOCK_HI] &= 0x0F;
+ uuidBytes[BYTE_OFFSET_CLOCK_HI] |= 0x10;
+ }
+
+
+ /**
+ * Generate a timeuuid with the given timestamp in milliseconds and the time offset. Useful when you need to
+ * generate sequential UUIDs for the same period in time. I.E
+ * <p/>
+ * newTimeUUID(1000, 0) <br/> newTimeUUID(1000, 1) <br /> newTimeUUID(1000, 2) <br />
+ * <p/>
+ * etc.
+ * <p/>
+ * Only use this method if you are absolutely sure you need it. When it doubt use the method without the timestamp
+ * offset
+ *
+ * @param ts The timestamp in milliseconds
+ * @param timeoffset The offset, which should always be <= 10000. If you go beyond this range, the millisecond will
+ * be incremented since this is beyond the possible values when coverrting from millis to 1/10 microseconds stored
+ * in the time uuid.
+ */
+ public static UUID newTimeUUID( long ts, int timeoffset ) {
+ if ( ts == 0 ) {
+ return newTimeUUID();
+ }
+
+ byte[] uuidBytes = new byte[16];
+ // 47 bits of randomness
+ EthernetAddress eth = EthernetAddress.constructMulticastAddress();
+ eth.toByteArray( uuidBytes, 10 );
+ setTimestamp( ts, uuidBytes, getRandomClockSequence(), timeoffset );
+
+ return uuid( uuidBytes );
+ }
+
+
+ /**
+ * Generate a new UUID with the given time stamp in milliseconds. This method guarantees that subsequent calls will
+ * be of increasing value chronologically. If a large number of subsequent calls are made to this method (>1000)
+ * with the same timestamp, you will have non-unique temporal values stored in your UUID.
+ */
+ public static UUID newTimeUUID( long ts ) {
+ tsLock.lock();
+ int pointer = customMicrosPointer.getAndIncrement();
+ try {
+ if ( pointer > 990 ) {
+ customMicrosPointer.set( 0 );
+ }
+ }
+ finally {
+ tsLock.unlock();
+ }
+ return newTimeUUID( ts, MICROS[pointer] );
+ }
+
+
+ public static UUID minTimeUUID( long ts ) {
+ byte[] uuidBytes = new byte[16];
+ setTimestamp( ts, uuidBytes, 0, 0 );
+
+ return uuid( uuidBytes );
+ }
+
+
+ public static UUID maxTimeUUID( long ts ) {
+ byte[] uuidBytes = new byte[16];
+ uuidBytes[10] = ( byte ) 0xFF;
+ uuidBytes[11] = ( byte ) 0xFF;
+ uuidBytes[12] = ( byte ) 0xFF;
+ uuidBytes[13] = ( byte ) 0xFF;
+ uuidBytes[14] = ( byte ) 0xFF;
+ uuidBytes[15] = ( byte ) 0xFF;
+ setTimestamp( ts, uuidBytes, 0x3FFF, 0x1FFF );
+
+ return uuid( uuidBytes );
+ }
+
+
+ /** Returns the minimum UUID */
+ public static UUID min( UUID first, UUID second ) {
+ if ( first == null ) {
+ if ( second == null ) {
+ return null;
+ }
+ return second;
+ }
+
+ if ( second == null ) {
+ return first;
+ }
+
+ if ( compare( first, second ) < 0 ) {
+ return first;
+ }
+ return second;
+ }
+
+
+ /** Returns the minimum UUID */
+ public static UUID max( UUID first, UUID second ) {
+ if ( first == null ) {
+ if ( second == null ) {
+ return null;
+ }
+ return second;
+ }
+
+ if ( second == null ) {
+ return first;
+ }
+
+ if ( compare( first, second ) < 0 ) {
+ return second;
+ }
+ return first;
+ }
+
+
+ /** Returns a UUID that is -1 of the passed uuid, sorted by time uuid only */
+ public static UUID decrement( UUID uuid ) {
+ if ( !isTimeBased( uuid ) ) {
+ throw new IllegalArgumentException( "The uuid must be a time type" );
+ }
+
+
+ //timestamp is in the 60 bit timestamp
+ long timestamp = uuid.timestamp();
+ timestamp--;
+
+ if ( timestamp < 0 ) {
+ throw new IllegalArgumentException( "You must specify a time uuid with a timestamp > 0" );
+ }
+
+ //get our bytes, then set the smaller timestamp into it
+ byte[] uuidBytes = bytes( uuid );
+
+ setTime( uuidBytes, timestamp );
+
+ return uuid( uuidBytes );
+ }
+
+
+ public static boolean isTimeBased( UUID uuid ) {
+ if ( uuid == null ) {
+ return false;
+ }
+ return uuid.version() == 1;
+ }
+
+
+ public static long getTimestampInMillis( UUID uuid ) {
+ if ( uuid == null ) {
+ return 0;
+ }
+ long t = uuid.timestamp();
+ return ( t - KCLOCK_OFFSET ) / KCLOCK_MULTIPLIER_L;
+ }
+
+
+ public static long getTimestampInMicros( UUID uuid ) {
+ if ( uuid == null ) {
+ return 0;
+ }
+ long t = uuid.timestamp();
+ return ( t - KCLOCK_OFFSET ) / 10;
+ }
+
+
+ public static UUID tryGetUUID( String s ) {
+ if ( s == null ) {
+ return null;
+ }
+ if ( s.length() != 36 ) {
+ return null;
+ }
+ // 8-4-4-4-12
+ // 0-7,8,9-12,13,14-17,18,19-22,23,24-35
+ if ( s.charAt( 8 ) != '-' ) {
+ return null;
+ }
+ if ( s.charAt( 13 ) != '-' ) {
+ return null;
+ }
+ if ( s.charAt( 18 ) != '-' ) {
+ return null;
+ }
+ if ( s.charAt( 23 ) != '-' ) {
+ return null;
+ }
+ UUID uuid = null;
+ try {
+ uuid = UUID.fromString( s );
+ }
+ catch ( Exception e ) {
+ LOG.info( "Could not convert String {} into a UUID", s, e );
+ }
+ return uuid;
+ }
+
+
+ public static boolean isUUID( String s ) {
+ return tryGetUUID( s ) != null;
+ }
+
+
+ public static UUID tryExtractUUID( String s ) {
+ if ( s == null ) {
+ return null;
+ }
+ if ( s.length() < 36 ) {
+ return null;
+ }
+ return tryGetUUID( s.substring( 0, 36 ) );
+ }
+
+
+ public static UUID tryExtractUUID( String s, int offset ) {
+ if ( s == null ) {
+ return null;
+ }
+ if ( ( s.length() - offset ) < 36 ) {
+ return null;
+ }
+ return tryGetUUID( s.substring( offset, offset + 36 ) );
+ }
+
+
+ public static String toBase64( UUID id ) {
+ if ( id == null ) {
+ return null;
+ }
+ return encodeBase64URLSafeString( bytes( id ) );
+ }
+
+
+ public static UUID fromBase64( String str ) {
+ if ( str == null ) {
+ return null;
+ }
+ byte[] bytes = decodeBase64( str );
+ if ( bytes.length != 16 ) {
+ return null;
+ }
+ return uuid( bytes );
+ }
+
+
+ public static int compare( UUID u1, UUID u2 ) {
+ return UUIDComparator.staticCompare( u1, u2 );
+ }
+
+
+ public static List<UUID> sort( List<UUID> uuids ) {
+ Collections.sort( uuids, new UUIDComparator() );
+ return uuids;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Version.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Version.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Version.java
new file mode 100644
index 0000000..352d6bc
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/Version.java
@@ -0,0 +1,428 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence.utils;
+
+/*******************************************************************************
+ * Copyright (c) 2010, Schley Andrew Kutz All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Schley Andrew Kutz nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ ******************************************************************************/
+
+import java.io.Serializable;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+
+
+/**
+ * The Version class can be used to parse a standard version string into its four components,
+ * MAJOR.MINOR.BUILD.REVISION.
+ */
+public class Version implements Serializable, Cloneable, Comparable<Version> {
+ /** A serial version UID. */
+ private static final long serialVersionUID = -4316270526722986552L;
+
+ /** A pattern to match the standard version format MAJOR.MINOR.BUILD.REVISION. */
+ private static final Pattern STD_VERSION_PATT =
+ Pattern.compile( "^([^\\d]*?)(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:\\.(\\d+))?(.*)$" );
+
+
+ /** Initialize a new Version object that is set to "0.0.0.0". */
+ public Version() {
+ }
+
+
+ /** Everything before the version in the string that was parsed. */
+ private String prefix;
+
+ /** Everything after the version in the string that was parsed. */
+ private String suffix;
+
+ /** The String that was parsed to create this version object. */
+ private String rawVersion;
+
+
+ /**
+ * Gets everything before the version in the string that was parsed.
+ *
+ * @return Everything before the version in the string that was parsed.
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+
+ /**
+ * Parses a new Version object from a String.
+ *
+ * @param toParse The String object to parse.
+ *
+ * @return A new Version object.
+ *
+ * @throws Exception When there is an error parsing the String.
+ */
+ public static Version parse( String toParse ) throws Exception {
+ Matcher m = STD_VERSION_PATT.matcher( toParse );
+
+ if ( !m.find() ) {
+ throw new Exception( String.format( "Error parsing version from '%s'", toParse ) );
+ }
+
+ Version v = new Version();
+ v.rawVersion = toParse;
+ v.prefix = m.group( 1 );
+
+ if ( StringUtils.isNotEmpty( m.group( 2 ) ) ) {
+ v.setMajor( m.group( 2 ) );
+ }
+
+ if ( StringUtils.isNotEmpty( m.group( 3 ) ) ) {
+ v.setMinor( m.group( 3 ) );
+ }
+
+ if ( StringUtils.isNotEmpty( m.group( 4 ) ) ) {
+ v.setBuild( m.group( 4 ) );
+ }
+
+ if ( StringUtils.isNotEmpty( m.group( 5 ) ) ) {
+ v.setRevision( m.group( 5 ) );
+ }
+
+ v.suffix = m.group( 6 );
+
+ return v;
+ }
+
+
+ /** The version's MAJOR component. */
+ private String major = "0";
+
+
+ /**
+ * Sets the version's MAJOR component.
+ *
+ * @param toSet The version's MAJOR component.
+ *
+ * @throws IllegalArgumentException When a null or non-numeric value is given.
+ */
+ public void setMajor( String toSet ) throws IllegalArgumentException {
+ if ( StringUtils.isEmpty( toSet ) ) {
+ throw new IllegalArgumentException( "Argument is null" );
+ }
+
+ if ( !toSet.matches( "\\d+" ) ) {
+ throw new IllegalArgumentException( "Argument is not numeric" );
+ }
+
+ if ( numberOfComponents < 1 ) {
+ numberOfComponents = 1;
+ }
+
+ major = toSet;
+ }
+
+
+ /** The version's MAJOR component as an integer. */
+ private int getMajorAsInt() {
+ return Integer.parseInt( major );
+ }
+
+
+ /** The version's MINOR component. */
+ private String minor = "0";
+
+
+ /**
+ * Sets the version's MINOR component.
+ *
+ * @param toSet The version's MINOR component.
+ *
+ * @throws IllegalArgumentException When a null or non-numeric value is given.
+ */
+ public void setMinor( String toSet ) throws IllegalArgumentException {
+ if ( StringUtils.isEmpty( toSet ) ) {
+ throw new IllegalArgumentException( "Argument is null" );
+ }
+
+ if ( !toSet.matches( "\\d+" ) ) {
+ throw new IllegalArgumentException( "Argument is not numeric" );
+ }
+
+ if ( numberOfComponents < 2 ) {
+ numberOfComponents = 2;
+ }
+
+ minor = toSet;
+ }
+
+
+ /** The version's MINOR component as an integer. */
+ private int getMinorAsInt() {
+ return Integer.parseInt( minor );
+ }
+
+
+ /** The version's BUILD component. */
+ private String build = "0";
+
+
+ /** The version's BUILD component as an integer. */
+ private int getBuildAsInt() {
+ return Integer.parseInt( build );
+ }
+
+
+ /**
+ * Gets the version's BUILD component.
+ *
+ * @return The version's BUILD component.
+ */
+ public String getBuild() {
+ return build;
+ }
+
+
+ /**
+ * Sets the version's BUILD component.
+ *
+ * @param toSet The version's BUILD component.
+ *
+ * @throws IllegalArgumentException When a null or non-numeric value is given.
+ */
+ public void setBuild( String toSet ) throws IllegalArgumentException {
+ if ( StringUtils.isEmpty( toSet ) ) {
+ throw new IllegalArgumentException( "Argument is null" );
+ }
+
+ if ( !toSet.matches( "\\d+" ) ) {
+ throw new IllegalArgumentException( "Argument is not numeric" );
+ }
+
+ if ( numberOfComponents < 3 ) {
+ numberOfComponents = 3;
+ }
+
+ build = toSet;
+ }
+
+
+ /**
+ * Sets the version's BUILD component.
+ *
+ * @param toSet The version's BUILD component.
+ */
+ public void setBuild( int toSet ) {
+ setBuild( String.valueOf( toSet ) );
+ }
+
+
+ /** The version's REVISION component. */
+ private String revision = "0";
+
+
+ /** The version's REVISION component as an integer. */
+ private int getRevisionAsInt() {
+ return Integer.parseInt( revision );
+ }
+
+
+ /**
+ * Sets the version's REVISION component.
+ *
+ * @param toSet The version's REVISION component.
+ *
+ * @throws IllegalArgumentException When a null or non-numeric value is given.
+ */
+ public void setRevision( String toSet ) throws IllegalArgumentException {
+ if ( StringUtils.isEmpty( toSet ) ) {
+ throw new IllegalArgumentException( "Argument is null" );
+ }
+
+ if ( !toSet.matches( "\\d+" ) ) {
+ throw new IllegalArgumentException( "Argument is not numeric" );
+ }
+
+ if ( numberOfComponents < 4 ) {
+ numberOfComponents = 4;
+ }
+
+ revision = toSet;
+ }
+
+
+ /**
+ * The number of components that make up the version. The value will always be between 1 (inclusive) and 4
+ * (inclusive).
+ */
+ private int numberOfComponents;
+
+
+ @Override
+ @SuppressWarnings("all")
+ public Object clone() throws CloneNotSupportedException {
+ Version v = new Version();
+
+ v.rawVersion = rawVersion;
+ v.prefix = prefix;
+ v.suffix = suffix;
+
+ v.numberOfComponents = numberOfComponents;
+
+ v.major = major;
+ v.minor = minor;
+ v.build = build;
+ v.revision = revision;
+
+ return v;
+ }
+
+
+ @Override
+ public boolean equals( Object toCompare ) {
+ // Compare pointers
+ if ( toCompare == this ) {
+ return true;
+ }
+
+ // Compare types
+ if ( !( toCompare instanceof Version ) ) {
+ return false;
+ }
+
+ return compareTo( ( Version ) toCompare ) == 0;
+ }
+
+
+ @Override
+ public int hashCode() {
+ return toString().hashCode();
+ }
+
+
+ @Override
+ public String toString() {
+ return String.format( "%s.%s.%s.%s", major, minor, build, revision );
+ }
+
+
+ /**
+ * Gets the version as a string using the specified number of components.
+ *
+ * @param components The number of components. Values less than 1 will be treated as 1 and values greater than 4
+ * will be treated as 4.
+ *
+ * @return The version as a string using the specified number of components.
+ */
+ public String toString( int components ) {
+ StringBuilder buff = new StringBuilder();
+ buff.append( major );
+
+ if ( components > 4 ) {
+ components = 4;
+ }
+
+ switch ( components ) {
+ case 2:
+ buff.append( String.format( ".%s", minor ) );
+ break;
+ case 3:
+ buff.append( String.format( ".%s.%s", minor, build ) );
+ break;
+ case 4:
+ buff.append( String.format( ".%s.%s.%s", minor, build, revision ) );
+ break;
+ default:
+ break;
+ }
+
+ return buff.toString();
+ }
+
+
+ private int compareInts( int x, int y ) {
+ if ( x == y ) {
+ return 0;
+ }
+
+ if ( x < y ) {
+ return -1;
+ }
+
+ return 1;
+ }
+
+
+ @Override
+ public int compareTo( Version toCompare ) {
+ int result = toString().compareTo( toCompare.toString() );
+
+ if ( result == 0 ) {
+ return result;
+ }
+
+ result = compareInts( getMajorAsInt(), toCompare.getMajorAsInt() );
+
+ if ( result != 0 ) {
+ return result;
+ }
+
+ result = compareInts( getMinorAsInt(), toCompare.getMinorAsInt() );
+
+ if ( result != 0 ) {
+ return result;
+ }
+
+ result = compareInts( getBuildAsInt(), toCompare.getBuildAsInt() );
+
+ if ( result != 0 ) {
+ return result;
+ }
+
+ result = compareInts( getRevisionAsInt(), toCompare.getRevisionAsInt() );
+
+ if ( result != 0 ) {
+ return result;
+ }
+
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/package-info.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/package-info.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/package-info.java
new file mode 100644
index 0000000..b22445d
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/utils/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.persistence.utils;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchTest.java
new file mode 100644
index 0000000..f6ee564
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchTest.java
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.usergrid.persistence.index.impl;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.usergrid.persistence.utils.ElasticSearchRule;
+import org.elasticsearch.ElasticsearchException;
+import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
+import org.elasticsearch.action.get.GetResponse;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.AdminClient;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Elastic search experiments in the form of a test.
+ */
+public class ElasticSearchTest {
+ private static final Logger logger = LoggerFactory.getLogger( ElasticSearchTest.class );
+
+ @Rule
+ public ElasticSearchRule elasticSearchRule = new ElasticSearchRule();
+
+ @Test
+ public void testSimpleCrud() {
+
+ String indexName = RandomStringUtils.randomAlphanumeric(20 ).toLowerCase();
+ String collectionName = "testtype1";
+ String id = RandomStringUtils.randomAlphanumeric(20 );
+
+ Client client = elasticSearchRule.getClient();
+
+ Map<String, Object> json = new HashMap<String, Object>();
+ json.put( "user", "edward" );
+ json.put( "postDate", new Date() );
+ json.put( "message", "who knows if the moon’s a baloon" );
+
+ // create
+ IndexResponse indexResponse = client.prepareIndex(indexName, collectionName, id)
+ .setSource( json ).execute().actionGet();
+ assertTrue( indexResponse.isCreated() );
+
+ // retrieve
+ GetResponse getResponse = client.prepareGet( indexName, collectionName, id).get();
+ assertEquals( "edward", getResponse.getSource().get( "user" ) );
+
+ // update
+ json.put( "message", "If freckles were lovely, and day was night");
+ client.prepareUpdate( indexName, collectionName, id).setDoc( json ).execute().actionGet();
+ getResponse = client.prepareGet( indexName, collectionName, id).get();
+ assertEquals("If freckles were lovely, and day was night",
+ getResponse.getSource().get( "message" ) );
+
+ // update via script
+ client.prepareUpdate( indexName, collectionName, id)
+ .setScript( "ctx._source.message = \"coming out of a keen city in the sky\"" )
+ .execute().actionGet();
+ getResponse = client.prepareGet( indexName, collectionName, id).get();
+ assertEquals("coming out of a keen city in the sky",
+ getResponse.getSource().get( "message" ) );
+
+ // delete
+ client.prepareDelete(indexName, collectionName, id).execute().actionGet();
+ getResponse = client.prepareGet( indexName, collectionName, id).get();
+ assertFalse( getResponse.isExists() );
+
+ client.close();
+ }
+
+
+ @Test
+ public void testStringDoubleIndexDynamicMapping() throws IOException {
+
+ Client client = elasticSearchRule.getClient();
+
+ AdminClient admin = client.admin();
+
+ String index = RandomStringUtils.randomAlphanumeric(20).toLowerCase();
+ String type = "testtype";
+ admin.indices().prepareCreate( index ).execute().actionGet();
+
+ // add dynamic string-double index mapping
+ XContentBuilder mxcb = EntityCollectionIndexImpl
+ .createDoubleStringIndexMapping( jsonBuilder(), type );
+ PutMappingResponse pmr = admin.indices().preparePutMapping(index)
+ .setType( type ).setSource( mxcb ).execute().actionGet();
+
+ indexSampleData( type, client, index );
+
+ testQuery( client, index, type,
+ QueryBuilders.termQuery( "name", "Orr Byers" ), 1 );
+
+ // term query is exact match
+ testQuery( client, index, type,
+ QueryBuilders.termQuery("name", "Byers" ), 0 );
+
+ // match query allows partial match
+ testQuery( client, index, type,
+ QueryBuilders.matchQuery( "name_ug_analyzed", "Byers" ), 1 );
+
+ testQuery( client, index, type,
+ QueryBuilders.termQuery( "company", "Geologix" ), 1 );
+
+ testQuery( client, index, type,
+ QueryBuilders.termQuery( "gender", "female" ), 3 );
+
+ // query of nested object fields supported
+ testQuery( client, index, type,
+ QueryBuilders.termQuery( "contact.email", "orrbyers@bittor.com" ), 1 );
+
+ client.close();
+ }
+
+
+ private void indexSampleData( String type, Client client, String index )
+ throws ElasticsearchException, IOException {
+
+ InputStream is = this.getClass().getResourceAsStream( "/sample-small.json" );
+ ObjectMapper mapper = new ObjectMapper();
+ List<Object> contacts = mapper.readValue( is, new TypeReference<List<Object>>() {} );
+
+ for ( Object o : contacts ) {
+ Map<String, Object> item = (Map<String, Object>)o;
+ String id = item.get( "id" ).toString();
+
+ XContentBuilder dxcb = ElasticSearchTest
+ .prepareContentForIndexing( jsonBuilder(), type, item );
+
+ IndexResponse ir = client.prepareIndex(index, type, id )
+ .setSource( dxcb ).setRefresh( true ).execute().actionGet();
+ }
+ }
+
+
+ private void testQuery( Client client, String index, String type, QueryBuilder qb, int num ) {
+ SearchResponse sr = client.prepareSearch( index ).setTypes( type )
+ .setQuery( qb ).setFrom( 0 ).setSize( 20 ).execute().actionGet();
+ assertEquals( num, sr.getHits().getTotalHits() );
+ }
+
+
+ public static XContentBuilder prepareContentForIndexing( String name, XContentBuilder builder,
+ String type, Map<String, Object> data ) throws IOException {
+
+ if ( name != null ) {
+ builder = builder.startObject( name );
+ } else {
+ builder = builder.startObject();
+ }
+ for ( String key : data.keySet() ) {
+ Object value = data.get( key );
+ try {
+
+ if ( value instanceof Map ) {
+ builder = prepareContentForIndexing(
+ key, builder, type, (Map<String, Object>)data.get(key));
+
+ } else if ( value instanceof List ) {
+ builder = prepareContentForIndexing(key, builder, type, (List)value);
+
+ } else if ( value instanceof String ) {
+ builder = builder
+ .field( key + "_ug_analyzed", value )
+ .field( key, value );
+
+ } else {
+ builder = builder
+ .field( key, value );
+
+ }
+ } catch ( Exception e ) {
+ logger.error( "Error processing {} : {}", key, value, e );
+ throw new RuntimeException(e);
+ }
+ }
+ builder = builder.endObject();
+ return builder;
+ }
+
+
+ public static XContentBuilder prepareContentForIndexing( XContentBuilder builder,
+ String type, Map<String, Object> dataMap ) throws IOException {
+ return prepareContentForIndexing( null, builder, type, dataMap );
+ }
+
+
+ public static XContentBuilder prepareContentForIndexing( String name, XContentBuilder builder,
+ String type, List dataList ) throws IOException {
+
+ if ( name != null ) {
+ builder = builder.startArray( name );
+ } else {
+ builder = builder.startArray();
+ }
+ for ( Object o : dataList ) {
+
+ if ( o instanceof Map ) {
+ builder = prepareContentForIndexing( builder, type, (Map<String, Object>)o );
+
+ } else if ( o instanceof List ) {
+ builder = prepareContentForIndexing( builder, type, (List)o);
+
+ } else {
+ builder = builder.value( o );
+
+ }
+ }
+ builder = builder.endArray();
+ return builder;
+ }
+
+
+ public static XContentBuilder prepareContentForIndexing( XContentBuilder builder,
+ String type, List dataList ) throws IOException {
+ return prepareContentForIndexing( null, builder, type, dataList );
+ }
+
+ void log( GetResponse getResponse ) {
+ logger.info( "-------------------------------------------------------------------------" );
+ logger.info( "id: " + getResponse.getId() );
+ logger.info( "type: " + getResponse.getType() );
+ logger.info( "version: " + getResponse.getVersion() );
+ logger.info( "index: " + getResponse.getIndex() );
+ logger.info( "source: " + getResponse.getSourceAsString() );
+ }
+}
[02/21] git commit: Initial commit of the async processor
Posted by sn...@apache.org.
Initial commit of the async processor
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3fd13f09
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3fd13f09
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3fd13f09
Branch: refs/heads/two-dot-o
Commit: 3fd13f097a1564cbf350cbc49270b96ad5b1d6be
Parents: 2de25a2
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Feb 20 17:48:00 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Feb 20 17:48:00 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/graph/EdgeManager.java | 2 +-
.../graph/consistency/AsyncProcessor.java | 35 ++++++++++++++++
.../graph/consistency/AsyncProcessorImpl.java | 37 +++++++++++++++++
.../graph/consistency/SimpleTimeoutEvent.java | 30 ++++++++++++++
.../graph/consistency/TimeoutEvent.java | 18 +++++++++
.../graph/consistency/TimeoutQueue.java | 42 ++++++++++++++++++++
.../persistence/graph/guice/GraphModule.java | 26 ++++++++++++
7 files changed, 189 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fd13f09/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/EdgeManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/EdgeManager.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/EdgeManager.java
index 39deb64..6a6a092 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/EdgeManager.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/EdgeManager.java
@@ -71,7 +71,7 @@ public interface EdgeManager {
Observable<Edge> deleteEdge( Edge edge );
/**
- * TODO: This needs to mark a node as deleted while async processing occurs, our reads would need to check this filter on read
+ * TODO: This needs to mark a node as deleted while consistency processing occurs, our reads would need to check this filter on read
*
* Remove the node from the graph.
*
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fd13f09/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/AsyncProcessor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/AsyncProcessor.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/AsyncProcessor.java
new file mode 100644
index 0000000..948ef2b
--- /dev/null
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/AsyncProcessor.java
@@ -0,0 +1,35 @@
+package org.apache.usergrid.persistence.graph.consistency;
+
+
+/**
+ * Used to fork lazy repair and other types of operations. This can be implemented
+ * across multiple environments.
+ *
+ */
+public interface AsyncProcessor {
+
+
+ /**
+ * The processor implementation is responsible for guaranteeing the events fire in the runtime environment.
+ * This could be local or clustered, consult the documentation on the implementation. Note that events published
+ * here could possibly be double published if the operation reaches it's timeout before completion. As a result, every
+ * receiver of the event should operate in an idempotent way.
+ *
+ * @param event The event to be scheduled for verification
+ * @param timeout The epoch time in milliseconds the event should fire
+ */
+ public <T> TimeoutEvent<T> verify(T event, long timeout);
+
+
+ /**
+ * Start processing the event immediately asynchronously.
+ *
+ * @param event
+ * @param <T>
+ */
+ public <T> void start(T event);
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fd13f09/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/AsyncProcessorImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/AsyncProcessorImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/AsyncProcessorImpl.java
new file mode 100644
index 0000000..2ee308a
--- /dev/null
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/AsyncProcessorImpl.java
@@ -0,0 +1,37 @@
+package org.apache.usergrid.persistence.graph.consistency;
+
+
+import com.google.common.eventbus.EventBus;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+
+/**
+ * The implementation of asynchronous processing
+ */
+@Singleton
+public class AsyncProcessorImpl implements AsyncProcessor {
+
+ private final EventBus bus;
+ private final TimeoutQueue queue;
+
+
+ @Inject
+ public AsyncProcessorImpl( final EventBus bus, final TimeoutQueue queue ) {
+ this.bus = bus;
+ this.queue = queue;
+ }
+
+
+ @Override
+ public <T> TimeoutEvent<T> verify( final T event, final long timeout ) {
+ return queue.queue( event, timeout );
+ }
+
+
+ @Override
+ public <T> void start( final T event ) {
+ //TODO, wrap this in hystrix for timeouts and capacity
+ bus.post( event );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fd13f09/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/SimpleTimeoutEvent.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/SimpleTimeoutEvent.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/SimpleTimeoutEvent.java
new file mode 100644
index 0000000..73ef653
--- /dev/null
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/SimpleTimeoutEvent.java
@@ -0,0 +1,30 @@
+package org.apache.usergrid.persistence.graph.consistency;
+
+
+/**
+ *
+ *
+ */
+public class SimpleTimeoutEvent<T> implements TimeoutEvent<T> {
+
+ private final T event;
+ private final long timeout;
+
+
+ public SimpleTimeoutEvent( final T event, final long timeout ) {
+ this.event = event;
+ this.timeout = timeout;
+ }
+
+
+ @Override
+ public T getEvent() {
+ return event;
+ }
+
+
+ @Override
+ public long getTimeout() {
+ return timeout;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fd13f09/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/TimeoutEvent.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/TimeoutEvent.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/TimeoutEvent.java
new file mode 100644
index 0000000..c482730
--- /dev/null
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/TimeoutEvent.java
@@ -0,0 +1,18 @@
+package org.apache.usergrid.persistence.graph.consistency;
+
+
+/**
+ * An interface for a timeout event
+ */
+public interface TimeoutEvent<T> {
+
+ /**
+ * @return The event to fire when our timeout is reached
+ */
+ T getEvent();
+
+ /**
+ * @return The time in epoch millis the event will time out
+ */
+ long getTimeout();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fd13f09/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/TimeoutQueue.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/TimeoutQueue.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/TimeoutQueue.java
new file mode 100644
index 0000000..e05194d
--- /dev/null
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/consistency/TimeoutQueue.java
@@ -0,0 +1,42 @@
+package org.apache.usergrid.persistence.graph.consistency;
+
+
+import java.util.Collection;
+
+
+/**
+ * Interface for implementations of a timeout queue.
+ */
+public interface TimeoutQueue {
+
+ /**
+ * Queue the event with the timeout provided
+ *
+ * @param event The event to queue
+ * @param timeout The timeout to set on the queue element
+ * @param <T> The type to return
+ */
+ public <T> TimeoutEvent<T> queue( T event, long timeout );
+
+
+ /**
+ * Take up to maxSize elements with a timeout <= the currentTime
+ *
+ * This implicitly re-schedules every taken operation at currentTime+timeout
+ *
+ * @param <T> The type to return
+ *
+ * @return A collection of events.
+ */
+ public <T> Collection<TimeoutEvent<T>> take( int maxSize, long currentTime, long timeout );
+
+
+ /**
+ * Remove this timeout event from the queue.
+ *
+ * @param event The event to remove
+ *
+ * @return True if the element was removed
+ */
+ public <T> boolean remove( TimeoutEvent<T> event );
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fd13f09/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
index f5758e8..00b1c41 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
@@ -39,9 +39,15 @@ import org.apache.usergrid.persistence.graph.serialization.impl.EdgeMetadataSeri
import org.apache.usergrid.persistence.graph.serialization.impl.EdgeSerializationImpl;
import org.apache.usergrid.persistence.graph.serialization.impl.NodeSerializationImpl;
+import com.google.common.eventbus.EventBus;
import com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
import com.google.inject.assistedinject.FactoryModuleBuilder;
+import com.google.inject.matcher.Matchers;
import com.google.inject.multibindings.Multibinder;
+import com.google.inject.spi.InjectionListener;
+import com.google.inject.spi.TypeEncounter;
+import com.google.inject.spi.TypeListener;
/**
@@ -81,5 +87,25 @@ public class GraphModule extends AbstractModule {
migrationBinding.addBinding().to( NodeSerializationImpl.class );
+ /**
+ * Graph event bus, will need to be refactored into it's own classes
+ */
+
+ final EventBus eventBus = new EventBus("asyncCleanup");
+ bind(EventBus.class).toInstance(eventBus);
+
+ //auto register every impl on the event bus
+ bindListener( Matchers.any(), new TypeListener() {
+ @Override
+ public <I> void hear(@SuppressWarnings("unused") final TypeLiteral<I> typeLiteral, final TypeEncounter<I> typeEncounter) {
+ typeEncounter.register(new InjectionListener<I>() {
+ @Override public void afterInjection(final I instance) {
+ eventBus.register(instance);
+ }
+ });
+ }
+ });
+
+
}
}
[10/21] Rename index to query index, add working query parser code.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThan.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThan.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThan.java
new file mode 100644
index 0000000..0f6495f
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThan.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class GreaterThan extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public GreaterThan( Token t ) {
+ super( t );
+ }
+
+
+ public GreaterThan() {
+ super( new CommonToken( 0, ">" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThanEqual.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThanEqual.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThanEqual.java
new file mode 100644
index 0000000..5d5d431
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThanEqual.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class GreaterThanEqual extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public GreaterThanEqual( Token t ) {
+ super( t );
+ }
+
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public GreaterThanEqual() {
+ super( new CommonToken( 0, ">=" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThan.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThan.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThan.java
new file mode 100644
index 0000000..a3c7979
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThan.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class LessThan extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public LessThan( Token t ) {
+ super( t );
+ }
+
+
+ public LessThan() {
+ super( new CommonToken( 0, "<" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThanEqual.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThanEqual.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThanEqual.java
new file mode 100644
index 0000000..7638721
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThanEqual.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class LessThanEqual extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public LessThanEqual( Token t ) {
+ super( t );
+ }
+
+
+ /**
+ */
+ public LessThanEqual() {
+ super( new CommonToken( 0, "<=" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Literal.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Literal.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Literal.java
new file mode 100644
index 0000000..60071c4
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Literal.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.Token;
+import org.antlr.runtime.tree.CommonTree;
+
+
+/**
+ * Abstract class for literals
+ *
+ * @author tnine
+ */
+public abstract class Literal<V> extends CommonTree {
+
+
+ protected Literal( Token t ) {
+ super( t );
+ }
+
+
+ /** Return the value of the literal the user has passed in */
+ public abstract V getValue();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LiteralFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LiteralFactory.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LiteralFactory.java
new file mode 100644
index 0000000..cc69f9d
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LiteralFactory.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import java.util.UUID;
+
+
+/**
+ * Simple factory for generating literal instance based on the runtime value
+ *
+ * @author tnine
+ */
+public class LiteralFactory {
+
+ /** Generate the correct literal subclass based on the runtime instance. */
+ public static final Literal<?> getLiteral( Object value ) {
+ if ( value instanceof Integer ) {
+ return new LongLiteral( ( Integer ) value );
+ }
+ if ( value instanceof Long ) {
+ return new LongLiteral( ( Long ) value );
+ }
+
+ if ( value instanceof String ) {
+ return new StringLiteral( ( String ) value );
+ }
+
+ if ( value instanceof Float ) {
+ return new FloatLiteral( ( Float ) value );
+ }
+
+ if ( value instanceof UUID ) {
+ return new UUIDLiteral( ( UUID ) value );
+ }
+
+ if ( value instanceof Boolean ) {
+ return new BooleanLiteral( ( Boolean ) value );
+ }
+
+ throw new UnsupportedOperationException(
+ String.format( "Unsupported type of %s was passed when trying to construct a literal",
+ value.getClass() ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LongLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LongLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LongLiteral.java
new file mode 100644
index 0000000..8f1b084
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LongLiteral.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class LongLiteral extends Literal<Long> implements NumericLiteral {
+
+ private long value;
+
+
+ /**
+ * @param t
+ */
+ public LongLiteral( Token t ) {
+ super( t );
+ this.value = Long.valueOf( t.getText() );
+ }
+
+
+ /**
+ *
+ * @param value
+ */
+ public LongLiteral( long value ) {
+ super( new ClassicToken( 0, String.valueOf( value ) ) );
+ this.value = value;
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public Long getValue() {
+ return this.value;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.NumericLiteral#getFloatValue()
+ */
+ @Override
+ public float getFloatValue() {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NotOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NotOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NotOperand.java
new file mode 100644
index 0000000..8388e5d
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NotOperand.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.exceptions.PersistenceException;
+
+
+/** @author tnine */
+public class NotOperand extends Operand {
+
+
+ public NotOperand( Token t ) {
+ super( t );
+ }
+
+
+ /** get the only child operation */
+ public Operand getOperation() {
+ return ( Operand ) this.children.get( 0 );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence.query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws PersistenceException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NumericLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NumericLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NumericLiteral.java
new file mode 100644
index 0000000..96d5f49
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NumericLiteral.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+/** @author tnine */
+public interface NumericLiteral {
+
+ /** Return the value of this numeric literal as a float */
+ public float getFloatValue();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Operand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Operand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Operand.java
new file mode 100644
index 0000000..0f59ca8
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Operand.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.Token;
+import org.antlr.runtime.tree.CommonTree;
+import org.apache.usergrid.persistence.exceptions.PersistenceException;
+
+
+/**
+ * Any logical operation should subclass. Boolean logic, equality, not, contains, within and others are examples of
+ * operands
+ *
+ * @author tnine
+ */
+public abstract class Operand extends CommonTree {
+
+
+ /** Default constructor to take a token */
+ public Operand( Token t ) {
+ super( t );
+ }
+
+
+ /** Get the pointer to the parent node */
+ public Operand getParent() {
+ return ( Operand ) super.getParent();
+ }
+
+
+ /** Visitor method */
+ public abstract void visit( QueryVisitor visitor ) throws PersistenceException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/OrOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/OrOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/OrOperand.java
new file mode 100644
index 0000000..1771dbc
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/OrOperand.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.exceptions.PersistenceException;
+
+
+/** @author tnine */
+public class OrOperand extends BooleanOperand {
+
+ /**
+ * @param left
+ * @param token
+ * @param right
+ */
+ public OrOperand( Token t ) {
+ super( t );
+ }
+
+
+ public OrOperand() {
+ super( new CommonToken( 0, "or" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws PersistenceException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c0543f5f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Property.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Property.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Property.java
new file mode 100644
index 0000000..36028c8
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Property.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.usergrid.persistence.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/**
+ * A property
+ *
+ * @author tnine
+ */
+public class Property extends Literal<String> {
+
+ private String property;
+
+
+ public Property( Token t ) {
+ super( t );
+ this.property = t.getText();
+ }
+
+
+ public Property( String property ) {
+ this( new ClassicToken( 0, property ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.usergrid.persistence.query.tree.Literal#getValue()
+ */
+ @Override
+ public String getValue() {
+ return this.property;
+ }
+
+
+ /**
+ * Subclasses an override. Indexed value could be different when stored internally. By default returns the same
+ * property
+ */
+ public String getIndexedValue() {
+ return this.property;
+ }
+}
[17/21] git commit: Added cache declaration to column family meta data
Posted by sn...@apache.org.
Added cache declaration to column family meta data
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9b7ec937
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9b7ec937
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9b7ec937
Branch: refs/heads/two-dot-o
Commit: 9b7ec937c301ba35e52ca42f93bb1dcd4ea6e592
Parents: 3fd13f0
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Feb 21 10:51:53 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Feb 21 10:52:07 2014 -0700
----------------------------------------------------------------------
.../EntityCollectionManagerFactory.java | 2 +-
.../MultiTennantColumnFamilyDefinition.java | 47 +++++++++++++++++++-
.../collection/mvcc/stage/load/Load.java | 2 +-
.../UniqueValueSerializationStrategyImpl.java | 2 +-
.../MvccEntitySerializationStrategyImpl.java | 2 +-
.../MvccLogEntrySerializationStrategyImpl.java | 2 +-
.../EntityCollectionManagerSyncIT.java | 2 +-
.../impl/EdgeMetadataSerializationImpl.java | 2 +-
.../impl/EdgeSerializationImpl.java | 2 +-
.../impl/NodeSerializationImpl.java | 2 +-
10 files changed, 55 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java
index 59a5e09..a2f2ff7 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerFactory.java
@@ -46,7 +46,7 @@ public interface EntityCollectionManagerFactory {
* The EntityCollectionManager can safely be used on the current thread
* and will cache responses. The returned instance should not be shared
* among threads it will not be guaranteed to be thread safe.
- * This implementation will be synchronous. Try to use the async
+ * This implementation will be synchronous. Try to use the consistency
* implementation if possible
*
* @param collectionScope The collectionScope collectionScope to use when
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/MultiTennantColumnFamilyDefinition.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/MultiTennantColumnFamilyDefinition.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/MultiTennantColumnFamilyDefinition.java
index a906fa4..ddbafc2 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/MultiTennantColumnFamilyDefinition.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/astyanax/MultiTennantColumnFamilyDefinition.java
@@ -33,30 +33,73 @@ import com.netflix.astyanax.model.ColumnFamily;
*/
public class MultiTennantColumnFamilyDefinition {
+
+ /**
+ * Options for caching on the CF
+ */
+ public enum CacheOption {
+ /**
+ * Use both row key cache and key cache
+ */
+ ALL( "ALL" ),
+
+ /**
+ * Cache keys only (the default)
+ */
+ KEYS( "KEYS_ONLY" ),
+
+ /**
+ * Cache rows only, no keys
+ */
+ ROWS( "ROWS_ONLY" ),
+
+ /**
+ * Cache neither
+ */
+ NONE( "NONE" );
+
+ private String value;
+
+
+ private CacheOption( String value ) {
+ this.value = value;
+ }
+
+
+ public String getValue() {
+ return value;
+ }
+ }
+
+
public static final String COMPARATOR_TYPE = "comparator_type";
public static final String READ_REPAIR_CHANCE = "read_repair_chance";
public static final String KEY_VALIDATION = "key_validation_class";
public static final String VALUE_VALIDATION = "default_validation_class";
+ public static final String CACHE_OPTION = "caching";
private final ColumnFamily columnFamily;
private final String columnComparatorType;
private final String keyValidationType;
private final String valueValidationType;
+ private final CacheOption cacheOption;
public MultiTennantColumnFamilyDefinition( final ColumnFamily columnFamily, final String keyValidationType,
- final String columnComparatorType, final String valueValidationType ) {
+ final String columnComparatorType, final String valueValidationType, final CacheOption cacheOption ) {
Preconditions.checkNotNull( columnFamily, "columnFamily is required" );
Preconditions.checkNotNull( columnComparatorType, "columnComparatorType is required" );
Preconditions.checkNotNull( keyValidationType, "keyValidationType is required" );
Preconditions.checkNotNull( valueValidationType, "valueValidationType is required" );
+ Preconditions.checkNotNull( cacheOption, "cacheOption is required" );
this.columnFamily = columnFamily;
this.columnComparatorType = columnComparatorType;
this.keyValidationType = keyValidationType;
this.valueValidationType = valueValidationType;
+ this.cacheOption = cacheOption;
}
@@ -66,6 +109,8 @@ public class MultiTennantColumnFamilyDefinition {
options.put( COMPARATOR_TYPE, columnComparatorType );
options.put( KEY_VALIDATION, keyValidationType );
options.put( VALUE_VALIDATION, valueValidationType );
+ options.put( CACHE_OPTION, cacheOption.getValue() );
+
//always use 10% read repair chance!
options.put( READ_REPAIR_CHANCE, 0.1d );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/load/Load.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/load/Load.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/load/Load.java
index 6f61d3e..20abc5a 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/load/Load.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/load/Load.java
@@ -94,7 +94,7 @@ public class Load implements Func1<CollectionIoEvent<Id>, Entity> {
//The version exists, but does not have entity data
if ( !targetVersion.isPresent() ) {
- //TODO, a lazy async repair/cleanup here?
+ //TODO, a lazy consistency repair/cleanup here?
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
index 751021e..421d831 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
@@ -75,7 +75,7 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ
CF_UNIQUE_VALUES,
BytesType.class.getSimpleName(),
ColumnTypes.DYNAMIC_COMPOSITE_TYPE,
- BytesType.class.getSimpleName() );
+ BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
return Collections.singleton( cf );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
index aa64ef7..ebb6edb 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
@@ -207,7 +207,7 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
//create the CF entity data. We want it reversed b/c we want the most recent version at the top of the
//row for fast seeks
MultiTennantColumnFamilyDefinition cf = new MultiTennantColumnFamilyDefinition( CF_ENTITY_DATA,
- BytesType.class.getSimpleName(), ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", BytesType.class.getSimpleName() );
+ BytesType.class.getSimpleName(), ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
return Collections.singleton( cf );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java
index a9734d2..bb09c3e 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java
@@ -198,7 +198,7 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial
MultiTennantColumnFamilyDefinition cf = new MultiTennantColumnFamilyDefinition( CF_ENTITY_LOG,
BytesType.class.getSimpleName(),
ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")",
- IntegerType.class.getSimpleName() );
+ IntegerType.class.getSimpleName() , MultiTennantColumnFamilyDefinition.CacheOption.KEYS);
return Collections.singleton( cf );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSyncIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSyncIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSyncIT.java
index 988bfc2..0f13814 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSyncIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerSyncIT.java
@@ -28,7 +28,7 @@ import static org.junit.Assert.assertNull;
/**
- * TODO: Refactor this and the async test into 1 common set of assertions with seperate invocations and result
+ * TODO: Refactor this and the consistency test into 1 common set of assertions with seperate invocations and result
* returns once jukito is finished
*
*/
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java
index d7e88d5..b6028ea 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationImpl.java
@@ -370,7 +370,7 @@ public class EdgeMetadataSerializationImpl implements EdgeMetadataSerialization,
*/
private MultiTennantColumnFamilyDefinition graphCf( MultiTennantColumnFamily cf ) {
return new MultiTennantColumnFamilyDefinition( cf,
- BytesType.class.getSimpleName(),UTF8Type.class.getSimpleName(), BytesType.class.getSimpleName() );
+ BytesType.class.getSimpleName(),UTF8Type.class.getSimpleName(), BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeSerializationImpl.java
index 3095995..4691973 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeSerializationImpl.java
@@ -513,7 +513,7 @@ public class EdgeSerializationImpl implements EdgeSerialization, Migration {
*/
private MultiTennantColumnFamilyDefinition graphCf( MultiTennantColumnFamily cf ) {
return new MultiTennantColumnFamilyDefinition( cf,
- BytesType.class.getSimpleName(), ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName() );
+ BytesType.class.getSimpleName(), ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName() , MultiTennantColumnFamilyDefinition.CacheOption.KEYS);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9b7ec937/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java
index e8ebc63..50e8373 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java
@@ -106,7 +106,7 @@ public class NodeSerializationImpl implements NodeSerialization, Migration {
public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies() {
return Collections.singleton(
new MultiTennantColumnFamilyDefinition( GRAPH_DELETE, BytesType.class.getSimpleName(),
- BooleanType.class.getSimpleName(), BytesType.class.getSimpleName() ) );
+ BooleanType.class.getSimpleName(), BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.ALL ) );
}