当前位置: 首页>>代码示例>>Golang>>正文


Golang log.Info函数代码示例

本文整理汇总了Golang中github.com/senarukana/rationaldb/log.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: allowQueries

func (sq *SqlQuery) allowQueries(dbconfig *eproto.DBConfigs) {
	sq.statemu.Lock()
	v := sq.state.Get()
	switch v {
	case ABORT, SERVING:
		sq.statemu.Unlock()
		log.Info("Ignoring allowQueries request, current state: %v", v)
		return
	case INITIALIZING, SHUTTING_DOWN:
		panic("unreachable")
	}
	// state is NOT_SERVING
	sq.setState(INITIALIZING)

	defer func() {
		if x := recover(); x != nil {
			log.Error("%s", x.(*TabletError).Message)
			sq.setState(NOT_SERVING)
			return
		}
		sq.setState(SERVING)
	}()

	sq.qe.Open(dbconfig)
	sq.dbconfig = dbconfig
	sq.sessionId = Rand()
	log.Info("Session id: %d", sq.sessionId)
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:28,代码来源:sqlquery.go

示例2: Init

func (em *Engine) Init(conf *proto.DBConfigs) error {
	log.Info("Begin init engine")
	if err := em.dbEngine.Init(conf); err != nil {
		log.Info("Init engine %v error, %v", em.dbEngine.Name(), err)
		return proto.ErrDbInitError
	}
	log.Info("Init engine %v complete", em.dbEngine.Name())
	return nil
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:9,代码来源:engine.go

示例3: execInsertPK

//-----------------------------------------------
// Execution
func (qe *QueryEngine) execInsertPK(logStats *sqlQueryStats, conn PoolConnection, plan *CompiledPlan) (qr *eproto.QueryResult) {
	log.Info("Execute insert pk sql %s", plan.Query)
	tableName := plan.TableName
	tableInfo := qe.schemaInfo.tables[plan.TableName]
	rowColumns := plan.RowColumns
	var key []byte
	var columnName string
	keys := make([][]byte, 0, len(rowColumns)*len(tableInfo.Columns))
	values := make([][]byte, 0, len(rowColumns)*len(tableInfo.Columns))
	pkList := buildValueList(tableInfo, plan.PKValues, plan.BindVars)
	for i, columnsMap := range rowColumns {
		pkvalue := buildPkValue(pkList[i])
		log.Info("Pk Value is %v", string(pkvalue))
		for _, columnDef := range tableInfo.Columns {
			columnName = columnDef.Name
			if columnDef.IsPk {
				key = buildTableRowColumnKey(tableName, columnName, pkvalue)
				log.Info("pk key is %v", string(key))
				keys = append(keys, key)
				values = append(values, []byte{'0'})
			} else if columnDef.IsAuto {
				if _, ok := columnsMap[columnName]; ok {
					panic(NewTabletErrorDB(FAIL, fmt.Errorf("field %s value is auto created", columnName)))
				}
				// TODO
			} else {
				value, ok := columnsMap[columnName]
				if !ok {
					if !columnDef.Nullable {
						panic(NewTabletErrorDB(FAIL, fmt.Errorf("column %s shouldn't be null", columnDef.Name)))
					}
				}
				if !value.(sqltypes.Value).IsNull() {
					key = buildTableRowColumnKey(tableName, columnName, pkvalue)
					log.Info("normal key is %v", string(key))
					keys = append(keys, key)
					values = append(values, value.(sqltypes.Value).Raw())
					log.Info("normal value is %v", value.(sqltypes.Value).String())
				}
			}
		}
	}
	atomic.AddInt64(&qe.activeConnection, 1)
	defer atomic.AddInt64(&qe.activeConnection, -1)
	err := conn.Puts(nil, keys, values)
	if err != nil {
		panic(NewTabletErrorDB(FAIL, err))
	}

	qr = &eproto.QueryResult{RowsAffected: uint64(len(rowColumns))}
	return qr
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:54,代码来源:query_engine.go

示例4: GetPlan

func (si *SchemaInfo) GetPlan(logStats *sqlQueryStats, sql string) (plan *ExecPlan) {
	log.Warn("plan sql %v", sql)
	si.mu.Lock()
	defer si.mu.Unlock()
	if plan := si.getQuery(sql); plan != nil {
		return plan
	}

	var tableInfo *schema.Table
	GetTable := func(tableName string) (table *schema.Table, ok bool) {
		tableInfo, ok = si.tables[tableName]
		if !ok {
			return nil, false
		}
		return tableInfo, true
	}
	splan, err := sqlparser.ExecParse(sql, GetTable)
	if err != nil {
		log.Info("parse error %v", err.Error())
		panic(NewTabletError(FAIL, "%s", err))
	}
	plan = &ExecPlan{ExecPlan: splan, Table: tableInfo}
	if plan.PlanId.IsSelect() {
		fields := make([]eproto.Field, len(plan.ColumnNumbers))
		for i, cIdx := range plan.ColumnNumbers {
			column := si.tables[plan.TableName].Columns[cIdx]
			fields[i] = eproto.Field{column.Name, int64(column.Category)}
		}
		plan.Fields = fields
	} else if plan.PlanId == sqlparser.PLAN_DDL || plan.PlanId == sqlparser.PLAN_SET {
		return plan
	}
	si.queries.Set(sql, plan)
	return plan
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:35,代码来源:schema_info.go

示例5: DropTable

func (si *SchemaInfo) DropTable(tableName string) {
	si.mu.Lock()
	defer si.mu.Unlock()
	delete(si.tables, tableName)
	si.queries.Clear()
	log.Info("Table %s forgotten", tableName)
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:7,代码来源:schema_info.go

示例6: selectAll

func (qe *QueryEngine) selectAll(logStats *sqlQueryStats, plan *CompiledPlan) (result *eproto.QueryResult) {
	tableName := plan.TableName
	pks := qe.getAllPks(logStats, plan.TableName, nil)
	var keys, values [][]byte
	for _, pk := range pks {
		for _, field := range plan.Fields {
			keys = append(keys, buildTableRowColumnKey(tableName, field.Name, pk))
		}
	}

	result = &eproto.QueryResult{}
	result.Fields = plan.Fields

	if len(pks) == 0 {
		result.RowsAffected = 0
		return result
	}

	values = qe.fetch(logStats, keys)

	rowList := make([][]sqltypes.Value, len(pks))
	for i := range pks {
		rowList[i] = make([]sqltypes.Value, len(plan.Fields))
		for j, field := range plan.Fields {
			rowList[i][j] = buildValue(values[i*len(plan.Fields)+j], field.Type)
			log.Info(rowList[i][j].String())
		}
	}
	result.Rows = rowList
	result.RowsAffected = uint64(len(pks))
	return result
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:32,代码来源:query_engine.go

示例7: execAnalyzeValue

func (node *Node) execAnalyzeValue() *Node {
	log.Info("node.Type %v", node.Type)
	switch node.Type {
	case STRING, NUMBER, VALUE_ARG:
		return node
	}
	return nil
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:8,代码来源:execution.go

示例8: ExecParse

func ExecParse(sql string, getTable TableGetter) (plan *ExecPlan, err error) {
	defer handleError(&err)

	tree, err := Parse(sql)

	log.Info("tree: %v", tree.Type)
	log.Info("%v", tree.TreeString())

	if err != nil {
		return nil, err
	}
	plan = tree.execAnalyzeSql(getTable)
	if plan.PlanId == PLAN_PASS_DML {
		log.Warn("PASS_DML: %s", sql)
	}
	return plan, nil
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:17,代码来源:execution.go

示例9: Open

func (qe *QueryEngine) Open(config *eproto.DBConfigs) {
	// Wait for Close, in case it's running
	qe.mu.Lock()
	defer qe.mu.Unlock()
	err := qe.engine.Init(config)
	if err != nil {
		log.Info(err.Error())
		panic(NewTabletErrorDB(FATAL, err))
	}
	connFactory := ConnectionCreator(config.AppConnectParams, qe.engine)
	qe.connPool.Open(connFactory)
	// qe.streamConnPool.Open(connFactory)
	// qe.reservedPool.Open(connFactory)
	start := time.Now().UnixNano()
	qe.schemaInfo.Open(connFactory)
	log.Info("Time taken to load the schema: %v ms", (time.Now().UnixNano()-start)/1e6)
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:17,代码来源:query_engine.go

示例10: execModifyAll

// No condition in the sql
// if modiftyType is true, update method, else delete method
func (qe *QueryEngine) execModifyAll(logStats *sqlQueryStats, conn PoolConnection, plan *CompiledPlan, modifyType bool) *eproto.QueryResult {
	pks := qe.getAllPks(logStats, plan.TableName, conn)
	log.Info("delete %d", len(pks))
	if modifyType {
		return qe.execUpdate(logStats, conn, plan, pks)
	} else {
		return qe.execDelete(logStats, conn, plan, pks)
	}
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:11,代码来源:query_engine.go

示例11: getAllPks

func (qe *QueryEngine) getAllPks(logStats *sqlQueryStats, tableName string, conn PoolConnection) (pks [][]byte) {
	tableInfo := qe.schemaInfo.tables[tableName]
	pkStart := []byte(fmt.Sprintf("%s|%s|", tableName, tableInfo.GetPk().Name))
	pkEnd := []byte(fmt.Sprintf("%s|%s||", tableName, tableInfo.GetPk().Name))
	_, pks = qe.fetchIterate(logStats, conn, pkStart, pkEnd, 0, true, false)
	for _, pk := range pks {
		log.Info("pkpkpk:%s", string(pk))
	}
	return pks
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:10,代码来源:query_engine.go

示例12: Execute

func (sq *SqlQuery) Execute(context *rpcproto.Context, query *proto.Query, reply *eproto.QueryResult) (err error) {
	log.Info("sql is %v", query.Sql)
	logStats := newSqlQueryStats("Execute", context)
	defer handleExecError(query, &err, logStats)

	sq.checkState(query.SessionId)

	*reply = *sq.qe.Execute(logStats, query)
	return nil
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:10,代码来源:sqlquery.go

示例13: Connect

func (em *Engine) Connect(params *proto.DbConnectParams) (conn *DBConnection, err error) {
	var c proto.DbConnection
	c, err = em.dbEngine.Connect(params)
	log.Info("Come to a new client %v, id is %d", params.UserName, c.Id())
	if conn != nil && err != nil {
		conn.Close()
		return nil, err
	}
	conn = &DBConnection{connectionParams: params, DbConnection: c}
	return conn, nil
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:11,代码来源:engine.go

示例14: Load

// Load loads the contents of a JSON file named
// filename into c.
func (c *cramMD5Credentials) Load(filename string) error {
	data, err := ioutil.ReadFile(filename)
	if err != nil {
		return err
	}
	if err = json.Unmarshal(data, c); err != nil {
		return err
	}
	log.Info("Loaded credentials from %s.", filename)
	return nil
}
开发者ID:dongzerun,项目名称:RationalDb,代码行数:13,代码来源:authentication.go

示例15: NewEngine

func NewEngine(name string) (*Engine, error) {
	em := new(Engine)
	if engineInit, ok := engineImpls[name]; ok {
		log.Info("Get Engine : %v", name)
		engine := engineInit()
		em.dbEngine = engine
		return em, nil
	} else {
		return nil, proto.ErrUnknownDBEngineName
	}
}
开发者ID:ngaut,项目名称:RationalDb,代码行数:11,代码来源:engine.go


注:本文中的github.com/senarukana/rationaldb/log.Info函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。