Changed license to Creative Commons Zero (CC0).
[sixth-data.git] / src / main / java / eu / svjatoslav / sixth / data / store / DataStore.java
1 /*
2  * Sixth Data. Author: Svjatoslav Agejenko. 
3  * This project is released under Creative Commons Zero (CC0) license.
4  *
5 */
6
7 package eu.svjatoslav.sixth.data.store;
8
9 import java.io.IOException;
10
11 /**
12  * Data store acts as a numerical ID to corresponding record map.
13  * <p>
14  * Record is basically an array of bytes of arbitrary length, identifiable by ID
15  * that is assigned to record during record creation.
16  * <p>
17  * Records can be updated with alternative content and length. Data store takes
18  * care of data fragmentation.
19  */
20 public interface DataStore {
21
22     /**
23      * Close datastore.
24      */
25     void close() throws IOException;
26
27     /**
28      * Create new record and set its initial contents.
29      */
30     int createRecord(byte[] value) throws IOException;
31
32     /**
33      * Delete record identified by given ID. DataStore will mark given ID as
34      * unused, and could reuse this ID later for another newly created record.
35      */
36     void deleteRecord(int id) throws IOException;
37
38     /**
39      * Read entire record into byte array.
40      */
41     byte[] readRecord(int id) throws IOException;
42
43     /**
44      * Update record with new value.
45      */
46     void updateRecord(int id, byte[] value) throws IOException;
47
48 }