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

     1  // Copyright 2015 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 config
    12  
    13  import (
    14  	"github.com/cockroachdb/cockroach/pkg/keys"
    15  	"github.com/cockroachdb/cockroach/pkg/roachpb"
    16  )
    17  
    18  // MakeZoneKeyPrefix returns the key prefix for id's row in the system.zones
    19  // table.
    20  func MakeZoneKeyPrefix(id uint32) roachpb.Key {
    21  	return keys.SystemSQLCodec.ZoneKeyPrefix(id)
    22  }
    23  
    24  // MakeZoneKey returns the key for id's entry in the system.zones table.
    25  func MakeZoneKey(id uint32) roachpb.Key {
    26  	return keys.SystemSQLCodec.ZoneKey(id)
    27  }
    28  
    29  // DecodeObjectID decodes the object ID from the front of key. It returns the
    30  // decoded object ID, the remainder of the key, and whether the result is valid
    31  // (i.e., whether the key was within the structured key space).
    32  func DecodeObjectID(key roachpb.RKey) (uint32, []byte, bool) {
    33  	rem, id, err := keys.TODOSQLCodec.DecodeTablePrefix(key.AsRawKey())
    34  	return id, rem, err == nil
    35  }