gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject svn commit: r1378656 - in /gora/branches/goraamazon: gora-core/src/main/java/org/apache/gora/persistency/ws/impl/ gora-core/src/main/java/org/apache/gora/query/ws/impl/ gora-core/src/main/java/org/apache/gora/store/ gora-core/src/main/java/org/apache/g...
Date Wed, 29 Aug 2012 17:31:02 GMT
Author: lewismc
Date: Wed Aug 29 17:31:01 2012
New Revision: 1378656

URL: http://svn.apache.org/viewvc?rev=1378656&view=rev
Log:
v5 commit for dynamodb module

Modified:
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/BeanFactoryWSImpl.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/PersistentWSBase.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/StateManagerWSImpl.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/PartitionWSQueryImpl.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/QueryWSBase.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/ResultWSBase.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/DataStore.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/WebServiceBackedDataStore.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/DataStoreBase.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/FileBackedDataStoreBase.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSBackedDataStoreBase.java
    gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java
    gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java
    gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBMapping.java

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/BeanFactoryWSImpl.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/BeanFactoryWSImpl.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/BeanFactoryWSImpl.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/BeanFactoryWSImpl.java Wed Aug 29 17:31:01 2012
@@ -31,16 +31,41 @@ import org.apache.gora.util.ReflectionUt
  */
 public class BeanFactoryWSImpl<K, T extends Persistent> implements BeanFactory<K, T> {
 
+  /**
+   * Class of the key to be used
+   */
   private Class<K> keyClass;
+  
+  /**
+   * Class of the persistent objects to be stored
+   */
   private Class<T> persistentClass;
   
+  /**
+   * Constructor of the key
+   */
   private Constructor<K> keyConstructor;
   
+  /**
+   * Object's key
+   */
   private K key;
+  
+  /**
+   * Persistent object of class T
+   */
   private T persistent;
   
+  /**
+   * Flag to be used to determine if a key is persistent or not
+   */
   private boolean isKeyPersistent = false;
   
+  /**
+   * Constructor
+   * @param keyClass
+   * @param persistentClass
+   */
   public BeanFactoryWSImpl(Class<K> keyClass, Class<T> persistentClass) {
     this.keyClass = keyClass;
     this.persistentClass = persistentClass;
@@ -60,7 +85,11 @@ public class BeanFactoryWSImpl<K, T exte
   
   @Override
   @SuppressWarnings("unchecked")
+  /**
+   * Creates a new key
+   */
   public K newKey() throws Exception {
+    // TODO this method should be checked to see how object states will be managed
     if(isKeyPersistent)
       return (K)((Persistent)key).newInstance(new StateManagerWSImpl());
     else if(keyConstructor == null) {
@@ -72,30 +101,49 @@ public class BeanFactoryWSImpl<K, T exte
  
   @SuppressWarnings("unchecked")
   @Override
+  /**
+   * Creates a new persistent object
+   */
   public T newPersistent() {
     return (T) persistent.newInstance(new StateManagerWSImpl());
   }
   
   @Override
+  /**
+   * Gets a cached key
+   */
   public K getCachedKey() {
     return key;
   }
   
   @Override
+  /**
+   * Gets a cached persistent object
+   */
   public T getCachedPersistent() {
     return persistent;
   }
   
   @Override
+  /**
+   * Gets the key class
+   */
   public Class<K> getKeyClass() {
     return keyClass;
   }
   
   @Override
+  /**
+   * Gets the persistent object class
+   */
   public Class<T> getPersistentClass() {
     return persistentClass;
   }
   
+  /**
+   * Returns if a key is an object of a persistent class
+   * @return True if it is or false if it is not
+   */
   public boolean isKeyPersistent() {
     return isKeyPersistent;
   }

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/PersistentWSBase.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/PersistentWSBase.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/PersistentWSBase.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/PersistentWSBase.java Wed Aug 29 17:31:01 2012
@@ -15,6 +15,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+/**
+ * @author Renato Marroquin
+ */
+
 package org.apache.gora.persistency.ws.impl;
 
 import java.nio.ByteBuffer;
@@ -25,23 +29,39 @@ import org.apache.gora.persistency.Persi
 import org.apache.gora.persistency.StateManager;
 
 /**
- * Base classs implementing common functionality for Persistent
- * classes.
+ * Base classs implementing common functionality for Web services 
+ * backed persistent classes.
  */
 public abstract class PersistentWSBase implements Persistent  {
 
+  /**
+   * Maps keys to their own classes
+   */
   protected static Map<Class<?>, Map<String, Integer>> FIELD_MAP =
     new HashMap<Class<?>, Map<String,Integer>>();
 
+  /**
+   * Maps fields to their own classes
+   */
   protected static Map<Class<?>, String[]> FIELDS =
     new HashMap<Class<?>, String[]>();
     
+  /**
+   * Object used to manage the state of fields
+   */
   private StateManager stateManager;
 
+  /**
+   * Constructor
+   */
   protected PersistentWSBase() {
     this(new StateManagerWSImpl());
   }
 
+  /**
+   * Constructor using a stateManager object
+   * @param stateManager
+   */
   protected PersistentWSBase(StateManager stateManager) {
     this.stateManager = stateManager;
     stateManager.setManagedPersistent(this);
@@ -64,197 +84,220 @@ public abstract class PersistentWSBase i
   }
 
   @Override
+  /**
+   * Gets the state manager
+   */
   public StateManager getStateManager() {
     return stateManager;
   }
 
   @Override
+  /**
+   * Gets fields using a specific class
+   */
   public String[] getFields() {
     return FIELDS.get(getClass());
   }
 
   @Override
+  /**
+   * Gets a specific field from the fields map
+   */
   public String getField(int index) {
     return FIELDS.get(getClass())[index];
   }
 
   @Override
+  /**
+   * Gets a field index based on the field name
+   */
   public int getFieldIndex(String field) {
     return FIELD_MAP.get(getClass()).get(field);
   }
 
   @Override
+  /**
+   * Clears maps of fields
+   */
   public void clear() {
-    /*List<Field> fields = getSchema().getFields();
-
-    for(int i=0; i<getFields().length; i++) {
-      switch(fields.get(i).schema().getType()) {
-        case MAP: 
-          if(get(i) != null) {
-            if (get(i) instanceof StatefulHashMap) {
-              ((StatefulHashMap)get(i)).reuse(); 
-            } else {
-              ((Map)get(i)).clear();
-            }
-          }
-          break;
-        case ARRAY:
-          if(get(i) != null) {
-            if(get(i) instanceof ListGenericArray) {
-              ((ListGenericArray)get(i)).clear();
-            } else {
-              put(i, new ListGenericArray(fields.get(i).schema()));
-            }
-          }
-          break;
-        case RECORD :
-          Persistent field = ((Persistent)get(i));
-          if(field != null) field.clear();
-          break;
-        case BOOLEAN: put(i, false); break;
-        case INT    : put(i, 0); break;
-        case DOUBLE : put(i, 0d); break;
-        case FLOAT  : put(i, 0f); break;
-        case LONG   : put(i, 0l); break;
-        case NULL   : break;
-        default     : put(i, null); break;
-      }
-    }*/
+    // TODO study the specific cases for other datatypes
     clearDirty();
     clearReadable();
   }
 
   @Override
+  /**
+   * Determines if a class is new or not
+   */
   public boolean isNew() {
     return getStateManager().isNew(this);
   }
 
   @Override
+  /**
+   * Sets this element as a new one inside the stateManager object
+   */
   public void setNew() {
     getStateManager().setNew(this);
   }
 
   @Override
+  /**
+   * Clears a new object from the stateManager
+   */
   public void clearNew() {
     getStateManager().clearNew(this);
   }
 
   @Override
+  /**
+   * Determines if an object has been modified or not
+   */
   public boolean isDirty() {
     return getStateManager().isDirty(this);
   }
 
   @Override
+  /**
+   * Determines if an object has been modified or not
+   * based on its field index
+   */
   public boolean isDirty(int fieldIndex) {
     return getStateManager().isDirty(this, fieldIndex);
   }
 
   @Override
+  /**
+   * Determines if an object has been modified or not
+   * based on its field name
+   */
   public boolean isDirty(String field) {
     return isDirty(getFieldIndex(field));
   }
 
   @Override
+  /**
+   * Sets this class as dirty
+   */
   public void setDirty() {
     getStateManager().setDirty(this);
   }
 
   @Override
+  /**
+   * Sets a specific field as dirty using its index
+   */
   public void setDirty(int fieldIndex) {
     getStateManager().setDirty(this, fieldIndex);
   }
 
   @Override
+  /**
+   * Sets a specific field as dirty using its name
+   */
   public void setDirty(String field) {
     setDirty(getFieldIndex(field));
   }
 
   @Override
+  /**
+   * Clears dirty fields using its index
+   */
   public void clearDirty(int fieldIndex) {
     getStateManager().clearDirty(this, fieldIndex);
   }
 
   @Override
+  /**
+   * Clears dirty fields using its name
+   */
   public void clearDirty(String field) {
     clearDirty(getFieldIndex(field));
   }
 
   @Override
+  /**
+   * Clears dirty fields from the state manager
+   */
   public void clearDirty() {
     getStateManager().clearDirty(this);
   }
 
   @Override
+  /**
+   * Checks if a field is readable using its index
+   */
   public boolean isReadable(int fieldIndex) {
     return getStateManager().isReadable(this, fieldIndex);
   }
 
   @Override
+  /**
+   * Checks if a field is readable using its name
+   */
   public boolean isReadable(String field) {
     return isReadable(getFieldIndex(field));
   }
 
   @Override
+  /**
+   * Sets a field as readable using its index
+   */
   public void setReadable(int fieldIndex) {
     getStateManager().setReadable(this, fieldIndex);
   }
 
   @Override
+  /**
+   * Sets a field as readable using its name
+   */
   public void setReadable(String field) {
     setReadable(getFieldIndex(field));
   }
 
   @Override
+  /**
+   * Clears this readable object from the state manager
+   */
   public void clearReadable() {
     getStateManager().clearReadable(this);
   }
 
   @Override
+  /**
+   * Clears a readable object based on its field index
+   * using a stateManager object
+   */
   public void clearReadable(int fieldIndex) {
     getStateManager().clearReadable(this, fieldIndex);
   }
 
   @Override
+  /**
+   * Clears a readable object based on its field name
+   * using a stateManager object
+   */
   public void clearReadable(String field) {
     clearReadable(getFieldIndex(field));
   }
 
   @Override
+  /**
+   * Determines if an object is equal to this class
+   */
   public boolean equals(Object o) {
     if (this == o) return true;
-    /*if (!(o instanceof SpecificRecord)) return false;
-
-    SpecificRecord r2 = (SpecificRecord)o;
-    if (!this.getSchema().equals(r2.getSchema())) return false;
-
-    return this.hashCode() == r2.hashCode();*/
+    // TODO we should check if the object has schema or not
     return true;
   }
 
   @Override
+  // TODO
   public int hashCode() {
     int result = 1;
-  /*  List<Field> fields = this.getSchema().getFields();
-    int end = fields.size();
-    for (int i = 0; i < end; i++) {
-      result = prime * result + getFieldHashCode(i, fields.get(i));
-    }
-    */
     return result;
   }
 
-  /*private int getFieldHashCode(int i, Field field) {
-    Object o = get(i);
-    if(o == null)
-      return 0;
-
-    if(field.schema().getType() == Type.BYTES) {
-      return getByteBufferHashCode((ByteBuffer)o);
-    }
-
-    return o.hashCode();
-  }*/
-
   /** ByteBuffer.hashCode() takes into account the position of the
    * buffer, but we do not want that*/
   private int getByteBufferHashCode(ByteBuffer buf) {
@@ -266,33 +309,34 @@ public abstract class PersistentWSBase i
   }
   
   @Override
+  /**
+   * Clones a persistent object
+   */
   public Persistent clone() {
-    //return datumReader.clone(this, getSchema());
 	  return null;
   }
   
   @Override
+  /**
+   * Converts an object to string
+   */
   public String toString() {
     StringBuilder builder = new StringBuilder();
     builder.append(super.toString());
     builder.append(" {\n");
-    /*List<Field> fields = getSchema().getFields();
-    for(int i=0; i<fields.size(); i++) {
-      builder.append("  \"").append(fields.get(i).name()).append("\":\"");
-      builder.append(get(i)).append("\"\n");
-    }
-    */
+    // TODO get fields
     builder.append("}");
     return builder.toString();
   }
-  
+
+  /**
+   * Checks if a field is equal between two objects
+   * @param index
+   * @param value
+   * @return
+   */
   protected boolean isFieldEqual(int index, Object value) {
-    /*Object old = get(index);
-    if (old == null && value == null)
-      return true;
-    if (old == null || value == null)
-      return false;
-    return value.equals(old);*/
+    // TODO
 	  return true;
   }
 }

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/StateManagerWSImpl.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/StateManagerWSImpl.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/StateManagerWSImpl.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/persistency/ws/impl/StateManagerWSImpl.java Wed Aug 29 17:31:01 2012
@@ -34,9 +34,15 @@ public class StateManagerWSImpl implemen
   protected BitSet dirtyBits;
   protected BitSet readableBits;
 
+  /**
+   * Constructor
+   */
   public StateManagerWSImpl() {
   }
 
+  /**
+   * Sets dirtyBits and readableBits sizes
+   */
   public void setManagedPersistent(Persistent persistent) {
    // dirtyBits = new BitSet(persistent.getSchema().getFields().size());
    // readableBits = new BitSet(persistent.getSchema().getFields().size());
@@ -44,60 +50,99 @@ public class StateManagerWSImpl implemen
   }
 
   @Override
+  /**
+   * Checks if an object is new or not
+   */
   public boolean isNew(Persistent persistent) {
     return isNew;
   }
   
   @Override
+  /**
+   * Sets an object as new
+   */
   public void setNew(Persistent persistent) {
     this.isNew = true;
   }
   
   @Override
+  /**
+   * Clear the new object by setting it as not new
+   */
   public void clearNew(Persistent persistent) {
     this.isNew = false;
   }
   
+  /**
+   * Sets an object as dirty using its index
+   */
   public void setDirty(Persistent persistent, int fieldIndex) {
     dirtyBits.set(fieldIndex);
     readableBits.set(fieldIndex);
   }
   
+  /**
+   * Determines if an object is dirty or not based on its index
+   */
   public boolean isDirty(Persistent persistent, int fieldIndex) {
     return dirtyBits.get(fieldIndex);
   }
 
+  /**
+   * Determines if an object is dirty
+   */
   public boolean isDirty(Persistent persistent) {
     return !dirtyBits.isEmpty();
   }
   
   @Override
+  /**
+   * Sets an object as dirty
+   */
   public void setDirty(Persistent persistent) {
     dirtyBits.set(0, dirtyBits.size());
   }
   
   @Override
+  /**
+   * Marks a persistent object as not dirty using its index
+   */
   public void clearDirty(Persistent persistent, int fieldIndex) {
     dirtyBits.clear(fieldIndex);
   }
   
+  /**
+   * Marks all objects as not dirty
+   */
   public void clearDirty(Persistent persistent) {
     dirtyBits.clear();
   }
   
+  /**
+   * Sets a persistent object as readable using its index
+   */
   public void setReadable(Persistent persistent, int fieldIndex) {
     readableBits.set(fieldIndex);
   }
 
+  /**
+   * Determines if an object is readable using its index
+   */
   public boolean isReadable(Persistent persistent, int fieldIndex) {
     return readableBits.get(fieldIndex);
   }
 
   @Override
+  /**
+   * Marks an object as non-readable using its index
+   */
   public void clearReadable(Persistent persistent, int fieldIndex) {
     readableBits.clear(fieldIndex);
   }
   
+  /**
+   * Marks all objects as non-readable
+   */
   public void clearReadable(Persistent persistent) {
     readableBits.clear();
   }

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/PartitionWSQueryImpl.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/PartitionWSQueryImpl.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/PartitionWSQueryImpl.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/PartitionWSQueryImpl.java Wed Aug 29 17:31:01 2012
@@ -15,7 +15,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+/**
+ * @author Renato Marroquin
+ */
 package org.apache.gora.query.ws.impl;
 
 import java.util.Arrays;
@@ -28,20 +30,38 @@ import org.apache.gora.store.DataStore;
 /**
  * Implementation for {@link PartitionQuery}.
  */
+//TODO this class should be reviewed when a web service backed datastore has the
+// ability to write partition queries
 public class PartitionWSQueryImpl<K, T extends Persistent>
   extends QueryWSBase<K, T> implements PartitionQuery<K, T> {
 
+  /**
+   * Base query
+   */
   protected Query<K, T> baseQuery;
+  
+  /**
+   * The places where this query will be executed
+   */
   protected String[] locations;
 
+  /**
+   * Constructor
+   */
   public PartitionWSQueryImpl() {
     super(null);
   }
 
+  /**
+   * Constructor
+   */
   public PartitionWSQueryImpl(Query<K, T> baseQuery, String... locations) {
     this(baseQuery, null, null, locations);
   }
 
+  /**
+   * Constructor
+   */
   public PartitionWSQueryImpl(Query<K, T> baseQuery, K startKey, K endKey,
       String... locations) {
     super(baseQuery.getDataStore());
@@ -53,100 +73,123 @@ public class PartitionWSQueryImpl<K, T e
   }
 
   @Override
-public String[] getLocations() {
+  /**
+   * Gets the locations where this query will be executed
+   */
+  public String[] getLocations() {
     return locations;
   }
 
+  /**
+   * Gets the base query to be used
+   * @return
+   */
   public Query<K, T> getBaseQuery() {
     return baseQuery;
   }
 
   /* Override everything except start-key/end-key */
-
   @Override
+  /**
+   * Gets the fields used
+   */
   public String[] getFields() {
     return baseQuery.getFields();
   }
 
   @Override
+  /**
+   * Gets the data store used
+   */
   public DataStore<K, T> getDataStore() {
     return baseQuery.getDataStore();
   }
 
   @Override
+  /**
+   * Gets the timestamp used
+   */
   public long getTimestamp() {
     return baseQuery.getTimestamp();
   }
 
   @Override
+  /**
+   * Gets the start time used
+   */
   public long getStartTime() {
     return baseQuery.getStartTime();
   }
 
   @Override
+  /**
+   * Gets the end time used
+   */
   public long getEndTime() {
     return baseQuery.getEndTime();
   }
 
   @Override
+  /**
+   * Gets the results limit number used
+   */
   public long getLimit() {
     return baseQuery.getLimit();
   }
 
   @Override
+  /**
+   * Sets the fields to be retrieved
+   */
   public void setFields(String... fields) {
     baseQuery.setFields(fields);
   }
 
   @Override
+  /**
+   * Sets the timestamp used
+   */
   public void setTimestamp(long timestamp) {
     baseQuery.setTimestamp(timestamp);
   }
 
   @Override
+  /**
+   * Sets the start time used
+   */
   public void setStartTime(long startTime) {
     baseQuery.setStartTime(startTime);
   }
 
   @Override
+  /**
+   * Sets the end time used
+   */
   public void setEndTime(long endTime) {
     baseQuery.setEndTime(endTime);
   }
 
   @Override
+  /**
+   * Sets the time range used
+   */
   public void setTimeRange(long startTime, long endTime) {
     baseQuery.setTimeRange(startTime, endTime);
   }
 
   @Override
+  /**
+   * Sets the maximum number of records to be retrieved
+   */
   public void setLimit(long limit) {
     baseQuery.setLimit(limit);
   }
 
-  /*@Override
-  public void write(DataOutput out) throws IOException {
-    super.write(out);
-    IOUtils.serialize(null, out, baseQuery);
-    IOUtils.writeStringArray(out, locations);
-  }*/
-
-  /*@Override
-  public void readFields(DataInput in) throws IOException {
-    super.readFields(in);
-    try {
-      baseQuery = IOUtils.deserialize(null, in, null);
-    } catch (ClassNotFoundException ex) {
-      throw new IOException(ex);
-    }
-    locations = IOUtils.readStringArray(in);
-    //we should override the data store as basequery's data store
-    //also we may not call super.readFields so that temporary this.dataStore
-    //is not created at all
-    this.dataStore = baseQuery.getDataStore();
-  }*/
-
   @Override
   @SuppressWarnings({ "rawtypes" })
+  /**
+   * Determines if this object is equal to another one
+   */
   public boolean equals(Object obj) {
     if(obj instanceof PartitionWSQueryImpl) {
       PartitionWSQueryImpl that = (PartitionWSQueryImpl) obj;

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/QueryWSBase.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/QueryWSBase.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/QueryWSBase.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/QueryWSBase.java Wed Aug 29 17:31:01 2012
@@ -15,7 +15,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+/**
+ * @author Renato Marroquin 
+ */
 package org.apache.gora.query.ws.impl;
 
 import org.apache.commons.lang.builder.EqualsBuilder;
@@ -31,78 +33,137 @@ import org.apache.gora.store.DataStore;
  */
 public abstract class QueryWSBase<K, T extends Persistent> implements Query<K,T>{
 	
+  /**
+   * Data store used for this query
+   */
   protected DataStore<K,T> dataStore;
 
+  /**
+   * Query represented in a string
+   */
   protected String queryString;
+  
+  /**
+   * Fields to be retrieved
+   */
   protected String[] fields;
 
+  /**
+   * Range key parameters
+   */
   protected K startKey;
   protected K endKey;
 
+  /**
+   * Query time parameters
+   */
   protected long startTime = -1;
   protected long endTime = -1;
 
+  /**
+   * Query filter
+   */
   protected String filter;
 
+  /**
+   * Max number of results to be retrieved
+   */
   protected long limit = -1;
 
+  /**
+   * Flag to determine whether a query is compiled or not
+   */
   protected boolean isCompiled = false;
 
   /** Object that will hold user's authentication tokens for webservice database */
   private Object authentication;
 
+  /**
+   * Constructor
+   * @param dataStore
+   */
   public QueryWSBase(DataStore<K,T> dataStore) {
     this.dataStore = dataStore;
   }
 
   @Override
+  /**
+   * Executes the query
+   */
   public Result<K,T> execute() throws Exception {
     //compile();
     return dataStore.execute(this);
   }
 
   @Override
+  /**
+   * Sets the data store to be used
+   */
   public void setDataStore(DataStore<K, T> dataStore) {
     this.dataStore = dataStore;
   }
 
   @Override
+  /**
+   * Gets the data store used for querying
+   */
   public DataStore<K, T> getDataStore() {
     return dataStore;
   }
 
   @Override
+  /**
+   * Sets the fields to be retrieved
+   */
   public void setFields(String... fields) {
     this.fields = fields;
   }
 
   @Override
+  /**
+   * Gets the fields to be retrieved
+   */
   public String[] getFields() {
     return fields;
   }
 
   @Override
+  /**
+   * Sets the key to be used for querying
+   */
   public void setKey(K key) {
     setKeyRange(key, key);
   }
 
   @Override
+  /**
+   * Sets the start key to be used for querying
+   */
   public void setStartKey(K startKey) {
     this.startKey = startKey;
   }
 
   @Override
+  /**
+   * Sets the end key to be used for querying
+   */
   public void setEndKey(K endKey) {
     this.endKey = endKey;
   }
 
   @Override
+  /**
+   * Sets the range key to be used for querying
+   */
   public void setKeyRange(K startKey, K endKey) {
     this.startKey = startKey;
     this.endKey = endKey;
   }
 
   @Override
+  /**
+   * Gets the key to be used for querying
+   */
   public K getKey() {
     if(startKey == endKey) {
       return startKey; //address comparison
@@ -111,71 +172,115 @@ public abstract class QueryWSBase<K, T e
   }
 
   @Override
+  /**
+   * Gets the start key to be used for querying
+   */
   public K getStartKey() {
     return startKey;
   }
 
   @Override
+  /**
+   * Gets the end key to be used for querying
+   */
   public K getEndKey() {
     return endKey;
   }
 
   @Override
+  /**
+   * Sets the timestamp to be used for querying
+   */
   public void setTimestamp(long timestamp) {
     setTimeRange(timestamp, timestamp);
   }
 
   @Override
+  /**
+   * Sets the start time for querying
+   */
   public void setStartTime(long startTime) {
     this.startTime = startTime;
   }
 
   @Override
+  /**
+   * Sets the end time for querying
+   */
   public void setEndTime(long endTime) {
     this.endTime = endTime;
   }
 
   @Override
+  /**
+   * Sets the range time for querying
+   */
   public void setTimeRange(long startTime, long endTime) {
     this.startTime = startTime;
     this.endTime = endTime;
   }
 
   @Override
+  /**
+   * Gets the timestamp set
+   */
   public long getTimestamp() {
     return startTime == endTime ? startTime : -1;
   }
 
   @Override
+  /**
+   * Gets the start time
+   */
   public long getStartTime() {
     return startTime;
   }
 
   @Override
+  /**
+   * Gets the end time
+   */
   public long getEndTime() {
     return endTime;
   }
 
   @Override
+  /**
+   * Sets the limit of results to be gotten
+   */
   public void setLimit(long limit) {
     this.limit = limit;
   }
 
   @Override
+  /**
+   * Gets the number limit of this query
+   */
   public long getLimit() {
     return limit;
   }
 
+  /**
+   * Gets the configuration object
+   * @return
+   */
   public Object getConf() {
     return authentication;
   }
 
+  /**
+   * Sets the configuration object
+   * @param auth
+   */
   public void setConf(Object auth) {
     this.authentication = auth;
   }
  
   @SuppressWarnings({ "rawtypes" })
   @Override
+  /**
+   * Determines if this object is equal to a different one
+   */
   public boolean equals(Object obj) {
     if(obj instanceof QueryWSBase) {
       QueryWSBase that = (QueryWSBase) obj;
@@ -193,6 +298,9 @@ public abstract class QueryWSBase<K, T e
   }
 
   @Override
+  /**
+   * Retrieves the object as hash code
+   */
   public int hashCode() {
     HashCodeBuilder builder = new HashCodeBuilder();
     builder.append(dataStore);
@@ -206,6 +314,9 @@ public abstract class QueryWSBase<K, T e
   }
 
   @Override
+  /**
+   * Convets an object to string
+   */
   public String toString() {
     ToStringBuilder builder = new ToStringBuilder(this);
     builder.append("dataStore", dataStore);

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/ResultWSBase.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/ResultWSBase.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/ResultWSBase.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/query/ws/impl/ResultWSBase.java Wed Aug 29 17:31:01 2012
@@ -15,6 +15,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+/**
+ * @author Renato Marroquin 
+ */
 
 package org.apache.gora.query.ws.impl;
 
@@ -31,12 +34,24 @@ import org.apache.gora.store.DataStore;
 public abstract class ResultWSBase<K, T extends Persistent> 
   implements Result<K, T> {
 
+  /**
+   * Data store used
+   */
   protected final DataStore<K,T> dataStore;
   
+  /**
+   * Query for obtaining this result
+   */
   protected final Query<K, T> query;
   
+  /**
+   * Key
+   */
   protected K key;
   
+  /**
+   * Persistent object
+   */
   protected T persistent;
   
   /** Query limit */
@@ -45,6 +60,11 @@ public abstract class ResultWSBase<K, T 
   /** How far we have proceeded*/
   protected long offset = 0;
   
+  /**
+   * Constructor
+   * @param dataStore
+   * @param query
+   */
   public ResultWSBase(DataStore<K,T> dataStore, Query<K,T> query) {
     this.dataStore = dataStore;
     this.query = query;
@@ -52,31 +72,49 @@ public abstract class ResultWSBase<K, T 
   }
   
   @Override
+  /**
+   * Gets the data store used for retrieving this result
+   */
   public DataStore<K, T> getDataStore() {
     return dataStore;
   }
   
   @Override
+  /**
+   * Gets the query used for this result
+   */
   public Query<K, T> getQuery() {
     return query;
   }
   
   @Override
+  /**
+   * Gets the persistent object
+   */
   public T get() {
     return persistent;
   }
   
   @Override
+  /**
+   * Gets the key
+   */
   public K getKey() {
     return key;
   }
     
   @Override
+  /**
+   * Gets the key class
+   */
   public Class<K> getKeyClass() {
     return getDataStore().getKeyClass();
   }
   
   @Override
+  /**
+   * Gets the persistent object class
+   */
   public Class<T> getPersistentClass() {
     return getDataStore().getPersistentClass();
   }
@@ -91,6 +129,9 @@ public abstract class ResultWSBase<K, T 
     return false;
   }
   
+  /**
+   * Clears the persistent object
+   */
   protected void clear() {
     if(persistent != null) {
       persistent.clear();
@@ -101,6 +142,9 @@ public abstract class ResultWSBase<K, T 
   }
   
   @Override
+  /**
+   * Returnts the next object from the result's lists
+   */
   public final boolean next() throws Exception {
 	  if(isLimitReached()) {
 		  return false;
@@ -116,6 +160,9 @@ public abstract class ResultWSBase<K, T 
   }
   
   @Override
+  /**
+   * Gets the offset inside the result's list
+   */
   public long getOffset() {
     return offset;
   }
@@ -126,6 +173,13 @@ public abstract class ResultWSBase<K, T 
    */
   protected abstract boolean nextInner() throws Exception; 
   
+  /**
+   * Creates an object if it does not exists
+   * @param persistent  Object to be created if it does not exist
+   * @return
+   * @throws Exception
+   * @throws IOException
+   */
   protected T getOrCreatePersistent(T persistent) throws Exception, IOException {
 	  if(persistent != null) {
 			return persistent;

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/DataStore.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/DataStore.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/DataStore.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/DataStore.java Wed Aug 29 17:31:01 2012
@@ -214,8 +214,8 @@ public interface DataStore<K, T> {
    */
   void close()  throws IOException, InterruptedException, Exception;
 
-  //void readFields() throws Exception;
+  //void readFields(Object in) throws Exception;
   
-  //void write() throws IOException;
+  //void write() throws Exception;
 
 }

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/WebServiceBackedDataStore.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/WebServiceBackedDataStore.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/WebServiceBackedDataStore.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/WebServiceBackedDataStore.java Wed Aug 29 17:31:01 2012
@@ -20,7 +20,8 @@ package org.apache.gora.store;
 
 import org.apache.gora.persistency.Persistent;
 
-/** FileBackedDataStore supplies necessary interfaces to set input 
+/** 
+ * FileBackedDataStore supplies necessary interfaces to set input 
  * and output paths for data stored which are file based.   
  */
 public interface WebServiceBackedDataStore<K, T extends Persistent> extends DataStore<K, T> {

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/DataStoreBase.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/DataStoreBase.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/DataStoreBase.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/DataStoreBase.java Wed Aug 29 17:31:01 2012
@@ -176,7 +176,6 @@ implements DataStore<K, T>, Configurable
     return conf;
   }
 
-  //@Override
   @SuppressWarnings("unchecked")
   public void readFields(DataInput in) throws IOException {
     try {
@@ -189,7 +188,6 @@ implements DataStore<K, T>, Configurable
     }
   }
 
-  //@Override
   public void write(DataOutput out) throws IOException {
     Text.writeString(out, getKeyClass().getCanonicalName());
     Text.writeString(out, getPersistentClass().getCanonicalName());

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/FileBackedDataStoreBase.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/FileBackedDataStoreBase.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/FileBackedDataStoreBase.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/impl/FileBackedDataStoreBase.java Wed Aug 29 17:31:01 2012
@@ -158,7 +158,7 @@ public InputStream getInputStream() {
   @Override
   public Result<K, T> execute(Query<K, T> query) throws IOException {
     if(query instanceof FileSplitPartitionQuery) {
-        return executePartial((FileSplitPartitionQuery<K, T>) query);
+      return executePartial((FileSplitPartitionQuery<K, T>) query);
     } else {
       return executeQuery(query);
     }

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSBackedDataStoreBase.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSBackedDataStoreBase.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSBackedDataStoreBase.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSBackedDataStoreBase.java Wed Aug 29 17:31:01 2012
@@ -15,7 +15,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+/**
+ * @author Renato Marroquin
+ */
 package org.apache.gora.store.ws.impl;
 
 import java.io.IOException;
@@ -24,30 +26,31 @@ import java.util.Properties;
 import org.apache.gora.persistency.Persistent;
 import org.apache.gora.query.Query;
 import org.apache.gora.query.Result;
-import org.apache.gora.store.FileBackedDataStore;
 import org.apache.gora.store.WebServiceBackedDataStore;
 import org.apache.gora.util.OperationNotSupportedException;
 
 /**
- * Base implementations for {@link FileBackedDataStore} methods.
+ * Base implementations for {@link WebServiceBackedDataStore} methods.
  */
 public abstract class WSBackedDataStoreBase<K, T extends Persistent>
   extends WSDataStoreBase<K, T> implements WebServiceBackedDataStore<K, T> {
 
   @Override
+  /**
+   * Initializes a web service backed data store
+   */
   public void initialize(Class<K> keyClass, Class<T> persistentClass,
       Properties properties) throws Exception {
     super.initialize(keyClass, persistentClass, properties);
-    //if(properties != null) {
-    //}
   }
+
   @Override
+  /**
+   * Executes a query inside a web service backed data store
+   */
   public Result<K, T> execute(Query<K, T> query) throws Exception {
-   /* if(query instanceof PartitionWSQueryImpl) {
-        return executePartial((FileSplitPartitionQuery<K, T>) query);
-    } else {*/
-      return executeQuery(query);
-    //}
+    // TODO We could have different types of execution {@link FileBackedDataStoreBase}
+    return executeQuery(query);
   }
 
   /**
@@ -57,48 +60,57 @@ public abstract class WSBackedDataStoreB
   protected abstract Result<K,T> executeQuery(Query<K,T> query)
     throws Exception;
 
+  @Override
   /**
-   * Executes a PartitialQuery, reading the data between start and end.
+   * Flushes objects into the data store
    */
-  //protected abstract Result<K,T> executePartial(FileSplitPartitionQuery<K,T> query)
-  //  throws Exception;
-
-  @Override
   public void flush() throws Exception {
   }
 
   @Override
+  /**
+   * Creates schema into the data store
+   */
   public void createSchema() throws Exception{
   }
 
   @Override
+  /**
+   * Deletes schema from the data store
+   */
   public void deleteSchema() throws Exception {
     throw new OperationNotSupportedException("delete schema is not supported for " +
     		"file backed data stores");
   }
 
   @Override
+  /**
+   * Verifies if a schema exists
+   */
   public boolean schemaExists() throws Exception {
     return true;
   }
 
   @Override
+  /**
+   * Writes an object into the data
+   */
   public void write(Object out) throws Exception {
     super.write(out);
-    //if(wsProvider != null)
-      // make write request
-    
   }
 
   @Override
+  /**
+   * Reads fields from an object
+   */
   public void readFields(Object in) throws Exception {
     super.readFields(in);
-    //if(wsProvider != null)
-    // make read request
   }
 
-  // TODO this could be close connection
   @Override
+  /**
+   * Closes the data store
+   */
   public void close() throws IOException, InterruptedException, Exception {
   }
 }

Modified: gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java (original)
+++ gora/branches/goraamazon/gora-core/src/main/java/org/apache/gora/store/ws/impl/WSDataStoreBase.java Wed Aug 29 17:31:01 2012
@@ -15,7 +15,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+/**
+ * @author Renato Marroquin
+ */
 package org.apache.gora.store.ws.impl;
 
 import java.util.Properties;
@@ -25,110 +27,84 @@ import org.apache.gora.store.DataStore;
 import org.apache.gora.util.StringUtils;
 
 /**
- * A Base class for Avro persistent {@link DataStore}s.
+ * A Base class for persistent objects{@link DataStore}s.
  */
 public abstract class WSDataStoreBase<K, T extends Persistent>
 implements DataStore<K, T>{
 	
-  //protected BeanFactory<K, T> beanFactory;
-
+  /**
+   * Class of the key to be used
+   */
   protected Class<K> keyClass;
+  
+  /**
+   * Class of the persistent object
+   */
   protected Class<T> persistentClass;
 
-  /** The web service provider's name*/
+  /** 
+   * The web service provider's name
+   */
   private String wsProvider;
 
-  /** A map of field names to Field objects containing schema's fields 
-  protected Map<String, Field> fieldMap; */
-
-  /** The authentication object to be used for our provider*/
+  /** 
+   * The authentication object to be used for our provider
+   */
   protected Object authentication;
 
-  /** Properties object */
+  /** 
+   * Properties object 
+   */
   protected Properties properties;
-  
-  //TODO see if a webservice database will have these persistent datums
-  //protected PersistentDatumReader<T> datumReader;
-  //protected PersistentDatumWriter<T> datumWriter;
 
+  /**
+   * Default constructor
+   */
   public WSDataStoreBase() {
   }
 
   @Override
+  /**
+   * Initializes the web services backed data store
+   */
   public void initialize(Class<K> keyClass, Class<T> persistentClass,
       Properties properties) throws Exception {
     setKeyClass(keyClass);
     setPersistentClass(persistentClass);
-    //TODO See if we need to create a factory to manage our beans
-    //if(this.beanFactory == null)
-    //  this.beanFactory = new BeanFactoryImpl<K, T>(keyClass, persistentClass);
   }
 
   @Override
+  /**
+   * Sets the persistent class to be used
+   */
   public void setPersistentClass(Class<T> persistentClass) {
     this.persistentClass = persistentClass;
   }
 
   @Override
+  /**
+   * Gets the persistent class being used
+   */
   public Class<T> getPersistentClass() {
     return persistentClass;
   }
 
   @Override
+  /**
+   * Gets the key class being used
+   */
   public Class<K> getKeyClass() {
     return keyClass;
   }
 
   @Override
+  /**
+   * Sets the key class to be used
+   */
   public void setKeyClass(Class<K> keyClass) {
     if(keyClass != null)
       this.keyClass = keyClass;
   }
-  /*
-  @Override
-  public K newKey() throws IOException {
-    try {
-      return beanFactory.newKey();
-    } catch (Exception ex) {
-      throw new IOException(ex);
-    }
-  }
-
-  @Override
-  public T newPersistent() throws IOException {
-    try {
-      return beanFactory.newPersistent();
-    } catch (Exception ex) {
-      throw new IOException(ex);
-    }
-  }
-
-  @Override
-  public void setBeanFactory(BeanFactory<K, T> beanFactory) {
-    this.beanFactory = beanFactory;
-  }
-
-  @Override
-  public BeanFactory<K, T> getBeanFactory() {
-    return beanFactory;
-  }
-
-  @Override
-  public T get(K key) throws Exception {
-    return get(key, getFieldsToQuery(null));
-  };
-*/
-  /**
-   * Checks whether the fields argument is null, and if so
-   * returns all the fields of the Persistent object, else returns the
-   * argument.
-   */
-  /*protected String[] getFieldsToQuery(String[] fields) {
-    if(fields != null) {
-      return fields;
-    }
-    return beanFactory.getCachedPersistent().getFields();
-  }*/
 
   /**
    * Gets the configuration (authentication) object
@@ -144,39 +120,29 @@ implements DataStore<K, T>{
   public void setConf(Object auth) {
     this.authentication = auth;
   }
-
-  //@Override
-  //@SuppressWarnings("unchecked")
-  public void readFields(Object in) throws Exception {
-  /*  try {
-      Class<K> keyClass = (Class<K>) ClassLoadingUtils.loadClass(Text.readString(in));
-      Class<T> persistentClass = (Class<T>)ClassLoadingUtils.loadClass(Text.readString(in));
-      Properties props = WritableUtils.readProperties(in);
-      initialize(keyClass, persistentClass, props);
-    } catch (ClassNotFoundException ex) {
-      throw new IOException(ex);
-    }
-    */
+  
+  /**
+   * Reads fields from an object
+   * @param obj
+   * @throws Exception
+   */
+  public void readFields(Object obj) throws Exception {
   }
 
-  //@Override
+  /**
+   * Writes an object
+   * @param obj
+   * @throws Exception
+   */
   public void write(Object obj) throws Exception {
-    /*Text.writeString(out, getKeyClass().getCanonicalName());
-    Text.writeString(out, getPersistentClass().getCanonicalName());
-    WritableUtils.writeProperties(out, properties);
-    */
   }
 
   @Override
   public boolean equals(Object obj) {
     if(obj instanceof WSDataStoreBase) {
       @SuppressWarnings("rawtypes")
-	  WSDataStoreBase that = (WSDataStoreBase) obj;
-      return that.equals(obj);
-     /* EqualsBuilder builder = new EqualsBuilder();
-      builder.append(this.keyClass, that.keyClass);
-      builder.append(this.persistentClass, that.persistentClass);
-      return builder.isEquals();*/
+      WSDataStoreBase that = (WSDataStoreBase) obj;
+      return that.equals(this);
     }
     return false;
   }
@@ -210,11 +176,19 @@ implements DataStore<K, T>{
     return StringUtils.getClassname(persistentClass);
   }
 
+  /**
+   * Gets web service provider name
+   * @return
+   */
   public String getWSProvider() {
-	return wsProvider;
+    return wsProvider;
   }
 
+  /**
+   * Sets web service provider name
+   * @param wsProvider
+   */
   public void setWsProvider(String wsProvider) {
-	this.wsProvider = wsProvider;
+    this.wsProvider = wsProvider;
   }
 }

Modified: gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java (original)
+++ gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/compiler/GoraDynamoDBCompiler.java Wed Aug 29 17:31:01 2012
@@ -99,15 +99,15 @@ public class GoraDynamoDBCompiler {
   private void setItems(List<Map<String, String>> pItems, int pIden) throws IOException{
     for(Map<String, String> item : pItems){
       for (String itemName : item.keySet()){
-	String itemType = "String";
-	if (item.get(itemName).toString().equals("N"))
-	itemType = "double";
-	if (item.get(itemName).toString().equals("SS"))
-	itemType = "Set<String>";
-	if (item.get(itemName).toString().equals("SN"))
-	itemType = "Set<double>";
-	line(pIden, "private " + itemType + " " + itemName + ";");
-	setItemMethods(itemName, itemType, pIden);
+        String itemType = "String";
+        if (item.get(itemName).toString().equals("N"))
+          itemType = "double";
+        if (item.get(itemName).toString().equals("SS"))
+          itemType = "Set<String>";
+        if (item.get(itemName).toString().equals("SN"))
+          itemType = "Set<double>";
+        line(pIden, "private " + itemType + " " + itemName + ";");
+        setItemMethods(itemName, itemType, pIden);
       }
     }
     line(0, "");

Modified: gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBMapping.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBMapping.java?rev=1378656&r1=1378655&r2=1378656&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBMapping.java (original)
+++ gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBMapping.java Wed Aug 29 17:31:01 2012
@@ -61,19 +61,20 @@ public class DynamoDBMapping {
    * @param provisionedThroughput	Provisioned throughput used within tables mapped.
    */
   public DynamoDBMapping(Map<String, List<Map<String, String>>> tables,
-	      				Map<String, KeySchema> tablesToKeySchemas,
-	      				Map<String, ProvisionedThroughput> provisionedThroughput) {
-	    this.tablesToItems = tables;
-	    this.tablesToKeySchemas = tablesToKeySchemas;
-	    this.tablesToPrTh = provisionedThroughput;
-	  }
+    Map<String, KeySchema> tablesToKeySchemas,
+    Map<String, ProvisionedThroughput> provisionedThroughput) {
+    
+    this.tablesToItems = tables;
+    this.tablesToKeySchemas = tablesToKeySchemas;
+    this.tablesToPrTh = provisionedThroughput;
+  }
 
   /**
    * Gets the tables with their own items
    * @return tablesToItem HashMap 
    */
   public Map<String,List<Map<String, String>>> getTables(){
-	  return tablesToItems;
+    return tablesToItems;
   }
   
   /**
@@ -82,7 +83,7 @@ public class DynamoDBMapping {
    * @return
    */
   public List<Map<String, String>> getItems(String tableName){
-	  return tablesToItems.get(tableName);
+    return tablesToItems.get(tableName);
   }
 
   /**
@@ -100,7 +101,7 @@ public class DynamoDBMapping {
    * @return
    */
   public ProvisionedThroughput getProvisionedThroughput(String tableName){
-	  return tablesToPrTh.get(tableName);
+    return tablesToPrTh.get(tableName);
   }
   
   /**
@@ -110,203 +111,202 @@ public class DynamoDBMapping {
    */
   public static class DynamoDBMappingBuilder {
 
-	  /**
-	   * Table name to be used to build the DynamoDBMapping object 
-	   */
-	  private String tableName;
-	  
-	  /**
-	   * This data structure can hold several tables, with their own items.
-	   * Map<TableName, List<Map<AttributeName,AttributeType>>
-	   */
-	  private Map<String, List<Map<String, String>>> tablesToItems = 
-			  new HashMap<String, List<Map<String, String>>>();
-	  
-	  private Map<String, KeySchema> tablesToKeySchemas = 
-			  new HashMap<String, KeySchema>();
-	  
-	  private Map<String, ProvisionedThroughput> tablesToPrTh =
-			  new HashMap<String, ProvisionedThroughput>();
-	  
-	  public void setTableName(String tabName){
-		  tableName = tabName;
-	  }
-	  
-	  /**
-	   * Gets the table name for which the table is being mapped
-	   * @param tableName
-	   * @return
-	   */
-	  public String getTableName(String tableName){
-		  return tableName;
-	  }
-	  
-	  /**
-	   * Sets the provisioned throughput for the specified table
-	   * @param tableName
-	   * @param readCapUnits
-	   * @param writeCapUnits
-	   */
-	  public void setProvisionedThroughput(String tableName, long readCapUnits, long writeCapUnits){
-		  ProvisionedThroughput ptDesc = new ProvisionedThroughput()
-		  													.withReadCapacityUnits(readCapUnits)
-		  													.withWriteCapacityUnits(writeCapUnits);
-		  tablesToPrTh.put(tableName, ptDesc);
-	  }
-	  
-	  /**
-	   * Sets the hash range key schema for the specified table
-	   * @param tableName
-	   * @param rangeKeyName
-	   * @param rangeKeyType
-	   */
-	  public void setHashRangeKeySchema(String tableName, String rangeKeyName, String rangeKeyType){
-		  KeySchema kSchema = tablesToKeySchemas.get(tableName);
-		  if ( kSchema == null)
-			  kSchema = new KeySchema();
-		   
-	      KeySchemaElement rangeKeyElement = new KeySchemaElement().
-	    		  										withAttributeName(rangeKeyName).
-	    			  									withAttributeType(rangeKeyType);
-	      kSchema.setRangeKeyElement(rangeKeyElement);
-	      tablesToKeySchemas.put(tableName, kSchema);
-	  }
-	  
-	  /**
-	   * Sets the hash key schema for the specified table
-	   * @param tableName
-	   * @param keyName
-	   * @param keyType
-	   */
-	  public void setHashKeySchema(String tableName, String keyName, String keyType){
-		  KeySchema kSchema = tablesToKeySchemas.get(tableName);
-		  if ( kSchema == null)
-			  kSchema = new KeySchema();
-		  
-		  KeySchemaElement hashKey = new KeySchemaElement().
-	    			  					 		withAttributeName(keyName).
-	    			  					 		withAttributeType(keyType);
-	      kSchema.setHashKeyElement(hashKey);
-		  tablesToKeySchemas.put(tableName, kSchema);
-	  }
-	  
-	  /**
-	   * Checks if a table exists, and if doesn't exist it creates the new table. 
-	   * @param tableName
-	   * @return The table identified by the parameter
-	   */
-	  private List<Map<String, String>> getOrCreateTable(String tableName) {
-	      
-    	List<Map<String, String>> items = tablesToItems.get(tableName);
-	    if (items == null) {
-	      items = new ArrayList<Map<String, String>>();
-	      tablesToItems.put(tableName, items);
-	    }
-	    return items;
-	  }
-	  
-      /**
-       * Gets the attribute for a specific item. The idea is to be able to get different items with different attributes.
-       * TODO This method is incomplete because the itemNumber might not be present and this would be a problem
-       * @param items
-       * @param itemNumber
-       * @return
-       */
-	  private HashMap<String, String> getOrCreateItemAttribs(List<Map<String, String>> items, int itemNumber){
-    	  HashMap<String, String> itemAttribs;
-    	  
-    	  if (items.isEmpty())
-    		  items.add(new HashMap<String, String>());
-    	  
-    	  itemAttribs = (HashMap<String, String>) items.get(itemNumber);
-    	  if (itemAttribs == null)
-    		  items.add(new HashMap<String, String>());
-    	  
-    	  return (HashMap<String, String>) items.get(itemNumber);
-    	  
+    /**
+     * Table name to be used to build the DynamoDBMapping object 
+     */
+    private String tableName;
+	  
+    /**
+     * This data structure can hold several tables, with their own items.
+     * Map<TableName, List<Map<AttributeName,AttributeType>>
+     */
+    private Map<String, List<Map<String, String>>> tablesToItems = 
+      new HashMap<String, List<Map<String, String>>>();
+	
+    /**
+     * Maps tables to key schemas
+     */
+    private Map<String, KeySchema> tablesToKeySchemas = new HashMap<String, KeySchema>();
+	
+    /**
+     * Maps tables to provisioned throughput
+     */
+    private Map<String, ProvisionedThroughput> tablesToPrTh = new HashMap<String, ProvisionedThroughput>();
+	  
+    /**
+     * Sets table name
+     * @param tabName
+     */
+    public void setTableName(String tabName){
+      tableName = tabName;
+    }
+	  
+    /**
+     * Gets the table name for which the table is being mapped
+     * @param tableName
+     * @return
+     */
+    public String getTableName(String tableName){
+      return tableName;
+    }
+	  
+    /**
+     * Sets the provisioned throughput for the specified table
+     * @param tableName
+     * @param readCapUnits
+     * @param writeCapUnits
+     */
+    public void setProvisionedThroughput(String tableName, long readCapUnits, long writeCapUnits){
+      ProvisionedThroughput ptDesc = 
+      new ProvisionedThroughput().withReadCapacityUnits(readCapUnits).withWriteCapacityUnits(writeCapUnits);
+      tablesToPrTh.put(tableName, ptDesc);
+    }
+	  
+    /**
+     * Sets the hash range key schema for the specified table
+     * @param tableName
+     * @param rangeKeyName
+     * @param rangeKeyType
+     */
+    public void setHashRangeKeySchema(String tableName, String rangeKeyName, String rangeKeyType){
+      KeySchema kSchema = tablesToKeySchemas.get(tableName);
+      if ( kSchema == null)
+        kSchema = new KeySchema();
+   
+	KeySchemaElement rangeKeyElement = 
+	new KeySchemaElement().withAttributeName(rangeKeyName).withAttributeType(rangeKeyType);
+	kSchema.setRangeKeyElement(rangeKeyElement);
+	tablesToKeySchemas.put(tableName, kSchema);
+    }
+	  
+    /**
+     * Sets the hash key schema for the specified table
+     * @param tableName
+     * @param keyName
+     * @param keyType
+     */
+    public void setHashKeySchema(String tableName, String keyName, String keyType){
+      KeySchema kSchema = tablesToKeySchemas.get(tableName);
+        if ( kSchema == null)
+	  kSchema = new KeySchema();
+	  KeySchemaElement hashKey = 
+	  new KeySchemaElement().withAttributeName(keyName).withAttributeType(keyType);
+          kSchema.setHashKeyElement(hashKey);
+	  tablesToKeySchemas.put(tableName, kSchema);
+    }
+	  
+    /**
+     * Checks if a table exists, and if doesn't exist it creates the new table. 
+     * @param tableName
+     * @return The table identified by the parameter
+     */
+    private List<Map<String, String>> getOrCreateTable(String tableName) {
+      
+      List<Map<String, String>> items = tablesToItems.get(tableName);
+      if (items == null) {
+        items = new ArrayList<Map<String, String>>();
+        tablesToItems.put(tableName, items);
       }
+      return items;
+    }
+	  
+    /**
+     * Gets the attribute for a specific item. The idea is to be able to get different items with different attributes.
+     * TODO This method is incomplete because the itemNumber might not be present and this would be a problem
+     * @param items
+     * @param itemNumber
+     * @return
+     */
+    private HashMap<String, String> getOrCreateItemAttribs(List<Map<String, String>> items, int itemNumber){
+      HashMap<String, String> itemAttribs;
+   	  
+      if (items.isEmpty())
+        items.add(new HashMap<String, String>());
+   	  
+   	itemAttribs = (HashMap<String, String>) items.get(itemNumber);
+   	if (itemAttribs == null)
+   	  items.add(new HashMap<String, String>());
+   	  return (HashMap<String, String>) items.get(itemNumber);
+    }
       
-	  /**
-	   * Adds an attribute to an specific item
-	   * @param tableName
-	   * @param attributeName
-	   * @param attrType
-	   * @param itemNumber
-	   */
-	  public void addAttribute(String tableName, String attributeName, String attrType, int itemNumber) {
-	    // selecting table
-	    List<Map<String, String>> items = getOrCreateTable(tableName);
-	    // add attribute to item
-	    HashMap<String, String> itemAttribs = getOrCreateItemAttribs(items, itemNumber);
-	    itemAttribs.put(attributeName, attrType);
-    	//items.add(itemAttribs);
-	    // add item to table
-	    //tablesToItems.put(tableName, items);
-	  }
-	  
-	  /**
-	   * Method to verify whether or not the schemas have been initialized
-	   * @return
-	   */
-	  private String verifyAllKeySchemas(){
-		  
-		  String wrongTable = "";
-		  // if there are not tables defined
-		  if (tablesToItems.isEmpty()) return "";
-		  
-		  for(String tableName : tablesToItems.keySet()){
-			  // if there are not schemas defined
-			  if (tablesToKeySchemas.isEmpty()) return "";
-			  if (!verifyKeySchema(tableName)) return "";
-		  }
-		  
-		  return wrongTable;
-		  
-	  }
-	  
-	  /**
-	   * Verifies is a table has a key schema defined
-	   * @param tableName	Table name to determine which key schema to obtain 
-	   * @return
-	   */
-	  private boolean verifyKeySchema(String tableName){
-		  KeySchema kSchema = tablesToKeySchemas.get(tableName);
-		  
-		  if (kSchema == null) 
-			  return false;
+    /**
+     * Adds an attribute to an specific item
+     * @param tableName
+     * @param attributeName
+     * @param attrType
+     * @param itemNumber
+     */
+     public void addAttribute(String tableName, String attributeName, String attrType, int itemNumber) {
+       // selecting table
+       List<Map<String, String>> items = getOrCreateTable(tableName);
+       // add attribute to item
+       HashMap<String, String> itemAttribs = getOrCreateItemAttribs(items, itemNumber);
+       itemAttribs.put(attributeName, attrType);
+       //items.add(itemAttribs);
+       // add item to table
+       //tablesToItems.put(tableName, items);
+     }
+	  
+    /**
+     * Method to verify whether or not the schemas have been initialized
+     * @return
+     */
+    private String verifyAllKeySchemas(){
+	  
+      String wrongTable = "";
+      // if there are not tables defined
+      if (tablesToItems.isEmpty()) return "";
+        for(String tableName : tablesToItems.keySet()){
+	  // if there are not schemas defined
+	  if (tablesToKeySchemas.isEmpty()) return "";
+	    if (!verifyKeySchema(tableName)) return "";
+        }
+      return wrongTable;
+    }
+	  
+    /**
+     * Verifies is a table has a key schema defined
+     * @param tableName	Table name to determine which key schema to obtain 
+     * @return
+     */
+    private boolean verifyKeySchema(String tableName){
+      KeySchema kSchema = tablesToKeySchemas.get(tableName);
+	  
+      if (kSchema == null) 
+        return false;
 			  
-		  KeySchemaElement rangeKey = kSchema.getRangeKeyElement();
-		  KeySchemaElement hashKey = kSchema.getHashKeyElement();
-		  // A range key must have a hash key as well
-		  if (rangeKey != null){
-			  if (hashKey != null)	
-				  return true;
-			  else 	  
-				  return false;
-		  }
-		  // A hash key may exist by itself
-		  if (hashKey != null)	  
-			  return true;
-		  return false;
-	  }
-	  
-	  /**
-	   * Constructs the DynamoDBMapping object
-	   * @return A newly constructed mapping.
-	   */
-	  public DynamoDBMapping build() {
-		  
-		  if (tableName == null) throw new IllegalStateException("tableName is not specified");
-	    
-		  // verifying items for at least a table
-		  if (tablesToItems.isEmpty()) throw new IllegalStateException("No tables");
-	      
-		  // verifying if key schemas have been properly defined
-		  String wrongTableName = verifyAllKeySchemas();  
-		  if (!wrongTableName.equals("")) throw new IllegalStateException("no key schemas defined for table " + wrongTableName);
-	     
-		  // Return the tableDescription and all the attributes needed
-	      return new DynamoDBMapping(tablesToItems,tablesToKeySchemas, tablesToPrTh);
-	  }
+	KeySchemaElement rangeKey = kSchema.getRangeKeyElement();
+	KeySchemaElement hashKey = kSchema.getHashKeyElement();
+	// A range key must have a hash key as well
+	if (rangeKey != null){
+	  if (hashKey != null)	
+	    return true;
+	  else 	  
+	    return false;
+	}
+	// A hash key may exist by itself
+	if (hashKey != null)	  
+	  return true;
+	  return false;
+    }
+	  
+    /**
+     * Constructs the DynamoDBMapping object
+     * @return A newly constructed mapping.
+     */
+    public DynamoDBMapping build() {
+	  
+      if (tableName == null) throw new IllegalStateException("tableName is not specified");
+    
+        // verifying items for at least a table
+        if (tablesToItems.isEmpty()) throw new IllegalStateException("No tables");
+      
+	  // verifying if key schemas have been properly defined
+	  String wrongTableName = verifyAllKeySchemas();  
+	  if (!wrongTableName.equals("")) throw new IllegalStateException("no key schemas defined for table " + wrongTableName);
+     
+	    // Return the tableDescription and all the attributes needed
+            return new DynamoDBMapping(tablesToItems,tablesToKeySchemas, tablesToPrTh);
+    }
   }
 }



Mime
View raw message