|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.faunos.skwish.Segment
com.faunos.skwish.sys.filters.UnionSegment
public class UnionSegment
A union of segments. An instance is based on any number of underlying subsegments. The subsegments are assumed to span non-overlapping IDs.
Each method call on an instance of this class delegates to a subsegment instance that handles the specified entry
id. New entries are only ever added to the high
subsegment.
| Field Summary |
|---|
| Fields inherited from class com.faunos.skwish.Segment |
|---|
validator |
| Constructor Summary | |
|---|---|
|
UnionSegment(Segment[] segments)
|
protected |
UnionSegment(Segment[] segments,
boolean checkOverlap,
boolean readOnly,
boolean autoSetReadOnly)
|
| Method Summary | |
|---|---|
void |
delete(long id,
int count,
boolean purge)
Deletes count entries starting at the entry with the specified id. |
protected long |
failReadOnly()
Throws an exception signifying an attempt to perform a write operation on a read-only instance. |
long |
getBaseId()
Returns the instance's base ID. |
void |
getEntry(long id,
ByteBuffer out,
ByteBuffer workBuffer)
Returns the contents of the entry with the specified id. |
FileChannel |
getEntryChannel(long id)
Returns the contents of the entry with the given id
as a FileChannel, or null, if deleted. |
long |
getEntryCount()
Returns the number of entries in this instance. |
int |
getEntryPart(long id,
long position,
ByteBuffer out,
ByteBuffer workBuffer)
Returns the specified part of the entry contents with the specified id. |
long |
getEntrySize(long id,
ByteBuffer workBuffer)
Returns the size of the entry with the specified id. |
long |
getNextId()
Returns the ID the entry will get on the next insertion. |
protected Segment |
getSegmentForId(long id)
Returns the subsegment containing the given id, or
null if no subsegment contains it. |
protected Segment |
hiSegment()
Returns the subsegment with the largest base Id. |
long |
insertEntry(ByteBuffer entry)
Inserts the given entry and returns the entry's ID. |
long |
insertEntry(ReadableByteChannel entry)
Inserts the entry represented by the given channel. |
boolean |
isReadOnly()
Determines whether this instance is read-only (unmodifiable). |
long |
killNext(int count)
Kills the next count entry IDs. |
protected Segment |
loSegment()
Returns the subsegment with the smallest base Id. |
| Methods inherited from class com.faunos.skwish.Segment |
|---|
contains, delete, delete, getEntry, getEntrySize, getEntryStream, hi, isDeleted, isDeleted, killNext, lo, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public UnionSegment(Segment[] segments)
throws IOException
IOException
protected UnionSegment(Segment[] segments,
boolean checkOverlap,
boolean readOnly,
boolean autoSetReadOnly)
throws IOException
IOException| Method Detail |
|---|
public boolean isReadOnly()
Segment
isReadOnly in class Segmenttrue, if any of the underlying segments is
public void delete(long id,
int count,
boolean purge)
throws IOException
Segment
delete in class Segmentid - the ID of the first entry to be deleted. Must be
a valid ID in this segment [baseId, baseId + entryCount)count - the number of entries to be deleted. Specifies a
range of IDs to be deleted: [id, id + count). The range
of IDs must be valid entries within this segment; o.w.
an exception is raised.purge - if true, the contents of the deleted entries
are signaled to be purged (overwritten) immediately;
o.w. the contents will be deleted on the next time the segment is
compacted.
IOExceptionpublic long getBaseId()
Segment
getBaseId in class SegmentSegment.getEntryCount()
public int getEntryPart(long id,
long position,
ByteBuffer out,
ByteBuffer workBuffer)
throws IOException
Segmentout.remaining() bytes of the contents of the entry
are copied into the given out buffer.
getEntryPart in class Segmentposition - the starting position into the entry from where data will be
copied into the out bufferout - the out buffer into which data is writtenworkBuffer - a work buffer with a minimum size of 16
out has
no remaining bytes), or -1, if the position is greater than the
size of the entry, or if the entry is deleted.
IOException
public void getEntry(long id,
ByteBuffer out,
ByteBuffer workBuffer)
throws IOException
Segmentout
buffer.
getEntry in class Segmentout - the buffer into which the contents are written. Its
remaining bytes must be large enough; o.w., an exception is raised.workBuffer - a work buffer used internally to read offsets. The minimum
capacity of this work buffer must be 16
IOException
public FileChannel getEntryChannel(long id)
throws IOException
Segmentid
as a FileChannel, or null, if deleted.
The returned channel is positioned at zero and is read-only.
getEntryChannel in class SegmentIOExceptionpublic long getEntryCount()
Segment
getEntryCount in class Segment
public long getEntrySize(long id,
ByteBuffer workBuffer)
throws IOException
Segment
getEntrySize in class SegmentIOExceptionpublic long getNextId()
Segment
getNextId in class Segment
public long killNext(int count)
throws IOException
Segmentcount entry IDs. A killed entry is an
entry that begins (and ends) life in the deleted state.
killNext in class Segmentcount - the number of entries to kill (must be greater than 1)
IOException
public long insertEntry(ByteBuffer entry)
throws IOException
Segment
insertEntry in class Segmententry - they contents of the entry
IOException
public long insertEntry(ReadableByteChannel entry)
throws IOException
Segmententry represented by the given channel.
The contents are of the entry is understood to be the entire
remaining contents in the specified channel.
This is the most efficient method for inserting a large-size entry
(even one that doesn't fit in memory).
insertEntry in class SegmentIOExceptionprotected final Segment getSegmentForId(long id)
id, or
null if no subsegment contains it.
id - an ID contained within this unionprotected final Segment loSegment()
protected final Segment hiSegment()
protected long failReadOnly()
UnsupportedOperationException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||