if ( index == -1 )
{
index = createNewPropertyIndex( name );
}
PropertyBlock block = new PropertyBlock();
getPropertyStore().encodeValue( block, index, value );
int size = block.getSize();
/*
* current is the current record traversed
* thatFits is the earliest record that can host the block
* thatHas is the record that already has a block for this index
*/
PropertyRecord current = null, thatFits = null, thatHas = null;
/*
* We keep going while there are records or until we both found the
* property if it exists and the place to put it, if exists.
*/
while ( !( nextProp == Record.NO_NEXT_PROPERTY.intValue() || ( thatHas != null && thatFits != null ) ) )
{
current = getPropertyStore().getRecord( nextProp );
/*
* current.getPropertyBlock() is cheap but not free. If we already
* have found thatHas, then we can skip this lookup.
*/
if ( thatHas == null && current.getPropertyBlock( index ) != null )
{
thatHas = current;
PropertyBlock removed = thatHas.removePropertyBlock( index );
if ( removed.isLight() )
{
getPropertyStore().makeHeavy( removed );
for ( DynamicRecord dynRec : removed.getValueRecords() )
{
thatHas.addDeletedRecord( dynRec );
}
}
getPropertyStore().updateRecord( thatHas );