usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [06/50] incubator-usergrid git commit: fixed unique value serialization
Date Mon, 13 Apr 2015 17:45:31 GMT
fixed unique value serialization


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/045bbd35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/045bbd35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/045bbd35

Branch: refs/heads/USERGRID-536
Commit: 045bbd35173adab6dd4fda556035da577dc3a483
Parents: 09734fa
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Fri Apr 3 13:20:03 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Fri Apr 3 13:20:03 2015 -0600

----------------------------------------------------------------------
 .../serialization/impl/TypeField.java           | 43 ++++++++++++++
 .../impl/UniqueTypeFieldRowKeySerializer.java   | 60 ++++++++++++++++++++
 .../UniqueValueSerializationStrategyV2Impl.java | 16 +++---
 .../org/apache/usergrid/ServiceApplication.java |  2 +-
 .../usergrid/services/CollectionServiceIT.java  |  2 +
 5 files changed, 114 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/045bbd35/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/TypeField.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/TypeField.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/TypeField.java
new file mode 100644
index 0000000..1fefdcf
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/TypeField.java
@@ -0,0 +1,43 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  *  contributor license agreements.  The ASF licenses this file to You
+ *  * under the Apache License, Version 2.0 (the "License"); you may not
+ *  * use this file except in compliance with the License.
+ *  * You may obtain a copy of the License at
+ *  *
+ *  *     http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing, software
+ *  * distributed under the License is distributed on an "AS IS" BASIS,
+ *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  * See the License for the specific language governing permissions and
+ *  * limitations under the License.  For additional information regarding
+ *  * copyright in this work, please see the NOTICE file in the top level
+ *  * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+import org.apache.usergrid.persistence.model.field.Field;
+
+/**
+ * Classy class class.
+ */
+public class TypeField {
+    private final String type;
+    private final Field field;
+
+    public TypeField(String type, Field field) {
+        this.type = type;
+        this.field = field;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public Field getField() {
+        return field;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/045bbd35/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueTypeFieldRowKeySerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueTypeFieldRowKeySerializer.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueTypeFieldRowKeySerializer.java
new file mode 100644
index 0000000..63cc096
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueTypeFieldRowKeySerializer.java
@@ -0,0 +1,60 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  *  contributor license agreements.  The ASF licenses this file to You
+ *  * under the Apache License, Version 2.0 (the "License"); you may not
+ *  * use this file except in compliance with the License.
+ *  * You may obtain a copy of the License at
+ *  *
+ *  *     http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing, software
+ *  * distributed under the License is distributed on an "AS IS" BASIS,
+ *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  * See the License for the specific language governing permissions and
+ *  * limitations under the License.  For additional information regarding
+ *  * copyright in this work, please see the NOTICE file in the top level
+ *  * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+import com.netflix.astyanax.model.CompositeBuilder;
+import com.netflix.astyanax.model.CompositeParser;
+import org.apache.usergrid.persistence.core.astyanax.CompositeFieldSerializer;
+import org.apache.usergrid.persistence.model.field.Field;
+
+/**
+ * Classy class class.
+ */
+public class UniqueTypeFieldRowKeySerializer  implements CompositeFieldSerializer<TypeField>{
+
+    private static final UniqueTypeFieldRowKeySerializer INSTANCE = new UniqueTypeFieldRowKeySerializer();
+
+    private final UniqueFieldRowKeySerializer innerSerializer;
+
+    public UniqueTypeFieldRowKeySerializer(){
+        innerSerializer = UniqueFieldRowKeySerializer.get();
+    }
+    @Override
+    public void toComposite(CompositeBuilder builder, TypeField value) {
+        builder.addString(value.getType());
+        innerSerializer.toComposite(builder,value.getField());
+    }
+
+    @Override
+    public TypeField fromComposite(CompositeParser composite) {
+        String type = composite.readString();
+        Field field = innerSerializer.fromComposite(composite);
+
+        return new TypeField(type,field);
+    }
+
+
+    /**
+     * Get the singleton serializer
+     */
+    public static UniqueTypeFieldRowKeySerializer get() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/045bbd35/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
index baeec22..1e8b389 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
@@ -46,15 +46,15 @@ import com.netflix.astyanax.Keyspace;
  * V1 impl with unique value serialization strategy with the collection scope
  */
 @Singleton
-public class UniqueValueSerializationStrategyV2Impl  extends UniqueValueSerializationStrategyImpl<Field,
Id> {
+public class UniqueValueSerializationStrategyV2Impl  extends UniqueValueSerializationStrategyImpl<TypeField,
Id> {
 
 
-    private static final ScopedRowKeySerializer<Field>  ROW_KEY_SER = new ScopedRowKeySerializer<>(
UniqueFieldRowKeySerializer.get() );
+    private static final ScopedRowKeySerializer<TypeField>  ROW_KEY_SER = new ScopedRowKeySerializer<>(
UniqueTypeFieldRowKeySerializer.get() );
 
 
     private static final EntityVersionSerializer ENTITY_VERSION_SER = new EntityVersionSerializer();
 
-    private static final MultiTennantColumnFamily<ScopedRowKey<Field>, EntityVersion>
+    private static final MultiTennantColumnFamily<ScopedRowKey<TypeField>, EntityVersion>
         CF_UNIQUE_VALUES = new MultiTennantColumnFamily<>( "Unique_Values_V2", ROW_KEY_SER,
ENTITY_VERSION_SER );
 
 
@@ -102,7 +102,7 @@ public class UniqueValueSerializationStrategyV2Impl  extends UniqueValueSerializ
 
 
     @Override
-    protected MultiTennantColumnFamily<ScopedRowKey<Field>, EntityVersion> getUniqueValuesCF()
{
+    protected MultiTennantColumnFamily<ScopedRowKey<TypeField>, EntityVersion>
getUniqueValuesCF() {
         return CF_UNIQUE_VALUES;
     }
 
@@ -115,14 +115,14 @@ public class UniqueValueSerializationStrategyV2Impl  extends UniqueValueSerializ
 
 
     @Override
-    protected Field createUniqueValueKey( final Id applicationId,  final String type, final
Field field) {
-        return field;
+    protected TypeField createUniqueValueKey( final Id applicationId,  final String type,
final Field field) {
+        return new TypeField(type,field);
     }
 
 
     @Override
-    protected Field parseRowKey( final ScopedRowKey<Field> rowKey ) {
-        return rowKey.getKey();
+    protected Field parseRowKey( final ScopedRowKey<TypeField> rowKey ) {
+        return rowKey.getKey().getField();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/045bbd35/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
index 4ba85f3..801a640 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
@@ -73,7 +73,7 @@ public class ServiceApplication extends CoreApplication {
         ServiceResults testRequest = testRequest( action, expectedCount, true, params );
 
         if ( !action.equals( ServiceAction.GET )) {
-            setup.getEntityIndex().refresh();
+            this.refreshIndex();
         }
 
         return testRequest;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/045bbd35/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java
b/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java
index bc77fab..a243339 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java
@@ -153,6 +153,7 @@ public class CollectionServiceIT extends AbstractServiceIT {
 
         app.testRequest( ServiceAction.GET, 1, "cats", "Tom" );
 
+        app.clear();
         app.put( "name", "Danny" );
 
         Entity dog = app.testRequest( ServiceAction.POST, 1, "dogs" ).getEntity();
@@ -214,6 +215,7 @@ public class CollectionServiceIT extends AbstractServiceIT {
             // ok
         }
 
+        app.refreshIndex();
         try {
             // try DELETE on cats with dogs name
             app.testRequest( ServiceAction.DELETE, 0, "cats", "Danny" );


Mime
View raw message