db4o 6.1

com.db4o.io
Class MemoryIoAdapter

java.lang.Object
  extended by com.db4o.io.IoAdapter
      extended by com.db4o.io.MemoryIoAdapter

public class MemoryIoAdapter
extends IoAdapter

IoAdapter for in-memory operation.

Configure db4o to operate with this in-memory IoAdapter with MemoryIoAdapter memoryIoAdapter = new MemoryIoAdapter();
Db4o.configure().io(memoryIoAdapter);



Use the normal #openFile() and #openServer() commands to open ObjectContainers and ObjectServers. The names specified as file names will be used to identify the byte[] content of the in-memory files in the _memoryFiles Hashtable in the adapter. After working with an in-memory ObjectContainer/ObjectServer the byte[] content is available in the MemoryIoAdapter by using get(String). To add old existing database byte[] content to a MemoryIoAdapter use put(String, byte[]). To reduce memory consumption of memory file names that will no longer be used call put(String, byte[]) and pass an empty byte array.


Constructor Summary
MemoryIoAdapter()
           
 
Method Summary
 void close()
          for internal processing only.
 void delete(java.lang.String path)
          deletes the given path from whatever 'file system' is addressed
 boolean exists(java.lang.String path)
          for internal processing only.
 byte[] get(java.lang.String name)
          returns the content bytes for a database with the given name.
 long getLength()
          for internal processing only.
 void growBy(int length)
          configures the length a memory file should grow, if no more free slots are found within.
 IoAdapter open(java.lang.String path, boolean lockFile, long initialLength)
          for internal processing only.
 void put(java.lang.String name, byte[] bytes)
          creates an in-memory database with the passed content bytes and adds it to the adapter for the specified name.
 int read(byte[] bytes, int length)
          for internal processing only.
 void seek(long pos)
          for internal processing only.
 void sync()
          for internal processing only.
 void write(byte[] buffer, int length)
          for internal processing only.
 
Methods inherited from class com.db4o.io.IoAdapter
blockCopy, blockSeek, blockSeek, blockSize, blockSize, copy, delegatedIoAdapter, read, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryIoAdapter

public MemoryIoAdapter()
Method Detail

put

public void put(java.lang.String name,
                byte[] bytes)
creates an in-memory database with the passed content bytes and adds it to the adapter for the specified name.

Parameters:
name - the name to be use for #openFile() or #openServer() calls
bytes - the database content

get

public byte[] get(java.lang.String name)
returns the content bytes for a database with the given name.

Parameters:
name - the name to be use for #openFile() or #openServer() calls
Returns:
the content bytes

growBy

public void growBy(int length)
configures the length a memory file should grow, if no more free slots are found within.

Specify a large value (100,000 or more) for best performance. Specify a small value (100) for the smallest memory consumption. The default setting is 10,000.

Parameters:
length - the length in bytes

close

public void close()
           throws java.io.IOException
for internal processing only.

Specified by:
close in class IoAdapter
Throws:
java.io.IOException

delete

public void delete(java.lang.String path)
Description copied from class: IoAdapter
deletes the given path from whatever 'file system' is addressed

Specified by:
delete in class IoAdapter

exists

public boolean exists(java.lang.String path)
for internal processing only.

Specified by:
exists in class IoAdapter

getLength

public long getLength()
               throws java.io.IOException
for internal processing only.

Specified by:
getLength in class IoAdapter
Throws:
java.io.IOException

open

public IoAdapter open(java.lang.String path,
                      boolean lockFile,
                      long initialLength)
               throws java.io.IOException
for internal processing only.

Specified by:
open in class IoAdapter
Throws:
java.io.IOException

read

public int read(byte[] bytes,
                int length)
         throws java.io.IOException
for internal processing only.

Specified by:
read in class IoAdapter
Throws:
java.io.IOException

seek

public void seek(long pos)
          throws java.io.IOException
for internal processing only.

Specified by:
seek in class IoAdapter
Throws:
java.io.IOException

sync

public void sync()
          throws java.io.IOException
for internal processing only.

Specified by:
sync in class IoAdapter
Throws:
java.io.IOException

write

public void write(byte[] buffer,
                  int length)
           throws java.io.IOException
for internal processing only.

Specified by:
write in class IoAdapter
Throws:
java.io.IOException

db4o 6.1