krati.store
Class DynamicDataArray

java.lang.Object
  extended by krati.store.AbstractDataArray
      extended by krati.store.DynamicDataArray
All Implemented Interfaces:
Array, DataArray, DynamicArray, Persistable

public final class DynamicDataArray
extends AbstractDataArray
implements DynamicArray

DynamicDataArray - a convenient class for creating a dynamic data array.

Author:
jwu Sep 24, 2010

Field Summary
 
Fields inherited from class krati.store.AbstractDataArray
_addrArray, _dataArray, _homeDir, _homePath
 
Constructor Summary
DynamicDataArray(int initialLength, File homeDirectory, SegmentFactory segmentFactory)
          Constructs a dynamic data array with the following default params.
DynamicDataArray(int initialLength, File homeDirectory, SegmentFactory segmentFactory, int segmentFileSizeMB)
          Constructs a dynamic data array with the following default params.
DynamicDataArray(int initialLength, int batchSize, int numSyncBatches, File homeDirectory, SegmentFactory segmentFactory, int segmentFileSizeMB, double segmentCompactFactor)
          Constructs a dynamic data array.
 
Method Summary
protected  AddressArray createAddressArray(int length, int batchSize, int numSyncBatches, File homeDirectory)
           
 void expandCapacity(int index)
          Expands the capacity of array to accommodate a given index.
 void set(int index, byte[] data, int offset, int length, long scn)
          Sets data at a specified index.
 void set(int index, byte[] data, long scn)
          Sets data at a specified index.
 
Methods inherited from class krati.store.AbstractDataArray
clear, get, get, get, getHomeDir, getHomePath, getHWMark, getLength, getLWMark, getStatus, hasData, hasIndex, length, persist, saveHWMark, sync, transferTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface krati.array.Array
clear, hasIndex, length
 

Constructor Detail

DynamicDataArray

public DynamicDataArray(int initialLength,
                        File homeDirectory,
                        SegmentFactory segmentFactory)
                 throws Exception
Constructs a dynamic data array with the following default params.
   batchSize            : 10000
   numSyncBatches       : 5
   segmentCompactFactor : 0.5
   segmentFileSizeMB    : 256
 

Parameters:
initialLength - - the initial array length
homeDirectory - - the home directory of data array
segmentFactory - - the segment factory
Throws:
Exception

DynamicDataArray

public DynamicDataArray(int initialLength,
                        File homeDirectory,
                        SegmentFactory segmentFactory,
                        int segmentFileSizeMB)
                 throws Exception
Constructs a dynamic data array with the following default params.
   batchSize              : 10000
   numSyncBatches         : 5
   segmentCompactFactor   : 0.5
 

Parameters:
initialLength - - the initial array length
homeDirectory - - the home directory of data array
segmentFactory - - the segment factory
segmentFileSizeMB - - the segment size in MB
Throws:
Exception

DynamicDataArray

public DynamicDataArray(int initialLength,
                        int batchSize,
                        int numSyncBatches,
                        File homeDirectory,
                        SegmentFactory segmentFactory,
                        int segmentFileSizeMB,
                        double segmentCompactFactor)
                 throws Exception
Constructs a dynamic data array.

Parameters:
initialLength - - the initial array length
batchSize - - the number of updates per update batch, i.e. the redo entry size
numSyncBatches - - the number of update batches required for updating the underlying address array
homeDirectory - - the home directory of data array
segmentFactory - - the segment factory
segmentFileSizeMB - - the segment size in MB
segmentCompactFactor - - the segment load threshold, below which a segment is eligible for compaction
Throws:
Exception
Method Detail

createAddressArray

protected AddressArray createAddressArray(int length,
                                          int batchSize,
                                          int numSyncBatches,
                                          File homeDirectory)
                                   throws Exception
Specified by:
createAddressArray in class AbstractDataArray
Throws:
Exception

expandCapacity

public void expandCapacity(int index)
                    throws Exception
Description copied from interface: DynamicArray
Expands the capacity of array to accommodate a given index.

Specified by:
expandCapacity in interface DynamicArray
Parameters:
index - an index in the array
Throws:
Exception

set

public void set(int index,
                byte[] data,
                long scn)
         throws Exception
Description copied from interface: DataArray
Sets data at a specified index.

Specified by:
set in interface DataArray
Overrides:
set in class AbstractDataArray
Parameters:
index - data index in DataArray
data - data to write to DataArray
Throws:
Exception

set

public void set(int index,
                byte[] data,
                int offset,
                int length,
                long scn)
         throws Exception
Description copied from interface: DataArray
Sets data at a specified index.

Specified by:
set in interface DataArray
Overrides:
set in class AbstractDataArray
Parameters:
index - data index in DataArray
data - data to write to DataArray
offset - the offset of the data array to start read
length - the length of data to read from the data array
Throws:
Exception


Copyright © 2011. All Rights Reserved.