|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstorage.advancedStorage.AdvancedStorageManager.Segment.Space
This class represents a space, a space is a set of units, each unit inside a space is identified by a unique number. Spaces provides methods for the free space management of units. Each space is mounted over a chunk (of primitive storage component).
Method Summary | |
long |
findFirstFreeUnit()
This function finds the first available unit in the space. |
long |
findFreeUnitCloseOf(long unitNumber)
Find a free unit in the same page of a given unit. |
void |
freeUnit(long unitNumber)
Sets a specific unit as free. |
int |
getChunkNumber()
Returns the number (in primitive storage component) of the chunk in wich the space is mounted. |
long |
getMaxNumberOfUnits()
Returns the maximun number of units that can be stored in the space. |
long |
getUsedSize()
Returns the number of bytes that the space is really using. |
boolean |
isEmpty()
Returns true if the space is empty, i.e. all is units are free.
|
boolean |
isFreeUnit(long unitNumber)
Checks if a unit is free. |
boolean |
isOccupiedUnit(long unitNumber)
Checks if a unit is occupied. |
void |
occupUnit(long unitNumber)
Sets a specific unit as occupied. |
void |
readUnit(long unitNumber,
byte[] b,
int off)
Reads fully a unit. |
void |
readUnit(long unitNumber,
int unitOffset,
int length,
byte[] b,
int off)
Reads partially a unit starting from an offset and reading a specific length. |
void |
reduce()
Reduce the logic assigned space, later the physical space can be reduced. |
void |
writeUnit(long unitNumber,
byte[] b,
int off)
Writes fully a unit. |
void |
writeUnit(long unitNumber,
int unitOffset,
int length,
byte[] b,
int off)
Writes partially a unit starting from an offset and writing a specific length of bytes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public int getChunkNumber()
public long getMaxNumberOfUnits()
public long getUsedSize() throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
public boolean isEmpty()
true
if the space is empty, i.e. all is units are free.
Returns false
otherwise.
public void readUnit(long unitNumber, int unitOffset, int length, byte[] b, int off) throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, UnitNumberOutOfRangeException, InvalidUnitOffsetException, OutOfUnitException
unitNumber
- The number of the unit inside the space.unitOffset
- The position of the unit from which the reading starts.length
- The number of bytes to be readed.b
- The byte array which the content of the readed unit will be stored.off
- The offset of b
from which the readed content will be stored.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
UnitNumberOutOfRangeException
InvalidUnitOffsetException
OutOfUnitException
public void readUnit(long unitNumber, byte[] b, int off) throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, UnitNumberOutOfRangeException
unitNumber
- The number of the unit inside the space.b
- The byte array which the content of the readed unit will be stored.off
- The offset of b
from which the readed content will be stored.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
UnitNumberOutOfRangeException
public void writeUnit(long unitNumber, int unitOffset, int length, byte[] b, int off) throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, UnitNumberOutOfRangeException, InvalidUnitOffsetException, OutOfUnitException
unitNumber
- The number of the unit.unitOffset
- The position of the unit from which the writing starts.b
- The byte array from which the units's content will be get.off
- The offset of b
from which the unit's content will be get.length
- The number of bytes to be wrote.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
UnitNumberOutOfRangeException
InvalidUnitOffsetException
OutOfUnitException
public void writeUnit(long unitNumber, byte[] b, int off) throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, UnitNumberOutOfRangeException
unitNumber
- The number of the unit.b
- The byte array from which the units's content will be get.off
- The offset of b
from which the unit's content will be get.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
UnitNumberOutOfRangeException
public long findFirstFreeUnit() throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, InconsistentStorageStructureException
-1
if there are not free units.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
InconsistentStorageStructureException
public long findFreeUnitCloseOf(long unitNumber) throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, UnitNumberOutOfRangeException
unitNumber
- The number of the unit that has to be in the same page
that the unit to be found.
-1
if there are not free units
in the same page that unitNumber
.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
UnitNumberOutOfRangeException
public void occupUnit(long unitNumber) throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, UnitNumberOutOfRangeException
unitNumber
- The number of the unit to occup.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
UnitNumberOutOfRangeException
public void freeUnit(long unitNumber) throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, UnitNumberOutOfRangeException
unitNumber
- The number of the unit to free.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
UnitNumberOutOfRangeException
public boolean isOccupiedUnit(long unitNumber) throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, UnitNumberOutOfRangeException
unitNumber
- The number of the unit.
true
if the specified unit is occupied, false
otherwise.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
UnitNumberOutOfRangeException
public boolean isFreeUnit(long unitNumber) throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException, UnitNumberOutOfRangeException
unitNumber
- The number of the unit.
true
if the specified unit is free, false
otherwise.
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
UnitNumberOutOfRangeException
public void reduce() throws PrimitiveStorageException, IntermediateStorageException, java.io.IOException
PrimitiveStorageException
IntermediateStorageException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |