Mercurial > hg > blitz_condensed
comparison src/org/dancres/blitz/entry/Storage.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.entry; | |
2 | |
3 import java.io.IOException; | |
4 | |
5 import org.dancres.blitz.arc.BackingStore; | |
6 | |
7 import org.dancres.blitz.mangler.MangledEntry; | |
8 import org.dancres.blitz.mangler.MangledField; | |
9 | |
10 import org.dancres.blitz.oid.OID; | |
11 | |
12 /** | |
13 Provides primitive methods for the manipulation of the storage mechanism. | |
14 Caching etc. is a higher-level responsibility. This interface can be | |
15 used to write, update and remove data. <P> | |
16 | |
17 It has basic understanding of what it stores in that it knows how | |
18 to index, how to store subtype information and the storage patterns used | |
19 for bucketing and other settings. <P> | |
20 | |
21 Basic lifecycle is to create storage element and then call didntExist. | |
22 If it returns true, one should set the indexing information using setFields. | |
23 Note that, if indexing is disabled, didntExist will always return true | |
24 and there's no requirement to call setFields. <P> | |
25 */ | |
26 public interface Storage extends BackingStore { | |
27 /** | |
28 @return <code>true</code> if initialization succeeded in accordance | |
29 with the mustExist flag. i.e. If mustExist is true and the databases | |
30 couldn't be opened one will receive <code>false</code> NOT an | |
31 exception. | |
32 */ | |
33 public boolean init(boolean mustExist) throws IOException; | |
34 | |
35 /** | |
36 Called to setup schema information, create indexes etc - should only | |
37 be called once in response to <code>true</code> being returned from | |
38 <code>didntExist()</code> | |
39 */ | |
40 public void setFields(MangledField[] aSetOfFields) throws IOException; | |
41 | |
42 /** | |
43 Indicates if we were created for the first time as the result of | |
44 a call to <code>EntryRepositoryFactory.get()</code>. Note that this | |
45 flag is reset after <code>setFields()</code> is called. Thus, even | |
46 if an EntryRepository has been informed of children, it will still | |
47 return <code>true</code> until <code>setFields</code> is called. | |
48 */ | |
49 public boolean noSchemaDefined(); | |
50 | |
51 public void close() throws IOException; | |
52 | |
53 /** | |
54 Storage instances support the concepts of: | |
55 | |
56 <ul> | |
57 <li> Temporarily holding Entry's in-memory only - useful for | |
58 transactional operations such as caching of writes until commit.</li> | |
59 <li> Caching of dirty data destined for disk but not yet written. This | |
60 allows for better performance as writes may be performed asynchronously. | |
61 </li> | |
62 | |
63 Before a disk search is performed via <code>find</code> this method | |
64 should be invoked to check for state which may not have reached disk | |
65 as yet. If this is not done, out-of-date state may be returned. | |
66 */ | |
67 public TupleLocator findCached(MangledEntry anEntry); | |
68 | |
69 /** | |
70 Return a set of potential matches based on the passed template. Note | |
71 one must test each returned tuple for an exact match across ALL keys | |
72 because this method is "speculative". It will return likely matches | |
73 it does not guarentee to have located an exact subset based on the | |
74 passed template. As a full match is necessary to avoid hash-collisions | |
75 this shouldn't be a problem. | |
76 | |
77 @param anEntry a template to use to locate matches. | |
78 | |
79 @return TupleLocator instance of <code>null</code> if there are no | |
80 possible matches. | |
81 */ | |
82 public TupleLocator find(MangledEntry anEntry) throws IOException; | |
83 | |
84 /** | |
85 Tells this Repository about a subtype which has just been created | |
86 and would need to be searched if this type were the specified template. | |
87 */ | |
88 public void addSubtype(String aType) throws IOException; | |
89 public String[] getSubtypes(); | |
90 | |
91 /** | |
92 @return a new UID for an entry to be added to storage. | |
93 */ | |
94 public OID getNextId() throws IOException; | |
95 | |
96 /** | |
97 Causes Storage instance to scan for expired Entry instances which will | |
98 be passed to <code>aReaper</code> | |
99 */ | |
100 public void bringOutTheDead(EntryReaper aReaper) throws IOException; | |
101 | |
102 /** | |
103 @return the type of Entry this storage element contains | |
104 */ | |
105 public String getType(); | |
106 | |
107 /** | |
108 @return the number of Entry's of the type currently held on disk. Note | |
109 that because of Blitz's caching/logging behaviour, this count doesn't | |
110 reflect the actual number of instances of this type. | |
111 */ | |
112 public int getNumEntries() throws IOException; | |
113 | |
114 public void delete() throws IOException; | |
115 } |