mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 03:17:50 +00:00
a) All tests green under -race for both PILOSA_TXSRC=roaring and PILOSA_TXSRC=badger. b) Distinct is merged back into mainline pilosa. Seebs notes on the Distinct work: merge Distinct plugin back into main source tree, convert to Tx We drop all references to the Preemptively Deprecated Don't You Dare Use This extension interface, and move the one and only extension we had (Distinct) into the main executor. Also this fixes an arguable bug, which is that Container.AsBitmap() would panic on a nil parameter, but it should have returned an empty bitmap, because a nil *Ccontainer is a valid empty container. This simplifies logic significantly in Distinct. Fixes #569 #570 #571 #572 #573 #584 #585
143 lines
3.2 KiB
Go
143 lines
3.2 KiB
Go
// home: https://github.com/glyerine/vprint
|
|
// Copyright 2019 Jason E. Aten, Ph.D. All rights reserved.
|
|
// License: MIT
|
|
//
|
|
// MIT License
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
// copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
// SOFTWARE.
|
|
|
|
package pilosa
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
"path"
|
|
"runtime"
|
|
"runtime/debug"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
const RFC3339MsecTz0 = "2006-01-02T15:04:05.000Z07:00"
|
|
const RFC3339UsecTz0 = "2006-01-02T15:04:05.000000Z07:00"
|
|
|
|
// for tons of debug output
|
|
var VerboseVerbose bool = false
|
|
|
|
// convience functions for . import
|
|
var pp = PP
|
|
var vv = VV
|
|
|
|
var panicOn = PanicOn
|
|
|
|
func init() {
|
|
// keeper linter happy
|
|
_ = pp
|
|
_ = vv
|
|
}
|
|
|
|
func PanicOn(err error) {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func PP(format string, a ...interface{}) {
|
|
if VerboseVerbose {
|
|
TSPrintf(format, a...)
|
|
}
|
|
}
|
|
|
|
func VV(format string, a ...interface{}) {
|
|
TSPrintf(format, a...)
|
|
}
|
|
|
|
func AlwaysPrintf(format string, a ...interface{}) {
|
|
TSPrintf(format, a...)
|
|
}
|
|
|
|
var tsPrintfMut sync.Mutex
|
|
|
|
// time-stamped printf
|
|
func TSPrintf(format string, a ...interface{}) {
|
|
tsPrintfMut.Lock()
|
|
Printf("\n%s %s ", FileLine(3), ts())
|
|
Printf(format+"\n", a...)
|
|
tsPrintfMut.Unlock()
|
|
}
|
|
|
|
// get timestamp for logging purposes
|
|
func ts() string {
|
|
return time.Now().Format(RFC3339UsecTz0)
|
|
}
|
|
|
|
// so we can multi write easily, use our own printf
|
|
var OurStdout io.Writer = os.Stdout
|
|
|
|
// Printf formats according to a format specifier and writes to standard output.
|
|
// It returns the number of bytes written and any write error encountered.
|
|
func Printf(format string, a ...interface{}) (n int, err error) {
|
|
return fmt.Fprintf(OurStdout, format, a...)
|
|
}
|
|
|
|
func FileLine(depth int) string {
|
|
_, fileName, fileLine, ok := runtime.Caller(depth)
|
|
var s string
|
|
if ok {
|
|
s = fmt.Sprintf("%s:%d", path.Base(fileName), fileLine)
|
|
} else {
|
|
s = ""
|
|
}
|
|
return s
|
|
}
|
|
|
|
func stack() string {
|
|
return string(debug.Stack())
|
|
}
|
|
|
|
func FileExists(name string) bool {
|
|
fi, err := os.Stat(name)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
if fi.IsDir() {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func DirExists(name string) bool {
|
|
fi, err := os.Stat(name)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
if fi.IsDir() {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func FileSize(name string) (int64, error) {
|
|
fi, err := os.Stat(name)
|
|
if err != nil {
|
|
return -1, err
|
|
}
|
|
return fi.Size(), nil
|
|
}
|