// getFile get file data from hbase.bucket_xxx. func (h *HBaseClient) getFile(bucket, filename string) (f *meta.File, err error) { var ( ks []byte c *hbasethrift.THBaseServiceClient r *hbasethrift.TResult_ cv *hbasethrift.TColumnValue ) if c, err = hbasePool.Get(); err != nil { log.Errorf("hbasePool.Get() error(%v)", err) return } ks = []byte(filename) if r, err = c.Get(h.tableName(bucket), &hbasethrift.TGet{Row: ks}); err != nil { hbasePool.Put(c, true) return } hbasePool.Put(c, false) if len(r.ColumnValues) == 0 { err = errors.ErrNeedleNotExist return } f = new(meta.File) f.Filename = filename for _, cv = range r.ColumnValues { if cv == nil { continue } if bytes.Equal(cv.Family, _familyFile) { if bytes.Equal(cv.Qualifier, _columnKey) { f.Key = int64(binary.BigEndian.Uint64(cv.Value)) } else if bytes.Equal(cv.Qualifier, _columnSha1) { f.Sha1 = string(cv.GetValue()) } else if bytes.Equal(cv.Qualifier, _columnMine) { f.Mine = string(cv.GetValue()) } else if bytes.Equal(cv.Qualifier, _columnStatus) { f.Status = int32(binary.BigEndian.Uint32(cv.Value)) } else if bytes.Equal(cv.Qualifier, _columnUpdateTime) { f.MTime = int64(binary.BigEndian.Uint64(cv.Value)) } } } return }
// getNeedle get meta data from hbase.bfsmeta func (h *HBaseClient) getNeedle(key int64) (n *meta.Needle, err error) { var ( ks []byte c *hbasethrift.THBaseServiceClient r *hbasethrift.TResult_ cv *hbasethrift.TColumnValue ) if c, err = hbasePool.Get(); err != nil { log.Errorf("hbasePool.Get() error(%v)", err) return } ks = h.key(key) if r, err = c.Get(_table, &hbasethrift.TGet{Row: ks}); err != nil { hbasePool.Put(c, true) return } hbasePool.Put(c, false) if len(r.ColumnValues) == 0 { err = errors.ErrNeedleNotExist return } n = new(meta.Needle) n.Key = key for _, cv = range r.ColumnValues { if cv == nil { continue } if bytes.Equal(cv.Family, _familyBasic) { if bytes.Equal(cv.Qualifier, _columnVid) { n.Vid = int32(binary.BigEndian.Uint32(cv.Value)) } else if bytes.Equal(cv.Qualifier, _columnCookie) { n.Cookie = int32(binary.BigEndian.Uint32(cv.Value)) } else if bytes.Equal(cv.Qualifier, _columnUpdateTime) { n.MTime = int64(binary.BigEndian.Uint64(cv.Value)) } } } return }