// DataTable can contain data for multiple graphs, we need to extract only 1
348136
func getChartData(data *DataTable, index int) (out [][]float64) {
	for _, r := range data.rows {
		out = append(out, []float64{r[0], r[index]})
	}

	return
}
1007966
func (lcs *lcs) Table() (table [][]int) {
	table, _ = lcs.TableContext(context.Background())
	return table
}
352109
func LoadTable(db *sql.DB, name string) (*Table, error) {
	t := makeTable(name)
	err := t.loadColumns(db)
	if err != nil {
		return nil, err
	}
	err = t.loadKeys(db)
	if err != nil {
		return nil, err
	}
	return t, nil
}
1045438
func (nDB *NetworkDB) WalkTable(tname string, fn func(string, string, []byte, bool) bool) error {
	nDB.RLock()
	values := make(map[string]interface{})
	nDB.indexes[byTable].WalkPrefix(fmt.Sprintf("/%s", tname), func(path string, v interface{}) bool {
		values[path] = v
		return false
	})
	nDB.RUnlock()

	for k, v := range values {
		params := strings.Split(k[1:], "/")
		nid := params[1]
		key := params[2]
		if fn(nid, key, v.(*entry).value, v.(*entry).deleting) {
			return nil
		}
	}

	return nil
}
1155109
func (m *DbMap) dropTable(t reflect.Type, name string, addIfExists bool) error {
	table := tableOrNil(m, t, name)
	if table == nil {
		return fmt.Errorf("table %s was not registered", table.TableName)
	}

	return m.dropTableImpl(table, addIfExists)
}
752954
func DataFormat(format, tmpl string) (DataFormatter, error) {
	switch format {
	case "json":
		if len(tmpl) > 0 {
			return nil, fmt.Errorf("json format does not support template option.")
		}
		return &JSONFormat{}, nil
	case "template":
		return &TemplateFormat{tmpl}, nil
	}
	return nil, fmt.Errorf("Unsupported format is specified.")
}
77108
func (pgb *ChainDB) DeindexTicketsTable() error {
	ticketsTablesDeIndexes := []deIndexingInfo{
		{DeindexTicketsTableOnHashes},
		{DeindexTicketsTableOnPoolStatus},
		{DeindexTicketsTableOnTxDbID},
	}

	var err error
	for _, val := range ticketsTablesDeIndexes {
		if err = val.DeIndexFunc(pgb.db); err != nil {
			warnUnlessNotExists(err)
			err = nil
		}
	}
	return err
}
1274842
func (n NodeList) DataSize() int {
	var size int
	for _, node := range n {
		size += len(node)
	}
	return size
}
332986
func (d *Databook) XML() (*Exportable, error) {
	b := newBuffer()
	b.WriteString("<databook>\n")
	for _, s := range d.sheets {
		b.WriteString("  <sheet>\n    <title>" + s.title + "</title>\n    ")
		row, err := s.dataset.XMLWithTagNamePrefixIndent("row", "      ", "  ")
		if err != nil {
			return nil, err
		}
		b.Write(row.Bytes())
		b.WriteString("\n  </sheet>")
	}
	b.WriteString("\n</databook>")
	return newExportable(b), nil
}
1275879
func (builder *TsListKeysCommandBuilder) WithTable(table string) *TsListKeysCommandBuilder {
	builder.protobuf.Table = []byte(table)
	return builder
}
747548
func (b *BlockData) GetRows(tableName string) (types.EventDataTable, error) {
	if table, ok := b.Data.Tables[tableName]; ok {
		return table, nil
	}
	return nil, fmt.Errorf("GetRows: tableName does not exists as a table in data structure: %s ", tableName)
}
101038
func GetColorTable(target uint32, format uint32, xtype uint32, table unsafe.Pointer) {
	C.glowGetColorTable(gpGetColorTable, (C.GLenum)(target), (C.GLenum)(format), (C.GLenum)(xtype), table)
}
650748
func DeleteTabletReplicationData(ctx context.Context, ts *Server, tablet *topodatapb.Tablet) error {
	return RemoveShardReplicationRecord(ctx, ts, tablet.Alias.Cell, tablet.Keyspace, tablet.Shard, tablet.Alias)
}
693139
func (b *UpdateBuilder) Table(table string) *UpdateBuilder {
	b.table = table
	return b
}
469798
func (vschema *VSchema) findTable(keyspace, tablename string) (*Table, error) {
	if keyspace == "" {
		table, ok := vschema.uniqueTables[tablename]
		if table == nil {
			if ok {
				return nil, fmt.Errorf("ambiguous table reference: %s", tablename)
			}
			if len(vschema.Keyspaces) != 1 {
				return nil, nil
			}
			// Loop happens only once.
			for _, ks := range vschema.Keyspaces {
				if ks.Keyspace.Sharded {
					return nil, nil
				}
				return &Table{Name: sqlparser.NewTableIdent(tablename), Keyspace: ks.Keyspace}, nil
			}
		}
		return table, nil
	}
	ks, ok := vschema.Keyspaces[keyspace]
	if !ok {
		return nil, fmt.Errorf("keyspace %s not found in vschema", keyspace)
	}
	table := ks.Tables[tablename]
	if table == nil {
		if ks.Keyspace.Sharded {
			return nil, nil
		}
		return &Table{Name: sqlparser.NewTableIdent(tablename), Keyspace: ks.Keyspace}, nil
	}
	return table, nil
}
262788
func (p *Parser) parseCreateTable(ctx *parseCtx) (model.Table, error) {
	if t := ctx.next(); t.Type != TABLE {
		return nil, errors.New(`expected TABLE`)
	}

	var table model.Table

	ctx.skipWhiteSpaces()
	var temporary bool
	if t := ctx.peek(); t.Type == TEMPORARY {
		ctx.advance()
		ctx.skipWhiteSpaces()
		temporary = true
	}

	// IF NOT EXISTS
	var notexists bool
	if ctx.peek().Type == IF {
		ctx.advance()
		if _, err := p.parseIdents(ctx, NOT, EXISTS); err != nil {
			return nil, err
		}
		ctx.skipWhiteSpaces()
		notexists = true
	}

	switch t := ctx.next(); t.Type {
	case IDENT, BACKTICK_IDENT:
		table = model.NewTable(t.Value)
	default:
		return nil, newParseError(ctx, t, "expected IDENT or BACKTICK_IDENT")
	}
	table.SetTemporary(temporary)
	table.SetIfNotExists(notexists)

	ctx.skipWhiteSpaces()
	switch t := ctx.peek(); t.Type {
	case LIKE:
		// CREATE TABLE foo LIKE bar
		ctx.advance()
		ctx.skipWhiteSpaces()
		switch t := ctx.next(); t.Type {
		case IDENT, BACKTICK_IDENT:
			table.SetLikeTable(t.Value)
		default:
			return nil, newParseError(ctx, t, "expected table name after LIKE")
		}

		ctx.skipWhiteSpaces()
		switch t := ctx.peek(); t.Type {
		case EOF, SEMICOLON:
			ctx.advance()
		}
		return table, nil
	case IF:
		ctx.advance()
		if _, err := p.parseIdents(ctx, NOT, EXISTS); err != nil {
			return nil, newParseError(ctx, t, "should NOT EXISTS")
		}
		ctx.skipWhiteSpaces()
		table.SetIfNotExists(true)
	}

	if t := ctx.next(); t.Type != LPAREN {
		return nil, newParseError(ctx, t, "expected LPAREN")
	}

	if err := p.parseCreateTableFields(ctx, table); err != nil {
		return nil, err
	}

	table, _ = table.Normalize()
	return table, nil
}
651447
func (session *Session) Table(tableNameOrBean interface{}) *Session {
	session.statement.Table(tableNameOrBean)
	return session
}