org.eclipse.jgit.storage.dht.spi.cache
Class CacheObjectIndexTable

java.lang.Object
  extended by org.eclipse.jgit.storage.dht.spi.cache.CacheObjectIndexTable
All Implemented Interfaces:
ObjectIndexTable

public class CacheObjectIndexTable
extends java.lang.Object
implements ObjectIndexTable

Cache wrapper around ObjectIndexTable.


Constructor Summary
CacheObjectIndexTable(ObjectIndexTable dbTable, CacheDatabase cacheDatabase)
          Initialize a new wrapper.
 
Method Summary
 void add(ObjectIndexKey objId, ObjectInfo info, WriteBuffer buffer)
          Record the fact that objId can be found by info.
 void get(Context options, java.util.Set<ObjectIndexKey> objects, AsyncCallback<java.util.Map<ObjectIndexKey,java.util.Collection<ObjectInfo>>> callback)
          Asynchronously locate one or more objects in the repository.
 void remove(ObjectIndexKey objId, ChunkKey chunk, WriteBuffer buffer)
          Remove a single chunk from an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheObjectIndexTable

public CacheObjectIndexTable(ObjectIndexTable dbTable,
                             CacheDatabase cacheDatabase)
Initialize a new wrapper.

Parameters:
dbTable - the underlying database's corresponding table.
cacheDatabase - the cache database.
Method Detail

get

public void get(Context options,
                java.util.Set<ObjectIndexKey> objects,
                AsyncCallback<java.util.Map<ObjectIndexKey,java.util.Collection<ObjectInfo>>> callback)
Description copied from interface: ObjectIndexTable
Asynchronously locate one or more objects in the repository.

Callers are responsible for breaking up very large collections of objects into smaller units, based on the reader's batch size option. 1,000 to 10,000 is a reasonable range for the reader to batch on.

Specified by:
get in interface ObjectIndexTable
Parameters:
options - options to control reading.
objects - set of object names to locate the chunks of.
callback - receives the results when ready.

add

public void add(ObjectIndexKey objId,
                ObjectInfo info,
                WriteBuffer buffer)
         throws DhtException
Description copied from interface: ObjectIndexTable
Record the fact that objId can be found by info.

If there is already data for objId in the table, this method should add the new chunk onto the existing data list.

This method should use batched asynchronous puts as much as possible. Initial imports of an existing repository may require millions of add operations to this table, one for each object being imported.

Specified by:
add in interface ObjectIndexTable
Parameters:
objId - the unique ObjectId.
info - a chunk that is known to store objId.
buffer - buffer to enqueue the put onto.
Throws:
DhtException - if the buffer flushed and an enqueued operation failed.

remove

public void remove(ObjectIndexKey objId,
                   ChunkKey chunk,
                   WriteBuffer buffer)
            throws DhtException
Description copied from interface: ObjectIndexTable
Remove a single chunk from an object.

If this is the last remaining chunk for the object, the object should also be removed from the table. Removal can be deferred, or can occur immediately. That is, get() may return the object with an empty collection, but to prevent unlimited disk usage the database should eventually remove the object.

Specified by:
remove in interface ObjectIndexTable
Parameters:
objId - the unique ObjectId.
chunk - the chunk that needs to be removed from this object.
buffer - buffer to enqueue the remove onto.
Throws:
DhtException - if the buffer flushed and an enqueued operation failed.


Copyright © 2011. All Rights Reserved.