incubator-gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattm...@apache.org
Subject svn commit: r1170035 - in /incubator/gora/trunk/gora-core/src: main/java/org/apache/gora/store/DataStore.java test/java/org/apache/gora/store/DataStoreTestUtil.java
Date Tue, 13 Sep 2011 04:53:10 GMT
Author: mattmann
Date: Tue Sep 13 04:53:10 2011
New Revision: 1170035

URL: http://svn.apache.org/viewvc?rev=1170035&view=rev
Log:
Apply patch for GORA-12: Semantics of DataStore.delete* contributed by Andrzej Bialecki.

Modified:
    incubator/gora/trunk/gora-core/src/main/java/org/apache/gora/store/DataStore.java
    incubator/gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java

Modified: incubator/gora/trunk/gora-core/src/main/java/org/apache/gora/store/DataStore.java
URL: http://svn.apache.org/viewvc/incubator/gora/trunk/gora-core/src/main/java/org/apache/gora/store/DataStore.java?rev=1170035&r1=1170034&r2=1170035&view=diff
==============================================================================
--- incubator/gora/trunk/gora-core/src/main/java/org/apache/gora/store/DataStore.java (original)
+++ incubator/gora/trunk/gora-core/src/main/java/org/apache/gora/store/DataStore.java Tue
Sep 13 04:53:10 2011
@@ -39,6 +39,10 @@ import org.apache.hadoop.io.Writable;
  * constructed by an instance of {@link DataStoreFactory}.
  *
  * <p> DataStores implementations should be thread safe.
+ * <p><a name="visibility"><b>Note:</b> Results of updates ({@link
#put(Object, Persistent)},
+ * {@link #delete(Object)} and {@link #deleteByQuery(Query)} operations) are
+ * guaranteed to be visible to subsequent get / execute operations ONLY
+ * after a subsequent call to {@link #flush()}.
  * @param <K> the class of keys in the datastore
  * @param <T> the class of persistent objects in the datastore
  */
@@ -143,19 +147,23 @@ public interface DataStore<K, T extends 
   T get(K key, String[] fields) throws IOException;
 
   /**
-   * Inserts the persistent object with the given key.
+   * Inserts the persistent object with the given key. If an 
+   * object with the same key already exists it will silently
+   * be replaced. See also the note on 
+   * <a href="#visibility">visibility</a>.
    */
   void put(K key, T obj) throws IOException;
 
   /**
    * Deletes the object with the given key
    * @param key the key of the object
-   * @return whether deleted the object successfuly
+   * @return whether the object was successfully deleted
    */
   boolean delete(K key) throws IOException;
 
   /**
    * Deletes all the objects matching the query.
+   * See also the note on <a href="#visibility">visibility</a>.
    * @param query matching records to this query will be deleted
    * @return number of deleted records
    */
@@ -186,7 +194,10 @@ public interface DataStore<K, T extends 
     throws IOException;
 
   /**
-   * Forces the write caches to be flushed.
+   * Forces the write caches to be flushed. DataStore implementations may
+   * optimize their writing by deferring the actual put / delete operations
+   * until this moment.
+   * See also the note on <a href="#visibility">visibility</a>.
    */
   void flush() throws IOException;
 
@@ -202,6 +213,12 @@ public interface DataStore<K, T extends 
    */
   BeanFactory<K,T> getBeanFactory();
 
+  /**
+   * Close the DataStore. This should release any resources held by the
+   * implementation, so that the instance is ready for GC.
+   * All other DataStore methods cannot be used after this
+   * method was called. Subsequent calls of this method are ignored.
+   */
   void close() throws IOException;
 
   Configuration getConf();

Modified: incubator/gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
URL: http://svn.apache.org/viewvc/incubator/gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java?rev=1170035&r1=1170034&r2=1170035&view=diff
==============================================================================
--- incubator/gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
(original)
+++ incubator/gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
Tue Sep 13 04:53:10 2011
@@ -592,6 +592,7 @@ public class DataStoreTestUtil {
 
     assertNumResults(store.newQuery(), URLS.length);
     store.deleteByQuery(query);
+    store.flush();
     assertEmptyResults(store.newQuery());
 
 
@@ -603,6 +604,7 @@ public class DataStoreTestUtil {
 
     assertNumResults(store.newQuery(), URLS.length);
     store.deleteByQuery(query);
+    store.flush();
     assertEmptyResults(store.newQuery());
 
 
@@ -614,6 +616,7 @@ public class DataStoreTestUtil {
 
     assertNumResults(store.newQuery(), URLS.length);
     store.deleteByQuery(query);
+    store.flush();
     assertEmptyResults(store.newQuery());
 
 
@@ -624,6 +627,7 @@ public class DataStoreTestUtil {
 
     assertNumResults(store.newQuery(), URLS.length);
     store.deleteByQuery(query);
+    store.flush();
     assertNumResults(store.newQuery(), URLS.length - (NUM_KEYS+1));
 
     store.truncateSchema();



Mime
View raw message