utils

package
v1.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PB_NONE = iota
	PB_INFO
	PB_VERBOSE

	//Verbose progress bar logs every 5 percent
	INCR_PERCENT = 5
)

* The following constants are used for determining when to display a progress bar * * PB_INFO only shows in info mode because some methods have a different way of * logging in verbose mode and we don't want them to conflict * PB_VERBOSE show a progress bar in INFO and VERBOSE mode * * A simple incremental progress tracker will be shown in info mode and * in verbose mode we will log progress at increments of 10%

View Source
const MINIMUM_GPDB4_VERSION = "4.3.17"
View Source
const MINIMUM_GPDB5_VERSION = "5.1.0"

Variables

View Source
var (
	Version       string
	WasTerminated bool

	/*
	 * Used for synchronizing DoCleanup.  In DoInit() we increment the group
	 * and then wait for at least one DoCleanup to finish, either in DoTeardown
	 * or the signal handler.
	 */
	CleanupGroup *sync.WaitGroup
)

* Non-flag variables

View Source
var CmdFlags *pflag.FlagSet

* Command-line flags

Functions

func ArrayIsDuplicated

func ArrayIsDuplicated(elems []string) bool

func CloseDataFile

func CloseDataFile(f *os.File)

func CopyFile

func CopyFile(src, dest string) error

func CurrentTimestamp

func CurrentTimestamp() string

func DollarQuoteString

func DollarQuoteString(literal string) string

Dollar-quoting logic is based on appendStringLiteralDQ() in pg_dump.

func EscapeSingleQuotes

func EscapeSingleQuotes(str string) string

func Exists

func Exists(slice []string, val string) bool

func GetUserAndHostInfo

func GetUserAndHostInfo() (string, string, string)

func GetVersion

func GetVersion() string

func HandleSingleDashes

func HandleSingleDashes(args []string) []string

func InitializePipeThroughParameters

func InitializePipeThroughParameters(compress bool, compressionType string, compressionLevel int)

func InitializeSignalHandler

func InitializeSignalHandler(cleanupFunc func(bool), procDesc string, termFlag *bool)

func MakeFQN

func MakeFQN(schema string, object string) string

This function assumes that all identifiers are already appropriately quoted

func MustGetFlagBool

func MustGetFlagBool(flagName string) bool

func MustGetFlagInt

func MustGetFlagInt(flagName string) int

func MustGetFlagString

func MustGetFlagString(flagName string) string

func MustGetFlagStringArray

func MustGetFlagStringArray(flagName string) []string

func MustGetFlagStringSlice

func MustGetFlagStringSlice(flagName string) []string

func MustPrintBytes

func MustPrintBytes(file io.Writer, bytes []byte) uint64

func MustPrintf

func MustPrintf(file io.Writer, s string, v ...interface{}) uint64

func MustPrintln

func MustPrintln(file io.Writer, v ...interface{}) uint64

func OpenDataFile

func OpenDataFile(filename string) *os.File

func OpenFileForWrite

func OpenFileForWrite(filename string) (*os.File, error)

func ParseMappingFile

func ParseMappingFile(lines []string) map[string]string

func ParseSchemaMappingFile

func ParseSchemaMappingFile(lines []string) ([]string, []string)

func QuoteIdent

func QuoteIdent(connectionPool *dbconn.DBConn, ident string) string

func ReadTableFile

func ReadTableFile(filename string) ([]string, error)

func ReadTableFileByFlag

func ReadTableFileByFlag(flagSet *pflag.FlagSet, flag string) ([]string, error)

func RedirectStream

func RedirectStream(reader io.Reader, writeCloser io.WriteCloser) error

func SetCmdFlags

func SetCmdFlags(flagSet *pflag.FlagSet)

func SetConnection

func SetConnection(conn *dbconn.DBConn)

func SetPipeThroughProgram

func SetPipeThroughProgram(compression PipeThroughProgram)

func SetVersion

func SetVersion(v string)

func SliceToQuotedString

func SliceToQuotedString(slice []string) string

func TerminateHangingCopySessions

func TerminateHangingCopySessions(conn *dbconn.DBConn, appName string)

func UnquoteIdent

func UnquoteIdent(ident string) string

func ValidateCompressionTypeAndLevel

func ValidateCompressionTypeAndLevel(compressionType string, compressionLevel int) error

func ValidateFQNs

func ValidateFQNs(tableList []string) error

func ValidateFullPath

func ValidateFullPath(path string) error

func ValidateGPDBVersionCompatibility

func ValidateGPDBVersionCompatibility(connectionPool *dbconn.DBConn)

func WriteDataFile

func WriteDataFile(f *os.File, line string) error

func WriteToFileAndMakeReadOnly

func WriteToFileAndMakeReadOnly(filename string, contents []byte) error

Types

type CompressionLevelsDescription

type CompressionLevelsDescription struct {
	Min int
	Max int
}

A description of compression levels for some compression type

type ExtendProgressBar

type ExtendProgressBar struct {
	*mpb.Bar
	*mpb.Progress
}

func (*ExtendProgressBar) Finish

func (epb *ExtendProgressBar) Finish()

func (*ExtendProgressBar) Increment

func (epb *ExtendProgressBar) Increment()

func (*ExtendProgressBar) Start

func (epb *ExtendProgressBar) Start()

type FileWithByteCount

type FileWithByteCount struct {
	Filename  string
	Writer    io.Writer
	File      *os.File
	ByteCount uint64
}

func NewFileWithByteCount

func NewFileWithByteCount(writer io.Writer) *FileWithByteCount

func NewFileWithByteCountFromFile

func NewFileWithByteCountFromFile(filename string) *FileWithByteCount

func (*FileWithByteCount) Close

func (file *FileWithByteCount) Close()

func (*FileWithByteCount) MustPrint

func (file *FileWithByteCount) MustPrint(s string)

func (*FileWithByteCount) MustPrintf

func (file *FileWithByteCount) MustPrintf(s string, v ...interface{})

func (*FileWithByteCount) MustPrintln

func (file *FileWithByteCount) MustPrintln(v ...interface{})

type FilterSet

type FilterSet struct {
	Set                 map[string]bool
	IsExclude           bool
	AlwaysMatchesFilter bool
}

* This set implementation can be used in one of two ways. An "include" set * returns true if an item is in the map and false otherwise, while an "exclude" * set returns false if an item is in the map and true otherwise, so that the * set can be used for filtering on items in lists. * * The alwaysMatchesFilter variable causes MatchesFilter() to always return true * if an empty list is passed, so that it doesn't attempt to filter on anything * The isExclude variable controls whether a set is an include set or an exclude * set.

func NewExcludeSet

func NewExcludeSet(list []string) *FilterSet

func NewIncludeSet

func NewIncludeSet(list []string) *FilterSet

func NewSet

func NewSet(list []string) *FilterSet

func (*FilterSet) Equals

func (s *FilterSet) Equals(s1 *FilterSet) bool

func (*FilterSet) Length

func (s *FilterSet) Length() int

func (*FilterSet) MatchesFilter

func (s *FilterSet) MatchesFilter(item string) bool

type FqnStruct

type FqnStruct struct {
	SchemaName string
	TableName  string
}

func SeparateSchemaAndTable

func SeparateSchemaAndTable(tableNames []string) ([]FqnStruct, error)

type PipeThroughProgram

type PipeThroughProgram struct {
	Name          string
	OutputCommand string
	InputCommand  string
	Extension     string
}

func GetPipeThroughProgram

func GetPipeThroughProgram() PipeThroughProgram

type ProgressBar

type ProgressBar interface {
	Start()
	Finish()
	Increment()
}

func NewProgressBar

func NewProgressBar(count int, prefix string, showProgressBar int) ProgressBar

func NewProgressBarEx

func NewProgressBarEx(progress *mpb.Progress, count int, prefix string) ProgressBar

type SegmentHostInfo

type SegmentHostInfo struct {
	Content  int32
	Hostname string
}

func GetSegmentsHost

func GetSegmentsHost(conn *dbconn.DBConn) []SegmentHostInfo

GetSegmentsHost retrieves the content ID and hostname for each primary segment. For Cloudberry Enterprise DB, it attempts to get segments for the warehouse identified by 'SHOW warehouse'. For other databases (GPDB, CBDB), it gets all primary segments.

func GetSegmentsIpAddress

func GetSegmentsIpAddress(conn *dbconn.DBConn, timestamp string) []SegmentHostInfo

GetSegmentsIpAddress resolves the IP address for each primary segment in the Greenplum database. It first retrieves the list of primary segments and their hostnames using the GetSegmentsHost function. Then, for each segment, it calls the getSegmentIpAddress function to resolve the IP address of the segment. The function returns a slice of SegmentIpInfo structs containing the content ID and IP address for each primary segment.

type VerboseProgressBar

type VerboseProgressBar struct {
	*mpb.Bar
	*mpb.Progress
	// contains filtered or unexported fields
}

func NewVerboseProgressBar

func NewVerboseProgressBar(count int, prefix string, bar *mpb.Bar, progress *mpb.Progress) *VerboseProgressBar

func (*VerboseProgressBar) Finish

func (vpb *VerboseProgressBar) Finish()

func (*VerboseProgressBar) Increment

func (vpb *VerboseProgressBar) Increment()

func (*VerboseProgressBar) Start

func (vpb *VerboseProgressBar) Start()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL