예제 #1
0
// conditionType is the type for condition consts.
type conditionType int

const (
	// conditionIfNotExist means the condition doesn't exist.
	conditionIfNotExist conditionType = iota + 1
	// conditionIfEqual means the condition is equals.
	conditionIfEqual
	// conditionForceSet means the condition is force set.
	conditionForceSet
)

var (
	p = pool.NewCache("memdb pool", 100, func() interface{} {
		return memdb.New(comparer.DefaultComparer, 1*1024*1024)
	})
)

// conditionValue is a data structure used to store current stored data and data verification condition.
type conditionValue struct {
	originValue []byte
	condition   conditionType
}

// IsErrNotFound checks if err is a kind of NotFound error.
func IsErrNotFound(err error) bool {
	if errors2.ErrorEqual(err, leveldb.ErrNotFound) || errors2.ErrorEqual(err, ErrNotExist) {
		return true
	}
예제 #2
0
파일: union_store.go 프로젝트: netroby/tidb
// conditionType is the type for condition consts.
type conditionType int

const (
	// conditionIfNotExist means the condition doesn't exist.
	conditionIfNotExist conditionType = iota + 1
	// conditionIfEqual means the condition is equals.
	conditionIfEqual
	// conditionForceSet means the condition is force set.
	conditionForceSet
)

var (
	p = pool.NewCache("memdb pool", 100, func() interface{} {
		return NewMemDbBuffer()
	})
)

// conditionValue is a data structure used to store current stored data and data verification condition.
type conditionValue struct {
	originValue []byte
	condition   conditionType
}

// IsErrNotFound checks if err is a kind of NotFound error.
func IsErrNotFound(err error) bool {
	if terror.ErrorEqual(err, ErrNotExist) {
		return true
	}
예제 #3
0
파일: main.go 프로젝트: pingcap/tidb-bench
	password   = flag.String("p", "", "password, default: empty")
	logLevel   = flag.String("L", "error", "log level, default: error")
	insertOnly = flag.Bool("insert-only", true, "insert data only")

	tableName string
)

const (
	forceDrop = true
)

var (
	connPool = pool.NewCache("pool", *poolSize, func() interface{} {
		db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s", *user, *password, *addr, *dbName))
		if err != nil {
			log.Fatal(err)
		}
		return db
	})
)

func init() {
	flag.Parse()
	if len(*tblPrefix) == 0 {
		// if user doesn't provide specific table prefix, we generate one.
		tableName = fmt.Sprintf("tidb_%v_bench", time.Now().UnixNano())
	} else {
		tableName = *tblPrefix + "_bench"
	}
}