gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject [32/37] gora git commit: Reformat the code
Date Wed, 23 Aug 2017 20:55:30 GMT
Reformat the code


Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/266ebf46
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/266ebf46
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/266ebf46

Branch: refs/heads/master
Commit: 266ebf464983940a1e36f2bf15737d258d471f24
Parents: 0de528e
Author: madhawa-gunasekara <madhawag@wso2.com>
Authored: Sun Aug 13 20:34:57 2017 +0530
Committer: madhawa-gunasekara <madhawag@wso2.com>
Committed: Sun Aug 13 20:34:57 2017 +0530

----------------------------------------------------------------------
 .../apache/gora/cassandra/bean/ClusterKeyField.java |  1 +
 .../org/apache/gora/cassandra/bean/KeySpace.java    |  4 ++++
 .../apache/gora/cassandra/query/CassandraQuery.java |  2 ++
 .../gora/cassandra/serializers/AvroSerializer.java  |  8 ++++++--
 .../cassandra/serializers/CassandraSerializer.java  | 10 +++++++---
 .../apache/gora/cassandra/store/CassandraStore.java | 16 ++--------------
 gora-cassandra-cql/src/test/conf/gora.properties    |  8 +-------
 .../test/conf/nativeSerialization/gora.properties   |  8 +-------
 .../test/conf/nativeUDT/gora-cassandra-mapping.xml  |  1 -
 9 files changed, 24 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/266ebf46/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/ClusterKeyField.java
----------------------------------------------------------------------
diff --git a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/ClusterKeyField.java
b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/ClusterKeyField.java
index 259025a..e1c88e3 100644
--- a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/ClusterKeyField.java
+++ b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/ClusterKeyField.java
@@ -23,6 +23,7 @@ package org.apache.gora.cassandra.bean;
 public class ClusterKeyField {
 
   private String columnName;
+
   private Order order;
 
   public ClusterKeyField() {

http://git-wip-us.apache.org/repos/asf/gora/blob/266ebf46/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/KeySpace.java
----------------------------------------------------------------------
diff --git a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/KeySpace.java
b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/KeySpace.java
index 7deb49a..898b370 100644
--- a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/KeySpace.java
+++ b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/bean/KeySpace.java
@@ -26,9 +26,13 @@ import java.util.Map;
 public class KeySpace {
 
   private String name;
+
   private PlacementStrategy placementStrategy;
+
   private boolean durableWritesEnabled;
+
   private int replicationFactor;
+
   private Map<String, Integer> dataCenters;
 
   public String getName() {

http://git-wip-us.apache.org/repos/asf/gora/blob/266ebf46/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/query/CassandraQuery.java
----------------------------------------------------------------------
diff --git a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/query/CassandraQuery.java
b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/query/CassandraQuery.java
index 919e946..45f9b77 100644
--- a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/query/CassandraQuery.java
+++ b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/query/CassandraQuery.java
@@ -33,7 +33,9 @@ import java.util.Map;
 public class CassandraQuery<K, T extends Persistent> extends QueryWSBase<K, T>
{
 
   private Filter<K, T> filter;
+
   private boolean localFilterEnabled = true;
+
   private Map<String, Object> updateFields = new HashMap<>();
 
   public CassandraQuery(DataStore<K, T> dataStore) {

http://git-wip-us.apache.org/repos/asf/gora/blob/266ebf46/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/AvroSerializer.java
----------------------------------------------------------------------
diff --git a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/AvroSerializer.java
b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/AvroSerializer.java
index 893de91..3037d6c 100644
--- a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/AvroSerializer.java
+++ b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/AvroSerializer.java
@@ -58,10 +58,14 @@ class AvroSerializer<K, T extends PersistentBase> extends CassandraSerializer
{
 
   private Schema persistentSchema;
 
-  AvroSerializer(CassandraClient cassandraClient, DataStore<K, T> dataStore, CassandraMapping
mapping, Schema schema) {
+  AvroSerializer(CassandraClient cassandraClient, DataStore<K, T> dataStore, CassandraMapping
mapping) {
     super(cassandraClient, dataStore.getKeyClass(), dataStore.getPersistentClass(), mapping);
+    if (PersistentBase.class.isAssignableFrom(dataStore.getPersistentClass())) {
+      persistentSchema = ((PersistentBase) dataStore.getBeanFactory().getCachedPersistent()).getSchema();
+    } else {
+      persistentSchema = null;
+    }
     this.cassandraDataStore = dataStore;
-    persistentSchema = schema;
     try {
       analyzePersistent();
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/gora/blob/266ebf46/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/CassandraSerializer.java
----------------------------------------------------------------------
diff --git a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/CassandraSerializer.java
b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/CassandraSerializer.java
index afddaef..ab072d5 100644
--- a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/CassandraSerializer.java
+++ b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/serializers/CassandraSerializer.java
@@ -20,7 +20,6 @@ package org.apache.gora.cassandra.serializers;
 import com.datastax.driver.core.KeyspaceMetadata;
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.TableMetadata;
-import org.apache.avro.Schema;
 import org.apache.gora.cassandra.bean.Field;
 import org.apache.gora.cassandra.store.CassandraClient;
 import org.apache.gora.cassandra.store.CassandraMapping;
@@ -41,12 +40,17 @@ import java.util.Map;
  * This is the abstract Cassandra Serializer class.
  */
 public abstract class CassandraSerializer<K, T extends Persistent> {
+
   private static final Logger LOG = LoggerFactory.getLogger(CassandraStore.class);
+
   protected Class<K> keyClass;
 
   protected Class<T> persistentClass;
+
   protected CassandraMapping mapping;
+
   protected CassandraClient client;
+
   protected Map<String, String> userDefineTypeMaps;
 
   CassandraSerializer(CassandraClient cc, Class<K> keyClass, Class<T> persistantClass,
CassandraMapping mapping) {
@@ -67,12 +71,12 @@ public abstract class CassandraSerializer<K, T extends Persistent>
{
    * @param <T>       persistent class
    * @return Serializer
    */
-  public static <K, T extends Persistent> CassandraSerializer getSerializer(CassandraClient
cc, String type, final DataStore<K, T> dataStore, CassandraMapping mapping, Schema schema)
{
+  public static <K, T extends Persistent> CassandraSerializer getSerializer(CassandraClient
cc, String type, final DataStore<K, T> dataStore, CassandraMapping mapping) {
     CassandraStore.SerializerType serType = type.isEmpty() ? CassandraStore.SerializerType.NATIVE
: CassandraStore.SerializerType.valueOf(type.toUpperCase(Locale.ENGLISH));
     CassandraSerializer serializer;
     switch (serType) {
       case AVRO:
-        serializer = new AvroSerializer(cc, dataStore, mapping, schema);
+        serializer = new AvroSerializer(cc, dataStore, mapping);
         break;
       case NATIVE:
       default:

http://git-wip-us.apache.org/repos/asf/gora/blob/266ebf46/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
----------------------------------------------------------------------
diff --git a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
index 65d29b7..799cd95 100644
--- a/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
+++ b/gora-cassandra-cql/src/main/java/org/apache/gora/cassandra/store/CassandraStore.java
@@ -17,13 +17,11 @@
 
 package org.apache.gora.cassandra.store;
 
-import org.apache.avro.Schema;
 import org.apache.gora.cassandra.query.CassandraQuery;
 import org.apache.gora.cassandra.serializers.CassandraSerializer;
 import org.apache.gora.persistency.BeanFactory;
 import org.apache.gora.persistency.Persistent;
 import org.apache.gora.persistency.impl.BeanFactoryImpl;
-import org.apache.gora.persistency.impl.PersistentBase;
 import org.apache.gora.query.PartitionQuery;
 import org.apache.gora.query.Query;
 import org.apache.gora.query.Result;
@@ -59,16 +57,11 @@ public class CassandraStore<K, T extends Persistent> implements
DataStore<K, T>
   private CassandraMapping mapping;
 
   private CassandraSerializer cassandraSerializer;
-  private String serializationType;
 
   public CassandraStore() {
     super();
   }
 
-  public String getSerializationType() {
-    return serializationType;
-  }
-
   /**
    * In initializing the cassandra datastore, read the mapping file, creates the basic connection
to cassandra cluster,
    * according to the gora properties
@@ -80,25 +73,20 @@ public class CassandraStore<K, T extends Persistent> implements
DataStore<K, T>
   @Override
   public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties
properties) {
     LOG.debug("Initializing Cassandra store");
-    Schema persistentSchema;
+    String serializationType;
     try {
       this.keyClass = keyClass;
       this.persistentClass = persistentClass;
       if (this.beanFactory == null) {
         this.beanFactory = new BeanFactoryImpl<>(keyClass, persistentClass);
       }
-      if (PersistentBase.class.isAssignableFrom(persistentClass)) {
-        persistentSchema = ((PersistentBase) this.beanFactory.getCachedPersistent()).getSchema();
-      } else {
-        persistentSchema = null;
-      }
       String mappingFile = DataStoreFactory.getMappingFile(properties, this, DEFAULT_MAPPING_FILE);
       serializationType = properties.getProperty(CassandraStoreParameters.CASSANDRA_SERIALIZATION_TYPE);
       CassandraMappingBuilder mappingBuilder = new CassandraMappingBuilder(this);
       mapping = mappingBuilder.readMapping(mappingFile);
       CassandraClient cassandraClient = new CassandraClient();
       cassandraClient.initialize(properties, mapping);
-      cassandraSerializer = CassandraSerializer.getSerializer(cassandraClient, serializationType,
this, mapping, persistentSchema);
+      cassandraSerializer = CassandraSerializer.getSerializer(cassandraClient, serializationType,
this, mapping);
     } catch (Exception e) {
       throw new RuntimeException("Error while initializing Cassandra store: " + e.getMessage(),
e);
     }

http://git-wip-us.apache.org/repos/asf/gora/blob/266ebf46/gora-cassandra-cql/src/test/conf/gora.properties
----------------------------------------------------------------------
diff --git a/gora-cassandra-cql/src/test/conf/gora.properties b/gora-cassandra-cql/src/test/conf/gora.properties
index fb98d63..e9a1b48 100644
--- a/gora-cassandra-cql/src/test/conf/gora.properties
+++ b/gora-cassandra-cql/src/test/conf/gora.properties
@@ -18,10 +18,4 @@ gora.datastore.default=org.apache.gora.cassandra.CassandraStore
 gora.cassandrastore.cluster=Gora Cassandra Test Cluster
 gora.cassandrastore.host=localhost:9160
 # property is annotated in CassandraClient#checkKeyspace()
-# options are ANY, ONE, TWO, THREE, LOCAL_QUORUM, EACH_QUORUM, QUORUM and ALL. 
-
-
-
-
-
-
+# options are ANY, ONE, TWO, THREE, LOCAL_QUORUM, EACH_QUORUM, QUORUM and ALL.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/gora/blob/266ebf46/gora-cassandra-cql/src/test/conf/nativeSerialization/gora.properties
----------------------------------------------------------------------
diff --git a/gora-cassandra-cql/src/test/conf/nativeSerialization/gora.properties b/gora-cassandra-cql/src/test/conf/nativeSerialization/gora.properties
index 3dcb007..6e5928d 100644
--- a/gora-cassandra-cql/src/test/conf/nativeSerialization/gora.properties
+++ b/gora-cassandra-cql/src/test/conf/nativeSerialization/gora.properties
@@ -16,10 +16,4 @@
 #
 gora.datastore.default=org.apache.gora.cassandra.CassandraStore
 gora.cassandrastore.cluster=Gora Test Cluster
-gora.cassandrastore.host=localhost:9160
-
-
-
-
-
-
+gora.cassandrastore.host=localhost:9160
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/gora/blob/266ebf46/gora-cassandra-cql/src/test/conf/nativeUDT/gora-cassandra-mapping.xml
----------------------------------------------------------------------
diff --git a/gora-cassandra-cql/src/test/conf/nativeUDT/gora-cassandra-mapping.xml b/gora-cassandra-cql/src/test/conf/nativeUDT/gora-cassandra-mapping.xml
index d6d99bf..ec81c2b 100644
--- a/gora-cassandra-cql/src/test/conf/nativeUDT/gora-cassandra-mapping.xml
+++ b/gora-cassandra-cql/src/test/conf/nativeUDT/gora-cassandra-mapping.xml
@@ -29,5 +29,4 @@
         <field name="customer" column="customer" type="udt(customer)"/>
     </class>
 
-
 </gora-otd>
\ No newline at end of file


Mime
View raw message