Documentation
¶
Index ¶
- Constants
- Variables
- func CRC32(data []byte) uint32
- func CombineUnique[T cmp.Ordered](a, b []T) []T
- func EnableRacePreemptionPoints() func()
- func EqualPtrFields(src, dst reflect.Value, prefix string) []string
- func ExpandTabsInRedactableBytes(s redact.RedactableBytes) (redact.RedactableBytes, error)
- func Filter[T any](collection []T, predicate func(T) bool) []T
- func GetSingleRune(s string) (rune, error)
- func GetSmallTrace(skip int) redact.RedactableString
- func InsertUnique[T cmp.Ordered](s []T, v T) []T
- func Map[T, K any](collection []T, fn func(T) K) []K
- func MapFrom[T any, K comparable, V any](collection []T, fn func(T) (K, V)) map[K]V
- func MoveTopKToFront(data sort.Interface, k int)
- func Pluralize(n int64) redact.SafeString
- func RacePreempt()
- func RandString(rng *rand.Rand, length int, alphabet string) string
- func Reduce[T any, U any](collection []T, fn func(acc U, el T, idx int) U, init U) U
- func RemoveTrailingSpaces(input string) string
- func ToLowerSingleByte(b byte) byte
- func TruncateString(s string, maxRunes int) string
- type EveryN
- type FNV64
- type FastIntMap
- func (m FastIntMap) ContentsIntoBuffer(buf *bytes.Buffer)
- func (m FastIntMap) Copy() FastIntMap
- func (m FastIntMap) Empty() bool
- func (m FastIntMap) ForEach(fn func(key, val int))
- func (m FastIntMap) Get(key int) (value int, ok bool)
- func (m FastIntMap) GetDefault(key int) (value int)
- func (m FastIntMap) Len() int
- func (m FastIntMap) MaxKey() (_ int, ok bool)
- func (m FastIntMap) MaxValue() (_ int, ok bool)
- func (m *FastIntMap) Set(key, val int)
- func (m FastIntMap) String() string
- func (m *FastIntMap) Unset(key int)
- type NoCopy
- type StringListBuilder
- type UnresolvedAddr
- func (*UnresolvedAddr) Descriptor() ([]byte, []int)
- func (this *UnresolvedAddr) Equal(that interface{}) bool
- func (a UnresolvedAddr) IsEmpty() bool
- func (m *UnresolvedAddr) Marshal() (dAtA []byte, err error)
- func (m *UnresolvedAddr) MarshalTo(dAtA []byte) (int, error)
- func (m *UnresolvedAddr) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a *UnresolvedAddr) Network() string
- func (*UnresolvedAddr) ProtoMessage()
- func (m *UnresolvedAddr) Reset()
- func (a UnresolvedAddr) Resolve() (net.Addr, error)
- func (m *UnresolvedAddr) Size() (n int)
- func (a UnresolvedAddr) String() string
- func (m *UnresolvedAddr) Unmarshal(dAtA []byte) error
- func (m *UnresolvedAddr) XXX_DiscardUnknown()
- func (m *UnresolvedAddr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *UnresolvedAddr) XXX_Merge(src proto.Message)
- func (m *UnresolvedAddr) XXX_Size() int
- func (m *UnresolvedAddr) XXX_Unmarshal(b []byte) error
Constants ¶
const RaceEnabled = false
RaceEnabled is true if CockroachDB was built with the race build tag.
Variables ¶
var ( ErrInvalidLengthUnresolvedAddr = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowUnresolvedAddr = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupUnresolvedAddr = fmt.Errorf("proto: unexpected end of group") )
var TestAddr = NewUnresolvedAddr("tcp", "127.0.0.1:0")
TestAddr is an address to use for test servers. Listening on port 0 causes the kernel to allocate an unused port.
Functions ¶
func CombineUnique ¶
CombineUnique merges two ordered slices. If both slices have unique elements then so does the resulting slice. More generally, each element is present max(timesInA, timesInB) times.
Takes ownership of both slices, and uses the longer one to store the result.
This function is used to combine slices where one of the slices is small or has mostly the same elements as the other. If the two slices are large and don't have many duplicates, this function should be avoided, because of the usage of `copy` that can increase CPU.
func EnableRacePreemptionPoints ¶
func EnableRacePreemptionPoints() func()
EnableRacePreemptionPoints enables goroutine preemption points declared with RacePreempt for builds using the race build tag.
func EqualPtrFields ¶
EqualPtrFields uses reflection to check two "mirror" structures for matching pointer fields that point to the same object. Used to verify cloning/deep copy functions.
Returns the names of equal pointer fields.
func ExpandTabsInRedactableBytes ¶
func ExpandTabsInRedactableBytes(s redact.RedactableBytes) (redact.RedactableBytes, error)
ExpandTabsInRedactableBytes expands tabs in the redactable byte slice, so that columns are aligned. The correctness of this function depends on the assumption that the `tabwriter` does not replace characters.
func Filter ¶
Filter returns a new slice that only contains elements from collection that satisfy predicate.
// Filter in place numbers = Filter(numbers, isEven) // Filter into a new slice odds := Filter(numbers, isEven)
func GetSingleRune ¶
GetSingleRune decodes the string s as a single rune if possible.
func GetSmallTrace ¶
func GetSmallTrace(skip int) redact.RedactableString
GetSmallTrace returns a comma-separated string containing the top 5 callers from a given skip level.
func InsertUnique ¶ added in v0.25.2
InsertUnique inserts an element into an ordered slice if the element is not already present while maintaining the ordering property. Possibly updated slice is returned.
func Map ¶
func Map[T, K any](collection []T, fn func(T) K) []K
Map returns a new slice containing the results of fn for each element within collection. Usage:
Map([]int{1, 2, 3}, func(i int) int { return i })
func MapFrom ¶
func MapFrom[T any, K comparable, V any](collection []T, fn func(T) (K, V)) map[K]V
MapFrom returns a map populated with keys and values returned by fn. Usage:
// Construct a set. MapFrom(numbers, func(i int) (int, struct{}) { return i, struct{}{} }) // Construct a map of numbers to their square. MapFrom(numbers, func(i int) (int, int) { return i, i * i })
func MoveTopKToFront ¶
MoveTopKToFront moves the top K elements to the front. It makes O(n) calls to data.Less and data.Swap (with very high probability). It uses Hoare's selection algorithm (aka quickselect).
func Pluralize ¶
func Pluralize(n int64) redact.SafeString
Pluralize returns a single character 's' unless n == 1.
func RacePreempt ¶
func RacePreempt()
RacePreempt adds a goroutine preemption point if CockroachDB was built with the race build tag and preemption points have been enabled. The function is a no-op (and should be optimized out through dead code elimination) if the race build tag was not used.
func RandString ¶
RandString generates a random string of the desired length from the input alphabet.
func Reduce ¶ added in v0.25.2
Reduce applies a function against an accumulator and each element of a collection, reducing it to a single value.
func RemoveTrailingSpaces ¶
RemoveTrailingSpaces splits the input string into lines, trims any trailing spaces from each line, then puts the lines back together.
Any newlines at the end of the input string are ignored.
The output string always ends in a newline.
func ToLowerSingleByte ¶
ToLowerSingleByte returns the lowercase of a given single ASCII byte. A non ASCII byte is returned unchanged.
func TruncateString ¶
TruncateString truncates a string to a given number of runes.
Types ¶
type EveryN ¶
type EveryN struct { // N is the minimum duration of time between log messages. N time.Duration syncutil.Mutex // contains filtered or unexported fields }
EveryN provides a way to rate limit spammy events. It tracks how recently a given event has occurred so that it can determine whether it's worth handling again.
The zero value for EveryN is usable and is equivalent to Every(0), meaning that all calls to ShouldProcess will return true.
NOTE: If you specifically care about log messages, you should use the version of this in the log package, as it integrates with the verbosity flags.
type FNV64 ¶
type FNV64 struct {
// contains filtered or unexported fields
}
FNV64 encapsulates the hash state.
func (*FNV64) Add ¶
Add modifies the underlying FNV64 state by accumulating the given integer hash to the existing state.
func (*FNV64) IsInitialized ¶
IsInitialized returns true if the hash struct was initialized, which happens automatically when created through MakeFNV64 above.
type FastIntMap ¶
type FastIntMap struct {
// contains filtered or unexported fields
}
FastIntMap is a replacement for map[int]int which is more efficient when both keys and values are small. It can be passed by value (but Copy must be used for independent modification of copies).
func (FastIntMap) ContentsIntoBuffer ¶
func (m FastIntMap) ContentsIntoBuffer(buf *bytes.Buffer)
ContentsIntoBuffer writes the contents of the map into the provided buffer in the following format:
key1:val1 key2:val2 ...
The keys are in ascending order.
func (FastIntMap) Copy ¶
func (m FastIntMap) Copy() FastIntMap
Copy returns a FastIntMap that can be independently modified.
func (FastIntMap) ForEach ¶
func (m FastIntMap) ForEach(fn func(key, val int))
ForEach calls the given function for each key/value pair in the map (in arbitrary order).
func (FastIntMap) Get ¶
func (m FastIntMap) Get(key int) (value int, ok bool)
Get returns the current value mapped to key, or (-1, false) if the key is unmapped.
func (FastIntMap) GetDefault ¶
func (m FastIntMap) GetDefault(key int) (value int)
GetDefault returns the current value mapped to key, or 0 if the key is unmapped.
func (FastIntMap) MaxKey ¶
func (m FastIntMap) MaxKey() (_ int, ok bool)
MaxKey returns the maximum key that is in the map. If the map is empty, returns ok=false.
func (FastIntMap) MaxValue ¶
func (m FastIntMap) MaxValue() (_ int, ok bool)
MaxValue returns the maximum value that is in the map. If the map is empty, returns (0, false).
func (FastIntMap) String ¶
func (m FastIntMap) String() string
String prints out the contents of the map in the following format:
map[key1:val1 key2:val2 ...]
The keys are in ascending order.
type NoCopy ¶
type NoCopy struct{}
NoCopy may be embedded into structs which must not be copied after the first use.
See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details.
type StringListBuilder ¶
type StringListBuilder struct {
// contains filtered or unexported fields
}
StringListBuilder helps printing out lists of items. See MakeStringListBuilder.
func MakeStringListBuilder ¶
func MakeStringListBuilder(begin, separator, end string) StringListBuilder
MakeStringListBuilder creates a StringListBuilder, which is used to print out lists of items. Sample usage:
b := MakeStringListBuilder("(", ", ", ")") b.Add(&buf, "x") b.Add(&buf, "y") b.Finish(&buf) // By now, we wrote "(x, y)".
If Add is not called, nothing is written.
func (*StringListBuilder) Add ¶
func (b *StringListBuilder) Add(w io.Writer, val string)
Add an item to the list.
func (*StringListBuilder) Addf ¶
func (b *StringListBuilder) Addf(w io.Writer, format string, args ...interface{})
Addf is a format variant of Add.
func (*StringListBuilder) Finish ¶
func (b *StringListBuilder) Finish(w io.Writer)
Finish must be called after all the elements have been added.
type UnresolvedAddr ¶
type UnresolvedAddr struct { NetworkField string `protobuf:"bytes,1,opt,name=network_field,json=networkField" json:"network_field"` AddressField string `protobuf:"bytes,2,opt,name=address_field,json=addressField" json:"address_field"` }
UnresolvedAddr is an unresolved version of net.Addr.
var IsolatedTestAddr *UnresolvedAddr
IsolatedTestAddr is an address to use for tests that need extra isolation by using more addresses than 127.0.0.1 (support for this is platform-specific and only enabled on Linux). Both TestAddr and IsolatedTestAddr guarantee that the chosen port is not in use when allocated, but IsolatedTestAddr draws from a larger pool of addresses so that when tests are run in a tight loop the system is less likely to run out of available ports or give a port to one test immediately after it was closed by another.
IsolatedTestAddr should be used for tests that open and close a large number of sockets, or tests which stop a server and rely on seeing a "connection refused" error afterwards. It cannot be used with tests that operate in secure mode since our test certificates are only valid for 127.0.0.1.
func MakeUnresolvedAddr ¶
func MakeUnresolvedAddr(network, addr string) UnresolvedAddr
MakeUnresolvedAddr populates an UnresolvedAddr from a network and raw address string.
func MakeUnresolvedAddrWithDefaults ¶
func MakeUnresolvedAddrWithDefaults(network, addr, defaultPort string) UnresolvedAddr
MakeUnresolvedAddrWithDefaults creates a new UnresolvedAddr from a network and raw address string, using the following defaults if not given:
- Network: tcp - Host: local hostname or 127.0.0.1 - Port: given default port
func NewUnresolvedAddr ¶
func NewUnresolvedAddr(network, addr string) *UnresolvedAddr
NewUnresolvedAddr creates a new UnresolvedAddr from a network and raw address string.
func (*UnresolvedAddr) Descriptor ¶
func (*UnresolvedAddr) Descriptor() ([]byte, []int)
func (*UnresolvedAddr) Equal ¶
func (this *UnresolvedAddr) Equal(that interface{}) bool
func (UnresolvedAddr) IsEmpty ¶
func (a UnresolvedAddr) IsEmpty() bool
IsEmpty returns true if the address has no network or address specified.
func (*UnresolvedAddr) Marshal ¶
func (m *UnresolvedAddr) Marshal() (dAtA []byte, err error)
func (*UnresolvedAddr) MarshalToSizedBuffer ¶
func (m *UnresolvedAddr) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*UnresolvedAddr) Network ¶
func (a *UnresolvedAddr) Network() string
Network returns the address's network name.
func (*UnresolvedAddr) ProtoMessage ¶
func (*UnresolvedAddr) ProtoMessage()
func (*UnresolvedAddr) Reset ¶
func (m *UnresolvedAddr) Reset()
func (UnresolvedAddr) Resolve ¶
func (a UnresolvedAddr) Resolve() (net.Addr, error)
Resolve attempts to resolve a into a net.Addr.
func (*UnresolvedAddr) Size ¶
func (m *UnresolvedAddr) Size() (n int)
func (UnresolvedAddr) String ¶
func (a UnresolvedAddr) String() string
String returns the address's string form.
func (*UnresolvedAddr) Unmarshal ¶
func (m *UnresolvedAddr) Unmarshal(dAtA []byte) error
func (*UnresolvedAddr) XXX_DiscardUnknown ¶
func (m *UnresolvedAddr) XXX_DiscardUnknown()
func (*UnresolvedAddr) XXX_Marshal ¶
func (m *UnresolvedAddr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*UnresolvedAddr) XXX_Merge ¶
func (m *UnresolvedAddr) XXX_Merge(src proto.Message)
func (*UnresolvedAddr) XXX_Size ¶
func (m *UnresolvedAddr) XXX_Size() int
func (*UnresolvedAddr) XXX_Unmarshal ¶
func (m *UnresolvedAddr) XXX_Unmarshal(b []byte) error
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
admission
|
|
admissionpb
Package admissionpb contains the base types for the admission package.
|
Package admissionpb contains the base types for the admission package. |
Package buildutil provides a constant CrdbTestBuild.
|
Package buildutil provides a constant CrdbTestBuild. |
Package encoding exposes some utilities for encoding data as bytes.
|
Package encoding exposes some utilities for encoding data as bytes. |
Package grunning is a library that's able to retrieve on-CPU running time for individual goroutines.
|
Package grunning is a library that's able to retrieve on-CPU running time for individual goroutines. |
Package hlc implements the Hybrid Logical Clock outlined in "Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases", available online at http://www.cse.buffalo.edu/tech-reports/2014-04.pdf.
|
Package hlc implements the Hybrid Logical Clock outlined in "Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases", available online at http://www.cse.buffalo.edu/tech-reports/2014-04.pdf. |
Package interval provides two implementations for an interval tree.
|
Package interval provides two implementations for an interval tree. |
log
|
|
netutil
|
|
Package num32 contains basic numeric functions that operate on scalar, vector, and matrix float32 values.
|
Package num32 contains basic numeric functions that operate on scalar, vector, and matrix float32 values. |
Package pretty prints documents based on a target line width.
|
Package pretty prints documents based on a target line width. |
gen
This binary takes the tzdata from Go's source and extracts all timezones names from them.
|
This binary takes the tzdata from Go's source and extracts all timezones names from them. |
pgdate
Package pgdate contains parsing functions and types for dates and times in a manner that is compatible with PostgreSQL.
|
Package pgdate contains parsing functions and types for dates and times in a manner that is compatible with PostgreSQL. |
Package tracing encapsulates all tracing facilities used in CockroachDB.
|
Package tracing encapsulates all tracing facilities used in CockroachDB. |