|
|||||||||
PREV CLASS NEXT CLASS | All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjhplot.io.HDataBase
public class HDataBase
This raw-level database allows to store and retrieve objects. It associates a key of type String with each record. The keys will be limited to a maximum length, although the record data will not be limited. The record will consist of only one "blob" of binary data. The number of records is not fixed at creation time. The file can grow and shrink as records are inserted and removed. Because our index and record data will be stored in the same file, this restriction will cause us to add extra logic to dynamically increase the index space by reorganizing records. The database operations not depend on the number of records in the file. In other words, they'll be of constant order time with respect to file accesses. The index is small enough to load into memory. This will make it easier for our implementation to fulfill the requirement that dictates access time. The code is based on: http://www.javaworld.com/javaworld/jw-01-1999/jw-01-step.html
Field Summary | |
---|---|
RecordsFile |
recordsFile
|
RecordReader |
rr
|
RecordWriter |
rw
|
Constructor Summary | |
---|---|
HDataBase(String file)
Open the database file for reading. |
|
HDataBase(String file,
String option)
Create a new persistent database. |
Method Summary | |
---|---|
boolean |
close()
Close the file |
Object |
get(String key)
Get object from the database using a key |
Enumeration |
getKeys()
Returns an enumeration of all the keys in the database. |
int |
getRecords()
Returns the current number of records in the database. |
boolean |
insert(String key,
Object obj)
Insert an object with a key |
boolean |
isExists(String key)
Checks if there is a record belonging to the given key. |
boolean |
remove(String key)
Remove object from the database using the key |
boolean |
update(Object ob,
String key)
Update the database with a new value |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public RecordsFile recordsFile
public RecordWriter rw
public RecordReader rr
Constructor Detail |
---|
public HDataBase(String file, String option)
file
- File nameoption
- Option to create the file . If "w" - write a file (or read)
file, if "r" only read created file.public HDataBase(String file)
file
- File nameMethod Detail |
---|
public Enumeration getKeys()
public int getRecords()
public boolean isExists(String key)
public boolean insert(String key, Object obj)
key
- key for objectobj
- Object for this key
public Object get(String key)
key
- Key to get the object
public boolean update(Object ob, String key)
ob
- Objectkey
- key
public boolean remove(String key)
key
- input key
public boolean close()
|
|||||||||
PREV CLASS NEXT CLASS | All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |