Class DatabasePartitionTable

java.lang.Object
org.apache.iotdb.confignode.persistence.partition.DatabasePartitionTable

public class DatabasePartitionTable extends Object
  • Constructor Details

    • DatabasePartitionTable

      public DatabasePartitionTable(String databaseName)
  • Method Details

    • isNotPreDeleted

      public boolean isNotPreDeleted()
    • setPreDeleted

      public void setPreDeleted(boolean preDeleted)
    • updateDataNode

      public void updateDataNode(TDataNodeLocation newDataNodeLocation)
      Update the DataNodeLocation in cached RegionGroups.
      Parameters:
      newDataNodeLocation - The new DataNodeLocation.
    • createRegionGroups

      public void createRegionGroups(List<TRegionReplicaSet> replicaSets)
      Cache allocation result of new RegionGroups.
      Parameters:
      replicaSets - List
    • getAllReplicaSets

      public Stream<TRegionReplicaSet> getAllReplicaSets()
      Returns:
      Deep copy of all Regions' RegionReplicaSet within one StorageGroup
    • getAllReplicaSets

      public List<TRegionReplicaSet> getAllReplicaSets(TConsensusGroupType type)
      Get all RegionGroups currently owned by this Database.
      Parameters:
      type - The specified TConsensusGroupType
      Returns:
      Deep copy of all Regions' RegionReplicaSet with the specified TConsensusGroupType
    • getAllReplicaSets

      public List<TRegionReplicaSet> getAllReplicaSets(int dataNodeId)
      Get all RegionGroups currently owned by the specified Database.
      Parameters:
      dataNodeId - The specified dataNodeId
      Returns:
      Deep copy of all RegionGroups' RegionReplicaSet with the specified dataNodeId
    • getReplicaSets

      public List<TRegionReplicaSet> getReplicaSets(List<TConsensusGroupId> regionGroupIds)
      Get the RegionGroups with the specified RegionGroupIds.
      Parameters:
      regionGroupIds - The specified RegionGroupIds
      Returns:
      Deep copy of the RegionGroups with the specified RegionGroupIds
    • getRegionCount

      public int getRegionCount(int dataNodeId, TConsensusGroupType type)
      Only leader use this interface.

      Get the number of Regions currently owned by the specified DataNode

      Parameters:
      dataNodeId - The specified DataNode
      type - SchemaRegion or DataRegion
      Returns:
      The number of Regions currently owned by the specified DataNode
    • countDataNodeScatterWidth

      public void countDataNodeScatterWidth(int dataNodeId, TConsensusGroupType type, BitSet scatterSet)
      Only leader use this interface.

      Count the scatter width of the specified DataNode

      Parameters:
      dataNodeId - The specified DataNode
      type - SchemaRegion or DataRegion
      scatterSet - The DataNodes in the cluster which have at least one identical schema/data replica as the specified DataNode will be set true in the scatterSet.
    • getRegionGroupCount

      public int getRegionGroupCount(TConsensusGroupType type)
      Get the number of RegionGroups currently owned by this StorageGroup.
      Parameters:
      type - SchemaRegion or DataRegion
      Returns:
      The number of Regions currently owned by this StorageGroup
    • getAllRegionGroupIds

      public List<TConsensusGroupId> getAllRegionGroupIds(TConsensusGroupType type)
      Only leader use this interface.

      Get all the RegionGroups currently owned by the specified Database

      Parameters:
      type - SchemaRegion or DataRegion
      Returns:
      List of TConsensusGroupId
    • getAssignedSeriesPartitionSlotsCount

      public int getAssignedSeriesPartitionSlotsCount()
    • getSchemaPartition

      public boolean getSchemaPartition(List<TSeriesPartitionSlot> partitionSlots, SchemaPartitionTable schemaPartition)
      Thread-safely get SchemaPartition within the specific StorageGroup.
      Parameters:
      partitionSlots - SeriesPartitionSlots
      schemaPartition - Where the results are stored
      Returns:
      True if all the SeriesPartitionSlots are matched, false otherwise
    • getDataPartition

      public boolean getDataPartition(Map<TSeriesPartitionSlot,TTimeSlotList> partitionSlots, DataPartitionTable dataPartition)
      Thread-safely get DataPartition within the specific StorageGroup.
      Parameters:
      partitionSlots - SeriesPartitionSlots and TimePartitionSlots
      dataPartition - Where the results are stored
      Returns:
      True if all the PartitionSlots are matched, false otherwise
    • getSuccessorDataPartition

      public TConsensusGroupId getSuccessorDataPartition(TSeriesPartitionSlot seriesPartitionSlot, TTimePartitionSlot timePartitionSlot)
      Checks whether the specified DataPartition has a successor and returns if it does.
      Parameters:
      seriesPartitionSlot - Corresponding SeriesPartitionSlot
      timePartitionSlot - Corresponding TimePartitionSlot
      Returns:
      The specific DataPartition's successor if exists, null otherwise
    • getPredecessorDataPartition

      public TConsensusGroupId getPredecessorDataPartition(TSeriesPartitionSlot seriesPartitionSlot, TTimePartitionSlot timePartitionSlot)
      Checks whether the specified DataPartition has a predecessor and returns if it does.
      Parameters:
      seriesPartitionSlot - Corresponding SeriesPartitionSlot
      timePartitionSlot - Corresponding TimePartitionSlot
      Returns:
      The specific DataPartition's predecessor if exists, null otherwise
    • createSchemaPartition

      public void createSchemaPartition(SchemaPartitionTable assignedSchemaPartition)
      Create SchemaPartition within the specific StorageGroup.
      Parameters:
      assignedSchemaPartition - Assigned result
    • createDataPartition

      public void createDataPartition(DataPartitionTable assignedDataPartition)
      Create DataPartition within the specific StorageGroup.
      Parameters:
      assignedDataPartition - Assigned result
    • filterUnassignedSchemaPartitionSlots

      public List<TSeriesPartitionSlot> filterUnassignedSchemaPartitionSlots(List<TSeriesPartitionSlot> partitionSlots)
      Only Leader use this interface. Filter unassigned SchemaPartitionSlots within the specific StorageGroup.
      Parameters:
      partitionSlots - List
      Returns:
      Unassigned PartitionSlots
    • getDatabaseRelatedDataNodes

      public Set<TDataNodeLocation> getDatabaseRelatedDataNodes(TConsensusGroupType type)
      Get the DataNodes who contain the specific StorageGroup's Schema or Data.
      Parameters:
      type - SchemaRegion or DataRegion
      Returns:
      Set, the related DataNodes
    • filterUnassignedDataPartitionSlots

      public Map<TSeriesPartitionSlot,TTimeSlotList> filterUnassignedDataPartitionSlots(Map<TSeriesPartitionSlot,TTimeSlotList> partitionSlots)
      Only Leader use this interface. Filter unassigned DataPartitionSlots within the specific StorageGroup.
      Parameters:
      partitionSlots - List
      Returns:
      Unassigned PartitionSlots
    • getRegionGroupSlotsCounter

      public List<org.apache.tsfile.utils.Pair<Long,TConsensusGroupId>> getRegionGroupSlotsCounter(TConsensusGroupType type)
      Only leader use this interface.
      Parameters:
      type - SchemaRegion or DataRegion
      Returns:
      RegionGroups' slot count and index
    • getRegionInfoList

      public List<TRegionInfo> getRegionInfoList(GetRegionInfoListPlan regionsInfoPlan)
    • serialize

      public void serialize(OutputStream outputStream, org.apache.thrift.protocol.TProtocol protocol) throws IOException, org.apache.thrift.TException
      Throws:
      IOException
      org.apache.thrift.TException
    • deserialize

      public void deserialize(InputStream inputStream, org.apache.thrift.protocol.TProtocol protocol) throws IOException, org.apache.thrift.TException
      Throws:
      IOException
      org.apache.thrift.TException
    • getRegionId

      public List<TConsensusGroupId> getRegionId(TConsensusGroupType type, TSeriesPartitionSlot seriesSlotId, TTimePartitionSlot startTimeSlotId, TTimePartitionSlot endTimeSlotId)
    • getTimeSlotList

      public List<TTimePartitionSlot> getTimeSlotList(TSeriesPartitionSlot seriesSlotId, TConsensusGroupId regionId, long startTime, long endTime)
    • getTimeSlotCount

      public long getTimeSlotCount()
    • getSeriesSlotList

      public List<TSeriesPartitionSlot> getSeriesSlotList(TConsensusGroupType type)
    • containRegionGroup

      public boolean containRegionGroup(TConsensusGroupId regionId)
      Check if the DatabasePartitionTable contains the specified Region.
      Parameters:
      regionId - TConsensusGroupId
      Returns:
      True if contains.
    • getDatabaseName

      public String getDatabaseName()
    • getSchemaRegionIds

      public List<Integer> getSchemaRegionIds()
    • getDataRegionIds

      public List<Integer> getDataRegionIds()
    • getRegionType

      public Optional<TConsensusGroupType> getRegionType(int regionId)
    • getLastDataAllotTable

      public Map<TSeriesPartitionSlot,TConsensusGroupId> getLastDataAllotTable()
      Get the last DataAllotTable.
      Returns:
      The last DataAllotTable
    • autoCleanPartitionTable

      public void autoCleanPartitionTable(long TTL, TTimePartitionSlot currentTimeSlot)
      Remove PartitionTable where the TimeSlot is expired.
      Parameters:
      TTL - The Time To Live
      currentTimeSlot - The current TimeSlot
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object