You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/04/10 18:28:02 UTC
[1/5] incubator-usergrid git commit: Removed legacy 1.0 code Cleaned
up Query object to only be query state/builder Refactor of tests to use query
language
Repository: incubator-usergrid
Updated Branches:
refs/heads/USERGRID-536 b1e0517eb -> 8060e16c9 (forced update)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/IntersectionIteratorTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/IntersectionIteratorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/IntersectionIteratorTest.java
deleted file mode 100644
index 540bf8b..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/IntersectionIteratorTest.java
+++ /dev/null
@@ -1,308 +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.query.ir.result;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-import org.junit.Test;
-
-import org.apache.usergrid.utils.UUIDUtils;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
-/** @author tnine */
-public class IntersectionIteratorTest {
-
- @Test
- public void mutipleIterators() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id5 = UUIDUtils.minTimeUUID( 5 );
- UUID id6 = UUIDUtils.minTimeUUID( 6 );
- UUID id7 = UUIDUtils.minTimeUUID( 7 );
- UUID id8 = UUIDUtils.minTimeUUID( 8 );
- UUID id9 = UUIDUtils.minTimeUUID( 9 );
- UUID id10 = UUIDUtils.minTimeUUID( 10 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator first = new InOrderIterator( 100 );
- first.add( id9 );
- first.add( id8 );
- first.add( id1 );
- first.add( id2 );
- first.add( id3 );
-
-
-
- InOrderIterator second = new InOrderIterator( 100 );
- second.add( id1 );
- second.add( id2 );
- second.add( id3 );
- second.add( id4 );
- second.add( id8 );
- second.add( id10 );
-
- InOrderIterator third = new InOrderIterator( 100 );
- third.add( id1 );
- third.add( id3 );
- third.add( id5 );
- third.add( id6 );
- third.add( id7 );
- third.add( id8 );
-
- InOrderIterator fourth = new InOrderIterator( 100 );
- fourth.add( id1 );
- fourth.add( id2 );
- fourth.add( id3 );
- fourth.add( id6 );
- fourth.add( id8 );
- fourth.add( id10 );
-
- IntersectionIterator intersection = new IntersectionIterator( 100 );
- intersection.addIterator( first );
- intersection.addIterator( second );
- intersection.addIterator( third );
- intersection.addIterator( fourth );
-
- Iterator<ScanColumn> union = intersection.next().iterator();
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( union.hasNext() );
- assertEquals( id8, union.next().getUUID() );
-
- assertTrue( union.hasNext() );
- assertEquals( id1, union.next().getUUID() );
-
- assertTrue( union.hasNext() );
- assertEquals( id3, union.next().getUUID() );
-
- assertFalse( union.hasNext() );
- }
-
-
- @Test
- public void oneIterator() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator first = new InOrderIterator( 100 );
- first.add( id1 );
- first.add( id2 );
- first.add( id3 );
- first.add( id4 );
-
- IntersectionIterator intersection = new IntersectionIterator( 100 );
- intersection.addIterator( first );
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( intersection.hasNext() );
-
- Set<ScanColumn> page = intersection.next();
-
- Iterator<ScanColumn> union = page.iterator();
-
- assertEquals( id1, union.next().getUUID() );
-
- assertTrue( union.hasNext() );
- assertEquals( id2, union.next().getUUID() );
-
- assertTrue( union.hasNext() );
- assertEquals( id3, union.next().getUUID() );
-
- assertTrue( union.hasNext() );
- assertEquals( id4, union.next().getUUID() );
-
- assertFalse( union.hasNext() );
- }
-
-
- @Test
- public void noIterator() {
- IntersectionIterator union = new IntersectionIterator( 100 );
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertFalse( union.hasNext() );
- }
-
-
- @Test
- public void largeIntersection() {
-
- int size = 10000;
- int firstIntersection = 100;
- int secondIntersection = 200;
-
- UUID[] firstSet = new UUID[size];
- UUID[] secondSet = new UUID[size];
- UUID[] thirdSet = new UUID[size];
-
- InOrderIterator first = new InOrderIterator( 100 );
- InOrderIterator second = new InOrderIterator( 100 );
- InOrderIterator third = new InOrderIterator( 100 );
-
- List<UUID> results = new ArrayList<UUID>( size / secondIntersection );
-
- for ( int i = 0; i < size; i++ ) {
- firstSet[i] = UUIDUtils.newTimeUUID();
- // every 100 elements, set the element equal to the first set. This way we
- // have intersection
-
- if ( i % firstIntersection == 0 ) {
- secondSet[i] = firstSet[i];
- }
- else {
- secondSet[i] = UUIDUtils.newTimeUUID();
- }
-
- if ( i % secondIntersection == 0 ) {
- thirdSet[i] = firstSet[i];
- results.add( firstSet[i] );
- }
-
- else {
- thirdSet[i] = UUIDUtils.newTimeUUID();
- }
- }
-
- first.add( firstSet );
-
- reverse( secondSet );
- //reverse the second
- second.add( secondSet );
- third.add( thirdSet );
-
- //now itersect them and make sure we get all results in a small set
-
- int numPages = 2;
- int pageSize = results.size() / numPages;
-
- IntersectionIterator intersection = new IntersectionIterator( pageSize );
- intersection.addIterator( first );
- intersection.addIterator( second );
- intersection.addIterator( third );
-
- assertTrue( intersection.hasNext() );
-
-
- Iterator<UUID> expected = results.iterator();
- Set<ScanColumn> resultSet = intersection.next();
- Iterator<ScanColumn> union = resultSet.iterator();
-
-
- while ( union.hasNext() ) {
- assertTrue( expected.hasNext() );
- assertEquals( expected.next(), union.next().getUUID() );
- }
-
-
- //now get the 2nd page
- resultSet = intersection.next();
- union = resultSet.iterator();
-
-
- while ( union.hasNext() ) {
- assertTrue( expected.hasNext() );
- assertEquals( expected.next(), union.next().getUUID() );
- }
-
- //no more elements
- assertFalse( intersection.hasNext() );
- assertFalse( expected.hasNext() );
- }
-
-
- /**
- * Tests that when there are multiple iterators, and one in the "middle" of the list returns no results, it will
- * short circuit since no results will be possible
- */
- @Test
- public void mutipleIteratorsNoIntersection() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id6 = UUIDUtils.minTimeUUID( 6 );
- UUID id8 = UUIDUtils.minTimeUUID( 8 );
- UUID id9 = UUIDUtils.minTimeUUID( 9 );
- UUID id10 = UUIDUtils.minTimeUUID( 10 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator first = new InOrderIterator( 100 );
- first.add( id1 );
- first.add( id2 );
- first.add( id3 );
- first.add( id8 );
- first.add( id9 );
-
- InOrderIterator second = new InOrderIterator( 100 );
- second.add( id1 );
- second.add( id2 );
- second.add( id3 );
- second.add( id4 );
- second.add( id8 );
- second.add( id10 );
-
- InOrderIterator third = new InOrderIterator( 100 );
-
- InOrderIterator fourth = new InOrderIterator( 100 );
- fourth.add( id1 );
- fourth.add( id2 );
- fourth.add( id3 );
- fourth.add( id6 );
- fourth.add( id8 );
- fourth.add( id10 );
-
- IntersectionIterator intersection = new IntersectionIterator( 100 );
- intersection.addIterator( first );
- intersection.addIterator( second );
- intersection.addIterator( third );
- intersection.addIterator( fourth );
-
- Iterator<ScanColumn> union = intersection.next().iterator();
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertFalse( union.hasNext() );
- }
-
-
- private void reverse( UUID[] array ) {
-
- UUID temp = null;
-
- for ( int i = 0; i < array.length / 2; i++ ) {
- temp = array[i];
- array[i] = array[array.length - i - 1];
- array[array.length - i - 1] = temp;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/IteratorHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/IteratorHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/IteratorHelper.java
deleted file mode 100644
index 049296e..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/IteratorHelper.java
+++ /dev/null
@@ -1,34 +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.query.ir.result;
-
-
-import java.nio.ByteBuffer;
-import java.util.UUID;
-
-
-/**
- *
- * @author: tnine
- *
- */
-public class IteratorHelper {
-
- public static ScanColumn uuidColumn( UUID value ) {
- return new UUIDIndexSliceParser.UUIDColumn( value, ByteBuffer.allocate( 0 ) );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/SubtractionIteratorTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/SubtractionIteratorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/SubtractionIteratorTest.java
deleted file mode 100644
index 7ab0f25..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/SubtractionIteratorTest.java
+++ /dev/null
@@ -1,182 +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.query.ir.result;
-
-
-import java.util.Set;
-import java.util.UUID;
-
-import org.junit.Test;
-
-import org.apache.usergrid.utils.UUIDUtils;
-
-import static org.apache.usergrid.persistence.query.ir.result.IteratorHelper.uuidColumn;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
-/** @author tnine */
-public class SubtractionIteratorTest {
-
- @Test
- public void smallerSubtract() {
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id5 = UUIDUtils.minTimeUUID( 5 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator keep = new InOrderIterator( 2 );
- keep.add( id1 );
- keep.add( id2 );
- keep.add( id3 );
- keep.add( id4 );
- keep.add( id5 );
-
- InOrderIterator subtract = new InOrderIterator( 2 );
- subtract.add( id1 );
- subtract.add( id3 );
- subtract.add( id5 );
-
- SubtractionIterator sub = new SubtractionIterator( 100 );
- sub.setKeepIterator( keep );
- sub.setSubtractIterator( subtract );
-
- // now make sure it's right, only 2 and 8 aren't intersected
- Set<ScanColumn> page = sub.next();
-
- assertTrue( page.contains( uuidColumn( id2 ) ) );
- assertTrue( page.contains( uuidColumn( id4 ) ) );
-
- assertEquals( 2, page.size() );
- }
-
-
- @Test
- public void smallerKeep() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id5 = UUIDUtils.minTimeUUID( 5 );
- UUID id6 = UUIDUtils.minTimeUUID( 6 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator keep = new InOrderIterator( 100 );
- keep.add( id1 );
- keep.add( id2 );
- keep.add( id5 );
- keep.add( id6 );
-
- InOrderIterator subtract = new InOrderIterator( 100 );
- subtract.add( id1 );
- subtract.add( id3 );
- subtract.add( id4 );
- subtract.add( id5 );
- subtract.add( id6 );
-
- SubtractionIterator sub = new SubtractionIterator( 100 );
- sub.setKeepIterator( keep );
- sub.setSubtractIterator( subtract );
-
- // now make sure it's right, only 2 and 8 aren't intersected
-
- Set<ScanColumn> page = sub.next();
-
- assertTrue( page.contains( uuidColumn( id2 ) ) );
-
- assertEquals( 1, page.size() );
- }
-
-
- @Test
- public void smallerKeepRemoveAll() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id5 = UUIDUtils.minTimeUUID( 5 );
- UUID id6 = UUIDUtils.minTimeUUID( 6 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator keep = new InOrderIterator( 100 );
- keep.add( id1 );
- keep.add( id3 );
- keep.add( id4 );
-
- InOrderIterator subtract = new InOrderIterator( 100 );
- subtract.add( id1 );
- subtract.add( id2 );
- subtract.add( id3 );
- subtract.add( id4 );
- subtract.add( id5 );
- subtract.add( id6 );
-
- SubtractionIterator sub = new SubtractionIterator( 100 );
- sub.setKeepIterator( keep );
- sub.setSubtractIterator( subtract );
-
- // now make sure it's right, only 2 and 8 aren't intersected
-
- assertFalse( sub.hasNext() );
- }
-
-
- @Test
- public void noKeep() {
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator keep = new InOrderIterator( 100 );
-
- InOrderIterator subtract = new InOrderIterator( 100 );
- subtract.add( id1 );
-
- SubtractionIterator sub = new SubtractionIterator( 100 );
- sub.setKeepIterator( keep );
- sub.setSubtractIterator( subtract );
-
- assertFalse( sub.hasNext() );
- }
-
-
- @Test
- public void noSubtract() {
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
-
- //keep only id 1
- InOrderIterator keep = new InOrderIterator( 100 );
- keep.add( id1 );
-
- InOrderIterator subtract = new InOrderIterator( 100 );
-
-
- SubtractionIterator sub = new SubtractionIterator( 100 );
- sub.setKeepIterator( keep );
- sub.setSubtractIterator( subtract );
-
- assertTrue( sub.hasNext() );
- Set<ScanColumn> page = sub.next();
-
- assertTrue( page.contains( uuidColumn( id1 ) ) );
- assertEquals( 1, page.size() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/UnionIteratorTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/UnionIteratorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/UnionIteratorTest.java
deleted file mode 100644
index 68d2313..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/UnionIteratorTest.java
+++ /dev/null
@@ -1,468 +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.query.ir.result;
-
-
-import java.nio.ByteBuffer;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.UUID;
-
-import org.junit.Test;
-
-import org.apache.usergrid.utils.UUIDUtils;
-
-import me.prettyprint.cassandra.serializers.UUIDSerializer;
-
-import static org.apache.usergrid.persistence.query.ir.result.IteratorHelper.uuidColumn;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * @author tnine
- */
-public class UnionIteratorTest {
-
- @Test
- public void testMutipleIterators() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id5 = UUIDUtils.minTimeUUID( 5 );
- UUID id6 = UUIDUtils.minTimeUUID( 6 );
- UUID id7 = UUIDUtils.minTimeUUID( 7 );
- UUID id8 = UUIDUtils.minTimeUUID( 8 );
- UUID id9 = UUIDUtils.minTimeUUID( 9 );
- UUID id10 = UUIDUtils.minTimeUUID( 10 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator first = new InOrderIterator( 100 );
- first.add( id1 );
- first.add( id2 );
- first.add( id3 );
- first.add( id8 );
- first.add( id9 );
-
- InOrderIterator second = new InOrderIterator( 100 );
- second.add( id1 );
- second.add( id2 );
- second.add( id3 );
- second.add( id4 );
- second.add( id8 );
- second.add( id10 );
-
- InOrderIterator third = new InOrderIterator( 100 );
- third.add( id6 );
- third.add( id7 );
- third.add( id1 );
- third.add( id3 );
- third.add( id5 );
- third.add( id8 );
-
- InOrderIterator fourth = new InOrderIterator( 100 );
- fourth.add( id1 );
- fourth.add( id6 );
- fourth.add( id2 );
- fourth.add( id3 );
- fourth.add( id8 );
- fourth.add( id9 );
-
-
- UnionIterator iter = new UnionIterator( 100, 0, null );
- iter.addIterator( first );
- iter.addIterator( second );
- iter.addIterator( third );
- iter.addIterator( fourth );
-
- Set<ScanColumn> union = iter.next();
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( union.contains( uuidColumn( id1 ) ) );
- assertTrue( union.contains( uuidColumn( id2 ) ) );
- assertTrue( union.contains( uuidColumn( id3 ) ) );
- assertTrue( union.contains( uuidColumn( id4 ) ) );
- assertTrue( union.contains( uuidColumn( id5 ) ) );
- assertTrue( union.contains( uuidColumn( id6 ) ) );
- assertTrue( union.contains( uuidColumn( id7 ) ) );
- assertTrue( union.contains( uuidColumn( id8 ) ) );
- assertTrue( union.contains( uuidColumn( id9 ) ) );
- assertTrue( union.contains( uuidColumn( id10 ) ) );
- }
-
-
- @Test
- public void testOneIterator() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator first = new InOrderIterator( 100 );
- first.add( id1 );
- first.add( id2 );
- first.add( id3 );
- first.add( id4 );
-
- UnionIterator union = new UnionIterator( 100, 0, null );
- union.addIterator( first );
-
- Set<ScanColumn> ids = union.next();
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( ids.contains( uuidColumn( id1 ) ) );
- assertTrue( ids.contains( uuidColumn( id2 ) ) );
- assertTrue( ids.contains( uuidColumn( id3 ) ) );
- assertTrue( ids.contains( uuidColumn( id4 ) ) );
-
- assertFalse( union.hasNext() );
- }
-
-
- @Test
- public void testEmptyFirstIterator() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
-
- // we should get intersection on 1, 3, and 8
- InOrderIterator first = new InOrderIterator( 100 );
-
- InOrderIterator second = new InOrderIterator( 100 );
- second.add( id1 );
- second.add( id2 );
- second.add( id3 );
- second.add( id4 );
-
- UnionIterator union = new UnionIterator( 100, 0, null );
- union.addIterator( first );
- union.addIterator( second );
-
- Set<ScanColumn> ids = union.next();
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( ids.contains( uuidColumn( id1 ) ) );
- assertTrue( ids.contains( uuidColumn( id2 ) ) );
- assertTrue( ids.contains( uuidColumn( id3 ) ) );
- assertTrue( ids.contains( uuidColumn( id4 ) ) );
-
- assertFalse( union.hasNext() );
- }
-
-
- @Test
- public void testNoIterator() {
-
- UnionIterator union = new UnionIterator( 100, 0, null );
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertFalse( union.hasNext() );
- }
-
-
- @Test
- public void largeUnionTest() {
-
- int size = 10000;
- int firstIntersection = 100;
- int secondIntersection = 200;
-
- int pageSize = 20;
-
- UUID[] firstSet = new UUID[size];
- UUID[] secondSet = new UUID[size];
- UUID[] thirdSet = new UUID[size];
-
- InOrderIterator first = new InOrderIterator( pageSize / 2 );
- InOrderIterator second = new InOrderIterator( pageSize / 2 );
- InOrderIterator third = new InOrderIterator( pageSize / 2 );
-
- Set<UUID> results = new HashSet<UUID>( size );
-
- for ( int i = 0; i < size; i++ ) {
- firstSet[i] = UUIDUtils.newTimeUUID();
- // every 100 elements, set the element equal to the first set. This way we
- // have intersection
-
- results.add( firstSet[i] );
-
- if ( i % firstIntersection == 0 ) {
- secondSet[i] = firstSet[i];
- }
- else {
- secondSet[i] = UUIDUtils.newTimeUUID();
- results.add( secondSet[i] );
- }
-
- if ( i % secondIntersection == 0 ) {
- thirdSet[i] = firstSet[i];
- }
-
- else {
- thirdSet[i] = UUIDUtils.newTimeUUID();
- results.add( thirdSet[i] );
- }
- }
-
- first.add( firstSet );
-
- reverse( secondSet );
- // reverse the second
- second.add( secondSet );
- third.add( thirdSet );
-
- // now intersect them and make sure we get all results in a small set
- UnionIterator union = new UnionIterator( pageSize, 0, null );
- union.addIterator( first );
- union.addIterator( second );
- union.addIterator( third );
-
-
- while ( union.hasNext() ) {
-
- // now get the 2nd page
- Set<ScanColumn> resultSet = union.next();
-
- for ( ScanColumn col : resultSet ) {
- boolean existed = results.remove( col.getUUID() );
-
- assertTrue( "Duplicate element was detected", existed );
- }
- }
-
- assertEquals( 0, results.size() );
- assertFalse( union.hasNext() );
- }
-
-
- @Test
- public void iterationCompleted() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id5 = UUIDUtils.minTimeUUID( 5 );
-
-
- UnionIterator union = new UnionIterator( 5, 0, null );
-
- InOrderIterator first = new InOrderIterator( 100 );
-
- InOrderIterator second = new InOrderIterator( 100 );
- second.add( id1 );
- second.add( id2 );
- second.add( id3 );
- second.add( id4 );
- second.add( id5 );
-
- union.addIterator( first );
- union.addIterator( second );
-
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( union.hasNext() );
-
- Set<ScanColumn> ids = union.next();
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( ids.contains( uuidColumn( id1 ) ) );
- assertTrue( ids.contains( uuidColumn( id2 ) ) );
- assertTrue( ids.contains( uuidColumn( id3 ) ) );
- assertTrue( ids.contains( uuidColumn( id4 ) ) );
- assertTrue( ids.contains( uuidColumn( id5 ) ) );
-
- //now try to get the next page
- ids = union.next();
- assertNull( ids );
- }
-
-
- @Test
- public void nullCursorBytes() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id5 = UUIDUtils.minTimeUUID( 5 );
-
-
- InOrderIterator second = new InOrderIterator( 100 );
- second.add( id1 );
- second.add( id2 );
- second.add( id3 );
- second.add( id4 );
- second.add( id5 );
-
- UnionIterator union = new UnionIterator( 100, 1, null );
-
- union.addIterator( second );
-
- Set<ScanColumn> ids = union.next();
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( ids.contains( uuidColumn( id1 ) ) );
- assertTrue( ids.contains( uuidColumn( id2 ) ) );
- assertTrue( ids.contains( uuidColumn( id3 ) ) );
- assertTrue( ids.contains( uuidColumn( id4 ) ) );
- assertTrue( ids.contains( uuidColumn( id5 ) ) );
- }
-
-
- @Test
- public void validCursorBytes() {
-
-
- ByteBuffer cursor = UUIDSerializer.get().toByteBuffer( UUIDUtils.minTimeUUID( 4 ) );
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id5 = UUIDUtils.minTimeUUID( 5 );
-
-
- InOrderIterator second = new InOrderIterator( 100 );
- second.add( id1 );
- second.add( id2 );
- second.add( id3 );
- second.add( id4 );
- second.add( id5 );
-
- UnionIterator union = new UnionIterator( 100, 1, cursor );
-
- union.addIterator( second );
-
- Set<ScanColumn> ids = union.next();
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertFalse( ids.contains( uuidColumn( id1 ) ) );
- assertFalse( ids.contains( uuidColumn( id2 ) ) );
- assertFalse( ids.contains( uuidColumn( id3 ) ) );
- assertFalse( ids.contains( uuidColumn( id4 ) ) );
- assertTrue( ids.contains( uuidColumn( id5 ) ) );
- }
-
-
- @Test
- public void resetCorrect() {
-
- UUID id1 = UUIDUtils.minTimeUUID( 1 );
- UUID id2 = UUIDUtils.minTimeUUID( 2 );
- UUID id3 = UUIDUtils.minTimeUUID( 3 );
- UUID id4 = UUIDUtils.minTimeUUID( 4 );
- UUID id5 = UUIDUtils.minTimeUUID( 5 );
- UUID id6 = UUIDUtils.minTimeUUID( 6 );
- UUID id7 = UUIDUtils.minTimeUUID( 75 );
-
-
- UnionIterator union = new UnionIterator( 5, 0, null );
-
- InOrderIterator first = new InOrderIterator( 100 );
- first.add( id3 );
- first.add( id6 );
- first.add( id4 );
-
-
- InOrderIterator second = new InOrderIterator( 100 );
- second.add( id7 );
- second.add( id1 );
- second.add( id2 );
- second.add( id5 );
-
-
- union.addIterator( first );
- union.addIterator( second );
-
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( union.hasNext() );
-
- Set<ScanColumn> ids = union.next();
-
-
- assertEquals(5, ids.size());
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( ids.contains( uuidColumn( id1 ) ) );
- assertTrue( ids.contains( uuidColumn( id2 ) ) );
- assertTrue( ids.contains( uuidColumn( id3 ) ) );
- assertTrue( ids.contains( uuidColumn( id4 ) ) );
- assertTrue( ids.contains( uuidColumn( id5 ) ) );
-
- ids = union.next();
-
-
- assertEquals(2, ids.size());
-
- assertTrue( ids.contains( uuidColumn( id6 ) ) );
- assertTrue( ids.contains( uuidColumn( id7 ) ) );
-
- //now try to get the next page
- ids = union.next();
- assertNull( ids );
-
- //now reset and re-test
- union.reset();
-
- ids = union.next();
-
- assertEquals(5, ids.size());
-
-
- // now make sure it's right, only 1, 3 and 8 intersect
- assertTrue( ids.contains( uuidColumn( id1 ) ) );
- assertTrue( ids.contains( uuidColumn( id2 ) ) );
- assertTrue( ids.contains( uuidColumn( id3 ) ) );
- assertTrue( ids.contains( uuidColumn( id4 ) ) );
- assertTrue( ids.contains( uuidColumn( id5 ) ) );
-
-
- ids = union.next();
-
- assertEquals(2, ids.size());
-
- assertTrue( ids.contains( uuidColumn( id6 ) ) );
- assertTrue( ids.contains( uuidColumn( id7 ) ) );
-
-
- //now try to get the next page
- ids = union.next();
- assertNull( ids );
- }
-
-
- private void reverse( UUID[] array ) {
-
- UUID temp = null;
-
- for ( int i = 0; i < array.length / 2; i++ ) {
- temp = array[i];
- array[i] = array[array.length - i - 1];
- array[array.length - i - 1] = temp;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
index 940effc..7748adb 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
@@ -89,6 +89,11 @@ public class CandidateResults implements Iterable<CandidateResult> {
}
+ public Collection<SelectFieldMapping> getGetFieldMappings() {
+ return getFieldMappings;
+ }
+
+
/**
* Get the candidates
* @return
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
index eaa2531..d86e83f 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
@@ -17,15 +17,6 @@
package org.apache.usergrid.rest.applications;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.multipart.BodyPart;
-import com.sun.jersey.multipart.BodyPartEntity;
-import com.sun.jersey.multipart.FormDataBodyPart;
-import com.sun.jersey.multipart.FormDataMultiPart;
-import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
@@ -33,6 +24,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
@@ -46,16 +38,23 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
import org.apache.commons.lang.StringUtils;
+
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.QueryUtils;
-import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.rest.AbstractContextResource;
import org.apache.usergrid.rest.ApiResponse;
import org.apache.usergrid.rest.RootResource;
@@ -72,11 +71,15 @@ import org.apache.usergrid.services.assets.data.AssetUtils;
import org.apache.usergrid.services.assets.data.BinaryStore;
import org.apache.usergrid.utils.InflectionUtils;
import org.apache.usergrid.utils.JsonUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.sun.jersey.api.json.JSONWithPadding;
+import com.sun.jersey.multipart.BodyPart;
+import com.sun.jersey.multipart.BodyPartEntity;
+import com.sun.jersey.multipart.FormDataBodyPart;
+import com.sun.jersey.multipart.FormDataMultiPart;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
@Component
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index 682044b..1252bd0 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -32,7 +32,7 @@ import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.exception.ConflictException;
import org.apache.usergrid.management.exceptions.*;
import org.apache.usergrid.persistence.*;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -143,7 +143,7 @@ import static org.apache.usergrid.persistence.entities.Activity.PROPERTY_OBJECT_
import static org.apache.usergrid.persistence.entities.Activity.PROPERTY_OBJECT_TYPE;
import static org.apache.usergrid.persistence.entities.Activity.PROPERTY_TITLE;
import static org.apache.usergrid.persistence.entities.Activity.PROPERTY_VERB;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import static org.apache.usergrid.security.AuthPrincipalType.ADMIN_USER;
import static org.apache.usergrid.security.AuthPrincipalType.APPLICATION;
import static org.apache.usergrid.security.AuthPrincipalType.APPLICATION_USER;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
index 8caecbc..988aa56 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
@@ -40,8 +40,8 @@ import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.SimpleEntityRef;
import org.apache.usergrid.persistence.entities.Export;
import org.apache.usergrid.persistence.entities.JobData;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/management/importer/FileImportJob.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/importer/FileImportJob.java b/stack/services/src/main/java/org/apache/usergrid/management/importer/FileImportJob.java
index 264c752..c656e96 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/FileImportJob.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/FileImportJob.java
@@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.UUID;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
@Component("fileImportJob")
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
index 6a53380..18879c0 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
@@ -28,8 +28,8 @@ import org.apache.usergrid.persistence.entities.FileImport;
import org.apache.usergrid.persistence.entities.Import;
import org.apache.usergrid.persistence.entities.JobData;
import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.utils.InflectionUtils;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParser;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java b/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java
index a5776fa..8a1f567 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java
@@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.management.ManagementService;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.entities.User;
import org.apache.usergrid.security.tokens.exceptions.BadTokenException;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java b/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
index 7e9157c..8e68edc 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
@@ -27,7 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.management.ManagementService;
import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.entities.User;
import org.apache.usergrid.security.tokens.exceptions.BadTokenException;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/security/shiro/Realm.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/shiro/Realm.java b/stack/services/src/main/java/org/apache/usergrid/security/shiro/Realm.java
index 9de1763..2736e30 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/shiro/Realm.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/shiro/Realm.java
@@ -79,7 +79,7 @@ import com.google.common.collect.HashBiMap;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_ALLOWED;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import static org.apache.usergrid.security.shiro.utils.SubjectUtils.getPermissionFromPath;
import static org.apache.usergrid.utils.StringUtils.stringOrSubstringAfterFirst;
import static org.apache.usergrid.utils.StringUtils.stringOrSubstringBeforeFirst;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
index dcd7557..326696a 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
@@ -27,12 +27,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.Schema;
import org.apache.usergrid.persistence.SimpleEntityRef;
import org.apache.usergrid.persistence.exceptions.UnexpectedEntityTypeException;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.services.ServiceResults.Type;
import org.apache.usergrid.services.exceptions.ForbiddenServiceOperationException;
import org.apache.usergrid.services.exceptions.ServiceResourceNotFoundException;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
index 1e4c4b8..467b09e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractConnectionsService.java
@@ -27,11 +27,11 @@ import org.apache.usergrid.persistence.ConnectionRef;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.Schema;
import org.apache.usergrid.persistence.SimpleEntityRef;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.services.ServiceParameter.IdParameter;
import org.apache.usergrid.services.ServiceParameter.NameParameter;
import org.apache.usergrid.services.ServiceParameter.QueryParameter;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/AbstractPathBasedColllectionService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractPathBasedColllectionService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractPathBasedColllectionService.java
index a197008..8bd02ea 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractPathBasedColllectionService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractPathBasedColllectionService.java
@@ -25,7 +25,7 @@ import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Schema;
import org.apache.usergrid.services.ServiceParameter.IdParameter;
import org.apache.usergrid.services.ServiceParameter.NameParameter;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
index e315fb1..957d7c7 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
@@ -31,7 +31,7 @@ import org.springframework.context.ApplicationContext;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.Schema;
import org.apache.usergrid.security.shiro.utils.SubjectUtils;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/ServiceContext.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceContext.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceContext.java
index b39acae..1650134 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceContext.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceContext.java
@@ -23,7 +23,7 @@ import java.util.Map;
import java.util.UUID;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.services.exceptions.ServiceResourceNotFoundException;
import static org.apache.usergrid.services.ServiceInfo.normalizeServicePattern;
import static org.apache.usergrid.utils.ListUtils.dequeueCopy;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java
index fc195ac..6e8a072 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceParameter.java
@@ -25,8 +25,9 @@ import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.Query;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.apache.usergrid.utils.ListUtils.dequeue;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java
index 69cff6c..90c3b7e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceRequest.java
@@ -26,7 +26,7 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.services.ServiceParameter.QueryParameter;
import org.apache.usergrid.services.ServiceResults.Type;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java
index 7a516ba..3db0064 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceResults.java
@@ -23,11 +23,11 @@ import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import org.apache.usergrid.persistence.AggregateCounterSet;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.QueryUtils;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Results;
@@ -127,45 +127,11 @@ public class ServiceResults extends Results {
}
- public ServiceResults getPreviousResults() {
- return previousResults;
- }
-
-
public Map<String, Object> getServiceMetadata() {
return serviceMetadata;
}
- public boolean hasSelection() {
- if ( request == null ) {
- return false;
- }
- Query q = getQuery();
- if ( q != null ) {
- return q.hasSelectSubjects();
- }
- return false;
- }
-
-
- public List<Object> getSelectionResults() {
- Query q = getQuery();
- if ( q == null ) {
- return null;
- }
- return QueryUtils.getSelectionResults( q, this );
- }
-
-
- public Object getSelectionResult() {
- Query q = getQuery();
- if ( q == null ) {
- return null;
- }
- return QueryUtils.getSelectionResult( q, this );
- }
-
public String getPath() {
return path;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/applications/ApplicationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/applications/ApplicationsService.java b/stack/services/src/main/java/org/apache/usergrid/services/applications/ApplicationsService.java
index 16afd7d..dc3a0d8 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/applications/ApplicationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/applications/ApplicationsService.java
@@ -26,7 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.services.AbstractService;
import org.apache.usergrid.services.ServiceContext;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/devices/DevicesService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/devices/DevicesService.java b/stack/services/src/main/java/org/apache/usergrid/services/devices/DevicesService.java
index 9e73e0a..adba128 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/devices/DevicesService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/devices/DevicesService.java
@@ -26,7 +26,7 @@ import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.Device;
import org.apache.usergrid.persistence.entities.User;
import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.security.shiro.utils.SubjectUtils;
import org.apache.usergrid.services.*;
import org.slf4j.Logger;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java b/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java
index 999a8cb..3240dc1 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/groups/GroupsService.java
@@ -26,7 +26,7 @@ import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.entities.Role;
import org.apache.usergrid.services.AbstractPathBasedColllectionService;
import org.apache.usergrid.services.ServiceContext;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/groups/activities/ActivitiesService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/groups/activities/ActivitiesService.java b/stack/services/src/main/java/org/apache/usergrid/services/groups/activities/ActivitiesService.java
index 5a34d89..e4cab95 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/groups/activities/ActivitiesService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/groups/activities/ActivitiesService.java
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.services.ServiceContext;
import org.apache.usergrid.services.ServiceResults;
import org.apache.usergrid.services.generic.GenericCollectionService;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/groups/users/activities/ActivitiesService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/groups/users/activities/ActivitiesService.java b/stack/services/src/main/java/org/apache/usergrid/services/groups/users/activities/ActivitiesService.java
index 60ed267..ebf3676 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/groups/users/activities/ActivitiesService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/groups/users/activities/ActivitiesService.java
@@ -27,7 +27,7 @@ import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.SimpleEntityRef;
import org.apache.usergrid.persistence.entities.User;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.services.ServiceContext;
import org.apache.usergrid.services.ServiceResults;
import org.apache.usergrid.services.generic.GenericCollectionService;
@@ -74,7 +74,7 @@ public class ActivitiesService extends GenericCollectionService {
return;
}
- Results r2 = em.getConnectingEntities( new SimpleEntityRef( user.getType(), user.getUuid()),
+ Results r2 = em.getConnectingEntities( new SimpleEntityRef( user.getType(), user.getUuid()),
"following", User.ENTITY_TYPE, Level.IDS );
if ( ( r2 == null ) || ( r2.isEmpty() ) ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
index 108a4a0..c2ac11f 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/InactiveDeviceManager.java
@@ -24,7 +24,7 @@ import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.entities.Notifier;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.services.notifications.impl.ApplicationQueueManagerImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index abd77ee..716f72b 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -39,7 +39,7 @@ import org.apache.usergrid.persistence.entities.Notifier;
import org.apache.usergrid.persistence.entities.Receipt;
import org.apache.usergrid.persistence.exceptions.RequiredPropertyNotFoundException;
import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.queue.QueueManager;
import org.apache.usergrid.persistence.queue.QueueManagerFactory;
import org.apache.usergrid.persistence.queue.QueueScope;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
index b183daa..0bcc272 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
@@ -26,7 +26,7 @@ import org.apache.usergrid.persistence.entities.Device;
import org.apache.usergrid.persistence.entities.Notification;
import org.apache.usergrid.persistence.entities.Notifier;
import org.apache.usergrid.persistence.entities.Receipt;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.queue.QueueManager;
import org.apache.usergrid.persistence.queue.QueueMessage;
import org.apache.usergrid.services.notifications.*;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java b/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
index 03bd24b..475d38d 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
@@ -24,7 +24,7 @@ import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.entities.Group;
import org.apache.usergrid.services.AbstractCollectionService;
import org.apache.usergrid.services.ServiceContext;
@@ -59,7 +59,7 @@ public class RolesService extends AbstractCollectionService {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.apache.usergrid.services.AbstractService#getEntityDictionary(org.apache.usergrid
* .services.ServiceContext, java.util.List, java.lang.String)
@@ -89,7 +89,7 @@ public class RolesService extends AbstractCollectionService {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.apache.usergrid.services.AbstractService#putEntityDictionary(org.apache.usergrid
* .services.ServiceContext, java.util.List, java.lang.String,
@@ -105,7 +105,7 @@ public class RolesService extends AbstractCollectionService {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.apache.usergrid.services.AbstractService#postEntityDictionary(org.apache.usergrid
* .services.ServiceContext, java.util.List, java.lang.String,
@@ -144,7 +144,7 @@ public class RolesService extends AbstractCollectionService {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.apache.usergrid.services.AbstractService#deleteEntityDictionary(org.apache.usergrid
* .services.ServiceContext, java.util.List, java.lang.String)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java b/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java
index ecf3c1e..42aec04 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/users/UsersService.java
@@ -30,7 +30,7 @@ import org.apache.usergrid.management.UserInfo;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.Schema;
import org.apache.usergrid.persistence.entities.Role;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/main/java/org/apache/usergrid/services/users/activities/ActivitiesService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/users/activities/ActivitiesService.java b/stack/services/src/main/java/org/apache/usergrid/services/users/activities/ActivitiesService.java
index 3467e4e..e7f3268 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/users/activities/ActivitiesService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/users/activities/ActivitiesService.java
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.entities.Activity;
import org.apache.usergrid.persistence.entities.Activity.ActivityObject;
import org.apache.usergrid.persistence.entities.User;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.services.ServiceContext;
import org.apache.usergrid.services.ServicePayload;
import org.apache.usergrid.services.ServiceResults;
@@ -134,7 +134,7 @@ public class ActivitiesService extends GenericCollectionService {
//publish to all connections
Results results = em.getConnectingEntities(
- new SimpleEntityRef( user.getType(), user.getUuid()),
+ new SimpleEntityRef( user.getType(), user.getUuid()),
"following", User.ENTITY_TYPE, Level.REFS);
if( results != null ){
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java b/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
index d0fa848..8c4924e 100644
--- a/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
+++ b/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
@@ -29,7 +29,7 @@ import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.cassandra.CassandraService;
import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
import org.apache.usergrid.persistence.entities.Application;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
index 892e4d1..7350dcd 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
@@ -66,8 +66,8 @@ import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.SimpleEntityRef;
import org.apache.usergrid.persistence.entities.FileImport;
import org.apache.usergrid.persistence.entities.Import;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.setup.ConcurrentProcessSingleton;
import com.amazonaws.SDKGlobalConfiguration;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportConnectionsTest.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportConnectionsTest.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportConnectionsTest.java
index 5e6651c..2c9db95 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportConnectionsTest.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportConnectionsTest.java
@@ -37,7 +37,7 @@ import org.apache.usergrid.persistence.PagingResultsIterator;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.entities.FileImport;
import org.apache.usergrid.persistence.entities.Import;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
index 4932ad7..fd199e6 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
@@ -40,7 +40,7 @@ import org.apache.usergrid.persistence.entities.Import;
import org.apache.usergrid.persistence.entities.JobData;
import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.persistence.index.utils.UUIDUtils;
import org.apache.usergrid.services.notifications.QueueListener;
import org.apache.usergrid.setup.ConcurrentProcessSingleton;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/test/java/org/apache/usergrid/services/ActivitiesServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/ActivitiesServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/ActivitiesServiceIT.java
index d31fe16..c4762f2 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/ActivitiesServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/ActivitiesServiceIT.java
@@ -22,7 +22,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.entities.Activity;
import static org.junit.Assert.assertNotNull;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java
index f686bb5..a6723b7 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java
@@ -27,7 +27,7 @@ import org.junit.Test;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.entities.Role;
import org.apache.usergrid.persistence.exceptions.RequiredPropertyNotFoundException;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java b/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java
index 1c8e850..ceaf996 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java
@@ -25,7 +25,7 @@ import java.util.UUID;
import org.apache.usergrid.cassandra.ClearShiroSubject;
import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import static org.junit.Assert.assertNotNull;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
index d02d104..798f183 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
@@ -19,7 +19,7 @@ package org.apache.usergrid.services.notifications;
import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.Notification;
import org.apache.usergrid.persistence.entities.Receipt;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.services.ServiceManagerFactory;
import org.junit.Before;
import org.junit.BeforeClass;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index dec7295..c99034f 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -20,7 +20,7 @@ import com.relayrides.pushy.apns.util.*;
import org.apache.commons.io.IOUtils;
import org.apache.usergrid.persistence.*;
import org.apache.usergrid.persistence.entities.*;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.queue.DefaultQueueManager;
import org.apache.usergrid.services.notifications.*;
import org.junit.*;
[4/5] incubator-usergrid git commit: Removed legacy 1.0 code Cleaned
up Query object to only be query state/builder Refactor of tests to use query
language
Posted by to...@apache.org.
Removed legacy 1.0 code
Cleaned up Query object to only be query state/builder
Refactor of tests to use query language
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e534d9c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e534d9c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e534d9c7
Branch: refs/heads/USERGRID-536
Commit: e534d9c7385245ad369499cc05e93a9a7ece3324
Parents: f95d39c
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Apr 9 01:10:53 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Apr 10 10:27:27 2015 -0600
----------------------------------------------------------------------
.../batch/service/SchedulerServiceImpl.java | 4 +-
.../corepersistence/CpEntityManager.java | 17 +-
.../corepersistence/CpRelationManager.java | 1297 ++----------------
.../events/EntityVersionDeletedHandler.java | 14 +-
.../CollectionResultsLoaderFactoryImpl.java | 6 +-
.../ConnectionResultsLoaderFactoryImpl.java | 6 +-
.../results/ElasticSearchQueryExecutor.java | 53 +-
.../corepersistence/results/EntityVerifier.java | 2 +-
.../results/FilteringLoader.java | 10 +-
.../corepersistence/results/ResultsLoader.java | 2 +-
.../results/ResultsLoaderFactory.java | 7 +-
.../results/ResultsVerifier.java | 4 +-
.../results/VersionVerifier.java | 12 +-
.../corepersistence/util/CpNamingUtils.java | 244 ++--
.../org/apache/usergrid/persistence/Query.java | 70 +-
.../apache/usergrid/persistence/QueryUtils.java | 61 +-
.../usergrid/persistence/RelationManager.java | 3 +-
.../java/org/apache/usergrid/Application.java | 2 +-
.../org/apache/usergrid/CoreApplication.java | 2 +-
.../usergrid/batch/job/SchedulerRuntime8IT.java | 8 +-
.../corepersistence/StaleIndexCleanupTest.java | 15 +-
.../usergrid/persistence/CollectionIT.java | 103 +-
.../apache/usergrid/persistence/CounterIT.java | 2 +-
.../usergrid/persistence/CountingMutatorIT.java | 2 +-
.../persistence/EntityConnectionsIT.java | 2 +-
.../usergrid/persistence/EntityManagerIT.java | 34 +-
.../EntityPropertyComparatorTest.java | 222 ---
.../org/apache/usergrid/persistence/GeoIT.java | 87 +-
.../persistence/GeoQueryBooleanTest.java | 20 +-
.../apache/usergrid/persistence/IndexIT.java | 42 -
.../usergrid/persistence/PathQueryIT.java | 21 +-
.../PerformanceEntityRebuildIndexTest.java | 2 +-
.../usergrid/persistence/PermissionsIT.java | 2 +-
.../apache/usergrid/persistence/QueryTest.java | 328 -----
.../cassandra/QueryProcessorTest.java | 822 -----------
.../SimpleIndexShardLocatorImplTest.java | 177 ---
...EntityLocationRefDistanceComparatorTest.java | 104 --
.../persistence/query/CollectionIoHelper.java | 2 +-
.../persistence/query/ConnectionHelper.java | 2 +-
.../query/IntersectionTransitivePagingIT.java | 2 +-
.../query/IntersectionUnionPagingIT.java | 2 +-
.../usergrid/persistence/query/IoHelper.java | 2 +-
.../persistence/query/IteratingQueryIT.java | 40 +-
.../persistence/query/NotSubPropertyIT.java | 2 +-
.../query/ir/result/AbstractScanColumnTest.java | 101 --
.../query/ir/result/InOrderIterator.java | 132 --
.../ir/result/IntersectionIteratorTest.java | 308 -----
.../query/ir/result/IteratorHelper.java | 34 -
.../ir/result/SubtractionIteratorTest.java | 182 ---
.../query/ir/result/UnionIteratorTest.java | 468 -------
.../persistence/index/CandidateResults.java | 5 +
.../rest/applications/ServiceResource.java | 35 +-
.../cassandra/ManagementServiceImpl.java | 4 +-
.../management/export/ExportServiceImpl.java | 4 +-
.../management/importer/FileImportJob.java | 2 +-
.../management/importer/ImportServiceImpl.java | 4 +-
.../security/providers/FacebookProvider.java | 2 +-
.../security/providers/FoursquareProvider.java | 2 +-
.../apache/usergrid/security/shiro/Realm.java | 2 +-
.../services/AbstractCollectionService.java | 4 +-
.../services/AbstractConnectionsService.java | 4 +-
.../AbstractPathBasedColllectionService.java | 2 +-
.../usergrid/services/AbstractService.java | 2 +-
.../usergrid/services/ServiceContext.java | 2 +-
.../usergrid/services/ServiceParameter.java | 3 +-
.../usergrid/services/ServiceRequest.java | 2 +-
.../usergrid/services/ServiceResults.java | 38 +-
.../applications/ApplicationsService.java | 2 +-
.../services/devices/DevicesService.java | 2 +-
.../usergrid/services/groups/GroupsService.java | 2 +-
.../groups/activities/ActivitiesService.java | 2 +-
.../users/activities/ActivitiesService.java | 4 +-
.../notifications/InactiveDeviceManager.java | 2 +-
.../notifications/NotificationsService.java | 2 +-
.../impl/ApplicationQueueManagerImpl.java | 2 +-
.../usergrid/services/roles/RolesService.java | 10 +-
.../usergrid/services/users/UsersService.java | 2 +-
.../users/activities/ActivitiesService.java | 4 +-
.../migration/AppInfoMigrationPluginTest.java | 2 +-
.../management/importer/ImportCollectionIT.java | 4 +-
.../importer/ImportConnectionsTest.java | 2 +-
.../management/importer/ImportServiceIT.java | 2 +-
.../usergrid/services/ActivitiesServiceIT.java | 2 +-
.../usergrid/services/RolesServiceIT.java | 2 +-
.../usergrid/services/ServiceInvocationIT.java | 2 +-
.../AbstractServiceNotificationIT.java | 2 +-
.../apns/NotificationsServiceIT.java | 2 +-
87 files changed, 583 insertions(+), 4674 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
index f3fab9e..87c1d50 100644
--- a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
@@ -377,9 +377,7 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
EntityManager em = emf.getEntityManager( emf.getManagementAppId() );
- Query query = new Query();
- query.addEqualityFilter( JOB_NAME, jobName );
- query.addEqualityFilter( JOB_ID, jobId );
+ Query query = Query.fromQL( "select * where " + JOB_NAME + " = '" + jobName + "' AND " + JOB_ID + " = " + jobId );
Results r = em.searchCollection( em.getApplicationRef(), "job_stats", query );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index e7159f9..90d4534 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -79,8 +79,10 @@ import org.apache.usergrid.persistence.exceptions.DuplicateUniquePropertyExistsE
import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
import org.apache.usergrid.persistence.exceptions.RequiredPropertyNotFoundException;
import org.apache.usergrid.persistence.exceptions.UnexpectedEntityTypeException;
+import org.apache.usergrid.persistence.graph.Edge;
import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexBatch;
+import org.apache.usergrid.persistence.index.IndexEdge;
import org.apache.usergrid.persistence.index.query.CounterResolution;
import org.apache.usergrid.persistence.index.query.Identifier;
import org.apache.usergrid.persistence.map.MapManager;
@@ -123,7 +125,7 @@ import static me.prettyprint.hector.api.factory.HFactory.createMutator;
import static org.apache.commons.lang.StringUtils.capitalize;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.usergrid.corepersistence.util.CpEntityMapUtils.entityToCpEntity;
-import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromCollection;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromSource;
import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
import static org.apache.usergrid.persistence.Schema.COLLECTION_USERS;
import static org.apache.usergrid.persistence.Schema.DICTIONARY_PERMISSIONS;
@@ -2697,11 +2699,6 @@ public class CpEntityManager implements EntityManager {
boolean entityHasDictionary = Schema.getDefaultSchema()
.hasDictionary( entity.getType(), dictionaryName );
- // Don't index dynamic dictionaries not defined by the schema
- if ( entityHasDictionary ) {
- getRelationManager( entity ).batchUpdateSetIndexes(
- batch, dictionaryName, elementValue, removeFromDictionary, timestampUuid );
- }
ApplicationCF dictionary_cf = entityHasDictionary
? ENTITY_DICTIONARIES : ENTITY_COMPOSITE_DICTIONARIES;
@@ -2876,16 +2873,14 @@ public class CpEntityManager implements EntityManager {
}
- void indexEntityIntoCollection( org.apache.usergrid.persistence.model.entity.Entity collectionEntity,
- org.apache.usergrid.persistence.model.entity.Entity memberEntity,
- String collName ) {
+ void indexEntityIntoCollection( final Edge edge, final org.apache.usergrid.persistence.model.entity.Entity collectionMember) {
final ApplicationEntityIndex aie = getManagerCache().getEntityIndex( getApplicationScope() );
final EntityIndexBatch batch = aie.createBatch();
// index member into entity collection | type scope
- IndexScope collectionIndexScope = generateScopeFromCollection( collectionEntity.getId(), collName );
- batch.index( collectionIndexScope, memberEntity );
+ final IndexEdge collectionIndexScope = generateScopeFromSource( edge );
+ batch.index( collectionIndexScope, collectionMember );
//TODO REMOVE INDEX CODE
// // index member into entity | all-types scope
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index bb9928a..5044298 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -17,10 +17,7 @@
package org.apache.usergrid.corepersistence;
-import java.nio.ByteBuffer;
-import java.util.AbstractMap;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -45,7 +42,8 @@ import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.IndexBucketLocator;
-import org.apache.usergrid.persistence.PagingResultsIterator;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.persistence.RelationManager;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.RoleRef;
@@ -54,22 +52,13 @@ import org.apache.usergrid.persistence.SimpleEntityRef;
import org.apache.usergrid.persistence.SimpleRoleRef;
import org.apache.usergrid.persistence.cassandra.CassandraService;
import org.apache.usergrid.persistence.cassandra.ConnectionRefImpl;
-import org.apache.usergrid.persistence.cassandra.IndexUpdate;
-import org.apache.usergrid.persistence.cassandra.QueryProcessorImpl;
-import org.apache.usergrid.persistence.cassandra.index.ConnectedIndexScanner;
-import org.apache.usergrid.persistence.cassandra.index.IndexBucketScanner;
-import org.apache.usergrid.persistence.cassandra.index.IndexScanner;
-import org.apache.usergrid.persistence.cassandra.index.NoOpIndexScanner;
-import org.apache.usergrid.persistence.core.future.BetterFuture;
import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.entities.Group;
import org.apache.usergrid.persistence.entities.User;
-import org.apache.usergrid.persistence.geo.ConnectionGeoSearch;
-import org.apache.usergrid.persistence.geo.EntityLocationRef;
-import org.apache.usergrid.persistence.geo.model.Point;
import org.apache.usergrid.persistence.graph.Edge;
import org.apache.usergrid.persistence.graph.GraphManager;
+import org.apache.usergrid.persistence.graph.SearchByEdge;
import org.apache.usergrid.persistence.graph.SearchByEdgeType;
import org.apache.usergrid.persistence.graph.impl.SimpleEdge;
import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
@@ -77,87 +66,39 @@ import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.IndexScope;
+import org.apache.usergrid.persistence.index.IndexEdge;
+import org.apache.usergrid.persistence.index.SearchEdge;
import org.apache.usergrid.persistence.index.SearchTypes;
import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.Query;
-import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.query.ir.AllNode;
-import org.apache.usergrid.persistence.query.ir.NameIdentifierNode;
-import org.apache.usergrid.persistence.query.ir.QueryNode;
-import org.apache.usergrid.persistence.query.ir.QuerySlice;
-import org.apache.usergrid.persistence.query.ir.SearchVisitor;
-import org.apache.usergrid.persistence.query.ir.WithinNode;
-import org.apache.usergrid.persistence.query.ir.result.ConnectionIndexSliceParser;
-import org.apache.usergrid.persistence.query.ir.result.ConnectionResultsLoaderFactory;
-import org.apache.usergrid.persistence.query.ir.result.ConnectionTypesIterator;
-import org.apache.usergrid.persistence.query.ir.result.EmptyIterator;
-import org.apache.usergrid.persistence.query.ir.result.GeoIterator;
-import org.apache.usergrid.persistence.query.ir.result.SliceIterator;
-import org.apache.usergrid.persistence.query.ir.result.StaticIdIterator;
import org.apache.usergrid.persistence.schema.CollectionInfo;
-import org.apache.usergrid.utils.IndexUtils;
import org.apache.usergrid.utils.MapUtils;
-import org.apache.usergrid.utils.UUIDUtils;
import com.codahale.metrics.Timer;
import com.google.common.base.Preconditions;
-import me.prettyprint.hector.api.Keyspace;
-import me.prettyprint.hector.api.beans.DynamicComposite;
-import me.prettyprint.hector.api.beans.HColumn;
-import me.prettyprint.hector.api.mutation.Mutator;
import rx.Observable;
import rx.functions.Action1;
import rx.functions.Func1;
-import static java.util.Arrays.asList;
-
-import static me.prettyprint.hector.api.factory.HFactory.createMutator;
-import static org.apache.usergrid.corepersistence.util.CpNamingUtils.createId;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.createCollectionEdge;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.createCollectionSearchEdge;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.createConnectionSearchByEdge;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.createConnectionSearchEdge;
+import static org.apache.usergrid.corepersistence.util.CpNamingUtils.createSearchEdgeFromSource;
import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromSource;
-import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromCollection;
-import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromConnection;
import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getNameFromEdgeType;
import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
-import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_ENTITIES;
-import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_TYPES;
-import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTING_ENTITIES;
-import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTING_TYPES;
-import static org.apache.usergrid.persistence.Schema.INDEX_CONNECTIONS;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_CREATED;
import static org.apache.usergrid.persistence.Schema.PROPERTY_INACTIVITY;
import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
import static org.apache.usergrid.persistence.Schema.PROPERTY_TITLE;
-import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
import static org.apache.usergrid.persistence.Schema.TYPE_ENTITY;
import static org.apache.usergrid.persistence.Schema.TYPE_ROLE;
import static org.apache.usergrid.persistence.Schema.getDefaultSchema;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_COMPOSITE_DICTIONARIES;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_DICTIONARIES;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_INDEX;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_INDEX_ENTRIES;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addDeleteToMutator;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addInsertToMutator;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.batchExecute;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.INDEX_ENTRY_LIST_COUNT;
-import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchDeleteLocationInConnectionsIndex;
-import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchRemoveLocationFromCollectionIndex;
-import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchStoreLocationInCollectionIndex;
-import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchStoreLocationInConnectionsIndex;
-import static org.apache.usergrid.persistence.cassandra.IndexUpdate.indexValueCode;
-import static org.apache.usergrid.persistence.cassandra.IndexUpdate.toIndexableValue;
-import static org.apache.usergrid.persistence.cassandra.IndexUpdate.validIndexableValue;
-import static org.apache.usergrid.persistence.cassandra.Serializers.be;
import static org.apache.usergrid.utils.ClassUtils.cast;
-import static org.apache.usergrid.utils.CompositeUtils.setGreaterThanEqualityFlag;
import static org.apache.usergrid.utils.InflectionUtils.singularize;
import static org.apache.usergrid.utils.MapUtils.addMapSet;
-import static org.apache.usergrid.utils.UUIDUtils.getTimestampInMicros;
/**
@@ -182,15 +123,8 @@ public class CpRelationManager implements RelationManager {
private ApplicationScope applicationScope;
- private CassandraService cass;
-
- private IndexBucketLocator indexBucketLocator;
-
private MetricsFactory metricsFactory;
private Timer updateCollectionTimer;
- private Timer createConnectionTimer;
- private Timer cassConnectionDelete;
- private Timer esDeleteConnectionTimer;
public CpRelationManager() {}
@@ -219,17 +153,9 @@ public class CpRelationManager implements RelationManager {
this.managerCache = emf.getManagerCache();
this.applicationScope = CpNamingUtils.getApplicationScope( applicationId );
- this.cass = em.getCass(); // TODO: eliminate need for this via Core Persistence
- this.indexBucketLocator = indexBucketLocator; // TODO: this also
this.metricsFactory = metricsFactory;
this.updateCollectionTimer = metricsFactory
.getTimer( CpRelationManager.class, "relation.manager.es.update.collection" );
- this.createConnectionTimer = metricsFactory
- .getTimer( CpRelationManager.class, "relation.manager.es.create.connection.timer" );
- this.cassConnectionDelete = metricsFactory
- .getTimer( CpRelationManager.class, "relation.manager.cassandra.delete.connection.batch.timer" );
- this.esDeleteConnectionTimer = metricsFactory.getTimer( CpRelationManager.class,
- "relation.manager.es.delete.connection.batch.timer" );
if ( logger.isDebugEnabled() ) {
@@ -327,7 +253,6 @@ public class CpRelationManager implements RelationManager {
return gm.loadEdgesToTarget(
new SimpleSearchByEdgeType( cpHeadEntity.getId(), edgeType, Long.MAX_VALUE,
SearchByEdgeType.Order.DESCENDING, null ) );
-
}
} );
@@ -399,7 +324,7 @@ public class CpRelationManager implements RelationManager {
// reindex the entity in the source entity's collection or connection index
- IndexScope indexScope = generateScopeFromSource(edge);
+ IndexEdge indexScope = generateScopeFromSource(edge);
entityIndexBatch.index( indexScope, cpEntity );
@@ -483,12 +408,9 @@ public class CpRelationManager implements RelationManager {
GraphManager gm = managerCache.getGraphManager( applicationScope );
- Observable<Edge> edgesToTarget = gm.loadEdgesToTarget( new SimpleSearchByEdgeType(
- targetId,
- CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
- System.currentTimeMillis(),
- SearchByEdgeType.Order.DESCENDING,
- null ) ); // last
+ Observable<Edge> edgesToTarget = gm.loadEdgesToTarget(
+ new SimpleSearchByEdgeType( targetId, CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
+ System.currentTimeMillis(), SearchByEdgeType.Order.DESCENDING, null ) ); // last
Iterator<Edge> iterator = edgesToTarget.toBlocking().getIterator();
int count = 0;
@@ -502,24 +424,6 @@ public class CpRelationManager implements RelationManager {
}
- private boolean moreThanOneOutboundConnection( EntityRef source, String connectionType ) {
-
- Id sourceId = new SimpleId( source.getUuid(), source.getType() );
-
- GraphManager gm = managerCache.getGraphManager( applicationScope );
-
- Observable<Edge> edgesFromSource = gm.loadEdgesFromSource( new SimpleSearchByEdgeType(
- sourceId,
- CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
- System.currentTimeMillis(),
- SearchByEdgeType.Order.DESCENDING,
- null ) ); // last
-
- int count = edgesFromSource.take( 2 ).count().toBlocking().last();
-
- return count > 1;
- }
-
@Override
public Set<String> getCollections() throws Exception {
@@ -529,7 +433,7 @@ public class CpRelationManager implements RelationManager {
GraphManager gm = managerCache.getGraphManager( applicationScope );
Observable<String> str = gm.getEdgeTypesFromSource(
- new SimpleSearchEdgeType( cpHeadEntity.getId(), null, null ) );
+ new SimpleSearchEdgeType( cpHeadEntity.getId(), null, null ) );
Iterator<String> iter = str.toBlocking().getIterator();
while ( iter.hasNext() ) {
@@ -542,19 +446,22 @@ public class CpRelationManager implements RelationManager {
@Override
- public Results getCollection( String collectionName,
- UUID startResult,
- int count,
- Level resultsLevel,
- boolean reversed ) throws Exception {
+ public Results getCollection( String collectionName, UUID startResult, int count, Level resultsLevel,
+ boolean reversed ) throws Exception {
- Query query = Query.fromQL( "select *" );
- query.setLimit( count );
- query.setReversed( reversed );
+
+ final String ql;
if ( startResult != null ) {
- query.addGreaterThanEqualFilter( "created", startResult.timestamp() );
+ ql = "select * where created > " + startResult.timestamp();
}
+ else {
+ ql = "select *";
+ }
+
+ Query query = Query.fromQL( ql );
+ query.setLimit( count );
+ query.setReversed( reversed );
return searchCollection( collectionName, query );
}
@@ -632,29 +539,18 @@ public class CpRelationManager implements RelationManager {
} );
}
- String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collName );
-
- UUID timeStampUuid = memberEntity.getId().getUuid() != null
- && UUIDUtils.isTimeBased( memberEntity.getId().getUuid() )
- ? memberEntity.getId().getUuid() : UUIDUtils.newTimeUUID();
-
- long uuidHash = UUIDUtils.getUUIDLong( timeStampUuid );
// create graph edge connection from head entity to member entity
- Edge edge = new SimpleEdge( cpHeadEntity.getId(), edgeType, memberEntity.getId(), uuidHash );
+ final Edge edge = createCollectionEdge( cpHeadEntity.getId(), collName, memberEntity.getId() );
GraphManager gm = managerCache.getGraphManager( applicationScope );
gm.writeEdge( edge ).toBlocking().last();
if(logger.isDebugEnabled()) {
- logger.debug( "Wrote edgeType {}\n from {}:{}\n to {}:{}\n scope {}:{}", new Object[] {
- edgeType, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(), memberEntity.getId().getType(),
- memberEntity.getId().getUuid(), applicationScope.getApplication().getType(),
- applicationScope.getApplication().getUuid()
- } );
+ logger.debug( "Wrote edge {}", edge );
}
- ( ( CpEntityManager ) em ).indexEntityIntoCollection( cpHeadEntity, memberEntity, collName );
+ ( ( CpEntityManager ) em ).indexEntityIntoCollection( edge, memberEntity );
if(logger.isDebugEnabled()) {
logger.debug( "Added entity {}:{} to collection {}", new Object[] {
@@ -775,40 +671,33 @@ public class CpRelationManager implements RelationManager {
org.apache.usergrid.persistence.model.entity.Entity memberEntity =
((CpEntityManager)em).load( entityId );
+
+
+ // remove edge from collection to item
+ GraphManager gm = managerCache.getGraphManager( applicationScope );
+
+
+ //run our delete
+ final Edge collectionToItemEdge = createCollectionEdge( cpHeadEntity.getId(), collName, memberEntity.getId() );
+ gm.deleteEdge( collectionToItemEdge ).toBlocking().last();
+
+
+ /**
+ * Remove from the index
+ *
+ */
+
final ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
final EntityIndexBatch batch = ei.createBatch();
// remove item from collection index
- IndexScope indexScope = generateScopeFromCollection( cpHeadEntity.getId(), collName );
+ SearchEdge indexScope = createCollectionSearchEdge( cpHeadEntity.getId(), collName );
batch.deindex( indexScope, memberEntity );
- // remove collection from item index
- IndexScope itemScope = generateScopeFromCollection( memberEntity.getId(),
- Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) );
-
-
- batch.deindex( itemScope, cpHeadEntity );
batch.execute();
- // remove edge from collection to item
- GraphManager gm = managerCache.getGraphManager( applicationScope );
- Edge collectionToItemEdge = new SimpleEdge(
- cpHeadEntity.getId(),
- CpNamingUtils.getEdgeTypeFromCollectionName( collName ),
- memberEntity.getId(), UUIDUtils.getUUIDLong( memberEntity.getId().getUuid() ) );
- gm.deleteEdge( collectionToItemEdge ).toBlocking().last();
-
- // remove edge from item to collection
- Edge itemToCollectionEdge = new SimpleEdge(
- memberEntity.getId(),
- CpNamingUtils.getEdgeTypeFromCollectionName(
- Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) ),
- cpHeadEntity.getId(),
- UUIDUtils.getUUIDLong( cpHeadEntity.getId().getUuid() ) );
-
- gm.deleteEdge( itemToCollectionEdge ).toBlocking().last();
// special handling for roles collection of a group
if ( headEntity.getType().equals( Group.ENTITY_TYPE ) ) {
@@ -884,15 +773,14 @@ public class CpRelationManager implements RelationManager {
+ "' of " + headEntity.getType() + ":" + headEntity .getUuid() );
}
- final IndexScope indexScope = generateScopeFromCollection( cpHeadEntity.getId(), collName );
+
+ final SearchEdge searchEdge = createCollectionSearchEdge( cpHeadEntity.getId(), collName );
final ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
final SearchTypes types = SearchTypes.fromTypes( collection.getType() );
- logger.debug( "Searching scope {}:{}",
-
- indexScope.getOwner().toString(), indexScope.getName() );
+ logger.debug( "Searching scope {}", searchEdge);
query.setEntityType( collection.getType() );
query = adjustQuery( query );
@@ -902,7 +790,7 @@ public class CpRelationManager implements RelationManager {
//execute the query and return our next result
- final QueryExecutor executor = new ElasticSearchQueryExecutor( resultsLoaderFactory, ei, applicationScope, indexScope, types, query );
+ final QueryExecutor executor = new ElasticSearchQueryExecutor( resultsLoaderFactory, ei, applicationScope, searchEdge, types, query );
return executor.next();
}
@@ -955,9 +843,9 @@ public class CpRelationManager implements RelationManager {
EntityIndexBatch batch = ei.createBatch();
// Index the new connection in app|source|type context
- IndexScope indexScope = generateScopeFromConnection( cpHeadEntity.getId(), connectionType );
+ IndexEdge edgeIndex = generateScopeFromSource( edge );
- batch.index( indexScope, targetEntity );
+ batch.index( edgeIndex, targetEntity );
// Index the new connection in app|scope|all-types context
//TODO REMOVE INDEX CODE
@@ -965,129 +853,11 @@ public class CpRelationManager implements RelationManager {
// batch.index( allTypesIndexScope, targetEntity );
- BetterFuture future = batch.execute();
-
- Keyspace ko = cass.getApplicationKeyspace( applicationId );
- Mutator<ByteBuffer> m = createMutator( ko, be );
- batchUpdateEntityConnection( m, false, connection, UUIDGenerator.newTimeUUID() );
- //Added Graphite Metrics
- Timer.Context timeElasticIndexBatch = createConnectionTimer.time();
- batchExecute( m, CassandraService.RETRY_COUNT );
- timeElasticIndexBatch.stop();
-
return connection;
}
- @SuppressWarnings( "unchecked" )
- public Mutator<ByteBuffer> batchUpdateEntityConnection(
- Mutator<ByteBuffer> batch,
- boolean disconnect,
- ConnectionRefImpl conn,
- UUID timestampUuid ) throws Exception {
-
- long timestamp = getTimestampInMicros( timestampUuid );
-
- Entity connectedEntity = em.get(new SimpleEntityRef(
- conn.getConnectedEntityType(), conn.getConnectedEntityId() ) );
-
- if ( connectedEntity == null ) {
- return batch;
- }
-
- // Create connection for requested params
-
- if ( disconnect ) {
-
- addDeleteToMutator(batch, ENTITY_COMPOSITE_DICTIONARIES,
- key(conn.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
- conn.getConnectionType() ),
- asList(conn.getConnectedEntityId(), conn.getConnectedEntityType() ), timestamp );
-
- addDeleteToMutator(batch, ENTITY_COMPOSITE_DICTIONARIES,
- key(conn.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
- conn.getConnectionType() ),
- asList(conn.getConnectingEntityId(), conn.getConnectingEntityType() ), timestamp );
-
- // delete the connection path if there will be no connections left
-
- // check out outbound edges of the given type. If we have more than the 1 specified,
- // we shouldn't delete the connection types from our outbound index
- if ( !moreThanOneOutboundConnection(conn.getConnectingEntity(), conn.getConnectionType() ) ) {
-
- addDeleteToMutator(batch, ENTITY_DICTIONARIES,
- key(conn.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
- conn.getConnectionType(), timestamp );
- }
-
- //check out inbound edges of the given type. If we have more than the 1 specified,
- // we shouldn't delete the connection types from our outbound index
- if ( !moreThanOneInboundConnection(conn.getConnectingEntity(), conn.getConnectionType() ) ) {
-
- addDeleteToMutator(batch, ENTITY_DICTIONARIES,
- key(conn.getConnectedEntityId(), DICTIONARY_CONNECTING_TYPES ),
- conn.getConnectionType(), timestamp );
- }
- }
- else {
-
- addInsertToMutator(batch, ENTITY_COMPOSITE_DICTIONARIES,
- key(conn.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
- conn.getConnectionType() ),
- asList(conn.getConnectedEntityId(), conn.getConnectedEntityType() ), timestamp,
- timestamp );
-
- addInsertToMutator(batch, ENTITY_COMPOSITE_DICTIONARIES,
- key(conn.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
- conn.getConnectionType() ),
- asList(conn.getConnectingEntityId(), conn.getConnectingEntityType() ), timestamp,
- timestamp );
-
- // Add connection type to connections set
- addInsertToMutator(batch, ENTITY_DICTIONARIES,
- key(conn.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
- conn.getConnectionType(), null, timestamp );
-
- // Add connection type to connections set
- addInsertToMutator(batch, ENTITY_DICTIONARIES,
- key(conn.getConnectedEntityId(), DICTIONARY_CONNECTING_TYPES ),
- conn.getConnectionType(), null, timestamp );
- }
-
- // Add indexes for the connected entity's list properties
-
- // Get the names of the list properties in the connected entity
- Set<String> dictionaryNames = em.getDictionaryNames( connectedEntity );
-
- // For each list property, get the values in the list and
- // update the index with those values
-
- Schema schema = getDefaultSchema();
-
- for ( String dictionaryName : dictionaryNames ) {
-
- boolean has_dictionary = schema.hasDictionary(
- connectedEntity.getType(), dictionaryName );
-
- boolean dictionary_indexed = schema.isDictionaryIndexedInConnections(
- connectedEntity.getType(), dictionaryName );
-
- if ( dictionary_indexed || !has_dictionary ) {
- Set<Object> elementValues = em.getDictionaryAsSet( connectedEntity, dictionaryName );
- for ( Object elementValue : elementValues ) {
- IndexUpdate indexUpdate = batchStartIndexUpdate(
- batch, connectedEntity, dictionaryName, elementValue,
- timestampUuid, has_dictionary, true, disconnect, false );
- batchUpdateConnectionIndex(indexUpdate, conn );
- }
- }
- }
-
- return batch;
- }
-
-
@Override
public ConnectionRef createConnection(
String pairedConnectionType,
@@ -1138,16 +908,6 @@ public class CpRelationManager implements RelationManager {
public void deleteConnection( ConnectionRef connectionRef ) throws Exception {
// First, clean up the dictionary records of the connection
- Keyspace ko = cass.getApplicationKeyspace( applicationId );
- Mutator<ByteBuffer> m = createMutator( ko, be );
- batchUpdateEntityConnection(
- m, true, ( ConnectionRefImpl ) connectionRef, UUIDGenerator.newTimeUUID() );
-
- //Added Graphite Metrics
- Timer.Context timeDeleteConnections = cassConnectionDelete.time();
- batchExecute( m, CassandraService.RETRY_COUNT );
- timeDeleteConnections.stop();
-
EntityRef connectingEntityRef = connectionRef.getConnectingEntity(); // source
EntityRef connectedEntityRef = connectionRef.getConnectedEntity(); // target
@@ -1177,30 +937,26 @@ public class CpRelationManager implements RelationManager {
targetEntity.getId(),
System.currentTimeMillis() );
+
+
GraphManager gm = managerCache.getGraphManager( applicationScope );
- gm.deleteEdge( edge ).toBlocking().last();
- final ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
- final EntityIndexBatch batch = ei.createBatch();
- // Deindex the connection in app|source|type context
- final Id cpId = createId( connectingEntityRef );
- IndexScope indexScope = generateScopeFromConnection( cpId, connectionType );
- batch.deindex( indexScope, targetEntity );
+ final Id sourceId = new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() );
- // Deindex the connection in app|source|type context
- //TODO REMOVE INDEX CODE
-// IndexScope allTypesIndexScope = new IndexScopeImpl(
-// new SimpleId( connectingEntityRef.getUuid(),
-// connectingEntityRef.getType() ),
-// CpNamingUtils.ALL_TYPES, entityType );
-//
-// batch.deindex( allTypesIndexScope, targetEntity );
+ final SearchByEdge search = createConnectionSearchByEdge( sourceId, connectionType, targetEntity.getId() );
+
+ //delete all the edges
+ final Edge lastEdge = gm.loadEdgeVersions( search ).flatMap( returnedEdge -> gm.deleteEdge( returnedEdge ) ).toBlocking().lastOrDefault(null);
+
+ if(lastEdge != null) {
+ final ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ final EntityIndexBatch batch = ei.createBatch();
+
+ SearchEdge indexScope = createSearchEdgeFromSource( lastEdge );
+ batch.deindex( indexScope, targetEntity );
+ }
- //Added Graphite Metrics
- Timer.Context timeDeleteConnection = esDeleteConnectionTimer.time();
- batch.execute();
- timeDeleteConnection.stop();
}
@@ -1302,21 +1058,15 @@ public class CpRelationManager implements RelationManager {
Preconditions.checkNotNull( connection, "connection must be specified" );
-// if ( query == null ) {
-// query = new Query();
-// }
-
headEntity = em.validate( headEntity );
- final IndexScope indexScope = generateScopeFromConnection( cpHeadEntity.getId(), connection );
+ final SearchEdge indexScope = createConnectionSearchEdge( cpHeadEntity.getId(), connection );
final SearchTypes searchTypes = SearchTypes.fromNullableTypes( query.getEntityType() );
ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
- logger.debug( "Searching connections from the scope {}:{} with types {}", new Object[] {
- indexScope.getOwner().toString(), indexScope.getName(), searchTypes
- } );
+ logger.debug( "Searching {}", indexScope );
query = adjustQuery( query );
@@ -1326,18 +1076,15 @@ public class CpRelationManager implements RelationManager {
final QueryExecutor executor = new ElasticSearchQueryExecutor(resultsLoaderFactory, ei, applicationScope, indexScope, searchTypes, query);
return executor.next();
-// CandidateResults crs = ei.search( indexScope, searchTypes, query );
-
-// return buildConnectionResults( indexScope, query, crs, connection );
}
private Query adjustQuery( Query query ) {
// handle the select by identifier case
- if ( query.getRootOperand() == null ) {
+ if(query.getQl() == null){
- // a name alias or email alias was specified
+ // a name alias or email alias was specified
if ( query.containsSingleNameOrEmailIdentifier() ) {
Identifier ident = query.getSingleIdentifier();
@@ -1346,47 +1093,50 @@ public class CpRelationManager implements RelationManager {
// This is fulgy to put here, but required.
if ( query.getEntityType().equals( User.ENTITY_TYPE ) && ident.isEmail() ) {
- Query newQuery = Query.fromQL( "select * where email='"
- + query.getSingleNameOrEmailIdentifier() + "'" );
- query.setRootOperand( newQuery.getRootOperand() );
+ final String newQuery = "select * where email='"
+ + query.getSingleNameOrEmailIdentifier() + "'" ;
+
+ query.setQl( newQuery );
+
}
// use the ident with the default alias. could be an email
else {
- Query newQuery = Query.fromQL( "select * where name='"
- + query.getSingleNameOrEmailIdentifier() + "'" );
- query.setRootOperand( newQuery.getRootOperand() );
+ final String newQuery = "select * where name='"
+ + query.getSingleNameOrEmailIdentifier() + "'" ;
+ query.setQl( newQuery );
}
}
else if ( query.containsSingleUuidIdentifier() ) {
- Query newQuery = Query.fromQL(
- "select * where uuid='" + query.getSingleUuidIdentifier() + "'" );
- query.setRootOperand( newQuery.getRootOperand() );
- }
- }
-
- if ( query.isReversed() ) {
-
- Query.SortPredicate desc =
- new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.DESCENDING );
-
- try {
- query.addSort( desc );
- }
- catch ( Exception e ) {
- logger.warn( "Attempted to reverse sort order already set", PROPERTY_CREATED );
+ //TODO, this shouldn't even come from ES, it should look up the entity directly
+ final String newQuery =
+ "select * where uuid='" + query.getSingleUuidIdentifier() + "'" ;
+ query.setQl( newQuery );
}
}
- if ( query.getSortPredicates().isEmpty() ) {
-
- Query.SortPredicate asc =
- new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.ASCENDING);
+ //TODO T.N. not sure if we still need this. If we do then we ned to modify our query interface.
- query.addSort( asc );
- }
+// final String ql = query.getQl();
+//
+// if ( query.isReversed() && ( StringUtils.isEmpty( ql ) || !(ql.contains( "order by " )) )) {
+//
+//
+// final String sortQueryString =
+//
+// SortPredicate
+// Query.SortPredicate desc =
+// new Query.SortPredicate( PROPERTY_CREATED, Query.SortDirection.DESCENDING );
+//
+// try {
+// query.addSort( desc );
+// }
+// catch ( Exception e ) {
+// logger.warn( "Attempted to reverse sort order already set", PROPERTY_CREATED );
+// }
+// }
return query;
}
@@ -1417,845 +1167,4 @@ public class CpRelationManager implements RelationManager {
}
return entity;
}
-
-//
-// private Results buildConnectionResults( final IndexScope indexScope,
-// final Query query, final CandidateResults crs, final String connectionType ) {
-//
-// if ( query.getLevel().equals( Level.ALL_PROPERTIES ) ) {
-// return buildResults( indexScope, query, crs, connectionType );
-// }
-//
-// final EntityRef sourceRef = new SimpleEntityRef( headEntity.getType(), headEntity.getUuid() );
-//
-// List<ConnectionRef> refs = new ArrayList<ConnectionRef>( crs.size() );
-//
-// for ( CandidateResult cr : crs ) {
-//
-// SimpleEntityRef targetRef =
-// new SimpleEntityRef( cr.getId().getType(), cr.getId().getUuid() );
-//
-// final ConnectionRef ref =
-// new ConnectionRefImpl( sourceRef, connectionType, targetRef );
-//
-// refs.add( ref );
-// }
-//
-// return Results.fromConnections( refs );
-// }
-
-
-
-
- @Override
- public void batchUpdateSetIndexes( Mutator<ByteBuffer> batch, String setName, Object elementValue,
- boolean removeFromSet, UUID timestampUuid ) throws Exception {
-
- Entity entity = getHeadEntity();
-
- elementValue = getDefaultSchema()
- .validateEntitySetValue( entity.getType(), setName, elementValue );
-
- IndexUpdate indexUpdate = batchStartIndexUpdate( batch, entity, setName, elementValue,
- timestampUuid, true, true, removeFromSet, false );
-
- // Update collections
-
- Map<String, Set<CollectionInfo>> containers =
- getDefaultSchema().getContainersIndexingDictionary( entity.getType(), setName );
-
- if ( containers != null ) {
- Map<EntityRef, Set<String>> containerEntities = getContainers();
- for ( EntityRef containerEntity : containerEntities.keySet() ) {
- if ( containerEntity.getType().equals( TYPE_APPLICATION )
- && Schema.isAssociatedEntityType( entity.getType() ) ) {
- logger.debug( "Extended properties for {} not indexed by application", entity.getType() );
- continue;
- }
- Set<String> collectionNames = containerEntities.get( containerEntity );
- Set<CollectionInfo> collections = containers.get( containerEntity.getType() );
-
- if ( collections != null ) {
-
- for ( CollectionInfo collection : collections ) {
- if ( collectionNames.contains( collection.getName() ) ) {
- batchUpdateCollectionIndex( indexUpdate, containerEntity, collection.getName() );
- }
- }
- }
- }
- }
-
- batchUpdateBackwardConnectionsDictionaryIndexes( indexUpdate );
- }
-
-
- /**
- * Batch update collection index.
- *
- * @param indexUpdate The update to apply
- * @param owner The entity that is the owner context of this entity update. Can either be an
- * application, or another * entity
- * @param collectionName the collection name
- *
- * @return The indexUpdate with batch mutations
- * @throws Exception the exception
- */
- public IndexUpdate batchUpdateCollectionIndex(
- IndexUpdate indexUpdate, EntityRef owner, String collectionName )
- throws Exception {
-
- logger.debug( "batchUpdateCollectionIndex" );
-
- Entity indexedEntity = indexUpdate.getEntity();
-
- String bucketId = indexBucketLocator
- .getBucket( applicationId, IndexBucketLocator.IndexType.COLLECTION, indexedEntity.getUuid(),
- indexedEntity.getType(), indexUpdate.getEntryName() );
-
- // the root name without the bucket
- // entity_id,collection_name,prop_name,
- Object index_name = null;
- // entity_id,collection_name,prop_name, bucketId
- Object index_key = null;
-
- // entity_id,collection_name,collected_entity_id,prop_name
-
- for ( IndexUpdate.IndexEntry entry : indexUpdate.getPrevEntries() ) {
-
- if ( entry.getValue() != null ) {
-
- index_name = key( owner.getUuid(), collectionName, entry.getPath() );
-
- index_key = key( index_name, bucketId );
-
- addDeleteToMutator( indexUpdate.getBatch(), ENTITY_INDEX, index_key,
- entry.getIndexComposite(), indexUpdate.getTimestamp() );
-
- if ( "location.coordinates".equals( entry.getPath() ) ) {
- EntityLocationRef loc = new EntityLocationRef( indexUpdate.getEntity(),
- entry.getTimestampUuid(), entry.getValue().toString() );
- batchRemoveLocationFromCollectionIndex( indexUpdate.getBatch(),
- indexBucketLocator, applicationId, index_name, loc );
- }
- }
- else {
- logger.error( "Unexpected condition - deserialized property value is null" );
- }
- }
-
- if ( ( indexUpdate.getNewEntries().size() > 0 )
- && ( !indexUpdate.isMultiValue()
- || ( indexUpdate.isMultiValue() && !indexUpdate.isRemoveListEntry() ) ) ) {
-
- for ( IndexUpdate.IndexEntry indexEntry : indexUpdate.getNewEntries() ) {
-
- // byte valueCode = indexEntry.getValueCode();
-
- index_name = key( owner.getUuid(), collectionName, indexEntry.getPath() );
-
- index_key = key( index_name, bucketId );
-
- // int i = 0;
-
- addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, index_key,
- indexEntry.getIndexComposite(), null, indexUpdate.getTimestamp() );
-
- if ( "location.coordinates".equals( indexEntry.getPath() ) ) {
- EntityLocationRef loc = new EntityLocationRef(
- indexUpdate.getEntity(),
- indexEntry.getTimestampUuid(),
- indexEntry.getValue().toString() );
- batchStoreLocationInCollectionIndex(
- indexUpdate.getBatch(),
- indexBucketLocator,
- applicationId,
- index_name,
- indexedEntity.getUuid(),
- loc );
- }
-
- // i++;
- }
- }
-
- for ( String index : indexUpdate.getIndexesSet() ) {
- addInsertToMutator( indexUpdate.getBatch(), ENTITY_DICTIONARIES,
- key( owner.getUuid(), collectionName, Schema.DICTIONARY_INDEXES ), index, null,
- indexUpdate.getTimestamp() );
- }
-
- return indexUpdate;
- }
-
-
- public IndexUpdate batchStartIndexUpdate(
- Mutator<ByteBuffer> batch, Entity entity, String entryName,
- Object entryValue, UUID timestampUuid, boolean schemaHasProperty,
- boolean isMultiValue, boolean removeListEntry, boolean fulltextIndexed )
- throws Exception {
- return batchStartIndexUpdate( batch, entity, entryName, entryValue, timestampUuid,
- schemaHasProperty, isMultiValue, removeListEntry, fulltextIndexed, false );
- }
-
-
- public IndexUpdate batchStartIndexUpdate(
- Mutator<ByteBuffer> batch, Entity entity, String entryName,
- Object entryValue, UUID timestampUuid, boolean schemaHasProperty,
- boolean isMultiValue, boolean removeListEntry, boolean fulltextIndexed,
- boolean skipRead ) throws Exception {
-
- long timestamp = getTimestampInMicros( timestampUuid );
-
- IndexUpdate indexUpdate = new IndexUpdate( batch, entity, entryName, entryValue,
- schemaHasProperty, isMultiValue, removeListEntry, timestampUuid );
-
- // entryName = entryName.toLowerCase();
-
- // entity_id,connection_type,connected_entity_id,prop_name
-
- if ( !skipRead ) {
-
- List<HColumn<ByteBuffer, ByteBuffer>> entries = null;
-
- if ( isMultiValue && validIndexableValue( entryValue ) ) {
- entries = cass.getColumns(
- cass.getApplicationKeyspace( applicationId ),
- ENTITY_INDEX_ENTRIES,
- entity.getUuid(),
- new DynamicComposite(
- entryName,
- indexValueCode( entryValue ),
- toIndexableValue( entryValue ) ),
- setGreaterThanEqualityFlag(
- new DynamicComposite(
- entryName, indexValueCode( entryValue ),
- toIndexableValue( entryValue ) ) ),
- INDEX_ENTRY_LIST_COUNT,
- false );
- }
- else {
- entries = cass.getColumns(
- cass.getApplicationKeyspace( applicationId ),
- ENTITY_INDEX_ENTRIES,
- entity.getUuid(),
- new DynamicComposite( entryName ),
- setGreaterThanEqualityFlag( new DynamicComposite( entryName ) ),
- INDEX_ENTRY_LIST_COUNT,
- false );
- }
-
- if ( logger.isDebugEnabled() ) {
- logger.debug( "Found {} previous index entries for {} of entity {}", new Object[] {
- entries.size(), entryName, entity.getUuid()
- } );
- }
-
- // Delete all matching entries from entry list
- for ( HColumn<ByteBuffer, ByteBuffer> entry : entries ) {
- UUID prev_timestamp = null;
- Object prev_value = null;
- String prev_obj_path = null;
-
- // new format:
- // composite(entryName,
- // value_code,prev_value,prev_timestamp,prev_obj_path) = null
- DynamicComposite composite =
- DynamicComposite.fromByteBuffer( entry.getName().duplicate() );
- prev_value = composite.get( 2 );
- prev_timestamp = ( UUID ) composite.get( 3 );
- if ( composite.size() > 4 ) {
- prev_obj_path = ( String ) composite.get( 4 );
- }
-
- if ( prev_value != null ) {
-
- String entryPath = entryName;
- if ( ( prev_obj_path != null ) && ( prev_obj_path.length() > 0 ) ) {
- entryPath = entryName + "." + prev_obj_path;
- }
-
- indexUpdate.addPrevEntry(
- entryPath, prev_value, prev_timestamp, entry.getName().duplicate() );
-
- // composite(property_value,connected_entity_id,entry_timestamp)
- // addDeleteToMutator(batch, ENTITY_INDEX_ENTRIES,
- // entity.getUuid(), entry.getName(), timestamp);
-
- }
- else {
- logger.error( "Unexpected condition - deserialized property value is null" );
- }
- }
- }
-
- if ( !isMultiValue || ( isMultiValue && !removeListEntry ) ) {
-
- List<Map.Entry<String, Object>> list =
- IndexUtils.getKeyValueList( entryName, entryValue, fulltextIndexed );
-
- if ( entryName.equalsIgnoreCase( "location" ) && ( entryValue instanceof Map ) ) {
- @SuppressWarnings( "rawtypes" ) double latitude =
- MapUtils.getDoubleValue( ( Map ) entryValue, "latitude" );
- @SuppressWarnings( "rawtypes" ) double longitude =
- MapUtils.getDoubleValue( ( Map ) entryValue, "longitude" );
- list.add( new AbstractMap.SimpleEntry<String, Object>( "location.coordinates",
- latitude + "," + longitude ) );
- }
-
- for ( Map.Entry<String, Object> indexEntry : list ) {
-
- if ( validIndexableValue( indexEntry.getValue() ) ) {
- indexUpdate.addNewEntry(
- indexEntry.getKey(), toIndexableValue( indexEntry.getValue() ) );
- }
- }
-
- if ( isMultiValue ) {
- addInsertToMutator( batch, ENTITY_INDEX_ENTRIES, entity.getUuid(),
- asList( entryName,
- indexValueCode( entryValue ),
- toIndexableValue( entryValue ),
- indexUpdate.getTimestampUuid() ),
- null, timestamp );
- }
- else {
- // int i = 0;
-
- for ( Map.Entry<String, Object> indexEntry : list ) {
-
- String name = indexEntry.getKey();
- if ( name.startsWith( entryName + "." ) ) {
- name = name.substring( entryName.length() + 1 );
- }
- else if ( name.startsWith( entryName ) ) {
- name = name.substring( entryName.length() );
- }
-
- byte code = indexValueCode( indexEntry.getValue() );
- Object val = toIndexableValue( indexEntry.getValue() );
- addInsertToMutator( batch, ENTITY_INDEX_ENTRIES, entity.getUuid(),
- asList( entryName, code, val, indexUpdate.getTimestampUuid(), name ),
- null, timestamp );
-
- indexUpdate.addIndex( indexEntry.getKey() );
- }
- }
-
- indexUpdate.addIndex( entryName );
- }
-
- return indexUpdate;
- }
-
-
- /**
- * Batch update backward connections set indexes.
- *
- * @param indexUpdate The index to update in the dictionary
- *
- * @return The index update
- *
- * @throws Exception the exception
- */
- public IndexUpdate batchUpdateBackwardConnectionsDictionaryIndexes(
- IndexUpdate indexUpdate ) throws Exception {
-
- logger.debug( "batchUpdateBackwardConnectionsListIndexes" );
-
- boolean entityHasDictionary = getDefaultSchema()
- .isDictionaryIndexedInConnections(
- indexUpdate.getEntity().getType(), indexUpdate.getEntryName() );
-
- if ( !entityHasDictionary ) {
- return indexUpdate;
- }
-
-
- return doBackwardConnectionsUpdate( indexUpdate );
- }
-
-
- /**
- * Search each reverse connection type in the graph for connections.
- * If one is found, update the index appropriately
- *
- * @param indexUpdate The index update to use
- *
- * @return The updated index update
- */
- private IndexUpdate doBackwardConnectionsUpdate( IndexUpdate indexUpdate ) throws Exception {
- final Entity targetEntity = indexUpdate.getEntity();
-
- logger.debug( "doBackwardConnectionsUpdate" );
-
- final ConnectionTypesIterator connectionTypes =
- new ConnectionTypesIterator( cass, applicationId, targetEntity.getUuid(), false, 100 );
-
- for ( String connectionType : connectionTypes ) {
-
- PagingResultsIterator itr =
- getReversedConnectionsIterator( targetEntity, connectionType );
-
- for ( Object connection : itr ) {
-
- final ConnectedEntityRef sourceEntity = ( ConnectedEntityRef ) connection;
-
- //we need to create a connection ref from the source entity (found via reverse edge)
- // to the entity we're about to update. This is the index that needs updated
- final ConnectionRefImpl connectionRef =
- new ConnectionRefImpl( sourceEntity, connectionType, indexUpdate.getEntity() );
-
- batchUpdateConnectionIndex( indexUpdate, connectionRef );
- }
- }
-
- return indexUpdate;
- }
-
-
- /**
- * Batch update connection index.
- *
- * @param indexUpdate The update operation to perform
- * @param connection The connection to update
- *
- * @return The index with the batch mutation udpated
- *
- * @throws Exception the exception
- */
- public IndexUpdate batchUpdateConnectionIndex(
- IndexUpdate indexUpdate, ConnectionRefImpl connection ) throws Exception {
-
- logger.debug( "batchUpdateConnectionIndex" );
-
- // UUID connection_id = connection.getUuid();
-
- UUID[] index_keys = connection.getIndexIds();
-
- // Delete all matching entries from entry list
- for ( IndexUpdate.IndexEntry entry : indexUpdate.getPrevEntries() ) {
-
- if ( entry.getValue() != null ) {
-
- batchDeleteConnectionIndexEntries( indexUpdate, entry, connection, index_keys );
-
- if ( "location.coordinates".equals( entry.getPath() ) ) {
- EntityLocationRef loc =
- new EntityLocationRef( indexUpdate.getEntity(), entry.getTimestampUuid(),
- entry.getValue().toString() );
- batchDeleteLocationInConnectionsIndex(
- indexUpdate.getBatch(), indexBucketLocator, applicationId,
- index_keys, entry.getPath(), loc );
- }
- }
- else {
- logger.error( "Unexpected condition - deserialized property value is null" );
- }
- }
-
- if ( ( indexUpdate.getNewEntries().size() > 0 )
- && ( !indexUpdate.isMultiValue() || ( indexUpdate.isMultiValue()
- && !indexUpdate.isRemoveListEntry() ) ) ) {
-
- for ( IndexUpdate.IndexEntry indexEntry : indexUpdate.getNewEntries() ) {
-
- batchAddConnectionIndexEntries( indexUpdate, indexEntry, connection, index_keys );
-
- if ( "location.coordinates".equals( indexEntry.getPath() ) ) {
- EntityLocationRef loc =
- new EntityLocationRef(
- indexUpdate.getEntity(),
- indexEntry.getTimestampUuid(),
- indexEntry.getValue().toString() );
- batchStoreLocationInConnectionsIndex(
- indexUpdate.getBatch(), indexBucketLocator, applicationId,
- index_keys, indexEntry.getPath(), loc );
- }
- }
-
- /*
- * addInsertToMutator(batch, EntityCF.SETS, key(connection_id,
- * Schema.INDEXES_SET), indexEntry.getKey(), null, false, timestamp); }
- *
- * addInsertToMutator(batch, EntityCF.SETS, key(connection_id,
- * Schema.INDEXES_SET), entryName, null, false, timestamp);
- */
- }
-
- for ( String index : indexUpdate.getIndexesSet() ) {
- addInsertToMutator( indexUpdate.getBatch(), ENTITY_DICTIONARIES,
- key( connection.getConnectingIndexId(), Schema.DICTIONARY_INDEXES), index, null,
- indexUpdate.getTimestamp() );
- }
-
- return indexUpdate;
- }
-
-
- /**
- * Get a paging results iterator. Should return an iterator for all results
- *
- * @param targetEntity The target entity search connections from
- *
- * @return connectionType The name of the edges to search
- */
- private PagingResultsIterator getReversedConnectionsIterator(
- EntityRef targetEntity, String connectionType ) throws Exception {
-
- return new PagingResultsIterator(
- getConnectingEntities( targetEntity, connectionType, null, Level.REFS ) );
- }
-
-
- /**
- * Get all edges that are to the targetEntity
- *
- * @param targetEntity The target entity to search edges in
- * @param connectionType The type of connection. If not specified, all connections are returned
- * @param connectedEntityType The connected entity type, if not specified all types are returned
- * @param resultsLevel The results level to return
- */
- private Results getConnectingEntities(
- EntityRef targetEntity, String connectionType, String connectedEntityType,
- Level resultsLevel ) throws Exception {
-
- return getConnectingEntities(
- targetEntity, connectionType, connectedEntityType, resultsLevel, 0);
- }
-
-
- /**
- * Get all edges that are to the targetEntity
- *
- * @param targetEntity The target entity to search edges in
- * @param connectionType The type of connection. If not specified, all connections are returned
- * @param connectedEntityType The connected entity type, if not specified all types are returned
- * @param count result limit
- */
- private Results getConnectingEntities( EntityRef targetEntity, String connectionType,
- String connectedEntityType, Level level, int count) throws Exception {
-
- Query query = new Query();
- query.setResultsLevel( level );
- query.setLimit( count );
-
- final ConnectionRefImpl connectionRef = new ConnectionRefImpl(
- new SimpleEntityRef( connectedEntityType, null ), connectionType, targetEntity );
- final ConnectionResultsLoaderFactory factory =
- new ConnectionResultsLoaderFactory( connectionRef );
-
- QueryProcessorImpl qp = new QueryProcessorImpl( query, null, em, factory );
- SearchConnectionVisitor visitor = new SearchConnectionVisitor( qp, connectionRef, false );
-
- return qp.getResults( visitor );
- }
-
-
- public Mutator<ByteBuffer> batchDeleteConnectionIndexEntries(
- IndexUpdate indexUpdate,
- IndexUpdate.IndexEntry entry,
- ConnectionRefImpl connection,
- UUID[] index_keys ) throws Exception {
-
- logger.debug( "batchDeleteConnectionIndexEntries" );
-
- // entity_id,prop_name
- Object property_index_key = key( index_keys[ConnectionRefImpl.ALL], INDEX_CONNECTIONS, entry.getPath(),
- indexBucketLocator.getBucket( applicationId, IndexBucketLocator.IndexType.CONNECTION,
- index_keys[ConnectionRefImpl.ALL], entry.getPath() ) );
-
- // entity_id,entity_type,prop_name
- Object entity_type_prop_index_key =
- key( index_keys[ConnectionRefImpl.BY_ENTITY_TYPE], INDEX_CONNECTIONS, entry.getPath(),
- indexBucketLocator.getBucket( applicationId, IndexBucketLocator.IndexType.CONNECTION,
- index_keys[ConnectionRefImpl.BY_ENTITY_TYPE], entry.getPath() ) );
-
- // entity_id,connection_type,prop_name
- Object connection_type_prop_index_key =
- key( index_keys[ConnectionRefImpl.BY_CONNECTION_TYPE], INDEX_CONNECTIONS, entry.getPath(),
- indexBucketLocator.getBucket( applicationId, IndexBucketLocator.IndexType.CONNECTION,
- index_keys[ConnectionRefImpl.BY_CONNECTION_TYPE], entry.getPath() ) );
-
- // entity_id,connection_type,entity_type,prop_name
- Object connection_type_and_entity_type_prop_index_key =
- key( index_keys[ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE], INDEX_CONNECTIONS, entry.getPath(),
- indexBucketLocator.getBucket( applicationId, IndexBucketLocator.IndexType.CONNECTION,
- index_keys[ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE], entry.getPath() ) );
-
- // composite(property_value,connected_entity_id,connection_type,entity_type,entry_timestamp)
- addDeleteToMutator( indexUpdate.getBatch(), ENTITY_INDEX, property_index_key,
- entry.getIndexComposite( connection.getConnectedEntityId(), connection.getConnectionType(),
- connection.getConnectedEntityType() ), indexUpdate.getTimestamp() );
-
- // composite(property_value,connected_entity_id,connection_type,entry_timestamp)
- addDeleteToMutator( indexUpdate.getBatch(), ENTITY_INDEX, entity_type_prop_index_key,
- entry.getIndexComposite( connection.getConnectedEntityId(), connection.getConnectionType() ),
- indexUpdate.getTimestamp() );
-
- // composite(property_value,connected_entity_id,entity_type,entry_timestamp)
- addDeleteToMutator( indexUpdate.getBatch(), ENTITY_INDEX, connection_type_prop_index_key,
- entry.getIndexComposite( connection.getConnectedEntityId(), connection.getConnectedEntityType() ),
- indexUpdate.getTimestamp() );
-
- // composite(property_value,connected_entity_id,entry_timestamp)
- addDeleteToMutator( indexUpdate.getBatch(), ENTITY_INDEX, connection_type_and_entity_type_prop_index_key,
- entry.getIndexComposite( connection.getConnectedEntityId() ), indexUpdate.getTimestamp() );
-
- return indexUpdate.getBatch();
- }
-
-
- public Mutator<ByteBuffer> batchAddConnectionIndexEntries( IndexUpdate indexUpdate, IndexUpdate.IndexEntry entry,
- ConnectionRefImpl conn, UUID[] index_keys ) {
-
- logger.debug( "batchAddConnectionIndexEntries" );
-
- // entity_id,prop_name
- Object property_index_key = key( index_keys[ConnectionRefImpl.ALL],
- INDEX_CONNECTIONS, entry.getPath(),
- indexBucketLocator.getBucket( applicationId,
- IndexBucketLocator.IndexType.CONNECTION, index_keys[ConnectionRefImpl.ALL],
- entry.getPath() ) );
-
- // entity_id,entity_type,prop_name
- Object entity_type_prop_index_key =
- key( index_keys[ConnectionRefImpl.BY_ENTITY_TYPE], INDEX_CONNECTIONS, entry.getPath(),
- indexBucketLocator.getBucket( applicationId, IndexBucketLocator.IndexType.CONNECTION,
- index_keys[ConnectionRefImpl.BY_ENTITY_TYPE], entry.getPath() ) );
-
- // entity_id,connection_type,prop_name
- Object connection_type_prop_index_key =
- key( index_keys[ConnectionRefImpl.BY_CONNECTION_TYPE], INDEX_CONNECTIONS, entry.getPath(),
- indexBucketLocator.getBucket( applicationId, IndexBucketLocator.IndexType.CONNECTION,
- index_keys[ConnectionRefImpl.BY_CONNECTION_TYPE], entry.getPath() ) );
-
- // entity_id,connection_type,entity_type,prop_name
- Object connection_type_and_entity_type_prop_index_key =
- key( index_keys[ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE],
- INDEX_CONNECTIONS, entry.getPath(),
- indexBucketLocator.getBucket( applicationId, IndexBucketLocator.IndexType.CONNECTION,
- index_keys[ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE], entry.getPath() ) );
-
- // composite(property_value,connected_entity_id,connection_type,entity_type,entry_timestamp)
- addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, property_index_key,
- entry.getIndexComposite( conn.getConnectedEntityId(), conn.getConnectionType(),
- conn.getConnectedEntityType() ), conn.getUuid(), indexUpdate.getTimestamp() );
-
- // composite(property_value,connected_entity_id,connection_type,entry_timestamp)
- addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, entity_type_prop_index_key,
- entry.getIndexComposite( conn.getConnectedEntityId(), conn.getConnectionType() ),
- conn.getUuid(), indexUpdate.getTimestamp() );
-
- // composite(property_value,connected_entity_id,entity_type,entry_timestamp)
- addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX, connection_type_prop_index_key,
- entry.getIndexComposite( conn.getConnectedEntityId(), conn.getConnectedEntityType() ),
- conn.getUuid(), indexUpdate.getTimestamp() );
-
- // composite(property_value,connected_entity_id,entry_timestamp)
- addInsertToMutator( indexUpdate.getBatch(), ENTITY_INDEX,
- connection_type_and_entity_type_prop_index_key,
- entry.getIndexComposite( conn.getConnectedEntityId() ), conn.getUuid(),
- indexUpdate.getTimestamp() );
-
- return indexUpdate.getBatch();
- }
-
-
- /**
- * Simple search visitor that performs all the joining
- *
- * @author tnine
- */
- private class SearchConnectionVisitor extends SearchVisitor {
-
- private final ConnectionRefImpl connection;
-
- /** True if we should search from source->target edges.
- * False if we should search from target<-source edges */
- private final boolean outgoing;
-
-
- /**
- * @param queryProcessor They query processor to use
- * @param connection The connection refernce
- * @param outgoing The direction to search. True if we should search from source->target
- * edges. False if we * should search from target<-source edges
- */
- public SearchConnectionVisitor( QueryProcessorImpl queryProcessor, ConnectionRefImpl connection,
- boolean outgoing ) {
- super( queryProcessor );
- this.connection = connection;
- this.outgoing = outgoing;
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.usergrid.persistence.query.ir.SearchVisitor#secondaryIndexScan(org.apache.usergrid.persistence
- * .query.ir
- * .QueryNode, org.apache.usergrid.persistence.query.ir.QuerySlice)
- */
- @Override
- protected IndexScanner secondaryIndexScan( QueryNode node, QuerySlice slice ) throws Exception {
-
- UUID id = ConnectionRefImpl.getIndexId(
- ConnectionRefImpl.BY_CONNECTION_AND_ENTITY_TYPE,
- headEntity,
- connection.getConnectionType(),
- connection.getConnectedEntityType(),
- new ConnectedEntityRef[0] );
-
- Object key = key( id, INDEX_CONNECTIONS );
-
- // update the cursor and order before we perform the slice
- // operation
- queryProcessor.applyCursorAndSort( slice );
-
- IndexScanner columns = null;
-
- if ( slice.isComplete() ) {
- columns = new NoOpIndexScanner();
- }
- else {
- columns = searchIndex( key, slice, queryProcessor.getPageSizeHint( node ) );
- }
-
- return columns;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.usergrid.persistence.query.ir.NodeVisitor#visit(org.apache.usergrid.
- * persistence.query.ir.WithinNode)
- */
- @Override
- public void visit( WithinNode node ) throws Exception {
-
- QuerySlice slice = node.getSlice();
-
- queryProcessor.applyCursorAndSort( slice );
-
- GeoIterator itr = new GeoIterator(
- new ConnectionGeoSearch( em, indexBucketLocator, cass, connection.getIndexId() ),
- query.getLimit(),
- slice,
- node.getPropertyName(),
- new Point( node.getLattitude(), node.getLongitude() ),
- node.getDistance() );
-
- results.push( itr );
- }
-
-
- @Override
- public void visit( AllNode node ) throws Exception {
- QuerySlice slice = node.getSlice();
-
- queryProcessor.applyCursorAndSort( slice );
-
- int size = queryProcessor.getPageSizeHint( node );
-
- ByteBuffer start = null;
-
- if ( slice.hasCursor() ) {
- start = slice.getCursor();
- }
-
-
- boolean skipFirst = !node.isForceKeepFirst() && slice.hasCursor();
-
- UUID entityIdToUse;
-
- //change our type depending on which direction we're loading
- String dictionaryType;
-
- //the target type
- String targetType;
-
- //this is on the "source" side of the edge
- if ( outgoing ) {
- entityIdToUse = connection.getConnectingEntityId();
- dictionaryType = DICTIONARY_CONNECTED_ENTITIES;
- targetType = connection.getConnectedEntityType();
- }
-
- //we're on the target side of the edge
- else {
- entityIdToUse = connection.getConnectedEntityId();
- dictionaryType = DICTIONARY_CONNECTING_ENTITIES;
- targetType = connection.getConnectingEntityType();
- }
-
- final String connectionType = connection.getConnectionType();
-
- final ConnectionIndexSliceParser connectionParser = new ConnectionIndexSliceParser( targetType );
-
- final Iterator<String> connectionTypes;
-
- //use the provided connection type
- if ( connectionType != null ) {
- connectionTypes = Collections.singleton( connectionType ).iterator();
- }
-
- //we need to iterate all connection types
- else {
- connectionTypes = new ConnectionTypesIterator(
- cass, applicationId, entityIdToUse, outgoing, size );
- }
-
- IndexScanner connectionScanner = new ConnectedIndexScanner(
- cass,
- dictionaryType,
- applicationId,
- entityIdToUse,
- connectionTypes,
- start,
- slice.isReversed(),
- size,
- skipFirst );
-
- this.results.push( new SliceIterator( slice, connectionScanner, connectionParser ) );
- }
-
-
- @Override
- public void visit( NameIdentifierNode nameIdentifierNode ) throws Exception {
-
- //TODO T.N. USERGRID-1919 actually validate this is connected
- EntityRef ref = em.getAlias( connection.getConnectedEntityType(), nameIdentifierNode.getName() );
-
- if ( ref == null ) {
- this.results.push( new EmptyIterator() );
- return;
- }
-
- this.results.push( new StaticIdIterator( ref.getUuid() ) );
- }
- }
-
-
- private IndexScanner searchIndex( Object indexKey, QuerySlice slice, int pageSize ) throws Exception {
-
- DynamicComposite[] range = slice.getRange();
-
- Object keyPrefix = key( indexKey, slice.getPropertyName() );
-
- IndexScanner scanner = new IndexBucketScanner(
- cass,
- indexBucketLocator,
- ENTITY_INDEX,
- applicationId,
- IndexBucketLocator.IndexType.CONNECTION,
- keyPrefix,
- range[0],
- range[1],
- slice.isReversed(),
- pageSize,
- slice.hasCursor(),
- slice.getPropertyName() );
-
- return scanner;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
index a2e9b30..32b6eb2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
@@ -24,20 +24,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.corepersistence.CpEntityManagerFactory;
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.collection.MvccLogEntry;
import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.graph.Edge;
import org.apache.usergrid.persistence.graph.GraphManager;
import org.apache.usergrid.persistence.graph.serialization.EdgesObservable;
import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.IndexBatchBuffer;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
+import org.apache.usergrid.persistence.index.IndexEdge;
import org.apache.usergrid.persistence.model.entity.Id;
import com.google.inject.Inject;
@@ -99,12 +95,12 @@ public class EntityVersionDeletedHandler implements EntityVersionDeleted {
//create an observable of all scopes to deIndex
//remove all indexes pointing to this
- final Observable<IndexScope> targetScopes = edgesObservable.edgesToTarget( gm, entityId ).map(
+ final Observable<IndexEdge> targetScopes = edgesObservable.edgesToTarget( gm, entityId ).map(
edge -> generateScopeFromSource( edge) );
//Remove all double indexes
- final Observable<IndexScope> sourceScopes = edgesObservable.edgesFromSource( gm, entityId ).map(
+ final Observable<IndexEdge> sourceScopes = edgesObservable.edgesFromSource( gm, entityId ).map(
edge -> generateScopeToTarget( edge ) );
@@ -133,11 +129,11 @@ public class EntityVersionDeletedHandler implements EntityVersionDeleted {
private static final class IndexScopeVersion{
- private final IndexScope scope;
+ private final IndexEdge scope;
private final MvccLogEntry version;
- private IndexScopeVersion( final IndexScope scope, final MvccLogEntry version ) {
+ private IndexScopeVersion( final IndexEdge scope, final MvccLogEntry version ) {
this.scope = scope;
this.version = version;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/CollectionResultsLoaderFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/CollectionResultsLoaderFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/CollectionResultsLoaderFactoryImpl.java
index 2f6f96d..2490e7c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/CollectionResultsLoaderFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/CollectionResultsLoaderFactoryImpl.java
@@ -21,9 +21,9 @@ package org.apache.usergrid.corepersistence.results;
import org.apache.usergrid.corepersistence.ManagerCache;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.index.IndexScope;
import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.index.SearchEdge;
/**
@@ -40,7 +40,7 @@ public class CollectionResultsLoaderFactoryImpl implements ResultsLoaderFactory
@Override
- public ResultsLoader getLoader( final ApplicationScope applicationScope, final IndexScope scope, final Query.Level resultsLevel ) {
+ public ResultsLoader getLoader( final ApplicationScope applicationScope, final SearchEdge scope, final Query.Level resultsLevel ) {
ResultsVerifier verifier;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ConnectionResultsLoaderFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ConnectionResultsLoaderFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ConnectionResultsLoaderFactoryImpl.java
index 876cf92..e9633c9 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ConnectionResultsLoaderFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ConnectionResultsLoaderFactoryImpl.java
@@ -22,9 +22,9 @@ package org.apache.usergrid.corepersistence.results;
import org.apache.usergrid.corepersistence.ManagerCache;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.index.IndexScope;
import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.index.SearchEdge;
/**
@@ -46,7 +46,7 @@ public class ConnectionResultsLoaderFactoryImpl implements ResultsLoaderFactory
@Override
- public ResultsLoader getLoader( final ApplicationScope applicationScope, final IndexScope scope, final Query.Level resultsLevel ) {
+ public ResultsLoader getLoader( final ApplicationScope applicationScope, final SearchEdge scope, final Query.Level resultsLevel ) {
ResultsVerifier verifier;
[2/5] incubator-usergrid git commit: Removed legacy 1.0 code Cleaned
up Query object to only be query state/builder Refactor of tests to use query
language
Posted by to...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
index a60a6b5..97f0045 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
@@ -29,10 +29,6 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.AbstractCoreIT;
import org.apache.usergrid.cassandra.SpringResource;
import org.apache.usergrid.persistence.cassandra.CassandraService;
-import org.apache.usergrid.persistence.cassandra.IndexUpdate;
-import org.apache.usergrid.persistence.cassandra.IndexUpdate.IndexEntry;
-import org.apache.usergrid.persistence.cassandra.RelationManagerImpl;
-import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.utils.JsonUtils;
import org.apache.usergrid.utils.UUIDUtils;
@@ -437,43 +433,5 @@ public class IndexIT extends AbstractCoreIT {
- //now read the index and see what properties are there
-
- RelationManager rm = em.getRelationManager( entity2Ref );
-
- if ( rm instanceof RelationManagerImpl ) { // only relevant for old-school EntityManagers
-
- RelationManagerImpl impl = (RelationManagerImpl)rm;
-
- CassandraService cass = SpringResource.getInstance().getBean( CassandraService.class );
-
- ByteBufferSerializer buf = ByteBufferSerializer.get();
-
- Keyspace ko = cass.getApplicationKeyspace( applicationId );
- Mutator<ByteBuffer> m = createMutator( ko, buf );
-
- IndexUpdate update = impl.batchStartIndexUpdate( m, entity1Ref,
- "status", "ignore", UUIDUtils.newTimeUUID(), false, false, true, false );
-
- int count = 0;
-
- IndexEntry lastMatch = null;
-
- for ( IndexEntry entry : update.getPrevEntries() ) {
- if ( "status".equals( entry.getPath() ) ) {
- count++;
- lastMatch = entry;
- }
- }
-
- assertEquals( 1, count );
-
- if ( lastMatch != null ) {
- assertEquals( "herring", lastMatch.getValue() );
- }
- else {
- fail( "The last match was null but should have been herring!" );
- }
- }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
index 6bddf76..c5873ea 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
@@ -28,8 +28,8 @@ import java.util.UUID;
import org.junit.Test;
import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import static org.junit.Assert.assertEquals;
@@ -71,11 +71,9 @@ public class PathQueryIT extends AbstractCoreIT {
int pageSize = 10; // shouldn't affect these tests
- Query userQuery = new Query();
+ Query userQuery = Query.fromQL( "select * where index >= 2 AND index <= 13" );
userQuery.setCollection( "users" );
userQuery.setLimit( pageSize );
- userQuery.addFilter( "index >= 2" );
- userQuery.addFilter( "index <= 13" );
int expectedUserQuerySize = 12;
// query the users, ignoring page boundaries
@@ -89,10 +87,9 @@ public class PathQueryIT extends AbstractCoreIT {
assertEquals( count, expectedUserQuerySize + 2 );
// query devices as a sub-query of the users, ignoring page boundaries
- Query deviceQuery = new Query();
+ Query deviceQuery = Query.fromQL( "select * where index >= 2 " );
deviceQuery.setCollection( "devices" );
deviceQuery.setLimit( pageSize );
- deviceQuery.addFilter( "index >= 2" );
int expectedDeviceQuerySize = 3;
PathQuery<EntityRef> usersPQ = new PathQuery<EntityRef>(
@@ -160,23 +157,19 @@ public class PathQueryIT extends AbstractCoreIT {
int pageSize = 3; // ensure we're crossing page boundaries
- Query groupQuery = new Query();
+ Query groupQuery = Query.fromQL( "select * where index <= 7 " );
groupQuery.setCollection( "groups" );
groupQuery.setLimit( pageSize );
- groupQuery.addFilter( "index <= 7" );
int expectedGroupQuerySize = 4;
- Query userQuery = new Query();
+ Query userQuery = Query.fromQL( "select * where index >= 2 AND index <= 6" );
userQuery.setCollection( "users" );
userQuery.setLimit( pageSize );
- userQuery.addFilter( "index >= 2" );
- userQuery.addFilter( "index <= 6" );
int expectedUserQuerySize = 5;
- Query deviceQuery = new Query();
+ Query deviceQuery = Query.fromQL( "select * where index >= 4 " );
deviceQuery.setCollection( "devices" );
deviceQuery.setLimit( pageSize );
- deviceQuery.addFilter( "index >= 4" );
int expectedDeviceQuerySize = 3;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 9336df8..b0fc245 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -40,7 +40,7 @@ import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexFactory;
import org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
index 6f76a79..bfdc3cf 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.usergrid.AbstractCoreIT;
import org.apache.usergrid.persistence.entities.Role;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
deleted file mode 100644
index 1b4bb6f..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java
+++ /dev/null
@@ -1,328 +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;
-
-
-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.index.exceptions.QueryParseException;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.SortDirection;
-import org.apache.usergrid.persistence.index.query.Query.SortPredicate;
-import org.apache.usergrid.persistence.index.query.tree.AndOperand;
-import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
-import org.apache.usergrid.persistence.index.query.tree.Equal;
-import org.apache.usergrid.persistence.index.query.tree.FloatLiteral;
-import org.apache.usergrid.persistence.index.query.tree.GreaterThan;
-import org.apache.usergrid.persistence.index.query.tree.GreaterThanEqual;
-import org.apache.usergrid.persistence.index.query.tree.LessThan;
-import org.apache.usergrid.persistence.index.query.tree.LessThanEqual;
-import org.apache.usergrid.persistence.index.query.tree.LongLiteral;
-import org.apache.usergrid.persistence.index.query.tree.NotOperand;
-import org.apache.usergrid.persistence.index.query.tree.StringLiteral;
-import org.apache.usergrid.persistence.index.query.tree.WithinOperand;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
-
-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.getLatitude().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 withinDistanceCorrect(){
- final Query query = Query.fromQL( "location within 2000 of 37.776753, -122.407846" );
-
- WithinOperand withinOperand = ( WithinOperand ) query.getRootOperand();
-
- final float distance = withinOperand.getDistance().getFloatValue();
- final float lat = withinOperand.getLatitude().getFloatValue();
- final float lon = withinOperand.getLongitude().getFloatValue();
-
- assertEquals( 2000f, distance, 0f );
- assertEquals( 37.776753f, lat, 0f );
- assertEquals( -122.407846f, lon, 0f );
- }
-
-
- @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();
- }
-
- assertEquals( "The query cannot be parsed. The token 'from' at column 4 on line 1 cannot be parsed", error );
- }
-
-
- @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/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
deleted file mode 100644
index 6d1ab8a..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java
+++ /dev/null
@@ -1,822 +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.cassandra;
-
-
-import java.math.BigInteger;
-import java.util.Iterator;
-import java.util.UUID;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.TokenRewriteStream;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import org.apache.usergrid.mq.QueryFilterLexer;
-import org.apache.usergrid.mq.QueryFilterParser;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterLexer;
-import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterParser;
-import org.apache.usergrid.persistence.query.ir.AndNode;
-import org.apache.usergrid.persistence.query.ir.NotNode;
-import org.apache.usergrid.persistence.query.ir.OrNode;
-import org.apache.usergrid.persistence.query.ir.QuerySlice;
-import org.apache.usergrid.persistence.query.ir.SliceNode;
-import org.apache.usergrid.persistence.query.ir.WithinNode;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * @author tnine
- */
-
-public class QueryProcessorTest {
-
- @Test
- public void equality() throws Exception {
- String queryString = "select * where a = 5";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( BigInteger.valueOf( 5 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 5 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void lessThan() throws Exception {
- String queryString = "select * where a < 5";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertNull( slice.getStart() );
-
- assertEquals( BigInteger.valueOf( 5 ), slice.getFinish().getValue() );
- assertFalse( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void lessThanEquals() throws Exception {
- String queryString = "select * where a <= 5";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertNull( slice.getStart() );
-
- assertEquals( BigInteger.valueOf( 5 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void greaterThan() throws Exception {
- String queryString = "select * where a > 5";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( BigInteger.valueOf( 5 ), slice.getStart().getValue() );
- assertFalse( slice.getStart().isInclusive() );
-
- assertNull( slice.getFinish() );
- }
-
-
- @Test
- public void greaterThanEquals() throws Exception {
- String queryString = "select * where a >= 5";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( BigInteger.valueOf( 5 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
-
- assertNull( slice.getFinish() );
- }
-
-
- @Test
- public void contains() throws Exception {
- String queryString = "select * where a contains 'foo'";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "a.keywords", slice.getPropertyName() );
-
- assertEquals( "foo", slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
-
- assertEquals( "foo", slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void containsLower() throws Exception {
- String queryString = "select * where a contains 'FOO'";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "a.keywords", slice.getPropertyName() );
-
- assertEquals( "foo", slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
-
- assertEquals( "foo", slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void containsRange() throws Exception, PersistenceException {
-
- String queryString = "select * where a contains 'foo*'";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- if ( !(processor.getEntityManager() instanceof EntityManagerImpl) ) {
- return; // only relevant for old entity manager
- }
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "a.keywords", slice.getPropertyName() );
-
- assertEquals( "foo", slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
-
- assertEquals( "foo\uffff", slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void within() throws Exception {
- String queryString = "select * where a within .5 of 157.00, 0.00";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- WithinNode node = ( WithinNode ) processor.getFirstNode();
-
- assertEquals( "a.coordinates", node.getPropertyName() );
- assertEquals( .5f, node.getDistance(), 0 );
- assertEquals( 157f, node.getLattitude(), 0 );
- assertEquals( 0f, node.getLongitude(), 0 );
- }
-
-
- @Test
- public void andEquality() throws Exception {
- assertAndQuery( "select * where a = 1 and b = 2 and c = 3" );
- assertAndQuery( "select * where a = 1 AND b = 2 and c = 3" );
- assertAndQuery( "select * where a = 1 AnD b = 2 and c = 3" );
- assertAndQuery( "select * where a = 1 ANd b = 2 and c = 3" );
- assertAndQuery( "select * where a = 1 anD b = 2 and c = 3" );
- assertAndQuery( "select * where a = 1 ANd b = 2 and c = 3" );
- assertAndQuery( "select * where a = 1 && b = 2 && c = 3" );
- }
-
-
- private void assertAndQuery( String queryString ) throws Exception {
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
-
- assertEquals( "a", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 1 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
-
- slice = slices.next();
-
- assertEquals( "b", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 2 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 2 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
-
- slice = slices.next();
-
- assertEquals( "c", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 3 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 3 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void orEquality() throws Exception {
- assertOrQuery( "select * where a = 1 or b = 2" );
- assertOrQuery( "select * where a = 1 OR b = 2" );
- assertOrQuery( "select * where a = 1 oR b = 2" );
- assertOrQuery( "select * where a = 1 Or b = 2" );
- assertOrQuery( "select * where a = 1 || b = 2" );
- }
-
-
- private void assertOrQuery( String queryString ) throws Exception {
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- OrNode node = ( OrNode ) processor.getFirstNode();
-
- SliceNode sliceNode = ( SliceNode ) node.getLeft();
-
- Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "a", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 1 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
-
- sliceNode = ( SliceNode ) node.getRight();
-
- slices = sliceNode.getAllSlices().iterator();
-
- slice = slices.next();
-
- assertEquals( "b", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 2 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 2 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- /** Tests that when properties are not siblings, they are properly assigned to a SliceNode */
- @Test
- public void nestedCompression() throws Exception {
- String queryString =
- "select * where (a > 1 and b > 10 and a < 10 and b < 20 ) or ( c >= 20 and d >= 30 and c <= 30 and d "
- + "<= 40)";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- OrNode node = ( OrNode ) processor.getFirstNode();
-
- SliceNode sliceNode = ( SliceNode ) node.getLeft();
-
- Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
-
- assertEquals( "a", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
- assertFalse( slice.getStart().isInclusive() );
-
- assertEquals( BigInteger.valueOf( 10 ), slice.getFinish().getValue() );
- assertFalse( slice.getFinish().isInclusive() );
-
-
- slice = slices.next();
-
-
- assertEquals( "b", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 10 ), slice.getStart().getValue() );
- assertFalse( slice.getStart().isInclusive() );
-
- assertEquals( BigInteger.valueOf( 20 ), slice.getFinish().getValue() );
- assertFalse( slice.getFinish().isInclusive() );
-
-
- sliceNode = ( SliceNode ) node.getRight();
-
- slices = sliceNode.getAllSlices().iterator();
-
- slice = slices.next();
-
-
- assertEquals( "c", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 20 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 30 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
-
- slice = slices.next();
-
- assertEquals( "d", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 30 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 40 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- /** Tests that when there are multiple or with and clauses, the tree is constructed correctly */
- @Test
- public void nestedOrCompression() throws Exception {
- String queryString =
- "select * where ((a > 1 and a < 10) or (b > 10 and b < 20 )) or (( c >= 20 and c <= 30 ) or (d >= 30"
- + " and d <= 40))";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- OrNode rootNode = ( OrNode ) processor.getFirstNode();
-
- OrNode node = ( OrNode ) rootNode.getLeft();
-
- // get the left node of the or
-
- SliceNode sliceNode = ( SliceNode ) node.getLeft();
-
- Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "a", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
- assertFalse( slice.getStart().isInclusive() );
-
- assertEquals( BigInteger.valueOf( 10 ), slice.getFinish().getValue() );
- assertFalse( slice.getFinish().isInclusive() );
-
- // get our right node
- sliceNode = ( SliceNode ) node.getRight();
-
- slices = sliceNode.getAllSlices().iterator();
-
- slice = slices.next();
-
- assertEquals( "b", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 10 ), slice.getStart().getValue() );
- assertFalse( slice.getStart().isInclusive() );
-
- assertEquals( BigInteger.valueOf( 20 ), slice.getFinish().getValue() );
- assertFalse( slice.getFinish().isInclusive() );
-
- node = ( OrNode ) rootNode.getRight();
-
- sliceNode = ( SliceNode ) node.getLeft();
-
- slices = sliceNode.getAllSlices().iterator();
-
- slice = slices.next();
-
- assertEquals( "c", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 20 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 30 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
-
- sliceNode = ( SliceNode ) node.getRight();
-
- slices = sliceNode.getAllSlices().iterator();
-
- slice = slices.next();
-
- assertEquals( "d", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 30 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 40 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- /** Tests that when NOT is not the root operand the tree has a different root */
- @Test
- public void andNot() throws Exception {
- String queryString = "select * where a > 1 and not b = 2";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- AndNode rootNode = ( AndNode ) processor.getFirstNode();
-
- SliceNode sliceNode = ( SliceNode ) rootNode.getLeft();
-
- Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "a", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 1 ), slice.getStart().getValue() );
- assertFalse( slice.getStart().isInclusive() );
-
- assertNull( slice.getFinish() );
-
- NotNode notNode = ( NotNode ) rootNode.getRight();
-
- // now get the child of the not node
- sliceNode = ( SliceNode ) notNode.getSubtractNode();
-
- slices = sliceNode.getAllSlices().iterator();
-
- slice = slices.next();
-
- assertEquals( "b", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 2 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 2 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- /** Tests that when NOT is the root operand, a full scan range is performed. */
- @Test
- public void notRootOperand() throws Exception {
- String queryString = "select * where not b = 2";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- NotNode rootNode = ( NotNode ) processor.getFirstNode();
-
- SliceNode sliceNode = ( SliceNode ) rootNode.getSubtractNode();
-
- Iterator<QuerySlice> slices = sliceNode.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "b", slice.getPropertyName() );
- assertEquals( BigInteger.valueOf( 2 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 2 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void stringWithSpaces() throws Exception {
- String queryString = "select * where a = 'foo with bar'";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "a", slice.getPropertyName() );
-
- assertEquals( "foo with bar", slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
-
- assertEquals( "foo with bar", slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void fieldWithDash() throws Exception {
- String queryString = "select * where a-foo = 5";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "a-foo", slice.getPropertyName() );
-
- assertEquals( BigInteger.valueOf( 5 ), slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( BigInteger.valueOf( 5 ), slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void stringWithDash() throws Exception {
- String queryString = "select * where a = 'foo-bar'";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "a", slice.getPropertyName() );
-
- assertEquals( "foo-bar", slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
-
- assertEquals( "foo-bar", slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- public void uuidParse() throws Exception {
-
- // UUID value = UUID.fromString("4b91a9c2-86a1-11e2-b7fa-68a86d52fa56");
- //
- //
- // String queryString = "select * where uuid = 4b91a9c2-86a1-11e2-b7fa-68a86d52fa56";
-
- UUID value = UUID.fromString( "c6ee8a1c-3ef4-11e2-8861-02e81adcf3d0" );
- String queryString = "select * where uuid = c6ee8a1c-3ef4-11e2-8861-02e81adcf3d0";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- Query query = parser.ql().query;
-
- QueryProcessor processor = new QueryProcessorImpl( query, null, null, null );
-
- SliceNode node = ( SliceNode ) processor.getFirstNode();
-
- Iterator<QuerySlice> slices = node.getAllSlices().iterator();
-
- QuerySlice slice = slices.next();
-
- assertEquals( "uuid", slice.getPropertyName() );
-
- assertEquals( value, slice.getStart().getValue() );
- assertTrue( slice.getStart().isInclusive() );
- assertEquals( value, slice.getFinish().getValue() );
- assertTrue( slice.getFinish().isInclusive() );
- }
-
-
- @Test
- @Ignore("no longer relevant for two-dot-o")
- public void validateHintSizeForOrder() throws Exception {
- String queryString = "order by name desc";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- QueryFilterLexer lexer = new QueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- QueryFilterParser parser = new QueryFilterParser( tokens );
-
- /**
- * Test set limit
- */
-
- final int limit = 105;
-
-// Query query = parser.ql().query;
-// query.setLimit( limit );
-//
-// QueryProcessor processor = new QueryProcessor( query, null, null, null );
-//
-// OrderByNode node = ( OrderByNode ) processor.getFirstNode();
-//
-// assertEquals( limit, processor.getPageSizeHint( node ) );
- }
-
-
- @Test
- @Ignore("no longer relevant for two-dot-o")
- public void validateHintSizeForEquality() throws Exception {
- String queryString = "select * where X = 'Foo'";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- /**
- * Test set limit
- */
-
- final int limit = 105;
-
- Query query = parser.ql().query;
- query.setLimit( limit );
-
-// QueryProcessor processor = new QueryProcessor( query, null, null, null );
-//
-// SliceNode node = ( SliceNode ) processor.getFirstNode();
-//
-// assertEquals( limit, processor.getPageSizeHint( node ) );
- }
-
-
- @Test
- @Ignore("no longer relevant for two-dot-o")
- public void validateHintSizeForComplexQueries() throws Exception {
- // String queryString = "select * where y = 'Foo' AND z = 'Bar'";
-
- String queryString = "select * where y = 'Foo' AND z = 'Bar'";
-
- ANTLRStringStream in = new ANTLRStringStream( queryString );
- CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- CpQueryFilterParser parser = new CpQueryFilterParser( tokens );
-
- /**
- * Test set limit
- */
-
- final int limit = 105;
-
- Query query = parser.ql().query;
- query.setLimit( limit );
-
-// QueryProcessor processor = new QueryProcessor( query, null, null, null );
-//
-// QueryNode slice = processor.getFirstNode();
-//
-// assertEquals( 1000, processor.getPageSizeHint( slice ) );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java
deleted file mode 100644
index 2618e49..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java
+++ /dev/null
@@ -1,177 +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.cassandra;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.Test;
-
-import org.apache.usergrid.persistence.IndexBucketLocator.IndexType;
-import org.apache.usergrid.utils.UUIDUtils;
-
-import com.yammer.metrics.Metrics;
-import com.yammer.metrics.core.Timer;
-import com.yammer.metrics.core.TimerContext;
-
-import static org.junit.Assert.assertEquals;
-
-
-/** @author tnine */
-
-public class SimpleIndexShardLocatorImplTest {
- @Test
- public void oneBucket() {
-
- UUID appId = UUIDUtils.newTimeUUID();
- String entityType = "user";
- String propName = "firstName";
-
- SimpleIndexBucketLocatorImpl locator = new SimpleIndexBucketLocatorImpl( 1 );
-
- List<String> buckets = locator.getBuckets( appId, IndexType.COLLECTION, entityType, propName );
-
- assertEquals( 1, buckets.size() );
-
- UUID testId1 = UUIDUtils.minTimeUUID( 0l );
-
- UUID testId2 = UUIDUtils.minTimeUUID( Long.MAX_VALUE / 2 );
-
- UUID testId3 = UUIDUtils.minTimeUUID( Long.MAX_VALUE );
-
- String bucket1 = locator.getBucket( appId, IndexType.COLLECTION, testId1, entityType, propName );
-
- String bucket2 = locator.getBucket( appId, IndexType.COLLECTION, testId2, entityType, propName );
-
- String bucket3 = locator.getBucket( appId, IndexType.COLLECTION, testId3, entityType, propName );
-
- assertEquals( bucket1, "000000000000000000000000000000000000000" );
- assertEquals( bucket2, "000000000000000000000000000000000000000" );
- assertEquals( bucket3, "000000000000000000000000000000000000000" );
- }
-
-
- @Test
- public void twoBuckets() {
-
- UUID appId = UUIDUtils.newTimeUUID();
- String entityType = "user";
- String propName = "firstName";
-
- SimpleIndexBucketLocatorImpl locator = new SimpleIndexBucketLocatorImpl( 2 );
-
- List<String> buckets = locator.getBuckets( appId, IndexType.COLLECTION, entityType, propName );
-
- assertEquals( 2, buckets.size() );
-
- UUID testId1 = UUIDUtils.minTimeUUID( 0l );
-
- UUID testId2 = UUIDUtils.maxTimeUUID( Long.MAX_VALUE / 2 );
-
- UUID testId3 = UUIDUtils.minTimeUUID( Long.MAX_VALUE );
-
- String bucket1 = locator.getBucket( appId, IndexType.COLLECTION, testId1, entityType, propName );
-
- String bucket2 = locator.getBucket( appId, IndexType.COLLECTION, testId2, entityType, propName );
-
- String bucket3 = locator.getBucket( appId, IndexType.COLLECTION, testId3, entityType, propName );
-
- assertEquals( bucket1, "000000000000000000000000000000000000000" );
- assertEquals( bucket2, "085070591730234615865843651857942052863" );
- assertEquals( bucket3, "000000000000000000000000000000000000000" );
- }
-
-
- @Test
- public void evenDistribution() {
-
- UUID appId = UUIDUtils.newTimeUUID();
- String entityType = "user";
- String propName = "firstName";
-
- int bucketSize = 20;
- float distributionPercentage = .05f;
-
- // test 100 elements
- SimpleIndexBucketLocatorImpl locator = new SimpleIndexBucketLocatorImpl( bucketSize );
-
- List<String> buckets = locator.getBuckets( appId, IndexType.COLLECTION, entityType, propName );
-
- assertEquals( bucketSize, buckets.size() );
-
- int testSize = 2000000;
-
- Map<String, Float> counts = new HashMap<String, Float>();
-
- final Timer hashes =
- Metrics.newTimer( SimpleIndexShardLocatorImplTest.class, "responses", TimeUnit.MILLISECONDS,
- TimeUnit.SECONDS );
-
- // ConsoleReporter.enable(1, TimeUnit.SECONDS);
-
- /**
- * Loop through each new UUID and add it's hash to our map
- */
- for ( int i = 0; i < testSize; i++ ) {
- UUID id = UUIDUtils.newTimeUUID();
-
- final TimerContext context = hashes.time();
-
- String bucket = locator.getBucket( appId, IndexType.COLLECTION, id, entityType, propName );
-
- context.stop();
-
- Float count = counts.get( bucket );
-
- if ( count == null ) {
- count = 0f;
- }
-
- counts.put( bucket, ++count );
- }
-
- /**
- * Check each entry is within +- 5% of every subsequent entry
- */
- List<String> keys = new ArrayList<String>( counts.keySet() );
- int keySize = keys.size();
-
- assertEquals( bucketSize, keySize );
-
- for ( int i = 0; i < keySize; i++ ) {
-
- float sourceCount = counts.get( keys.get( i ) );
-
- for ( int j = i + 1; j < keySize; j++ ) {
- float destCount = counts.get( keys.get( j ) );
-
- // find the maximum allowed value for the assert based on the
- // largest value in the pair
- float maxDelta = Math.max( sourceCount, destCount ) * distributionPercentage;
-
- assertEquals(
- String.format( "Not within %f as percentage for keys '%s' and '%s'", distributionPercentage,
- keys.get( i ), keys.get( j ) ), sourceCount, destCount, maxDelta );
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparatorTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparatorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparatorTest.java
deleted file mode 100644
index d2cf8ad..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparatorTest.java
+++ /dev/null
@@ -1,104 +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.geo;
-
-
-import java.util.UUID;
-
-import org.junit.Test;
-
-import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.utils.UUIDUtils;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-
-/** @author tnine */
-public class EntityLocationRefDistanceComparatorTest {
-
-
- @Test
- public void locationDistanceComparator() {
- EntityLocationRefDistanceComparator comp = new EntityLocationRefDistanceComparator();
-
- UUID firstId = UUIDUtils.newTimeUUID();
- UUID matchId = UUID.fromString( firstId.toString() );
-
-
- Point zero = new Point( 0, 0 );
-
- EntityLocationRef first = new EntityLocationRef( ( String ) null, firstId, 0, 0 );
- first.calcDistance( zero );
-
- EntityLocationRef second = new EntityLocationRef( ( String ) null, matchId, 0, 0 );
- second.calcDistance( zero );
-
- assertEquals( 0, comp.compare( first, second ) );
-
- //now increase the distance on the second one
-
- second = new EntityLocationRef( ( String ) null, matchId, 1, 1 );
- second.calcDistance( zero );
-
- assertTrue( comp.compare( first, second ) < 0 );
-
- //set the first one to be farther
- first = new EntityLocationRef( ( String ) null, firstId, 1, 1 );
- first.calcDistance( zero );
-
- second = new EntityLocationRef( ( String ) null, matchId, 0, 0 );
- second.calcDistance( zero );
-
- assertTrue( comp.compare( first, second ) > 0 );
-
- //now compare by UUID.
-
- UUID secondId = UUIDUtils.newTimeUUID();
-
- first = new EntityLocationRef( ( String ) null, firstId, 0, 0 );
- first.calcDistance( zero );
-
- second = new EntityLocationRef( ( String ) null, secondId, 0, 0 );
- second.calcDistance( zero );
-
- assertTrue( comp.compare( first, second ) < 0 );
-
- first = new EntityLocationRef( ( String ) null, secondId, 0, 0 );
- first.calcDistance( zero );
-
- second = new EntityLocationRef( ( String ) null, firstId, 0, 0 );
- second.calcDistance( zero );
-
- assertTrue( comp.compare( first, second ) > 0 );
-
- //compare nulls
-
- assertTrue( comp.compare( null, first ) > 0 );
- assertTrue( comp.compare( first, null ) < 0 );
-
- assertEquals( 0, comp.compare( null, null ) );
-
-
- double less = 0;
- double more = 1000;
-
- int compare = Double.compare( less, more );
-
- assertTrue( compare < 1 );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
index 8965013..8cc3b73 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
@@ -25,7 +25,7 @@ import java.util.Map;
import org.apache.usergrid.CoreApplication;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
index 5f9874b..e99ae9c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
@@ -26,7 +26,7 @@ import java.util.Map;
import org.apache.usergrid.CoreApplication;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
index 195ccdb..3b12353 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
@@ -33,7 +33,7 @@ import org.apache.usergrid.CoreApplication;
import org.apache.usergrid.CoreITSetup;
import org.apache.usergrid.CoreITSetupImpl;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
index b78bc46..e8ee0b6 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
@@ -34,7 +34,7 @@ import org.apache.usergrid.CoreITSetup;
import org.apache.usergrid.CoreITSetupImpl;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java
index 1032bd0..cb1f020 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java
@@ -24,7 +24,7 @@ import java.util.Map;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
index c2b8b87..02d3a52 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
@@ -37,7 +37,7 @@ import org.apache.usergrid.CoreITSetup;
import org.apache.usergrid.CoreITSetupImpl;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -303,8 +303,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- Query query = new Query();
- query.addSort( "created" );
+ Query query = Query.fromQL("sort by created" );
query.setLimit( queryLimit );
int count = 0;
@@ -374,9 +373,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- Query query = new Query();
- query.addSort( "created" );
- query.addEqualityFilter( "intersect", true );
+ Query query = Query.fromQL( "select * where intersect = true sort by created" );
query.setLimit( queryLimit );
int count = 0;
@@ -446,10 +443,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- Query query = new Query();
- query.addSort( "created" );
- query.addEqualityFilter( "intersect", true );
- query.addEqualityFilter( "intersect2", true );
+ Query query = Query.fromQL( "select * where intersect = true AND intersect2 = true sort by created" );
query.setLimit( queryLimit );
int count = 0;
@@ -506,11 +500,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- Query query = new Query();
- query.addSort( "created" );
- // nothing will ever match this, the search should short circuit
- query.addEqualityFilter( "intersect", true );
- query.addEqualityFilter( "intersect2", true );
+ Query query = Query.fromQL( "select * where intersect = true AND intersect2 = true sort by created" );
query.setLimit( queryLimit );
start = System.currentTimeMillis();
@@ -701,10 +691,8 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- Query query = new Query();
- query.addSort( "created" );
+ Query query = Query.fromQL( "select * where searched = true sort by created" );
query.setLimit( queryLimit );
- query.addEqualityFilter( "searched", true );
int count = 0;
@@ -756,9 +744,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- Query query = new Query();
- query.addSort( "index desc" );
- query.addLessThanEqualFilter( "index", startValue );
+ Query query = Query.fromQL( "select * where index = "+ startValue + " sort by index desc" );
query.setLimit( queryLimit );
int count = 0;
@@ -818,9 +804,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- Query query = new Query();
- query.addSort( "index desc" );
- query.addLessThanFilter( "index", startValue );
+ Query query = Query.fromQL( "select * where index = "+ startValue + " sort by index desc" );
query.setLimit( queryLimit );
int count = 0;
@@ -880,9 +864,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- Query query = new Query();
- query.addSort( "index desc" );
- query.addGreaterThanEqualFilter( "index", startValue );
+ Query query = Query.fromQL( "select * where index = "+ startValue + " sort by index desc" );
query.setLimit( queryLimit );
int count = 0;
@@ -941,9 +923,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- Query query = new Query();
- query.addSort( "index desc" );
- query.addGreaterThanFilter( "index", startValue );
+ Query query = Query.fromQL( "select * where index = "+ startValue + " sort by index desc" );
query.setLimit( queryLimit );
int count = 0;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java
index d0b292d..ff66f8e 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/NotSubPropertyIT.java
@@ -33,7 +33,7 @@ import org.apache.usergrid.CoreApplication;
import org.apache.usergrid.CoreITSetup;
import org.apache.usergrid.CoreITSetupImpl;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/AbstractScanColumnTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/AbstractScanColumnTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/AbstractScanColumnTest.java
deleted file mode 100644
index a936e7f..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/AbstractScanColumnTest.java
+++ /dev/null
@@ -1,101 +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.query.ir.result;
-
-
-import java.nio.ByteBuffer;
-import java.util.UUID;
-
-import org.junit.Test;
-
-import org.apache.usergrid.utils.UUIDUtils;
-
-import static junit.framework.Assert.assertNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
-
-/**
- * Simple test to test null value
- */
-public class AbstractScanColumnTest {
-
- @Test
- public void testValues() {
- final UUID uuid = UUIDUtils.newTimeUUID();
- final ByteBuffer buffer = ByteBuffer.allocate( 4 );
- buffer.putInt( 1 );
- buffer.rewind();
-
- TestScanColumn col = new TestScanColumn( uuid, buffer );
-
- assertSame( uuid, col.getUUID() );
-
- assertEquals( 1, col.getCursorValue().getInt() );
- }
-
-
- @Test
- public void nullUUID() {
- final UUID uuid = null;
- final ByteBuffer buffer = ByteBuffer.allocate( 4 );
- buffer.putInt( 1 );
- buffer.rewind();
-
- TestScanColumn col = new TestScanColumn( uuid, buffer );
-
- assertNull( col.getUUID() );
-
- assertEquals( 1, col.getCursorValue().getInt() );
- }
-
-
- @Test
- public void nullBuffer() {
- final UUID uuid = UUIDUtils.newTimeUUID();
- final ByteBuffer buffer = null;
-
- TestScanColumn col = new TestScanColumn( uuid, buffer );
-
- assertSame( uuid, col.getUUID() );
-
- assertNull( col.getCursorValue() );
- }
-
-
- @Test
- public void nullBoth() {
- final UUID uuid = null;
- final ByteBuffer buffer = null;
-
- TestScanColumn col = new TestScanColumn( uuid, buffer );
-
- assertNull( col.getUUID() );
-
- assertNull( col.getCursorValue() );
- }
-
-
-
-
- private class TestScanColumn extends AbstractScanColumn {
-
- protected TestScanColumn( final UUID uuid, final ByteBuffer buffer ) {
- super( uuid, buffer );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/InOrderIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/InOrderIterator.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/InOrderIterator.java
deleted file mode 100644
index b79b38a..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ir/result/InOrderIterator.java
+++ /dev/null
@@ -1,132 +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.query.ir.result;
-
-
-import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-import org.junit.Ignore;
-
-import org.apache.usergrid.persistence.cassandra.CursorCache;
-
-import com.google.common.collect.Iterables;
-
-
-/**
- * Simple iterator for testing that iterates UUIDs in the order returned
- *
- * @author tnine
- */
-@Ignore("not a test")
-public class InOrderIterator implements ResultIterator {
-
- private LinkedHashSet<ScanColumn> uuids = new LinkedHashSet<ScanColumn>();
- private Iterator<List<ScanColumn>> iterator;
- private int pageSize = 1000;
-
-
- public InOrderIterator( int pageSize ) {
- this.pageSize = pageSize;
- }
-
-
- /** Add a uuid to the list */
- public void add( UUID... ids ) {
- for ( UUID current : ids ) {
- uuids.add( new UUIDIndexSliceParser.UUIDColumn( current, ByteBuffer.allocate( 0 ) ) );
- }
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Iterable#iterator()
- */
- @Override
- public Iterator<Set<ScanColumn>> iterator() {
- if ( iterator == null ) {
- reset();
- }
-
- return this;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Iterator#hasNext()
- */
- @Override
- public boolean hasNext() {
- if ( iterator == null ) {
- reset();
- }
-
- return iterator.hasNext();
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Iterator#next()
- */
- @Override
- public Set<ScanColumn> next() {
- if ( iterator == null ) {
- reset();
- }
-
- return new LinkedHashSet<ScanColumn>( iterator.next() );
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.usergrid.persistence.query.ir.result.ResultIterator#reset()
- */
- @Override
- public void reset() {
- this.iterator = Iterables.partition( uuids, pageSize ).iterator();
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Iterator#remove()
- */
- @Override
- public void remove() {
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.usergrid.persistence.query.ir.result.ResultIterator#finalizeCursor(org.apache.usergrid.persistence.cassandra
- * .CursorCache)
- */
- @Override
- public void finalizeCursor( CursorCache cache, UUID lastLoaded ) {
-
- }
-}
[3/5] incubator-usergrid git commit: Removed legacy 1.0 code Cleaned
up Query object to only be query state/builder Refactor of tests to use query
language
Posted by to...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java
index ae2e350..aa4f743 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ElasticSearchQueryExecutor.java
@@ -26,14 +26,13 @@ import java.util.NoSuchElementException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.IndexScope;
+import org.apache.usergrid.persistence.index.CandidateResults;
+import org.apache.usergrid.persistence.index.SearchEdge;
import org.apache.usergrid.persistence.index.SearchTypes;
-import org.apache.usergrid.persistence.index.query.CandidateResults;
-import org.apache.usergrid.persistence.Query;
public class ElasticSearchQueryExecutor implements QueryExecutor {
@@ -46,7 +45,7 @@ public class ElasticSearchQueryExecutor implements QueryExecutor {
private final ApplicationEntityIndex entityIndex;
- private final IndexScope indexScope;
+ private final SearchEdge indexScope;
private final SearchTypes types;
@@ -59,7 +58,7 @@ public class ElasticSearchQueryExecutor implements QueryExecutor {
public ElasticSearchQueryExecutor( final ResultsLoaderFactory resultsLoaderFactory, final ApplicationEntityIndex entityIndex,
- final ApplicationScope applicationScope, final IndexScope indexScope,
+ final ApplicationScope applicationScope, final SearchEdge indexScope,
final SearchTypes types, final Query query ) {
this.resultsLoaderFactory = resultsLoaderFactory;
this.applicationScope = applicationScope;
@@ -90,42 +89,38 @@ public class ElasticSearchQueryExecutor implements QueryExecutor {
Results results = null;
int queryCount = 0;
- boolean satisfied = false;
+ CandidateResults crs = null;
- while ( !satisfied && queryCount++ < maxQueries ) {
+ while ( queryCount++ < maxQueries ) {
- CandidateResults crs = entityIndex.search( indexScope, types, query );
+ crs = entityIndex.search( indexScope, types, query.getQl(), query.getLimit() );
logger.debug( "Calling build results 1" );
results = buildResults( indexScope, query, crs );
- if ( crs.isEmpty() || !crs.hasCursor() ) { // no results, no cursor, can't get more
- satisfied = true;
- }
-
/**
* In an edge case where we delete stale entities, we could potentially get less results than expected.
* This will only occur once during the repair phase.
* We need to ensure that we short circuit before we overflow the requested limit during a repair.
*/
- else if ( results.size() > 0 ) { // got what we need
- satisfied = true;
+ if ( crs.isEmpty() || !crs.hasCursor() || results.size() > 0 ) { // no results, no cursor, can't get more
+ break;
}
+
+
//we didn't load anything, but there was a cursor, this means a read repair occured. We have to short
//circuit to avoid over returning the result set
- else if ( crs.hasCursor() ) {
- satisfied = false;
- // need to query for more
- // ask for just what we need to satisfy, don't want to exceed limit
- query.setCursor( results.getCursor() );
- query.setLimit( originalLimit - results.size() );
- logger.warn( "Satisfy query limit {}, new limit {} query count {}", new Object[] {
- originalLimit, query.getLimit(), queryCount
- } );
- }
+ // need to query for more
+ // ask for just what we need to satisfy, don't want to exceed limit
+ query.setCursor( results.getCursor() );
+ query.setLimit( originalLimit - results.size() );
+
+ logger.warn( "Satisfy query limit {}, new limit {} query count {}", new Object[] {
+ originalLimit, query.getLimit(), queryCount
+ } );
}
//now set our cursor if we have one for the next iteration
@@ -139,6 +134,12 @@ public class ElasticSearchQueryExecutor implements QueryExecutor {
}
+ //set our select subjects into our query if provided
+ if(crs != null){
+ query.setSelectSubjects( crs.getGetFieldMappings() );
+ }
+
+
//set our current results and the flag
this.currentResults = results;
}
@@ -150,7 +151,7 @@ public class ElasticSearchQueryExecutor implements QueryExecutor {
* @param query Query that was executed
* @param crs Candidates to be considered for results
*/
- private Results buildResults( final IndexScope indexScope, final Query query, final CandidateResults crs ) {
+ private Results buildResults( final SearchEdge indexScope, final Query query, final CandidateResults crs ) {
logger.debug( "buildResults() from {} candidates", crs.size() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityVerifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityVerifier.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityVerifier.java
index 075abc4..a2dd5e0 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityVerifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/EntityVerifier.java
@@ -38,7 +38,7 @@ import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.EntitySet;
import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.index.query.CandidateResult;
+import org.apache.usergrid.persistence.index.CandidateResult;
import org.apache.usergrid.persistence.model.entity.Id;
import com.fasterxml.uuid.UUIDComparator;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
index c12bb2c..a48e1b8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
@@ -38,9 +38,9 @@ import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.query.CandidateResult;
-import org.apache.usergrid.persistence.index.query.CandidateResults;
+import org.apache.usergrid.persistence.index.SearchEdge;
+import org.apache.usergrid.persistence.index.CandidateResult;
+import org.apache.usergrid.persistence.index.CandidateResults;
import org.apache.usergrid.persistence.model.entity.Id;
import com.fasterxml.uuid.UUIDComparator;
@@ -55,7 +55,7 @@ public class FilteringLoader implements ResultsLoader {
private final ManagerCache managerCache;
private final ResultsVerifier resultsVerifier;
private final ApplicationScope applicationScope;
- private final IndexScope indexScope;
+ private final SearchEdge indexScope;
private final EntityIndexBatch indexBatch;
@@ -68,7 +68,7 @@ public class FilteringLoader implements ResultsLoader {
* @param indexScope The index scope used in the search
*/
protected FilteringLoader( final ManagerCache managerCache, final ResultsVerifier resultsVerifier,
- final ApplicationScope applicationScope, final IndexScope indexScope ) {
+ final ApplicationScope applicationScope, final SearchEdge indexScope ) {
this.managerCache = managerCache;
this.resultsVerifier = resultsVerifier;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoader.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoader.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoader.java
index 28df6b6..e8a7bdf 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoader.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoader.java
@@ -21,7 +21,7 @@ package org.apache.usergrid.corepersistence.results;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.CandidateResults;
+import org.apache.usergrid.persistence.index.CandidateResults;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
index 12589e2..3399a35 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
@@ -20,10 +20,9 @@
package org.apache.usergrid.corepersistence.results;
-import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.index.IndexScope;
import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.index.SearchEdge;
/**
@@ -37,6 +36,6 @@ public interface ResultsLoaderFactory {
* @param indexScope The index scope used in the search
* @param
*/
- ResultsLoader getLoader( final ApplicationScope applicationScope, final IndexScope indexScope,
+ ResultsLoader getLoader( final ApplicationScope applicationScope, final SearchEdge indexScope,
final Query.Level resultsLevel );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
index 1b92bcc..46e0983 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
@@ -23,7 +23,7 @@ package org.apache.usergrid.corepersistence.results;
import java.util.Collection;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
-import org.apache.usergrid.persistence.index.query.CandidateResult;
+import org.apache.usergrid.persistence.index.CandidateResult;
import org.apache.usergrid.persistence.model.entity.Id;
@@ -37,7 +37,7 @@ public interface ResultsVerifier {
public void loadResults(Collection<Id> ids, EntityCollectionManager ecm);
/**
- * Return true if the candidate result is a valid result that should be retained. If it should
+ * Return true if the candidate result is a valid result that should be retained. If it should
* not it should also be removed from the list of possible return values in this loader
* @param candidateResult
*/
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
index c541550..574ba55 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.MvccLogEntry;
import org.apache.usergrid.persistence.collection.VersionSet;
-import org.apache.usergrid.persistence.index.query.CandidateResult;
+import org.apache.usergrid.persistence.index.CandidateResult;
import org.apache.usergrid.persistence.model.entity.Id;
import com.fasterxml.uuid.UUIDComparator;
@@ -59,7 +59,7 @@ public abstract class VersionVerifier implements ResultsVerifier {
//version wasn't found ,deindex
if ( version == null ) {
- logger.warn( "Version for Entity {}:{} not found",
+ logger.warn( "Version for Entity {}:{} not found",
entityId.getUuid(), entityId.getUuid() );
return false;
@@ -69,10 +69,10 @@ public abstract class VersionVerifier implements ResultsVerifier {
if ( UUIDComparator.staticCompare( savedVersion, candidateResult.getVersion() ) > 0 ) {
logger.debug( "Stale version of Entity uuid:{} type:{}, stale v:{}, latest v:{}",
- new Object[] {
- entityId.getUuid(),
- entityId.getType(),
- candidateResult.getVersion(),
+ new Object[] {
+ entityId.getUuid(),
+ entityId.getType(),
+ candidateResult.getVersion(),
savedVersion
} );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
index 49929dc..0376780 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
@@ -22,19 +22,23 @@ package org.apache.usergrid.corepersistence.util;
import java.util.UUID;
import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.Schema;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.entities.Application;
import org.apache.usergrid.persistence.graph.Edge;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
+import org.apache.usergrid.persistence.graph.SearchByEdge;
+import org.apache.usergrid.persistence.graph.SearchByEdgeType;
+import org.apache.usergrid.persistence.graph.impl.SimpleEdge;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
+import org.apache.usergrid.persistence.index.IndexEdge;
+import org.apache.usergrid.persistence.index.SearchEdge;
+import org.apache.usergrid.persistence.index.impl.IndexEdgeImpl;
+import org.apache.usergrid.persistence.index.impl.SearchEdgeImpl;
import org.apache.usergrid.persistence.map.MapScope;
import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
-
-import com.clearspring.analytics.util.Preconditions;
+import org.apache.usergrid.utils.UUIDUtils;
/**
@@ -49,12 +53,10 @@ public class CpNamingUtils {
public static final String EDGE_CONN_SUFFIX = "zzzconnzzz";
/** App where we store management info */
- public static final UUID MANAGEMENT_APPLICATION_ID =
- UUID.fromString("b6768a08-b5d5-11e3-a495-11ddb1de66c8");
+ public static final UUID MANAGEMENT_APPLICATION_ID = UUID.fromString( "b6768a08-b5d5-11e3-a495-11ddb1de66c8" );
/** Old and deprecated SYSTEM_APP */
- public static final UUID SYSTEM_APP_ID =
- UUID.fromString("b6768a08-b5d5-11e3-a495-10ddb1de66c3");
+ public static final UUID SYSTEM_APP_ID = UUID.fromString( "b6768a08-b5d5-11e3-a495-10ddb1de66c3" );
/**
* Information about applications is stored in the management app using these types
@@ -71,162 +73,140 @@ public class CpNamingUtils {
public static String TYPES_BY_UUID_MAP = "zzz_typesbyuuid_zzz";
-
-
/**
- * Get the collection name from the entity/id type
- * @param type
- * @return
+ * Create an Id object from the entity ref
*/
- private static String getCollectionScopeNameFromEntityType( String type ) {
- String csn = EDGE_COLL_SUFFIX + Schema.defaultCollectionName( type );
- return csn.toLowerCase();
+ public static Id createId( final EntityRef entityRef ) {
+ return new SimpleId( entityRef.getUuid(), entityRef.getType() );
}
- private static String getCollectionScopeNameFromCollectionName( String name ) {
- String csn = EDGE_COLL_SUFFIX + name;
- return csn.toLowerCase();
+ /**
+ * Generate a standard edge name for our graph using the connection name. To be used only for searching. DO NOT use
+ * for creation. Use the createConnectionEdge instead.
+ *
+ * @param connectionType The type of connection made
+ */
+ public static String getEdgeTypeFromConnectionType( String connectionType ) {
+ return ( EDGE_CONN_SUFFIX + "|" + connectionType ).toLowerCase();
}
- private static String getConnectionScopeName( String connectionType ) {
- String csn = EDGE_CONN_SUFFIX + connectionType ;
- return csn.toLowerCase();
+ /**
+ * Generate a standard edges from for a collection
+ *
+ * To be used only for searching DO NOT use for creation. Use the createCollectionEdge instead.
+ */
+ public static String getEdgeTypeFromCollectionName( String collectionName ) {
+ return ( EDGE_COLL_SUFFIX + "|" + collectionName ).toLowerCase();
}
/**
* Get the index scope for the edge from the source
- * @param edge
- * @return
*/
- public static IndexScope generateScopeFromSource(final Edge edge ){
-
-
- final Id nodeId = edge.getSourceNode();
- final String scopeName = getNameFromEdgeType( edge.getType() );
-
-
- return new IndexScopeImpl( nodeId, scopeName );
-
+ public static IndexEdge generateScopeFromSource( final Edge edge ) {
+ return new IndexEdgeImpl( edge.getSourceNode(), edge.getType(), SearchEdge.NodeType.SOURCE,
+ edge.getTimestamp() );
}
-
-
-
/**
* Get the index scope for the edge from the source
- * @param edge
- * @return
*/
- public static IndexScope generateScopeToTarget(final Edge edge ){
-
-
-
- final Id nodeId = edge.getTargetNode();
- final String scopeName = getNameFromEdgeType( edge.getType() );
-
+ public static IndexEdge generateScopeToTarget( final Edge edge ) {
+ return new IndexEdgeImpl( edge.getTargetNode(), edge.getType(), SearchEdge.NodeType.TARGET,
+ edge.getTimestamp() );
+ }
- return new IndexScopeImpl( nodeId, scopeName );
+ /**
+ * Create the search edge from the source
+ */
+ public static SearchEdge createSearchEdgeFromSource( final Edge edge ) {
+ return new SearchEdgeImpl( edge.getSourceNode(), edge.getType(), SearchEdge.NodeType.SOURCE );
}
/**
- * Generate either the collection name or connection name from the edgeName
- * @param edgeName
+ *
+ * @param sourceId
+ * @param collectionName
+ * @param entityId
* @return
*/
- public static String getNameFromEdgeType(final String edgeName){
+ public static Edge createCollectionEdge( final Id sourceId, final String collectionName, final Id entityId ) {
+ final String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collectionName );
+ final UUID entityIdUUID = entityId.getUuid();
- if(isCollectionEdgeType( edgeName )){
- return getCollectionScopeNameFromCollectionName(getCollectionName(edgeName) );
- }
+ //if they don't use a time based uuid (such as in devices) we need to create a timestamp from "now" since
+ // this is when the entity
+ //will be added to the collection
+ final UUID timeStampUuid = UUIDUtils.isTimeBased( entityIdUUID ) ? entityIdUUID : UUIDUtils.newTimeUUID();
- return getConnectionScopeName(getConnectionType( edgeName ) );
+ long uuidTimestamp = UUIDUtils.getUUIDLong( timeStampUuid );
+ // create graph edge connection from head entity to member entity
+ return new SimpleEdge( sourceId, edgeType, entityId, uuidTimestamp );
}
/**
- * Get the index scope from the colleciton name
- * @param nodeId The source or target node id
- * @param collectionName The name of the collection. Ex "users"
- * @return
+ * Create a connection searchEdge
*/
- public static IndexScope generateScopeFromCollection( final Id nodeId, final String collectionName ){
- return new IndexScopeImpl( nodeId, getCollectionScopeNameFromCollectionName( collectionName ) );
+ public static SearchEdge createCollectionSearchEdge( final Id sourceId, final String connectionType ) {
+ return new SearchEdgeImpl( sourceId, getEdgeTypeFromCollectionName( connectionType ),
+ SearchEdge.NodeType.SOURCE );
}
/**
- * Get the scope from the connection
- * @param nodeId
- * @param connectionName
- * @return
+ * Create a new connection edge from the source node with the given connection type and target id
*/
- public static IndexScope generateScopeFromConnection( final Id nodeId, final String connectionName ){
- return new IndexScopeImpl( nodeId, getConnectionScopeName( connectionName ) );
+ public static Edge createConnectionEdge( final Id sourceEntityId, final String connectionType,
+ final Id targetEntityId ) {
+ final String edgeType = getEdgeTypeFromConnectionType( connectionType );
+
+ // create graph edge connection from head entity to member entity
+ return new SimpleEdge( sourceEntityId, edgeType, targetEntityId, System.currentTimeMillis() );
}
/**
- * Create an Id object from the entity ref
- * @param entityRef
- * @return
+ * Create a connection searchEdge
+ *
+ * @param sourceId The source id in the connection
+ * @param connectionType The type of the connection to create a search for
*/
- public static Id createId(final EntityRef entityRef){
- return new SimpleId( entityRef.getUuid(), entityRef.getType() );
- }
-
- private static boolean isCollectionEdgeType( String type ) {
- return type.startsWith( EDGE_COLL_SUFFIX );
- }
-
-
- private static boolean isConnectionEdgeType( String type ) {
- return type.startsWith( EDGE_CONN_SUFFIX );
- }
-
-
-
- private static String getConnectionType( String edgeType ) {
- String[] parts = edgeType.split( "\\|" );
- return parts[1];
- }
-
-
- private static String getCollectionName( String edgeType ) {
- String[] parts = edgeType.split( "\\|" );
- return parts[1];
+ public static SearchEdge createConnectionSearchEdge( final Id sourceId, final String connectionType ) {
+ return new SearchEdgeImpl( sourceId, getEdgeTypeFromConnectionType( connectionType ),
+ SearchEdge.NodeType.SOURCE );
}
/**
- * Generate a standard edge name for our graph using the connection name
- * @param connectionType The type of connection made
- * @return
+ * search for all versions of a connection between 2 entities in teh graph
+ *
+ * @param sourceId The source id of the edge
+ * @param connectionType The connection type used in the edge
+ * @param targetId The target id
+ *
+ * @return A search by edge command to search the graph
*/
- public static String getEdgeTypeFromConnectionType( String connectionType ) {
- return (EDGE_CONN_SUFFIX + "|" + connectionType).toLowerCase();
- }
+ public static SearchByEdge createConnectionSearchByEdge( final Id sourceId, final String connectionType,
+ final Id targetId ) {
+ final String edgeType = getEdgeTypeFromConnectionType( connectionType );
- /**
- * Generate a standard edges from for a collection
- * @param collectionName
- * @return
- */
- public static String getEdgeTypeFromCollectionName( String collectionName ) {
- return (EDGE_COLL_SUFFIX + "|" + collectionName).toLowerCase();
+ return new SimpleSearchByEdge( sourceId, edgeType, targetId, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING,
+ null );
}
/**
* Get the application scope from the given uuid
+ *
* @param applicationId The applicationId
*/
public static ApplicationScope getApplicationScope( UUID applicationId ) {
@@ -240,8 +220,8 @@ public class CpNamingUtils {
/**
* Generate an applicationId from the given UUID
- * @param applicationId the applicationId
*
+ * @param applicationId the applicationId
*/
public static Id generateApplicationId( UUID applicationId ) {
return new SimpleId( applicationId, Application.ENTITY_TYPE );
@@ -250,11 +230,51 @@ public class CpNamingUtils {
/**
* Get the map scope for the applicationId to store entity uuid to type mapping
- *
- * @param applicationId
- * @return
*/
- public static MapScope getEntityTypeMapScope( final Id applicationId ){
- return new MapScopeImpl(applicationId, CpNamingUtils.TYPES_BY_UUID_MAP );
+ public static MapScope getEntityTypeMapScope( final Id applicationId ) {
+ return new MapScopeImpl( applicationId, CpNamingUtils.TYPES_BY_UUID_MAP );
+ }
+
+
+ /**
+ * Generate either the collection name or connection name from the edgeName
+ */
+ public static String getNameFromEdgeType( final String edgeName ) {
+
+
+ if ( isCollectionEdgeType( edgeName ) ) {
+ return getCollectionScopeNameFromCollectionName( getCollectionName( edgeName ) );
+ }
+
+ return getConnectionScopeName( getConnectionType( edgeName ) );
+ }
+
+
+ private static boolean isCollectionEdgeType( String type ) {
+ return type.startsWith( EDGE_COLL_SUFFIX );
+ }
+
+
+ private static String getConnectionType( String edgeType ) {
+ String[] parts = edgeType.split( "\\|" );
+ return parts[1];
+ }
+
+
+ private static String getCollectionName( String edgeType ) {
+ String[] parts = edgeType.split( "\\|" );
+ return parts[1];
+ }
+
+
+ private static String getCollectionScopeNameFromCollectionName( String name ) {
+ String csn = EDGE_COLL_SUFFIX + name;
+ return csn.toLowerCase();
+ }
+
+
+ private static String getConnectionScopeName( String connectionType ) {
+ String csn = EDGE_CONN_SUFFIX + connectionType;
+ return csn.toLowerCase();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java b/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
index 66152d4..163593e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
@@ -19,62 +19,44 @@
package org.apache.usergrid.persistence;
-import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
import java.util.UUID;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
-import org.apache.usergrid.persistence.index.exceptions.IndexException;
+
+import org.apache.usergrid.persistence.index.SelectFieldMapping;
import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
-import org.apache.usergrid.persistence.index.impl.EsQueryVistor;
-import org.apache.usergrid.persistence.index.impl.IndexingUtils;
import org.apache.usergrid.persistence.index.query.CounterResolution;
import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.tree.AndOperand;
-import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
-import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterLexer;
-import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterParser;
-import org.apache.usergrid.persistence.index.query.tree.Equal;
-import org.apache.usergrid.persistence.index.query.tree.EqualityOperand;
-import org.apache.usergrid.persistence.index.query.tree.GreaterThan;
-import org.apache.usergrid.persistence.index.query.tree.GreaterThanEqual;
-import org.apache.usergrid.persistence.index.query.tree.LessThan;
-import org.apache.usergrid.persistence.index.query.tree.LessThanEqual;
import org.apache.usergrid.persistence.index.query.tree.Operand;
-import org.apache.usergrid.persistence.index.query.tree.QueryVisitor;
import org.apache.usergrid.persistence.index.utils.ClassUtils;
import org.apache.usergrid.persistence.index.utils.ConversionUtils;
import org.apache.usergrid.persistence.index.utils.ListUtils;
import org.apache.usergrid.persistence.index.utils.MapUtils;
-import org.elasticsearch.index.query.FilterBuilder;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class Query {
private static final Logger logger = LoggerFactory.getLogger( Query.class );
+
+
+
public enum Level {
IDS, REFS, CORE_PROPERTIES, ALL_PROPERTIES, LINKED_PROPERTIES
}
@@ -105,6 +87,7 @@ public class Query {
private List<CounterFilterPredicate> counterFilters;
private String collection;
private String ql;
+ private Collection<SelectFieldMapping> selectFields;
private static ObjectMapper mapper = new ObjectMapper();
@@ -339,6 +322,31 @@ public class Query {
}
+ /**
+ * Return true if the query generated select subjects
+ * @return
+ */
+ public boolean hasSelectSubjects() {
+ return this.selectFields != null || this.selectFields.size() > 0;
+ }
+
+
+ /**
+ * Set the select subjects from our query results
+ */
+ public void setSelectSubjects( final Collection<SelectFieldMapping> selectFields ) {
+ this.selectFields = selectFields;
+ }
+
+
+ /**
+ * Get the select assignments from our resetus if they were set
+ */
+ public Collection<SelectFieldMapping> getSelectAssignments() {
+ return this.selectFields;
+ }
+
+
public boolean containsNameOrEmailIdentifiersOnly() {
if ( hasQueryPredicates() ) {
return false;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java b/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java
index 4f8ad18..b2397c8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/QueryUtils.java
@@ -18,16 +18,17 @@ package org.apache.usergrid.persistence;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import org.apache.usergrid.persistence.Query;
-import static org.apache.usergrid.utils.ClassUtils.cast;
-import org.apache.usergrid.utils.JsonUtils;
+import org.apache.usergrid.persistence.index.SelectFieldMapping;
+import org.apache.usergrid.utils.JsonUtils;
import org.apache.usergrid.utils.ListUtils;
+import static org.apache.usergrid.utils.ClassUtils.cast;
+
/**
* Utilities to deal with query extraction and generation
@@ -54,6 +55,13 @@ public class QueryUtils {
return null;
}
+
+ /**
+ * When a query has select fields, parse the results into a result set by the field mappings
+ * @param q
+ * @param rs
+ * @return
+ */
public static List<Object> getSelectionResults( Query q, Results rs ) {
List<Entity> entities = rs.getEntities();
@@ -68,33 +76,14 @@ public class QueryUtils {
List<Object> results = new ArrayList<Object>();
for ( Entity entity : entities ) {
- if ( q.isMergeSelectResults() ) {
- boolean include = false;
- Map<String, Object> result = new LinkedHashMap<String, Object>();
- Map<String, String> selects = q.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 = q.getSelectSubjects();
- for ( String select : selects ) {
- Object obj = JsonUtils.select( entity, select );
- if ( obj != null ) {
- include = true;
- }
- result.add( obj );
- }
- if ( include ) {
+
+
+ Collection<SelectFieldMapping> selects = q.getSelectAssignments();
+ for ( SelectFieldMapping select : selects ) {
+ Object obj = JsonUtils.select( entity, select.getSourceFieldName(), false );
+ if ( obj != null ) {
+ Map<String, Object> result = new LinkedHashMap<String, Object>();
+ result.put( select.getTargetFieldName(), obj );
results.add( result );
}
}
@@ -106,14 +95,4 @@ public class QueryUtils {
return results;
}
-
-
- public static Object getSelectionResult( Query q, Results rs ) {
- List<Object> r = QueryUtils.getSelectionResults( q, rs );
- if ( ( r != null ) && ( r.size() > 0 ) ) {
- return r.get( 0 );
- }
- return null;
- }
-
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
index 52a4806..218ea3a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
@@ -116,6 +116,5 @@ public interface RelationManager {
public Set<String> getConnectionIndexes( String connectionType ) throws Exception;
- public void batchUpdateSetIndexes( Mutator<ByteBuffer> batch, String setName, Object elementValue,
- boolean removeFromSet, UUID timestampUuid ) throws Exception;
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/Application.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/Application.java b/stack/core/src/test/java/org/apache/usergrid/Application.java
index faa9b4f..56028bb 100644
--- a/stack/core/src/test/java/org/apache/usergrid/Application.java
+++ b/stack/core/src/test/java/org/apache/usergrid/Application.java
@@ -26,7 +26,7 @@ import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index c59ff72..d3861a6 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -36,7 +36,7 @@ import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.SimpleEntityRef;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import static junit.framework.Assert.assertNotNull;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
index abc5a13..a8c88ff 100644
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime8IT.java
@@ -24,7 +24,7 @@ import org.junit.Test;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.entities.JobData;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.utils.UUIDUtils;
import static org.junit.Assert.assertEquals;
@@ -66,8 +66,7 @@ public class SchedulerRuntime8IT extends AbstractSchedulerRuntimeIT {
// now query and make sure it equals the saved value
- Query query = new Query();
- query.addEqualityFilter( "notificationId", notificationId );
+ Query query = Query.fromQL( "notificationId = " + notificationId );
Results r = scheduler.queryJobData( query );
@@ -77,8 +76,7 @@ public class SchedulerRuntime8IT extends AbstractSchedulerRuntimeIT {
assertEquals( saved.getUuid(), r.getEntity().getUuid() );
// query by uuid
- query = new Query();
- query.addEqualityFilter( "stringprop", "test" );
+ query = Query.fromQL( "stringprop = 'test'" );
r = scheduler.queryJobData( query );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index f743f0b..ce12419 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -46,12 +46,11 @@ import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
+import org.apache.usergrid.persistence.index.CandidateResults;
import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexScope;
+import org.apache.usergrid.persistence.index.SearchEdge;
import org.apache.usergrid.persistence.index.SearchTypes;
-import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
-import org.apache.usergrid.persistence.index.query.CandidateResults;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
@@ -61,7 +60,6 @@ import com.google.inject.Injector;
import net.jcip.annotations.NotThreadSafe;
import static org.apache.usergrid.corepersistence.CoreModule.EVENTS_DISABLED;
-import static org.apache.usergrid.corepersistence.util.CpNamingUtils.generateScopeFromCollection;
import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
import static org.junit.Assert.assertEquals;
@@ -494,13 +492,10 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
ApplicationEntityIndex ei = eif.createApplicationEntityIndex(as);
final Id rootId = createId(em.getApplicationId(), TYPE_APPLICATION);
- IndexScope is = generateScopeFromCollection(rootId, collName );
- Query rcq = Query.fromQL( query );
+ SearchEdge is = CpNamingUtils.createCollectionSearchEdge( rootId, collName );
- // TODO: why does this have no effect; max we ever get is 1000 entities
- rcq.setLimit( 10000 ); // no paging
- return ei.search( is, SearchTypes.fromTypes( type ), rcq );
+ return ei.search( is, SearchTypes.fromTypes( type ), query, 10000 );
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
index 129a701..3f05d05 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
@@ -36,8 +36,8 @@ import org.apache.usergrid.CoreApplication;
import org.apache.usergrid.persistence.entities.User;
import org.apache.usergrid.persistence.exceptions.DuplicateUniquePropertyExistsException;
import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.utils.JsonUtils;
import org.apache.usergrid.utils.UUIDUtils;
@@ -146,13 +146,12 @@ public class CollectionIT extends AbstractCoreIT {
assertEquals( 3, r.size() ); // success
// query verb
- query = new Query().addEqualityFilter( "verb", "tweet2" );
+ query = Query.fromQL( "verb = 'tweet2'" );
r = app.searchCollection( user, "activities", query );
assertEquals( 2, r.size() );
// query verb, sort created
- query = new Query().addEqualityFilter( "verb", "tweet2" );
- query.addSort( "created" );
+ query = Query.fromQL( "verb = 'tweet2' order by created" );
r = app.searchCollection( user, "activities", query );
assertEquals( 2, r.size() );
List<Entity> entities = r.getEntities();
@@ -160,8 +159,7 @@ public class CollectionIT extends AbstractCoreIT {
assertEquals( entities.get( 1 ).getUuid(), activity3.getUuid() );
// query verb, sort ordinal
- query = new Query().addEqualityFilter( "verb", "tweet2" );
- query.addSort( "ordinal" );
+ query = Query.fromQL( "verb = 'tweet2' order by ordinal" );
r = app.searchCollection( user, "activities", query );
assertEquals( 2, r.size() );
entities = r.getEntities();
@@ -172,8 +170,7 @@ public class CollectionIT extends AbstractCoreIT {
// it works in the exact same test in the QueryIndex module/
// // empty query, sort content
- query = new Query();
- query.addSort( "content" );
+ query = Query.fromQL( "order by content" );
r = app.searchCollection( user, "activities", query );
assertEquals( 3, r.size() );
entities = r.getEntities();
@@ -183,14 +180,12 @@ public class CollectionIT extends AbstractCoreIT {
assertEquals( entities.get( 2 ).getUuid(), activity3.getUuid() );
// empty query, sort verb
- query = new Query();
- query.addSort( "verb" );
+ query = Query.fromQL( "order by verb" );
r = app.searchCollection( user, "activities", query );
assertEquals( 3, r.size() );
// empty query, sort ordinal
- query = new Query();
- query.addSort( "ordinal" );
+ query = Query.fromQL( "order by ordinal" );
r = app.searchCollection( user, "activities", query );
assertEquals( 3, r.size() );
entities = r.getEntities();
@@ -199,13 +194,12 @@ public class CollectionIT extends AbstractCoreIT {
assertEquals( entities.get( 2 ).getUuid(), activity.getUuid() );
// query ordinal
- query = new Query().addEqualityFilter( "ordinal", 2 );
+ query = Query.fromQL( "ordinal = 2" );
r = app.searchCollection( user, "activities", query );
assertEquals( 1, r.size() );
// query ordinal and sort ordinal
- query = new Query().addEqualityFilter( "ordinal", 2 );
- query.addSort( "ordinal" );
+ query = Query.fromQL( "ordinal = 2 order by ordinal");
r = app.searchCollection( user, "activities", query );
assertEquals( 1, r.size() );
}
@@ -231,8 +225,7 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
// EntityRef
- Query query = new Query();
- query.addEqualityFilter( "firstname", firstName );
+ Query query = Query.fromQL( "firstname = '" + firstName + "'" );
Results r = em.searchCollection( em.getApplicationRef(), "users", query );
@@ -252,15 +245,14 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
// search with the old username, should be no results
- query.addEqualityFilter( "firstname", firstName );
+ query = Query.fromQL( "firstname = '" + firstName + "'" );
r = em.searchCollection( em.getApplicationRef(), "users", query );
assertEquals( 0, r.size() );
// search with the new username, should be results.
- query = new Query();
- query.addEqualityFilter( "firstname", newFirstName );
+ query = Query.fromQL( "firstname = '" + newFirstName + "'" );
r = em.searchCollection( em.getApplicationRef(), "users", query );
@@ -292,8 +284,7 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
// EntityRef
- Query query = new Query();
- query.addEqualityFilter( "middlename", middleName );
+ final Query query = Query.fromQL( "middlename = '" + middleName + "'" );
Results r = em.searchCollection( em.getApplicationRef(), "users", query );
@@ -325,8 +316,7 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
// EntityRef
- Query query = new Query();
- query.addEqualityFilter( "lastname", lastName );
+ final Query query = Query.fromQL( "lastname = '" + lastName + "'" );
Results r = em.searchCollection( em.getApplicationRef(), "users", query );
@@ -373,9 +363,11 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
+ final Query query = Query.fromQL( "nickname = 'ed'" );
+
Results r = em.searchCollection( group, "users",
- new Query().addEqualityFilter( "nickname", "ed" )
- .withResultsLevel(Level.LINKED_PROPERTIES ) );
+ query
+ .withResultsLevel( Level.LINKED_PROPERTIES ) );
LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
assertEquals( 1, r.size() );
@@ -404,8 +396,7 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
// EntityRef
- Query query = new Query();
- query.addEqualityFilter( "name", groupName );
+ final Query query = Query.fromQL( "name = '" + groupName + "'" );
Results r = em.searchCollection( em.getApplicationRef(), "groups", query );
@@ -437,8 +428,8 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
// EntityRef
- Query query = new Query();
- query.addEqualityFilter( "title", titleName );
+
+ final Query query = Query.fromQL( "title = '" + titleName + "'" );
Results r = em.searchCollection( em.getApplicationRef(), "groups", query );
@@ -494,7 +485,9 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
- Results r = em.searchCollection( user, "activities", Query.searchForProperty( "verb", "post" ) );
+ final Query query = Query.fromQL( "verb = 'post'" );
+
+ Results r = em.searchCollection( user, "activities", query);
LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
assertEquals( 2, r.size() );
}
@@ -1019,10 +1012,7 @@ public class CollectionIT extends AbstractCoreIT {
int pageSize = 10;
app.refreshIndex();
-
- Query query = new Query();
- query.setLimit( pageSize );
- query.addFilter( "index < " + size * 2 );
+ final Query query = Query.fromQL( "index < " + size * 2 );
Results r = null;
@@ -1073,9 +1063,8 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
- Query query = Query.fromQL("select * where index >= " + size / 2);
+ Query query = Query.fromQL("select * where index >= " + size / 2 + " + sort by index asc");
query.setLimit( pageSize );
- query.addSort(new Query.SortPredicate("index", Query.SortDirection.ASCENDING));
Results r = null;
@@ -1125,9 +1114,8 @@ public class CollectionIT extends AbstractCoreIT {
int pageSize = 10;
- Query query = Query.fromQL("select * where index >= 10 and index <= 29");
+ Query query = Query.fromQL("select * where index >= 10 and index <= 29 sort by index asc");
query.setLimit( pageSize );
- query.addSort(new Query.SortPredicate("index", Query.SortDirection.ASCENDING));
Results r = null;
@@ -1177,9 +1165,8 @@ public class CollectionIT extends AbstractCoreIT {
int pageSize = 10;
- Query query = Query.fromQL("select * where index >= 10 and index <= 29");
+ Query query = Query.fromQL("select * where index >= 10 and index <= 29 sort by index asc");
query.setLimit( pageSize );
- query.addSort(new Query.SortPredicate("index", Query.SortDirection.ASCENDING));
Results r = em.searchCollection( em.getApplicationRef(), "pages", query );
@@ -1227,18 +1214,16 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
- Query query = new Query();
- query.addEqualityFilter( "rootprop1", "simpleprop" );
+ Query query = Query.fromQL( "rootprop1 = 'simpleprop'" );
Entity entity;
Results results;
- results = em.searchCollection(em.getApplicationRef(), "tests", query);
- entity = results.getEntitiesMap().get(saved.getUuid());
+ results = em.searchCollection( em.getApplicationRef(), "tests", query );
+ entity = results.getEntitiesMap().get( saved.getUuid() );
assertNotNull( entity );
// query on the nested int value
- query = new Query();
- query.addEqualityFilter( "subentity.intprop", 10 );
+ query = Query.fromQL( "subentity.intprop = 10" );
results = em.searchCollection( em.getApplicationRef(), "tests", query );
@@ -1247,9 +1232,7 @@ public class CollectionIT extends AbstractCoreIT {
assertNotNull( entity );
// query on the nexted tokenized value
- query = new Query();
- query.addContainsFilter( "subentity.substring", "tokenized" );
- query.addContainsFilter( "subentity.substring", "indexed" );
+ query = Query.fromQL( "subentity.substring contains 'tokenized' and subentity.substring contains 'indexed'" );
results = em.searchCollection( em.getApplicationRef(), "tests", query );
@@ -1278,8 +1261,7 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
- Query query = new Query();
- query.addEqualityFilter( "intprop", 10 );
+ Query query = Query.fromQL( "intprop = 10" );
Results results = em.searchCollection( em.getApplicationRef(), "tests", query );
@@ -1288,8 +1270,7 @@ public class CollectionIT extends AbstractCoreIT {
assertNotNull( entity );
// query on the nested int value
- query = new Query();
- query.addEqualityFilter( "array", "val1" );
+ query = Query.fromQL( "array = 'val1'" );
results = em.searchCollection( em.getApplicationRef(), "tests", query );
@@ -1298,8 +1279,7 @@ public class CollectionIT extends AbstractCoreIT {
assertNotNull( entity );
// query on the nexted tokenized value
- query = new Query();
- query.addEqualityFilter( "array", "val2" );
+ query = Query.fromQL( "array = 'val2'" );
results = em.searchCollection( em.getApplicationRef(), "tests", query );
@@ -1307,8 +1287,7 @@ public class CollectionIT extends AbstractCoreIT {
assertNotNull( entity );
- query = new Query();
- query.addEqualityFilter( "array", "val3" );
+ query = Query.fromQL( "array = 'val3'" );
results = em.searchCollection( em.getApplicationRef(), "tests", query );
@@ -1316,8 +1295,7 @@ public class CollectionIT extends AbstractCoreIT {
assertNull( entity );
- query = new Query();
- query.addContainsFilter( "array", "spaces" );
+ query = Query.fromQL( "array contains 'spaces'" );
results = em.searchCollection( em.getApplicationRef(), "tests", query );
entity = results.getEntitiesMap().get( saved.getUuid() );
@@ -1342,8 +1320,7 @@ public class CollectionIT extends AbstractCoreIT {
app.refreshIndex();
- Query query = new Query();
- query.addEqualityFilter( "myString", "My simple string" );
+ Query query = Query.fromQL("myString = 'My simple string'" );
Results results = em.searchCollection( em.getApplicationRef(), "tests", query );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
index a5e1493..5bc448f 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
@@ -37,7 +37,7 @@ import org.apache.usergrid.persistence.entities.Event;
import org.apache.usergrid.persistence.entities.Group;
import org.apache.usergrid.persistence.entities.User;
import org.apache.usergrid.persistence.index.query.CounterResolution;
-import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.Query;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import org.apache.usergrid.utils.ImmediateCounterRule;
import org.apache.usergrid.utils.JsonUtils;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
index 175cc74..abb9417 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.usergrid.AbstractCoreIT;
import org.apache.usergrid.persistence.hector.CountingMutator;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import org.apache.usergrid.utils.UUIDUtils;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
index 2e7de4f..6b508b4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.AbstractCoreIT;
import org.apache.usergrid.persistence.entities.User;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query.Level;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
index cd255c6..3545739 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
@@ -37,8 +37,8 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.usergrid.AbstractCoreIT;
import org.apache.usergrid.persistence.entities.Group;
import org.apache.usergrid.persistence.entities.User;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Query.Level;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import org.apache.usergrid.utils.UUIDUtils;
@@ -79,7 +79,7 @@ public class EntityManagerIT extends AbstractCoreIT {
user = em.get( user );
assertNotNull( user );
assertEquals( "user.username not expected value", "edanuff", user.getProperty( "username"));
- assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email" ));
+ assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email" ) );
app.refreshIndex();
@@ -93,20 +93,22 @@ public class EntityManagerIT extends AbstractCoreIT {
LOG.info( "user.username: " + user.getProperty( "username" ) );
LOG.info( "user.email: " + user.getProperty( "email" ) );
- Results results = em.searchCollection( em.getApplicationRef(), "users",
- new Query().addEqualityFilter( "username", "edanuff" ) );
+ final Query query = Query.fromQL("username = 'edanuff'");
+
+ Results results = em.searchCollection( em.getApplicationRef(), "users", query );
assertNotNull( results );
assertEquals( 1, results.size() );
user = results.getEntity();
assertNotNull( user );
- assertEquals( "user.username not expected value", "edanuff", user.getProperty( "username"));
- assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email"));
+ assertEquals( "user.username not expected value", "edanuff", user.getProperty( "username" ) );
+ assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email" ) );
LOG.info( "user.username: " + user.getProperty( "username" ) );
LOG.info( "user.email: " + user.getProperty( "email" ) );
- results = em.searchCollection( em.getApplicationRef(), "users",
- new Query().addEqualityFilter( "email", "ed@anuff.com" ) );
+ final Query emailQuery = Query.fromQL( "email = 'ed@anuff.com'" );
+
+ results = em.searchCollection( em.getApplicationRef(), "users", emailQuery );
assertNotNull( results );
assertEquals( 1, results.size() );
user = results.getEntity();
@@ -287,8 +289,12 @@ public class EntityManagerIT extends AbstractCoreIT {
// now search by username, no results should be returned
+
+ final Query emailQuery = Query.fromQL( "name = '" + name +"'" );
+
+
Results r = em.searchCollection( em.getApplicationRef(), "thing",
- new Query().addEqualityFilter( "name", name ) );
+ emailQuery );
assertEquals( 0, r.size() );
}
@@ -320,8 +326,9 @@ public class EntityManagerIT extends AbstractCoreIT {
// now search by username, no results should be returned
+ final Query query = Query.fromQL( "username = '" + name + "'" );
Results r = em.searchCollection( em.getApplicationRef(), "users",
- new Query().addEqualityFilter( "username", name ) );
+ query );
assertEquals( 0, r.size() );
@@ -337,8 +344,9 @@ public class EntityManagerIT extends AbstractCoreIT {
app.refreshIndex();
- r = em.searchCollection( em.getApplicationRef(), "users",
- new Query().addEqualityFilter( "username", name ) );
+ final Query userNameQuery = Query.fromQL( "username = '" + name + "'" );
+
+ r = em.searchCollection( em.getApplicationRef(), "users", userNameQuery);
assertEquals( 1, r.size() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/EntityPropertyComparatorTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityPropertyComparatorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityPropertyComparatorTest.java
deleted file mode 100644
index b5284a9..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityPropertyComparatorTest.java
+++ /dev/null
@@ -1,222 +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;
-
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-
-/** Test for the entity comparator */
-public class EntityPropertyComparatorTest {
-
-
- @Test
- public void testNulls() throws Exception {
-
- DynamicEntity first = new DynamicEntity();
- first.setProperty( "test", true );
-
- EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
- assertEquals( 0, forward.compare( null, null ) );
-
- assertEquals( -1, forward.compare( first, null ) );
-
- assertEquals( 1, forward.compare( null, first ) );
-
-
- //now test in reverse
-
- EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
- assertEquals( 0, reverse.compare( null, null ) );
-
- assertEquals( -1, reverse.compare( first, null ) );
-
- assertEquals( 1, reverse.compare( null, first ) );
- }
-
-
- @Test
- public void testBooleans() throws Exception {
-
- DynamicEntity second = new DynamicEntity();
- second.setProperty( "test", true );
-
-
- DynamicEntity first = new DynamicEntity();
- first.setProperty( "test", false );
-
- EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
- assertEquals( 0, forward.compare( second, second ) );
-
- assertEquals( 1, forward.compare( second, first ) );
-
- assertEquals( -1, forward.compare( first, second ) );
-
-
- //now test in reverse
-
- EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
- assertEquals( 0, reverse.compare( second, second ) );
-
- assertEquals( 1, reverse.compare( first, second ) );
-
- assertEquals( -1, reverse.compare( second, first ) );
- }
-
-
- @Test
- public void testFloat() throws Exception {
-
- DynamicEntity second = new DynamicEntity();
- second.setProperty( "test", 1.0f );
-
-
- DynamicEntity first = new DynamicEntity();
- first.setProperty( "test", 0.0f );
-
- EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
- assertEquals( 0, forward.compare( second, second ) );
-
- assertEquals( 1, forward.compare( second, first ) );
-
- assertEquals( -1, forward.compare( first, second ) );
-
-
- //now test in reverse
-
- EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
- assertEquals( 0, reverse.compare( second, second ) );
-
- assertEquals( 1, reverse.compare( first, second ) );
-
- assertEquals( -1, reverse.compare( second, first ) );
- }
-
-
- @Test
- public void testLong() throws Exception {
-
- DynamicEntity second = new DynamicEntity();
- second.setProperty( "test", 1l );
-
-
- DynamicEntity first = new DynamicEntity();
- first.setProperty( "test", 0l );
-
- EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
- assertEquals( 0, forward.compare( second, second ) );
-
- assertEquals( 1, forward.compare( second, first ) );
-
- assertEquals( -1, forward.compare( first, second ) );
-
-
- //now test in reverse
-
- EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
- assertEquals( 0, reverse.compare( second, second ) );
-
- assertEquals( 1, reverse.compare( first, second ) );
-
- assertEquals( -1, reverse.compare( second, first ) );
- }
-
-
- @Test
- public void testDouble() throws Exception {
-
- DynamicEntity second = new DynamicEntity();
- second.setProperty( "test", 1d );
-
-
- DynamicEntity first = new DynamicEntity();
- first.setProperty( "test", 0d );
-
-
- EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
- assertEquals( 0, forward.compare( second, second ) );
-
- assertEquals( 1, forward.compare( second, first ) );
-
- assertEquals( -1, forward.compare( first, second ) );
-
-
- //now test in reverse
-
- EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
- assertEquals( 0, reverse.compare( second, second ) );
-
- assertEquals( 1, reverse.compare( first, second ) );
-
- assertEquals( -1, reverse.compare( second, first ) );
- }
-
-
- @Test
- public void testString() throws Exception {
-
- DynamicEntity second = new DynamicEntity();
- second.setProperty( "test", "b" );
-
-
- DynamicEntity first = new DynamicEntity();
- first.setProperty( "test", "a" );
-
- EntityPropertyComparator forward = new EntityPropertyComparator( "test", false );
-
-
- assertEquals( 0, forward.compare( second, second ) );
-
- assertEquals( 1, forward.compare( second, first ) );
-
- assertEquals( -1, forward.compare( first, second ) );
-
-
- //now test in reverse
-
- EntityPropertyComparator reverse = new EntityPropertyComparator( "test", true );
-
-
- assertEquals( 0, reverse.compare( second, second ) );
-
- assertEquals( 1, reverse.compare( first, second ) );
-
- assertEquals( -1, reverse.compare( second, first ) );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index c50ccaf..614e5f6 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -28,8 +28,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.persistence.model.field.value.Location;
import org.apache.usergrid.utils.MapUtils;
@@ -143,10 +141,11 @@ public class GeoIT extends AbstractCoreIT {
assertNotNull(user);
app.refreshIndex();
- Point center = new Point(37.776753, -122.407846);
+ final double lat = 37.776753;
+ final double lon = -122.407846;
//2. Query from a point near the entity's location
Query query = Query.fromQL("select * where location within 100 of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
Results listResults = em.searchCollection(em.getApplicationRef(), "users", query);
assertEquals(1, listResults.size());
@@ -263,9 +262,10 @@ public class GeoIT extends AbstractCoreIT {
EntityManager em = loadGeolocationTestEntities();
//2. Query the collection from a point more than 10000m from the locations
// and ensure that no entities are returned when restricted to a 10000m radius
- Point center = new Point(37.776753, -122.407846);
+ final double lat = 37.776753;
+ final double lon = -122.407846;
Query query = Query.fromQL("select * where location within " + NEARBY_RADIUS + " of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
assertEquals("Results within " + NEARBY_RADIUS + "m from center", 0, listResults.size());
@@ -273,7 +273,7 @@ public class GeoIT extends AbstractCoreIT {
// and ensure that all entities are returned when the distance is set to the
// circumference of the earth
Query query2 = Query.fromQL("select * where location within " + CIRCUMFERENCE_OF_THE_EARTH + " of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
listResults = em.searchCollection(em.getApplicationRef(), "stores", query2);
assertEquals("Results within " + CIRCUMFERENCE_OF_THE_EARTH
@@ -292,27 +292,28 @@ public class GeoIT extends AbstractCoreIT {
* circumference of the earth
*/
public void testGeoFromNearbyLocation() throws Exception {
- LOG.info("GeoIT.testGeoFromNearbyLocation");
+ LOG.info( "GeoIT.testGeoFromNearbyLocation" );
//1. create entities with geo
EntityManager em = loadGeolocationTestEntities();
- Point center = new Point(-33.746369, 150.952185);
+ final double lat = -33.746369;
+ final double lon = 150.952185;
//2. Query the collection from a point less than 10000m from the locations
// and ensure that one entity is returned when restricted to a 10000m radius
Query query = Query.fromQL("select * where location within " + NEARBY_RADIUS + " of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
- assertEquals("Results within " + NEARBY_RADIUS + "m from center", 1, listResults.size());
+ assertEquals( "Results within " + NEARBY_RADIUS + "m from center", 1, listResults.size() );
//3. Query the collection from a point less than 10000m from the locations
// and ensure that all entities are returned when the distance is set to the
// circumference of the earth
- query = Query.fromQL("select * where location within " + CIRCUMFERENCE_OF_THE_EARTH + " of "
- + center.getLat() + "," + center.getLon());
+ query = Query.fromQL(
+ "select * where location within " + CIRCUMFERENCE_OF_THE_EARTH + " of " + lat + "," + lon );
listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
- assertEquals("Results within " + CIRCUMFERENCE_OF_THE_EARTH
- + "m from center", LOCATION_PROPERTIES.size(), listResults.size());
+ assertEquals( "Results within " + CIRCUMFERENCE_OF_THE_EARTH + "m from center", LOCATION_PROPERTIES.size(),
+ listResults.size() );
}
/**
@@ -332,26 +333,29 @@ public class GeoIT extends AbstractCoreIT {
//1 Create entities with geo
EntityManager em = loadGeolocationTestEntities();
//2 Create a list of points from different geographic areas
- List<Point> points = new ArrayList<Point>();
- points.add(new Point(-90.000000, 90.000000));//Antarctica
- points.add(new Point(90, 90));//Santa's house
- points.add(new Point(33.746369, -89));//Woodland, MS
- points.add(new Point(34.35, 58.22)); //Buenos Aires
- points.add(new Point(39.55, 116.25));//Beijing, China
- points.add(new Point(44.52, 20.32)); //Belgrade, Serbia
- points.add(new Point(-1.000000, 102.000000));//Somewhere in Indonesia
- for (Point center : points) {
+ List<double[]> points = new ArrayList<>();
+ points.add(new double[]{-90.000000, 90.000000});//Antarctica
+ points.add(new double[]{90, 90});;//Santa's house
+ points.add( new double[]{ 33.746369, -89});;//Woodland, MS
+ points.add( new double[] { 34.35, 58.22 } );; //Buenos Aires
+ points.add( new double[] { 39.55, 116.25 } );;//Beijing, China
+ points.add( new double[]{ 44.52, 20.32});; //Belgrade, Serbia
+ points.add( new double[] { -1.000000, 102.000000 } );;//Somewhere in Indonesia
+ for (double[] center : points) {
//3 Query the collection from each point
// and ensure that no entities are returned when restricted to a 10000m radius
+ final double lat = center[0];
+ final double lon = center[1];
+
Query query = Query.fromQL("select * where location within 10000 of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
assertEquals("Results less than 10000m away from center", 0, listResults.size());
//4 Query the collection from each point
// and ensure that all entities are returned when the distance is set to the
// circumference of the earth
Query query2 = Query.fromQL("select * where location within 40000000 of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
listResults = em.searchCollection(em.getApplicationRef(), "stores", query2);
assertEquals("Results from center point to ridiculously far",
LOCATION_PROPERTIES.size(), listResults.size());
@@ -364,7 +368,7 @@ public class GeoIT extends AbstractCoreIT {
EntityManager em = app.getEntityManager();
- assertNotNull(em);
+ assertNotNull( em );
// save objects in a diagonal line from -90 -180 to 90 180
@@ -394,11 +398,11 @@ public class GeoIT extends AbstractCoreIT {
app.refreshIndex();
- Query query = new Query();
- // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
+ // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
// just to be save
- query.addFilter("location within 50000000 of -90, -180");
- query.setLimit(100);
+ Query query = Query.fromQL("location within 50000000 of -90, -180" );
+
+ query.setLimit( 100 );
int count = 0;
Results results;
@@ -417,7 +421,7 @@ public class GeoIT extends AbstractCoreIT {
while (results.getCursor() != null);
// check we got back all 500 entities
- assertEquals(numEntities, count);
+ assertEquals( numEntities, count );
}
@@ -441,11 +445,10 @@ public class GeoIT extends AbstractCoreIT {
app.refreshIndex();
- Query query = new Query();
// earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
- // just to be save
- query.addFilter("location within 50000000 of 0, 0");
- query.setLimit(100);
+ // just to be save
+ Query query = Query.fromQL("location within 50000000 of 0, 0" );
+ query.setLimit( 100 );
int count = 0;
Results results;
@@ -502,10 +505,10 @@ public class GeoIT extends AbstractCoreIT {
app.refreshIndex();
- Query query = new Query();
- // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
+ // earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
// just to be save
- query.addFilter("location within 50000000 of -90, -180");
+ Query query = Query.fromQL( "location within 50000000 of -90, -180" );
+
query.setLimit(100);
int count = 0;
@@ -529,7 +532,7 @@ public class GeoIT extends AbstractCoreIT {
public void testGeoWithIntersection() throws Exception {
EntityManager em = app.getEntityManager();
- assertNotNull(em);
+ assertNotNull( em );
int size = 100;
int min = 50;
@@ -643,9 +646,7 @@ public class GeoIT extends AbstractCoreIT {
long startTime = System.currentTimeMillis();
//now test at the EM level, there should be 0 results.
- Query query = new Query();
-
- query.addFilter("location within 1000 of 48.38626, 9.94175"); // lat, lon
+ Query query = Query.fromQL( "location within 1000 of 48.38626, 9.94175");
query.setLimit(limit);
Results results = em.searchCollection(em.getApplicationRef(), "stores", query);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e534d9c7/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
index 3dfab3f..8d01754 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
@@ -26,12 +26,8 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.commons.lang3.RandomStringUtils;
import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -87,22 +83,23 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
app.refreshIndex();
// define center point about 300m from that location
- Point center = new Point( 37.774277, -122.404744 );
+ final double lat = 37.774277;
+ final double lon = -122.404744 ;
Query query = Query.fromQL( "select * where location within 400 of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
Results listResults = em.searchCollection( em.getApplicationRef(), "users", query );
assertEquals( 2, listResults.size() );
query = Query.fromQL( "select * where employer='Apigee' or location within 100 of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
listResults = em.searchCollection( em.getApplicationRef(), "users", query );
// no results because geo filter applied after query even in the case or 'or'
assertEquals( 0, listResults.size() );
query = Query.fromQL( "select * where employer='Apigee' or location within 400 of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
listResults = em.searchCollection( em.getApplicationRef(), "users", query );
// only one result because geo filter applied after query even in the case or 'or'
@@ -166,19 +163,20 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
app.refreshIndex();
// define center point about 300m from that location
- Point center = new Point( 37.774277, -122.404744 );
+ final double lat = 37.774277;
+ final double lon = -122.404744 ;
// one user within 400 meters IS NOT blocked by bart
Query query = Query.fromQL(
"select * where NOT blockedBy.name='bart' and location within 400 of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
Results listResults = em.searchCollection( em.getApplicationRef(), "users", query );
assertEquals( 1, listResults.size() );
// one user within 400 meters IS blocked by bart
query = Query.fromQL(
"select * where blockedBy.name='bart' and location within 400 of "
- + center.getLat() + "," + center.getLon());
+ + lat + "," + lon);
listResults = em.searchCollection( em.getApplicationRef(), "users", query );
assertEquals( 1, listResults.size() );
[5/5] incubator-usergrid git commit: Fixes querying by UUID
Posted by to...@apache.org.
Fixes querying by UUID
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/8060e16c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/8060e16c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/8060e16c
Branch: refs/heads/USERGRID-536
Commit: 8060e16c9f56bf702cb2bf4404d6443b0faa5382
Parents: e534d9c
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Apr 9 17:26:24 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Apr 10 10:27:50 2015 -0600
----------------------------------------------------------------------
.../persistence/index/impl/EntityField.java | 27 +-
.../index/impl/EntityMappingParser.java | 15 ++
.../persistence/index/impl/EsQueryVistor.java | 41 +--
.../persistence/index/impl/IndexingUtils.java | 6 +-
.../persistence/index/usergrid-mappings.json | 6 +-
.../persistence/index/impl/EntityIndexTest.java | 45 ++++
.../index/impl/EntityToMapConverterTest.java | 249 +++++++++----------
7 files changed, 233 insertions(+), 156 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8060e16c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
index 7e7c610..a1eec91 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
@@ -26,6 +26,7 @@ package org.apache.usergrid.persistence.index.impl;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
/**
@@ -49,7 +50,7 @@ public class EntityField extends HashMap<String, Object> {
*/
public static EntityField create( final String fieldName, final String value ) {
EntityField field = new EntityField();
- field.put( IndexingUtils.FIELD_NAME, fieldName );
+ field.put( IndexingUtils.FIELD_NAME, fieldName.toLowerCase() );
field.put( IndexingUtils.FIELD_STRING, value );
return field;
@@ -57,11 +58,23 @@ public class EntityField extends HashMap<String, Object> {
/**
+ * Set a uuid value into the field
+ */
+ public static EntityField create( final String fieldName, final UUID value ) {
+ EntityField field = new EntityField();
+ field.put( IndexingUtils.FIELD_NAME, fieldName.toLowerCase() );
+ field.put( IndexingUtils.FIELD_UUID, value.toString() );
+
+ return field;
+ }
+
+
+ /**
* Set a string value into the field
*/
public static EntityField create( final String fieldName, final boolean value ) {
EntityField field = new EntityField();
- field.put( IndexingUtils.FIELD_NAME, fieldName );
+ field.put( IndexingUtils.FIELD_NAME, fieldName.toLowerCase() );
field.put( IndexingUtils.FIELD_BOOLEAN, value );
return field;
@@ -75,7 +88,7 @@ public class EntityField extends HashMap<String, Object> {
*/
public static EntityField create( final String fieldName, final int value ) {
EntityField field = new EntityField();
- field.put( IndexingUtils.FIELD_NAME, fieldName );
+ field.put( IndexingUtils.FIELD_NAME, fieldName.toLowerCase() );
field.put( IndexingUtils.FIELD_LONG, value );
return field;
@@ -87,7 +100,7 @@ public class EntityField extends HashMap<String, Object> {
*/
public static EntityField create( final String fieldName, final long value ) {
EntityField field = new EntityField();
- field.put( IndexingUtils.FIELD_NAME, fieldName );
+ field.put( IndexingUtils.FIELD_NAME, fieldName.toLowerCase() );
field.put( IndexingUtils.FIELD_LONG, value );
return field;
@@ -99,7 +112,7 @@ public class EntityField extends HashMap<String, Object> {
*/
public static EntityField create( final String fieldName, final float value ) {
EntityField field = new EntityField();
- field.put( IndexingUtils.FIELD_NAME, fieldName );
+ field.put( IndexingUtils.FIELD_NAME, fieldName.toLowerCase() );
field.put( IndexingUtils.FIELD_DOUBLE, value );
return field;
@@ -111,7 +124,7 @@ public class EntityField extends HashMap<String, Object> {
*/
public static EntityField create( final String fieldName, final double value ) {
EntityField field = new EntityField();
- field.put( IndexingUtils.FIELD_NAME, fieldName );
+ field.put( IndexingUtils.FIELD_NAME, fieldName.toLowerCase() );
field.put( IndexingUtils.FIELD_DOUBLE, value );
return field;
@@ -125,7 +138,7 @@ public class EntityField extends HashMap<String, Object> {
*/
public static EntityField create( final String fieldName, final Map location) {
EntityField field = new EntityField();
- field.put( IndexingUtils.FIELD_NAME, fieldName );
+ field.put( IndexingUtils.FIELD_NAME, fieldName.toLowerCase() );
field.put( IndexingUtils.FIELD_LOCATION, location );
return field;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8060e16c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
index 0369ff0..9adc35d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
@@ -29,6 +29,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Stack;
+import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,6 +72,15 @@ public class EntityMappingParser implements FieldParser {
}
+
+ /**
+ * Visit al the primitive values
+ */
+ private void visit( final UUID value ) {
+ fields.add( EntityField.create( fieldStack.peek(), value ) );
+ }
+
+
private void visit( final boolean value ) {
fields.add( EntityField.create( fieldStack.peek(), value ) );
}
@@ -155,6 +165,11 @@ public class EntityMappingParser implements FieldParser {
return;
}
+ if(object instanceof UUID){
+ visit((UUID) object);
+ return;
+ }
+
if ( object instanceof Boolean ) {
visit( ( Boolean ) object );
return;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8060e16c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index 316a297..74925fd 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -19,10 +19,8 @@
package org.apache.usergrid.persistence.index.impl;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
import java.util.Stack;
+import java.util.UUID;
import org.elasticsearch.common.geo.GeoDistance;
import org.elasticsearch.common.unit.DistanceUnit;
@@ -82,7 +80,6 @@ public class EsQueryVistor implements QueryVisitor {
private final GeoSortFields geoSortFields = new GeoSortFields();
-
@Override
public void visit( AndOperand op ) throws IndexException {
@@ -122,7 +119,7 @@ public class EsQueryVistor implements QueryVisitor {
queryBuilders.push( rightQuery );
}
//put in an empty in case we're not the root. I.E X and Y and Z
- else{
+ else {
queryBuilders.push( NoOpQueryBuilder.INSTANCE );
}
@@ -147,7 +144,7 @@ public class EsQueryVistor implements QueryVisitor {
filterBuilders.push( rightFilter );
}
//push in a no-op in case we're not the root I.E X and Y and Z
- else{
+ else {
filterBuilders.push( NoOpFilterBuilder.INSTANCE );
}
}
@@ -183,8 +180,8 @@ public class EsQueryVistor implements QueryVisitor {
queryBuilders.push( rightQuery );
}
- //put in an empty in case we're not the root. I.E X or Y or Z
- else{
+ //put in an empty in case we're not the root. I.E X or Y or Z
+ else {
queryBuilders.push( NoOpQueryBuilder.INSTANCE );
}
@@ -206,11 +203,10 @@ public class EsQueryVistor implements QueryVisitor {
else if ( useRightFilter ) {
filterBuilders.push( rightFilter );
}
- //put in an empty in case we're not the root. I.E X or Y or Z
- else{
+ //put in an empty in case we're not the root. I.E X or Y or Z
+ else {
queryBuilders.push( NoOpQueryBuilder.INSTANCE );
}
-
}
@@ -225,7 +221,7 @@ public class EsQueryVistor implements QueryVisitor {
if ( use( notQueryBuilder ) ) {
queryBuilders.push( QueryBuilders.boolQuery().mustNot( notQueryBuilder ) );
}
- else{
+ else {
queryBuilders.push( NoOpQueryBuilder.INSTANCE );
}
@@ -235,7 +231,7 @@ public class EsQueryVistor implements QueryVisitor {
if ( use( notFilterBuilder ) ) {
filterBuilders.push( FilterBuilders.boolFilter().mustNot( notFilterBuilder ) );
}
- else{
+ else {
filterBuilders.push( NoOpFilterBuilder.INSTANCE );
}
}
@@ -278,8 +274,9 @@ public class EsQueryVistor implements QueryVisitor {
float distance = op.getDistance().getFloatValue();
- final FilterBuilder fb = FilterBuilders.geoDistanceFilter( IndexingUtils.FIELD_LOCATION_NESTED ).lat( lat ).lon( lon )
- .distance( distance, DistanceUnit.METERS );
+ final FilterBuilder fb =
+ FilterBuilders.geoDistanceFilter( IndexingUtils.FIELD_LOCATION_NESTED ).lat( lat ).lon( lon )
+ .distance( distance, DistanceUnit.METERS );
filterBuilders.push( fieldNameTerm( name, fb ) );
@@ -290,8 +287,8 @@ public class EsQueryVistor implements QueryVisitor {
//this geoSort won't has a sort on it
final GeoDistanceSortBuilder geoSort =
- SortBuilders.geoDistanceSort( IndexingUtils.FIELD_LOCATION_NESTED )
- .unit( DistanceUnit.METERS ).geoDistance( GeoDistance.SLOPPY_ARC ).point( lat, lon );
+ SortBuilders.geoDistanceSort( IndexingUtils.FIELD_LOCATION_NESTED ).unit( DistanceUnit.METERS )
+ .geoDistance( GeoDistance.SLOPPY_ARC ).point( lat, lon );
final TermFilterBuilder sortPropertyName = sortPropertyTermFilter( name );
@@ -505,6 +502,11 @@ public class EsQueryVistor implements QueryVisitor {
}
+ if ( object instanceof UUID ) {
+ return IndexingUtils.FIELD_UUID_NESTED;
+ }
+
+
throw new UnsupportedOperationException(
"Unkown search type of " + object.getClass().getName() + " encountered" );
}
@@ -518,6 +520,10 @@ public class EsQueryVistor implements QueryVisitor {
return ( ( String ) input ).toLowerCase();
}
+ if ( input instanceof UUID ) {
+ return input.toString();
+ }
+
return input;
}
@@ -536,5 +542,4 @@ public class EsQueryVistor implements QueryVisitor {
private boolean use( final FilterBuilder filterBuilder ) {
return filterBuilder != NoOpFilterBuilder.INSTANCE;
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8060e16c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
index 7a70e15..3ccac44 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
@@ -66,7 +66,6 @@ public class IndexingUtils {
public static final String ENTITY_FIELDS = "fields";
-
/**
* Reserved field types in our document
*
@@ -78,9 +77,7 @@ public class IndexingUtils {
public static final String FIELD_DOUBLE = "double";
public static final String FIELD_LOCATION = "location";
public static final String FIELD_STRING = "string";
-
-
-
+ public static final String FIELD_UUID = "uuid";
/**
@@ -92,6 +89,7 @@ public class IndexingUtils {
public static final String FIELD_DOUBLE_NESTED = ENTITY_FIELDS + "." + FIELD_DOUBLE;
public static final String FIELD_LOCATION_NESTED = ENTITY_FIELDS + "." + FIELD_LOCATION;
public static final String FIELD_STRING_NESTED = ENTITY_FIELDS + "." + FIELD_STRING;
+ public static final String FIELD_UUID_NESTED = ENTITY_FIELDS + "." + FIELD_UUID;
public static final String FIELD_STRING_EQUALS_NESTED = FIELD_STRING_NESTED + ".exact";
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8060e16c/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json b/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
index e90f5a7..4da1902 100644
--- a/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
+++ b/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
@@ -79,8 +79,12 @@
"index": "not_analyzed",
"doc_values": true
}
-
}
+ },
+ "uuid": {
+ "type": "string",
+ "index": "not_analyzed",
+ "doc_values": true
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8060e16c/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
index 082b72d..c9feadb 100644
--- 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
@@ -729,6 +729,51 @@ public class EntityIndexTest extends BaseIT {
}
+
+ @Test
+ public void queryByUUID() throws Throwable {
+
+ Id appId = new SimpleId( "application" );
+ Id ownerId = new SimpleId( "owner" );
+
+ ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+
+ IndexEdge indexSCope = new IndexEdgeImpl( ownerId, "user", SearchEdge.NodeType.SOURCE, 10 );
+
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
+
+
+ final UUID searchUUID = UUIDGenerator.newTimeUUID();
+
+ Map entityMap = new HashMap() {{
+ put( "searchUUID", searchUUID );
+ }};
+
+ Entity user = EntityIndexMapUtils.fromMap( entityMap );
+
+ final Id entityId = new SimpleId( "entitytype" );
+
+ EntityUtils.setId( user, entityId );
+ EntityUtils.setVersion( user, UUIDGenerator.newTimeUUID() );
+
+
+ EntityIndexBatch batch = entityIndex.createBatch();
+
+ batch.index( indexSCope, user );
+ batch.execute().get();
+ ei.refresh();
+
+ final String query = "where searchUUID = " + searchUUID;
+
+ final CandidateResults r = entityIndex.search( indexSCope, SearchTypes.fromTypes( entityId.getType() ), query, 10 );
+ assertEquals( user.getId(), r.get( 0 ).getId() );
+
+ batch.deindex( indexSCope, user.getId(), user.getVersion() );
+ batch.execute().get();
+ ei.refresh();
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8060e16c/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
index 002e9b2..7fed42c 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
@@ -45,6 +45,7 @@ import org.apache.usergrid.persistence.model.field.IntegerField;
import org.apache.usergrid.persistence.model.field.LocationField;
import org.apache.usergrid.persistence.model.field.LongField;
import org.apache.usergrid.persistence.model.field.StringField;
+import org.apache.usergrid.persistence.model.field.UUIDField;
import org.apache.usergrid.persistence.model.field.value.EntityObject;
import org.apache.usergrid.persistence.model.field.value.Location;
import org.apache.usergrid.persistence.model.util.EntityUtils;
@@ -74,7 +75,7 @@ public class EntityToMapConverterTest {
final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) );
final IndexEdge indexEdge =
- new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
+ new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, entity );
@@ -130,66 +131,73 @@ public class EntityToMapConverterTest {
@Test
public void testStringField() {
- testSingleField( new StringField( "name", "value" ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_STRING ) ) );
+ testSingleField( new StringField( "Name", "value" ),
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_STRING ) ) );
}
@Test
public void testBooleanField() {
- testSingleField( new BooleanField( "name", true ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_BOOLEAN ) ) );
+ testSingleField( new BooleanField( "Name", true ), ( field, entityField ) -> assertEquals( field.getValue(),
+ entityField.get( IndexingUtils.FIELD_BOOLEAN ) ) );
}
@Test
public void testIntegerField() {
- testSingleField( new IntegerField( "name", 100 ),
- ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_LONG )
- ) );
+ testSingleField( new IntegerField( "Name", 100 ),
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_LONG ) ) );
}
@Test
public void testLongField() {
- testSingleField( new LongField( "name", 100l ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_LONG ) ) );
+ testSingleField( new LongField( "Name", 100l ),
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_LONG ) ) );
}
@Test
public void testFloadField() {
- testSingleField( new FloatField( "name", 1.10f ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
+ testSingleField( new FloatField( "Name", 1.10f ),
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
+ }
+
+
+ /**
+ * Test converting a UUID to a string
+ */
+ @Test
+ public void testUUIDField() {
+ testSingleField( new UUIDField( "Name", UUIDGenerator.newTimeUUID() ),
+ ( field, entityField ) -> assertEquals( field.getValue().toString(), entityField.get( IndexingUtils.FIELD_UUID ) ) );
}
@Test
public void testDoubleField() {
- testSingleField( new DoubleField( "name", 2.20d ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
+ testSingleField( new DoubleField( "Name", 2.20d ),
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
}
@Test
public void testLocationField() {
- testSingleField( new LocationField( "name", new Location( 10, 20 ) ), ( field, entityField ) -> {
+ testSingleField( new LocationField( "Name", new Location( 10, 20 ) ), ( field, entityField ) -> {
final Map<String, Double> latLong = ( Map<String, Double> ) entityField.get( IndexingUtils.FIELD_LOCATION );
assertEquals( Double.valueOf( 10 ),
- latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LAT ) );
+ latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LAT ) );
assertEquals( Double.valueOf( 20 ),
- latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LON ) );
+ latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LON ) );
} );
}
-
/**
* Test the single field in our root level
*/
- public <T> void testSingleField( final Field<T> field,
- Action2<Field, EntityField> assertFunction ) {
+ public <T> void testSingleField( final Field<T> field, Action2<Field, EntityField> assertFunction ) {
Entity entity = new Entity( "test" );
entity.setField( field );
@@ -201,7 +209,7 @@ public class EntityToMapConverterTest {
final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) );
final IndexEdge indexEdge =
- new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
+ new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, entity );
@@ -213,7 +221,10 @@ public class EntityToMapConverterTest {
final EntityField esField = fields.get( 0 );
- assertEquals( field.getName(), esField.get( IndexingUtils.FIELD_NAME ) );
+ //always test the lower case arrays
+ final String fieldName = field.getName().toLowerCase();
+
+ assertEquals( fieldName, esField.get( IndexingUtils.FIELD_NAME ) );
assertFunction.call( field, esField );
}
@@ -324,7 +335,7 @@ public class EntityToMapConverterTest {
final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) );
final IndexEdge indexEdge =
- new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
+ new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, entity );
@@ -345,47 +356,45 @@ public class EntityToMapConverterTest {
}
-
@Test
public void testStringFieldSubObject() {
- testNestedField( new StringField( "name", "value" ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_STRING ) ) );
+ testNestedField( new StringField( "name", "value" ),
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_STRING ) ) );
}
@Test
public void testBooleanFieldSubObject() {
testNestedField( new BooleanField( "name", true ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_BOOLEAN ) ) );
+ entityField.get( IndexingUtils.FIELD_BOOLEAN ) ) );
}
@Test
public void testIntegerFieldSubObject() {
testNestedField( new IntegerField( "name", 100 ),
- ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_LONG )
- ) );
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_LONG ) ) );
}
@Test
public void testLongFieldSubObject() {
- testNestedField( new LongField( "name", 100l ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_LONG ) ) );
+ testNestedField( new LongField( "name", 100l ),
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_LONG ) ) );
}
@Test
public void testFloadFieldSubObject() {
- testNestedField( new FloatField( "name", 1.10f ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
+ testNestedField( new FloatField( "name", 1.10f ),
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
}
@Test
public void testDoubleFieldSubObject() {
- testNestedField( new DoubleField( "name", 2.20d ), ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
+ testNestedField( new DoubleField( "name", 2.20d ),
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
}
@@ -395,117 +404,111 @@ public class EntityToMapConverterTest {
final Map<String, Double> latLong = ( Map<String, Double> ) entityField.get( IndexingUtils.FIELD_LOCATION );
assertEquals( Double.valueOf( 10 ),
- latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LAT ) );
+ latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LAT ) );
assertEquals( Double.valueOf( 20 ),
- latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LON ) );
+ latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LON ) );
} );
}
- /**
- * Test primitive arrays in the root of an object
- *
- * @param storedField The field stored on the nested object
- * @param assertFunction The function
- */
- private <T> void testNestedField( final Field<T> storedField, Action2<Field, EntityField> assertFunction ) {
-
- EntityObject leafEntity = new EntityObject( );
+ /**
+ * Test primitive arrays in the root of an object
+ *
+ * @param storedField The field stored on the nested object
+ * @param assertFunction The function
+ */
+ private <T> void testNestedField( final Field<T> storedField, Action2<Field, EntityField> assertFunction ) {
- leafEntity.setField( storedField );
+ EntityObject leafEntity = new EntityObject();
+ leafEntity.setField( storedField );
- final EntityObjectField nested2Field = new EntityObjectField( "nested2", leafEntity );
+ final EntityObjectField nested2Field = new EntityObjectField( "nested2", leafEntity );
- final EntityObject nested2 = new EntityObject();
- nested2.setField( nested2Field );
+ final EntityObject nested2 = new EntityObject();
+ nested2.setField( nested2Field );
- final EntityObjectField nested1Field = new EntityObjectField( "nested1", nested2 );
+ final EntityObjectField nested1Field = new EntityObjectField( "nested1", nested2 );
- Entity rootEntity = new Entity( "test" );
+ Entity rootEntity = new Entity( "test" );
- rootEntity.setField( nested1Field );
+ rootEntity.setField( nested1Field );
- final UUID version = UUIDGenerator.newTimeUUID();
+ final UUID version = UUIDGenerator.newTimeUUID();
- EntityUtils.setVersion( rootEntity, version );
+ EntityUtils.setVersion( rootEntity, version );
- final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) );
+ final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) );
- final IndexEdge indexEdge =
- new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
+ final IndexEdge indexEdge =
+ new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
- final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, rootEntity );
+ final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, rootEntity );
- final List<EntityField> fields = ( List<EntityField> ) entityMap.get( IndexingUtils.ENTITY_FIELDS );
+ final List<EntityField> fields = ( List<EntityField> ) entityMap.get( IndexingUtils.ENTITY_FIELDS );
- assertEquals( 1, fields.size() );
+ assertEquals( 1, fields.size() );
- for ( int i = 0; i < fields.size(); i++ ) {
- final EntityField field = fields.get( i );
+ for ( int i = 0; i < fields.size(); i++ ) {
+ final EntityField field = fields.get( i );
- final String path = "nested1.nested2." + storedField.getName();
+ final String path = "nested1.nested2." + storedField.getName();
- assertEquals( path, field.get( IndexingUtils.FIELD_NAME ) );
+ assertEquals( path, field.get( IndexingUtils.FIELD_NAME ) );
- assertFunction.call( storedField, field );
- }
- }
+ assertFunction.call( storedField, field );
+ }
+ }
@Test
public void testStringFieldSubObjectArray() {
testNestedFieldArraySubObject( new StringField( "name", "value" ),
- ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_STRING ) ) );
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_STRING ) ) );
}
@Test
public void testBooleanFieldSubObjectArray() {
testNestedFieldArraySubObject( new BooleanField( "name", true ),
- ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_BOOLEAN ) ) );
+ ( field, entityField ) -> assertEquals( field.getValue(),
+ entityField.get( IndexingUtils.FIELD_BOOLEAN ) ) );
}
@Test
public void testIntegerFieldSubObjectArray() {
testNestedFieldArraySubObject( new IntegerField( "name", 100 ),
- ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_LONG )
- ) );
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_LONG ) ) );
}
@Test
public void testLongFieldSubObjectArray() {
testNestedFieldArraySubObject( new LongField( "name", 100l ),
- ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_LONG ) ) );
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_LONG ) ) );
}
@Test
public void testFloadFieldSubObjectArray() {
testNestedFieldArraySubObject( new FloatField( "name", 1.10f ),
- ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
}
@Test
public void testDoubleFieldSubObjectArray() {
testNestedFieldArraySubObject( new DoubleField( "name", 2.20d ),
- ( field, entityField ) -> assertEquals( field.getValue(),
- entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
+ ( field, entityField ) -> assertEquals( field.getValue(), entityField.get( IndexingUtils.FIELD_DOUBLE ) ) );
}
@@ -515,89 +518,85 @@ public class EntityToMapConverterTest {
final Map<String, Double> latLong = ( Map<String, Double> ) entityField.get( IndexingUtils.FIELD_LOCATION );
assertEquals( Double.valueOf( 10 ),
- latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LAT ) );
+ latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LAT ) );
assertEquals( Double.valueOf( 20 ),
- latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LON ) );
+ latLong.get( org.apache.usergrid.persistence.model.entity.EntityToMapConverter.LON ) );
} );
}
- /**
- * Test primitive arrays in the root of an object
- *
- * @param storedField The field stored on the nested object
- * @param assertFunction The function
- */
- private <T> void testNestedFieldArraySubObject( final Field<T> storedField,
- Action2<Field, EntityField> assertFunction ) {
-
- EntityObject leafEntity = new EntityObject( );
-
- leafEntity.setField( storedField );
+ /**
+ * Test primitive arrays in the root of an object
+ *
+ * @param storedField The field stored on the nested object
+ * @param assertFunction The function
+ */
+ private <T> void testNestedFieldArraySubObject( final Field<T> storedField,
+ Action2<Field, EntityField> assertFunction ) {
+ EntityObject leafEntity = new EntityObject();
+ leafEntity.setField( storedField );
- final EntityObjectField nested2Field = new EntityObjectField( "nested2", leafEntity );
- final EntityObject nested2 = new EntityObject();
- nested2.setField( nested2Field );
+ final EntityObjectField nested2Field = new EntityObjectField( "nested2", leafEntity );
- final EntityObjectField nested1Field = new EntityObjectField( "nested1", nested2 );
+ final EntityObject nested2 = new EntityObject();
+ nested2.setField( nested2Field );
- final EntityObject nested1 = new EntityObject();
- nested1.setField( nested1Field );
+ final EntityObjectField nested1Field = new EntityObjectField( "nested1", nested2 );
+ final EntityObject nested1 = new EntityObject();
+ nested1.setField( nested1Field );
- final ArrayField<EntityObject> array = new ArrayField<>( "array" );
+ final ArrayField<EntityObject> array = new ArrayField<>( "array" );
- array.add( nested1 );
+ array.add( nested1 );
- Entity rootEntity = new Entity( "test" );
+ Entity rootEntity = new Entity( "test" );
- rootEntity.setField( array );
+ rootEntity.setField( array );
- final UUID version = UUIDGenerator.newTimeUUID();
+ final UUID version = UUIDGenerator.newTimeUUID();
- EntityUtils.setVersion( rootEntity, version );
+ EntityUtils.setVersion( rootEntity, version );
- final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) );
+ final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) );
- final IndexEdge indexEdge =
- new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
+ final IndexEdge indexEdge =
+ new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
- final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, rootEntity );
+ final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, rootEntity );
- final List<EntityField> fields = ( List<EntityField> ) entityMap.get( IndexingUtils.ENTITY_FIELDS );
+ final List<EntityField> fields = ( List<EntityField> ) entityMap.get( IndexingUtils.ENTITY_FIELDS );
- assertEquals( 1, fields.size() );
+ assertEquals( 1, fields.size() );
- for ( int i = 0; i < fields.size(); i++ ) {
- final EntityField field = fields.get( i );
+ for ( int i = 0; i < fields.size(); i++ ) {
+ final EntityField field = fields.get( i );
- final String path = "array.nested1.nested2." + storedField.getName();
+ final String path = "array.nested1.nested2." + storedField.getName();
- assertEquals( path, field.get( IndexingUtils.FIELD_NAME ) );
+ assertEquals( path, field.get( IndexingUtils.FIELD_NAME ) );
- assertFunction.call( storedField, field );
- }
- }
+ assertFunction.call( storedField, field );
+ }
+ }
/**
* 2d + arrays aren't supported, ensure we drop elements with a depth > 1
- *
*/
@Test
public void testNDimensionalArray() {
-
//create an object with a string value in it, this should be indexed
final StringField string = new StringField( "string", "value" );
@@ -613,13 +612,12 @@ public class EntityToMapConverterTest {
final ArrayField<Object> array = new ArrayField<>( "array" );
//not indexed
- array.add( subArray);
+ array.add( subArray );
//indexed
array.add( nested1 );
-
Entity rootEntity = new Entity( "test" );
rootEntity.setField( array );
@@ -632,7 +630,7 @@ public class EntityToMapConverterTest {
final ApplicationScope scope = new ApplicationScopeImpl( createId( "application" ) );
final IndexEdge indexEdge =
- new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
+ new IndexEdgeImpl( createId( "source" ), "testEdgeType", SearchEdge.NodeType.SOURCE, 1000 );
final Map<String, Object> entityMap = EntityToMapConverter.convert( scope, indexEdge, rootEntity );
@@ -650,7 +648,6 @@ public class EntityToMapConverterTest {
assertEquals( path, field.get( IndexingUtils.FIELD_NAME ) );
- assertEquals("value", field.get( IndexingUtils.FIELD_STRING ));
-
+ assertEquals( "value", field.get( IndexingUtils.FIELD_STRING ) );
}
}