Package org.datanucleus
Class FetchPlanForClass
- java.lang.Object
-
- org.datanucleus.FetchPlanForClass
-
public class FetchPlanForClass extends java.lang.Object
Representation of the fetch plan for a particular class, defining the members that are to be fetched.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) AbstractClassMetaData
cmd
MetaData for the class that this represents.(package private) boolean
dirty
Whether the record is dirty and needs the fields recalculating.private java.util.Map<java.lang.Integer,java.util.Set<FetchGroupMetaData>>
fetchGroupsByMemberNumber
Cache of fetch groups by member number, as calculating them in getFetchGroupsForMemberNumber() is O(n^2) Map> (package private) int[]
memberNumbers
Absolute numbers of fields/properties in the fetch plan for this class.(package private) FetchPlan
plan
Parent FetchPlan.(package private) java.util.Map<java.lang.Integer,java.lang.Integer>
recursionDepthByMemberNumber
-
Constructor Summary
Constructors Constructor Description FetchPlanForClass(AbstractClassMetaData cmd, FetchPlan fetchPlan)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AbstractClassMetaData
getAbstractClassMetaData()
Accessor for the MetaData for this classes plan.(package private) FetchPlanForClass
getCopy(FetchPlan fp)
Returns a copy of this object with all settings initialised.private java.util.Set<FetchGroupMetaData>
getFetchGroupsForMemberNumber(java.util.Set<FetchGroupMetaData> fgmds, int memberNum)
Get all the (MetaData-based) fetch groups where this member number is included.FetchPlan
getFetchPlan()
Accessor for the FetchPlan that this classes plan relates to.int[]
getMemberNumbers()
Get the absolute numbers of the members in the fetch plan for this class.java.util.BitSet
getMemberNumbersByBitSet()
Get all members (of this class, and superclasses) in the fetch plan.private java.util.BitSet
getMemberNumbersByBitSet(AbstractClassMetaData cmd)
Get all members in the fetch plan for this class and superclasses.private java.util.BitSet
getMemberNumbersForFetchGroup(FetchGroupMetaData fgmd)
Get the absolute member numbers for a particular Fetch Group.private java.util.BitSet
getMemberNumbersForFetchGroups(java.util.Set<FetchGroupMetaData> fgmds)
Get the absolute number of the members for an array of Fetch Group.int
getRecursionDepthForMember(int memberNum)
Method to return the recursion depth of this member number in the overall fetch plan.boolean
hasMember(int memberNumber)
Return whether the specified field/property is in the fetch planboolean
isToCallPostLoadFetchPlan(boolean[] loadedMembers)
Whether to call the post load or not.(package private) void
markDirty()
private void
setAsAll(java.util.BitSet memberNums)
Sets the given BitSet of member numbers to include all the members.private void
setAsDefault(java.util.BitSet memberNums)
Sets the given BitSet of member numbers to include the DFG members.private void
setAsNone(java.util.BitSet memberNums)
Sets the given BitSet of member numbers to include none of the members (except the PKs).java.lang.String
toString()
-
-
-
Field Detail
-
plan
final FetchPlan plan
Parent FetchPlan.
-
cmd
final AbstractClassMetaData cmd
MetaData for the class that this represents.
-
memberNumbers
int[] memberNumbers
Absolute numbers of fields/properties in the fetch plan for this class.
-
dirty
boolean dirty
Whether the record is dirty and needs the fields recalculating.
-
recursionDepthByMemberNumber
java.util.Map<java.lang.Integer,java.lang.Integer> recursionDepthByMemberNumber
-
fetchGroupsByMemberNumber
private java.util.Map<java.lang.Integer,java.util.Set<FetchGroupMetaData>> fetchGroupsByMemberNumber
Cache of fetch groups by member number, as calculating them in getFetchGroupsForMemberNumber() is O(n^2) Map>
-
-
Constructor Detail
-
FetchPlanForClass
public FetchPlanForClass(AbstractClassMetaData cmd, FetchPlan fetchPlan)
Constructor.- Parameters:
cmd
- MetaData for the classfetchPlan
- the FetchPlan
-
-
Method Detail
-
getFetchPlan
public final FetchPlan getFetchPlan()
Accessor for the FetchPlan that this classes plan relates to.- Returns:
- The FetchPlan
-
getAbstractClassMetaData
public final AbstractClassMetaData getAbstractClassMetaData()
Accessor for the MetaData for this classes plan.- Returns:
- MetaData for the class represented here
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
markDirty
void markDirty()
-
getCopy
FetchPlanForClass getCopy(FetchPlan fp)
Returns a copy of this object with all settings initialised. Used when a Query has to have its own FetchPlan, so takes a copy of that of the ExecutionContext.- Returns:
- the FetchPlanForClass copy
-
getRecursionDepthForMember
public int getRecursionDepthForMember(int memberNum)
Method to return the recursion depth of this member number in the overall fetch plan.- Parameters:
memberNum
- Number of member in this class- Returns:
- The recursion depth
-
hasMember
public boolean hasMember(int memberNumber)
Return whether the specified field/property is in the fetch plan- Parameters:
memberNumber
- The member number- Returns:
- Whether it is in the FetchPlan
-
getMemberNumbers
public int[] getMemberNumbers()
Get the absolute numbers of the members in the fetch plan for this class.- Returns:
- an array with the absolute position of the members
-
getMemberNumbersByBitSet
public java.util.BitSet getMemberNumbersByBitSet()
Get all members (of this class, and superclasses) in the fetch plan.- Returns:
- an BitSet with the bits set in the absolute position of the fields
-
getMemberNumbersByBitSet
private java.util.BitSet getMemberNumbersByBitSet(AbstractClassMetaData cmd)
Get all members in the fetch plan for this class and superclasses.- Parameters:
cmd
- metadata for the class- Returns:
- an BitSet with the bits set in the absolute position of the members
-
getMemberNumbersForFetchGroups
private java.util.BitSet getMemberNumbersForFetchGroups(java.util.Set<FetchGroupMetaData> fgmds)
Get the absolute number of the members for an array of Fetch Group.- Parameters:
fgmds
- The Fetch Groups- Returns:
- a BitSet with flags set to true in the member number positions
-
getMemberNumbersForFetchGroup
private java.util.BitSet getMemberNumbersForFetchGroup(FetchGroupMetaData fgmd)
Get the absolute member numbers for a particular Fetch Group.- Parameters:
fgmd
- The Fetch Group- Returns:
- a list of member numbers
-
setAsDefault
private void setAsDefault(java.util.BitSet memberNums)
Sets the given BitSet of member numbers to include the DFG members.- Parameters:
memberNums
- BitSet of member numbers
-
setAsAll
private void setAsAll(java.util.BitSet memberNums)
Sets the given BitSet of member numbers to include all the members.- Parameters:
memberNums
- BitSet of member numbers
-
setAsNone
private void setAsNone(java.util.BitSet memberNums)
Sets the given BitSet of member numbers to include none of the members (except the PKs).- Parameters:
memberNums
- BitSet of member numbers
-
isToCallPostLoadFetchPlan
public boolean isToCallPostLoadFetchPlan(boolean[] loadedMembers)
Whether to call the post load or not. Checks if members in actual FetchPlan where not previouly loaded and the post-load is enabled in the metadata.- Parameters:
loadedMembers
- already loaded members- Returns:
- if is to call the postLoad
-
getFetchGroupsForMemberNumber
private java.util.Set<FetchGroupMetaData> getFetchGroupsForMemberNumber(java.util.Set<FetchGroupMetaData> fgmds, int memberNum)
Get all the (MetaData-based) fetch groups where this member number is included.- Parameters:
fgmds
- The Fetch GroupsmemberNum
- the member absolute number- Returns:
- The Fetch Groups
-
-