|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.lucene.gdata.storage.lucenestorage.StorageBuffer
public class StorageBuffer
The StorageBuffer is used to buffer incoming updates, deletes and inserts to
the storage. The storage uses an lucene index to store the enries. As
modifying the index all the time an altering request comes in is not
efficent. The entries will be added to the buffer to be available for
incoming storage queries. If the loadfactor for the
StorageModifier
is
reached the modifier will perform a batch update on the index. Each entry
will be associated with a feed id inside a associative datastructure to
return a requested entry efficiently.
This implementation uses ReadWriteLock
.
The read lock may be held simultaneously by multiple reader threads, so long
as there are no writers. The write lock is exclusive.
The entry and feed ID's must not be a composite key. The entry and feed ID must be unique.
ReentrantReadWriteLock
,
StorageModifier
,
StorageCoreController
Field Summary | |
---|---|
protected static int |
DEFAULT_BUFFER_COUNT
|
Constructor Summary | |
---|---|
protected |
StorageBuffer(int expectedBufferCount)
Constructs a new StorageBuffer. |
Method Summary | |
---|---|
void |
addDeleted(String entryId,
String feedId)
Adds a deleted entry to the buffer. |
void |
addEntry(StorageEntryWrapper wrapper)
Adds a StorageEntryWrapper to the buffer. |
void |
close()
clears the buffer - |
int |
getBufferSize()
|
StorageEntryWrapper |
getEntry(String entryId,
String feedId)
Returns an entry for the given entry id in the feed context spezified by the feed id; |
String[] |
getExculdList()
The buffer contains updated and delete entries. |
protected Long |
getFeedLastModified(String feedId)
the timestamp of the last modification for the given feed id |
protected Set<Map.Entry<String,Long>> |
getLastModified()
|
List<StorageEntryWrapper> |
getSortedEntries(String feedId)
Returns all entries for the given feed id sorted by the update timestamp desc. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int DEFAULT_BUFFER_COUNT
Constructor Detail |
---|
protected StorageBuffer(int expectedBufferCount)
The expectedBufferCount sould be higher than the maximum of entries added
to the buffer, resizing the buffer is very efficient. For detailed
infomation HashMap
as this is used inside the buffer
expectedBufferCount
- -
the expected size of the bufferMethod Detail |
---|
public void addEntry(StorageEntryWrapper wrapper)
StorageEntryWrapper
to the buffer. If a wrapper
representing the same entry are already in the buffer the wrapper will be
replaced.
This method does ignore already delted entries. This should before the entry is added to the buffer.
wrapper
- -
the wrapper to bufferprotected Long getFeedLastModified(String feedId)
feedId
- -
feed id
protected Set<Map.Entry<String,Long>> getLastModified()
public List<StorageEntryWrapper> getSortedEntries(String feedId)
feedId
- -
the feed id
List
of all StorageEntryWrapper
object buffered
in this buffer or an empty list if not entry has been buffered
for the given feedpublic void addDeleted(String entryId, String feedId)
entryId
- -
the deleted entry idfeedId
- -
the feed of the entrypublic StorageEntryWrapper getEntry(String entryId, String feedId)
entryId
- -
the id of the entry to returnfeedId
- -
the feed containing the entry
null
if the corresponding entry is
not in the buffer.public String[] getExculdList()
This list contains all entries should not be found by the index searcher. This method creates a copy of the current list to prevent concurrent modification exceptions while iteration over the collection.
ModifiedEntryFilter
public void close()
public int getBufferSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |