View Javadoc

1   /**
2    * 
3    */
4   package org.treetank.api;
5   
6   import org.treetank.bucket.MetaBucket;
7   import org.treetank.exception.TTException;
8   import org.treetank.exception.TTIOException;
9   
10  /**
11   * Read-Transaction of a bucket ensuring read-only access to any buckets.
12   * The transaction must be bound to a revision and bases on a session.
13   * 
14   * <code>
15   *      //Ensure, storage and resources are created
16   *      final IStorage storage = Storage.openStorage(FILE);
17   *      final ISession session =
18   *           storage.getSession(new SessionConfiguration(RESOURCENAME, KEY));
19   *      final IBucketReadTrx pRtx = session.beginBucketRtx(REVISION);
20   * </code>
21   * 
22   * Each {@link IBucketReadTrx} can afterwards get datas from the bucket-layer and the underlaying backend.
23   * Note that each session furthermore has access to a centralized store of common strings referencable over a
24   * key.
25   * 
26   * @author Sebastian Graf, University of Konstanz
27   * 
28   */
29  public interface IBucketReadTrx {
30  
31      /**
32       * Getting the data related to a key.
33       * 
34       * @param pKey
35       *            the key of the data
36       * @return a suitable {@link IData}
37       * @throws TTException
38       *             if anything weird happens
39       */
40      IData getData(final long pKey) throws TTIOException;
41  
42      /**
43       * Getting the revision number of this transaction
44       * 
45       * @return the revision number of this transaction
46       * @throws TTIOException
47       *             if deserialization fails.
48       * 
49       */
50      long getRevision() throws TTIOException;
51  
52      /**
53       * Close the transaction.
54       * 
55       * @return true if successful, false otherwise
56       * @throws TTIOException
57       *             if anything weird happens
58       */
59      boolean close() throws TTIOException;
60  
61      /**
62       * Check if transaction is closed.
63       * 
64       * @return true if closed, false otherwise
65       */
66      boolean isClosed();
67  
68      /**
69       * Getting the map with the entire mapping for retrieving meta-information related to the bundle.
70       * 
71       * @return the meta bucket
72       */
73      MetaBucket getMetaBucket();
74  
75  }