|
|||||||||
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(java.lang.String file)
Open the database file for reading. |
|
HDataBase(java.lang.String file,
java.lang.String option)
Create a new persistent database. |
Method Summary | |
---|---|
boolean |
close()
Close the file |
java.lang.Object |
get(java.lang.String key)
Get object from the database using akey |
boolean |
insert(java.lang.Object ob,
java.lang.String key)
Insert an object with a key |
boolean |
remove(java.lang.String key)
Remove object from the database using the key |
boolean |
update(java.lang.Object ob,
java.lang.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(java.lang.String file, java.lang.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(java.lang.String file)
file
- File nameMethod Detail |
---|
public boolean insert(java.lang.Object ob, java.lang.String key)
ob
- Objectkey
- key for object
public java.lang.Object get(java.lang.String key)
key
- Key to get the object
public boolean update(java.lang.Object ob, java.lang.String key)
ob
- Objectkey
- key
public boolean remove(java.lang.String key)
key
- input key
public boolean close()
|
|||||||||
PREV CLASS NEXT CLASS | All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |