github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/base/zone.go (about)

     1  // Copyright 2019 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package base
    12  
    13  // SubzoneID represents a subzone within a zone. It's the subzone's index within
    14  // the parent zone + 1; there's no subzone 0 so that 0 can be used as a
    15  // sentinel.
    16  type SubzoneID uint32
    17  
    18  // ToSubzoneIndex turns a SubzoneID into the index corresponding to the correct
    19  // Subzone within the parent zone's Subzones slice.
    20  func (id SubzoneID) ToSubzoneIndex() int32 {
    21  	return int32(id) - 1
    22  }
    23  
    24  // SubzoneIDFromIndex turns a subzone's index within its parent zone into its
    25  // SubzoneID.
    26  func SubzoneIDFromIndex(idx int) SubzoneID {
    27  	return SubzoneID(idx + 1)
    28  }