Class SyntheticRecordPlanner


  • @API(INTERNAL)
    public class SyntheticRecordPlanner
    extends Object
    A planner for SyntheticRecordPlan and SyntheticRecordFromStoredRecordPlan 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 (the FromStoredRecord case). The planner is initialized with a RecordMetaData, for getting synthetic record type definitions (such as the joins that make up a joined record type) and a RecordQueryPlanner, which is used to plan the underlying scans of stored records from which the records to be indexed can be synthesized.
    • Constructor Detail

      • SyntheticRecordPlanner

        public SyntheticRecordPlanner​(@Nonnull
                                      RecordMetaData recordMetaData,
                                      @Nonnull
                                      RecordStoreState storeState)
        Initialize a new planner.
        Parameters:
        recordMetaData - meta-data to use for planning
        storeState - 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 type
        onlyIfIndexed - 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 built
        recordTypes - a subset of the index's record types or null 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 the OnlineIndexer 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 type
        joinConstituent - the constituent type
        Returns:
        a plan that can be applied to a record of the given type to generate synthetic records