public class SegmentCacheIndexImpl extends Object implements SegmentCacheIndex
Not thread safe.
Constructor and Description |
---|
SegmentCacheIndexImpl(Thread thread)
Creates a SegmentCacheIndexImpl.
|
Modifier and Type | Method and Description |
---|---|
void |
add(SegmentHeader header,
SegmentBuilder.SegmentConverter converter,
boolean loading)
Adds a header to the index.
|
void |
cancel(Execution exec)
This method must remove all registrations as a client
for the given execution.
|
boolean |
contains(SegmentHeader header)
Tells whether or not a given segment is known to this index.
|
List<List<SegmentHeader>> |
findRollupCandidates(String schemaName,
ByteString schemaChecksum,
String cubeName,
String measureName,
String rolapStarFactTableName,
BitKey constrainedColsBitKey,
Map<String,Comparable> coordinates,
List<String> compoundPredicates)
Returns a list of segments that can be rolled up to satisfy a given
cell request.
|
SegmentBuilder.SegmentConverter |
getConverter(String schemaName,
ByteString schemaChecksum,
String cubeName,
String rolapStarFactTableName,
String measureName,
List<String> compoundPredicates)
Returns a converter that can convert the given header to internal
format.
|
Future<SegmentBody> |
getFuture(Execution exec,
SegmentHeader header)
Returns a future slot for a segment body, if a segment is currently
loading, otherwise null.
|
List<SegmentHeader> |
intersectRegion(String schemaName,
ByteString schemaChecksum,
String cubeName,
String measureName,
String rolapStarFactTableName,
SegmentColumn[] region)
Finds a list of headers that intersect a given region.
|
void |
linkSqlStatement(SegmentHeader header,
Statement stmt)
Allows to link a
Statement to a segment. |
void |
loadFailed(SegmentHeader header,
Throwable throwable)
Notifies the segment index that a segment failed to load, and removes the
segment from the index.
|
void |
loadSucceeded(SegmentHeader header,
SegmentBody body)
Changes the state of a header from loading to loaded.
|
List<SegmentHeader> |
locate(String schemaName,
ByteString schemaChecksum,
String cubeName,
String measureName,
String rolapStarFactTableName,
BitKey constrainedColsBitKey,
Map<String,Comparable> coordinates,
List<String> compoundPredicates)
Identifies the segment headers that contain a given cell.
|
static List |
makeConverterKey(CellRequest request,
AggregationKey key) |
static List |
makeConverterKey(SegmentHeader header) |
static boolean |
matches(SegmentHeader header,
Map<String,Comparable> coords,
List<String> compoundPredicates) |
void |
printCacheState(PrintWriter pw)
Prints the state of the cache to the given writer.
|
void |
remove(SegmentHeader header)
Removes a header from the index.
|
void |
setConverter(String schemaName,
ByteString schemaChecksum,
String cubeName,
String rolapStarFactTableName,
String measureName,
List<String> compoundPredicates,
SegmentBuilder.SegmentConverter converter)
Sets a converter that can convert headers in for a given measure to
internal format.
|
void |
update(SegmentHeader oldHeader,
SegmentHeader newHeader)
Updates a header in the index.
|
public SegmentCacheIndexImpl(Thread thread)
thread
- Thread that must be used to execute commands.public static List makeConverterKey(SegmentHeader header)
public static List makeConverterKey(CellRequest request, AggregationKey key)
public List<SegmentHeader> locate(String schemaName, ByteString schemaChecksum, String cubeName, String measureName, String rolapStarFactTableName, BitKey constrainedColsBitKey, Map<String,Comparable> coordinates, List<String> compoundPredicates)
SegmentCacheIndex
locate
in interface SegmentCacheIndex
schemaName
- Schema nameschemaChecksum
- Schema checksumcubeName
- Cube namemeasureName
- Measure namerolapStarFactTableName
- Fact table tableconstrainedColsBitKey
- Bit keycoordinates
- CoordinatescompoundPredicates
- Compound predicatespublic void add(SegmentHeader header, SegmentBuilder.SegmentConverter converter, boolean loading)
SegmentCacheIndex
add
in interface SegmentCacheIndex
header
- Segment headerconverter
- Segment converterloading
- Whether segment is pending a load from SQLpublic void update(SegmentHeader oldHeader, SegmentHeader newHeader)
SegmentCacheIndex
update
in interface SegmentCacheIndex
oldHeader
- The old header to replace.newHeader
- The new header to use instead.public void loadSucceeded(SegmentHeader header, SegmentBody body)
SegmentCacheIndex
The segment must have previously been added by calling SegmentCacheIndex.add(mondrian.spi.SegmentHeader, mondrian.rolap.agg.SegmentBuilder.SegmentConverter, boolean)
with a not-null value of the bodyFuture
parameter;
neither loadSucceeded
nor SegmentCacheIndex.loadFailed(mondrian.spi.SegmentHeader, java.lang.Throwable)
must have been
called.
Informs anyone waiting on the future supplied with
SegmentCacheIndex.add(mondrian.spi.SegmentHeader, mondrian.rolap.agg.SegmentBuilder.SegmentConverter, boolean)
.
loadSucceeded
in interface SegmentCacheIndex
header
- Segment headerbody
- Segment bodypublic void loadFailed(SegmentHeader header, Throwable throwable)
SegmentCacheIndex
The segment must have previously been added using SegmentCacheIndex.add(mondrian.spi.SegmentHeader, mondrian.rolap.agg.SegmentBuilder.SegmentConverter, boolean)
with a not-null value of the bodyFuture
parameter;
neither SegmentCacheIndex.loadSucceeded(mondrian.spi.SegmentHeader, mondrian.spi.SegmentBody)
nor loadFailed
must have been
called.
Informs anyone waiting on the future supplied with
SegmentCacheIndex.add(mondrian.spi.SegmentHeader, mondrian.rolap.agg.SegmentBuilder.SegmentConverter, boolean)
.
loadFailed
in interface SegmentCacheIndex
header
- Headerthrowable
- Error messagepublic void remove(SegmentHeader header)
SegmentCacheIndex
remove
in interface SegmentCacheIndex
header
- Segment headerpublic static boolean matches(SegmentHeader header, Map<String,Comparable> coords, List<String> compoundPredicates)
public List<SegmentHeader> intersectRegion(String schemaName, ByteString schemaChecksum, String cubeName, String measureName, String rolapStarFactTableName, SegmentColumn[] region)
SegmentCacheIndex
This method is used to find out which headers need to be trimmed or removed during a flush.
intersectRegion
in interface SegmentCacheIndex
schemaName
- Schema nameschemaChecksum
- Schema checksumcubeName
- Cube namemeasureName
- Measure namerolapStarFactTableName
- Fact table tableregion
- Regionpublic void printCacheState(PrintWriter pw)
SegmentCacheIndex
printCacheState
in interface SegmentCacheIndex
pw
- Print writerpublic Future<SegmentBody> getFuture(Execution exec, SegmentHeader header)
SegmentCacheIndex
When this method is invoked, the execution instance of the
thread is automatically added to the list of clients for the
given segment. The calling code is responsible for calling
SegmentCacheIndex.cancel(Execution)
when it is done with the segments,
or else this registration will prevent others from canceling
the running SQL statements associated to this segment.
getFuture
in interface SegmentCacheIndex
header
- Segment headerpublic void linkSqlStatement(SegmentHeader header, Statement stmt)
SegmentCacheIndex
Statement
to a segment. This allows
the index to cleanup when SegmentCacheIndex.cancel(Execution)
is
invoked and orphaned segments are left.linkSqlStatement
in interface SegmentCacheIndex
header
- The segment.stmt
- The SQL statement.public boolean contains(SegmentHeader header)
SegmentCacheIndex
contains
in interface SegmentCacheIndex
public void cancel(Execution exec)
SegmentCacheIndex
cancel
in interface SegmentCacheIndex
exec
- The execution to unregister.public SegmentBuilder.SegmentConverter getConverter(String schemaName, ByteString schemaChecksum, String cubeName, String rolapStarFactTableName, String measureName, List<String> compoundPredicates)
SegmentCacheIndex
getConverter
in interface SegmentCacheIndex
schemaName
- Schema nameschemaChecksum
- Schema checksumcubeName
- Cube namerolapStarFactTableName
- Fact tablemeasureName
- Measure namecompoundPredicates
- Compound predicatespublic void setConverter(String schemaName, ByteString schemaChecksum, String cubeName, String rolapStarFactTableName, String measureName, List<String> compoundPredicates, SegmentBuilder.SegmentConverter converter)
SegmentCacheIndex
setConverter
in interface SegmentCacheIndex
schemaName
- Schema nameschemaChecksum
- Schema checksumcubeName
- Cube namerolapStarFactTableName
- Fact tablemeasureName
- Measure namecompoundPredicates
- Compound predicatesconverter
- Converter to storepublic List<List<SegmentHeader>> findRollupCandidates(String schemaName, ByteString schemaChecksum, String cubeName, String measureName, String rolapStarFactTableName, BitKey constrainedColsBitKey, Map<String,Comparable> coordinates, List<String> compoundPredicates)
SegmentCacheIndex
findRollupCandidates
in interface SegmentCacheIndex
schemaName
- Schema nameschemaChecksum
- Schema checksumcubeName
- Cube namemeasureName
- Measure namerolapStarFactTableName
- Fact table tableconstrainedColsBitKey
- Bit keycoordinates
- CoordinatescompoundPredicates
- Compound predicatesCopyright © 2019 Hitachi Vantara. All rights reserved.