hbase.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package dao
  2. import (
  3. "context"
  4. "go-common/library/log"
  5. "github.com/tsuna/gohbase/hrpc"
  6. )
  7. var (
  8. prefix = "bucket_"
  9. )
  10. // CreateTable .
  11. // TODO check namespace
  12. func (d *Dao) CreateTable(c context.Context, table string) error {
  13. families := make(map[string]map[string]string)
  14. families["bfsfile"] = map[string]string{
  15. "BLOOMFILTER": "ROW",
  16. "VERSIONS": "1",
  17. "IN_MEMORY": "false",
  18. "KEEP_DELETED_CELLS": "false",
  19. "DATA_BLOCK_ENCODING": "NONE",
  20. "TTL": "2147483647", // NOTE: 2147483647 is forever
  21. "COMPRESSION": "NONE",
  22. "MIN_VERSIONS": "0",
  23. "BLOCKCACHE": "true",
  24. "BLOCKSIZE": "65536",
  25. "REPLICATION_SCOPE": "0",
  26. }
  27. b := [][]byte{[]byte("1"), []byte("2"), []byte("3"), []byte("4"), []byte("5"), []byte("6"), []byte("7"),
  28. []byte("8"), []byte("9"), []byte("a"), []byte("b"), []byte("c"), []byte("d"), []byte("e"), []byte("f")}
  29. ct := hrpc.NewCreateTable(c, []byte(prefix+table), families, hrpc.SplitKeys(b))
  30. err := d.hbase.CreateTable(ct)
  31. if err != nil {
  32. log.Error("CreateTable(),err:%+v", err)
  33. return err
  34. }
  35. return nil
  36. }