Class SyntheticRecordPlanner
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.synthetic.SyntheticRecordPlanner
-
@API(INTERNAL) public class SyntheticRecordPlanner extends Object
A planner forSyntheticRecordPlan
andSyntheticRecordFromStoredRecordPlan
plans. The planner is invoked when plans are needed for index maintenance, either to generate all synthetic records for rebuilding a whole index or to generate affected synthetic records when a stored record is modified (theFromStoredRecord
case). The planner is initialized with aRecordMetaData
, for getting synthetic record type definitions (such as the joins that make up a joined record type) and aRecordQueryPlanner
, which is used to plan the underlying scans of stored records from which the records to be indexed can be synthesized.
-
-
Constructor Summary
Constructors Constructor Description SyntheticRecordPlanner(FDBRecordStore store)
Initialize a new planner.SyntheticRecordPlanner(RecordMetaData recordMetaData, RecordStoreState storeState)
Initialize a new planner.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SyntheticRecordFromStoredRecordPlan
forIndex(Index index)
Construct a plan for generating synthetic records for a given index.SyntheticRecordFromStoredRecordPlan
forJoinConstituent(JoinedRecordType joinedRecordType, JoinedRecordType.JoinConstituent joinConstituent)
Construct a plan for generating synthetic records from a constituent of a joined record type.SyntheticRecordFromStoredRecordPlan
forType(JoinedRecordType joinedRecordType)
Construct a plan for generating all joined records of a given type.SyntheticRecordFromStoredRecordPlan
forType(SyntheticRecordType<?> syntheticRecordType)
Construct a plan for generating all synthetic records of a given type.SyntheticRecordFromStoredRecordPlan
fromStoredType(RecordType storedRecordType, boolean onlyIfIndexed)
Construct a plan for generating synthetic records from a record of a given stored record type.SyntheticRecordPlan
scanForType(SyntheticRecordType<?> syntheticRecordType)
Construct a plan for generating all synthetic records of a given type.Set<RecordType>
storedRecordTypesForIndex(Index index, Collection<RecordType> recordTypes)
Determine what stored record types would be need to scanned in order to rebuild a given index.
-
-
-
Constructor Detail
-
SyntheticRecordPlanner
public SyntheticRecordPlanner(@Nonnull RecordMetaData recordMetaData, @Nonnull RecordStoreState storeState)
Initialize a new planner.- Parameters:
recordMetaData
- meta-data to use for planningstoreState
- index enabling state to use for planning
-
SyntheticRecordPlanner
public SyntheticRecordPlanner(@Nonnull FDBRecordStore store)
Initialize a new planner.- Parameters:
store
- a record store
-
-
Method Detail
-
scanForType
@Nonnull public SyntheticRecordPlan scanForType(@Nonnull SyntheticRecordType<?> syntheticRecordType)
Construct a plan for generating all synthetic records of a given type. The generated records will derive from some stored record in a record store.- Parameters:
syntheticRecordType
- the synthetic record type- Returns:
- a plan that can be applied to a record store to generate synthetic records
-
forType
@Nonnull public SyntheticRecordFromStoredRecordPlan forType(@Nonnull SyntheticRecordType<?> syntheticRecordType)
Construct a plan for generating all synthetic records of a given type. The generated records will derive from some stored record in a record store.- Parameters:
syntheticRecordType
- the synthetic record type- Returns:
- a plan that can be applied to a record store to generate synthetic records
-
forType
@Nonnull public SyntheticRecordFromStoredRecordPlan forType(@Nonnull JoinedRecordType joinedRecordType)
Construct a plan for generating all joined records of a given type. The generated records will derive from stored records in a record store.- Parameters:
joinedRecordType
- the joined record type- Returns:
- a plan that can be applied to a record store to generate joined records
-
fromStoredType
@Nullable public SyntheticRecordFromStoredRecordPlan fromStoredType(@Nonnull RecordType storedRecordType, boolean onlyIfIndexed)
Construct a plan for generating synthetic records from a record of a given stored record type. The generated records will derive from the stored record. Used when the record is updated to find synthetic records whose indexes need to be updated.- Parameters:
storedRecordType
- the stored record typeonlyIfIndexed
- only include synthetic types on which indexes are defined- Returns:
- a plan that can be applied to a record of the given type to generate synthetic records or
null
if no indexed synthetic types include the given stored record type.
-
storedRecordTypesForIndex
public Set<RecordType> storedRecordTypesForIndex(@Nonnull Index index, @Nullable Collection<RecordType> recordTypes)
Determine what stored record types would be need to scanned in order to rebuild a given index. From those scans, queries will be executed to load other record types to complete the synthesis.In cases such as full outer join, there is no single record type from which all joins can be produced.
- Parameters:
index
- the index that needs to be builtrecordTypes
- a subset of the index's record types ornull
for all- Returns:
- a set of stored record types that are sufficient to generate the synthesized records for the index
-
forIndex
@Nonnull public SyntheticRecordFromStoredRecordPlan forIndex(@Nonnull Index index)
Construct a plan for generating synthetic records for a given index. The generated records will be of indexed record types. Used by theOnlineIndexer
to build from a full scan of stored records.- Parameters:
index
- an index on synthetic record types- Returns:
- a plan that can be applied to scanned records to generate synthetic records
-
forJoinConstituent
@Nonnull public SyntheticRecordFromStoredRecordPlan forJoinConstituent(@Nonnull JoinedRecordType joinedRecordType, @Nonnull JoinedRecordType.JoinConstituent joinConstituent)
Construct a plan for generating synthetic records from a constituent of a joined record type. The generated records will start the joins from this constituent.- Parameters:
joinedRecordType
- the joined record typejoinConstituent
- the constituent type- Returns:
- a plan that can be applied to a record of the given type to generate synthetic records
-
-