Interface CacheBlock<T>
-
- All Superinterfaces:
org.apache.hadoop.io.Writable
- All Known Implementing Classes:
CompressedMatrixBlock
,FrameBlock
,MatrixBlock
,TensorBlock
public interface CacheBlock<T> extends org.apache.hadoop.io.Writable
Interface for all blocks handled by lazy write buffer. This abstraction allows us to keep the buffer pool independent of matrix and frame blocks.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
compactEmptyBlock()
Free unnecessarily allocated empty block.DataCharacteristics
getDataCharacteristics()
double
getDouble(int r, int c)
Returns the double value at the passed row and column.double
getDoubleNaN(int r, int c)
Returns the double value at the passed row and column.long
getExactSerializedSize()
Get the exact serialized size in bytes of the cache block.long
getInMemorySize()
Get the in-memory size in bytes of the cache block.int
getNumColumns()
int
getNumRows()
String
getString(int r, int c)
Returns the string of the value at the passed row and column.boolean
isShallowSerialize()
Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.boolean
isShallowSerialize(boolean inclConvert)
Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.CacheBlock<T>
merge(T that, boolean appendOnly)
Merge disjoint: merges all non-zero values of the given input into the current block.CacheBlock<T>
slice(int rl, int ru)
Slice a sub block out of the current block and write into the given output block.CacheBlock<T>
slice(int rl, int ru, boolean deep)
Slice a sub block out of the current block and write into the given output block.CacheBlock<T>
slice(int rl, int ru, int cl, int cu)
Slice a sub block out of the current block and write into the given output block.CacheBlock<T>
slice(int rl, int ru, int cl, int cu, boolean deep)
Slice a sub block out of the current block and write into the given output block.CacheBlock<T>
slice(int rl, int ru, int cl, int cu, boolean deep, T block)
Slice a sub block out of the current block and write into the given output block.CacheBlock<T>
slice(int rl, int ru, int cl, int cu, T block)
Slice a sub block out of the current block and write into the given output block.CacheBlock<T>
slice(IndexRange ixrange, T ret)
Slice a sub block out of the current block and write into the given output block.void
toShallowSerializeBlock()
Converts a cache block that is not shallow serializable into a form that is shallow serializable.
-
-
-
Method Detail
-
getNumRows
int getNumRows()
-
getNumColumns
int getNumColumns()
-
getDataCharacteristics
DataCharacteristics getDataCharacteristics()
-
getInMemorySize
long getInMemorySize()
Get the in-memory size in bytes of the cache block.- Returns:
- in-memory size in bytes of cache block
-
getExactSerializedSize
long getExactSerializedSize()
Get the exact serialized size in bytes of the cache block.- Returns:
- exact serialized size in bytes of cache block
-
isShallowSerialize
boolean isShallowSerialize()
Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.- Returns:
- true if shallow serialized
-
isShallowSerialize
boolean isShallowSerialize(boolean inclConvert)
Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.- Parameters:
inclConvert
- if true report blocks as shallow serialize that are currently not amenable but can be brought into an amenable form viatoShallowSerializeBlock
.- Returns:
- true if shallow serialized
-
toShallowSerializeBlock
void toShallowSerializeBlock()
Converts a cache block that is not shallow serializable into a form that is shallow serializable. This methods has no affect if the given cache block is not amenable.
-
compactEmptyBlock
void compactEmptyBlock()
Free unnecessarily allocated empty block.
-
slice
CacheBlock<T> slice(IndexRange ixrange, T ret)
Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.- Parameters:
ixrange
- index range inclusiveret
- outputBlock- Returns:
- sub-block of cache block
-
slice
CacheBlock<T> slice(int rl, int ru)
Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.- Parameters:
rl
- row lowerru
- row upper inclusive- Returns:
- sub-block of cache block
-
slice
CacheBlock<T> slice(int rl, int ru, boolean deep)
Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.- Parameters:
rl
- row lowerru
- row upper inclusivedeep
- enforce deep-copy- Returns:
- sub-block of cache block
-
slice
CacheBlock<T> slice(int rl, int ru, int cl, int cu)
Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.- Parameters:
rl
- row lowerru
- row upper inclusivecl
- column lowercu
- column upper inclusive- Returns:
- sub-block of cache block
-
slice
CacheBlock<T> slice(int rl, int ru, int cl, int cu, T block)
Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.- Parameters:
rl
- row lowerru
- row upper inclusivecl
- column lowercu
- column upper inclusiveblock
- cache block- Returns:
- sub-block of cache block
-
slice
CacheBlock<T> slice(int rl, int ru, int cl, int cu, boolean deep)
Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.- Parameters:
rl
- row lowerru
- row upper inclusivecl
- column lowercu
- column upper inclusivedeep
- enforce deep-copy- Returns:
- sub-block of cache block
-
slice
CacheBlock<T> slice(int rl, int ru, int cl, int cu, boolean deep, T block)
Slice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.- Parameters:
rl
- row lowerru
- row upper inclusivecl
- column lowercu
- column upper inclusivedeep
- enforce deep-copyblock
- cache block- Returns:
- sub-block of cache block
-
merge
CacheBlock<T> merge(T that, boolean appendOnly)
Merge disjoint: merges all non-zero values of the given input into the current block. Note that this method does NOT check for overlapping entries; it's the callers responsibility of ensuring disjoint blocks. The appendOnly parameter is only relevant for sparse target blocks; if true, we only append values and do not sort sparse rows for each call; this is useful whenever we merge iterators of matrix blocks into one target block.- Parameters:
that
- cache blockappendOnly
- Indicate if the merger can be append only on sparse rows.- Returns:
- the merged group, in most implementations 'this' is modified.
-
getDouble
double getDouble(int r, int c)
Returns the double value at the passed row and column. If the value is missing 0 is returned.- Parameters:
r
- row of the valuec
- column of the value- Returns:
- double value at the passed row and column
-
getDoubleNaN
double getDoubleNaN(int r, int c)
Returns the double value at the passed row and column. If the value is missing NaN is returned.- Parameters:
r
- row of the valuec
- column of the value- Returns:
- double value at the passed row and column
-
getString
String getString(int r, int c)
Returns the string of the value at the passed row and column. If the value is missing or NaN, null is returned.- Parameters:
r
- row of the valuec
- column of the value- Returns:
- string of the value at the passed row and column
-
-