Remove unnecessary import renaming

This commit is contained in:
kortschak 2014-06-28 22:47:04 +09:30
parent 929beb624c
commit d8b615f154

View file

@ -24,9 +24,9 @@ import (
"github.com/barakmich/glog" "github.com/barakmich/glog"
"github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb"
leveldb_cache "github.com/syndtr/goleveldb/leveldb/cache" cache "github.com/syndtr/goleveldb/leveldb/cache"
leveldb_opt "github.com/syndtr/goleveldb/leveldb/opt" "github.com/syndtr/goleveldb/leveldb/opt"
leveldb_util "github.com/syndtr/goleveldb/leveldb/util" util "github.com/syndtr/goleveldb/leveldb/util"
"github.com/google/cayley/graph" "github.com/google/cayley/graph"
) )
@ -35,18 +35,18 @@ const DefaultCacheSize = 2
const DefaultWriteBufferSize = 20 const DefaultWriteBufferSize = 20
type TripleStore struct { type TripleStore struct {
dbOpts *leveldb_opt.Options dbOpts *opt.Options
db *leveldb.DB db *leveldb.DB
path string path string
open bool open bool
size int64 size int64
hasher hash.Hash hasher hash.Hash
writeopts *leveldb_opt.WriteOptions writeopts *opt.WriteOptions
readopts *leveldb_opt.ReadOptions readopts *opt.ReadOptions
} }
func CreateNewLevelDB(path string) bool { func CreateNewLevelDB(path string) bool {
opts := &leveldb_opt.Options{} opts := &opt.Options{}
db, err := leveldb.OpenFile(path, opts) db, err := leveldb.OpenFile(path, opts)
if err != nil { if err != nil {
glog.Errorln("Error: couldn't create database", err) glog.Errorln("Error: couldn't create database", err)
@ -55,7 +55,7 @@ func CreateNewLevelDB(path string) bool {
defer db.Close() defer db.Close()
ts := &TripleStore{} ts := &TripleStore{}
ts.db = db ts.db = db
ts.writeopts = &leveldb_opt.WriteOptions{ ts.writeopts = &opt.WriteOptions{
Sync: true, Sync: true,
} }
ts.Close() ts.Close()
@ -69,8 +69,8 @@ func NewTripleStore(path string, options graph.OptionsDict) *TripleStore {
if val, ok := options.GetIntKey("cache_size_mb"); ok { if val, ok := options.GetIntKey("cache_size_mb"); ok {
cache_size = val cache_size = val
} }
ts.dbOpts = &leveldb_opt.Options{ ts.dbOpts = &opt.Options{
BlockCache: leveldb_cache.NewLRUCache(cache_size * leveldb_opt.MiB), BlockCache: cache.NewLRUCache(cache_size * opt.MiB),
} }
ts.dbOpts.ErrorIfMissing = true ts.dbOpts.ErrorIfMissing = true
@ -78,12 +78,12 @@ func NewTripleStore(path string, options graph.OptionsDict) *TripleStore {
if val, ok := options.GetIntKey("write_buffer_mb"); ok { if val, ok := options.GetIntKey("write_buffer_mb"); ok {
write_buffer_mb = val write_buffer_mb = val
} }
ts.dbOpts.WriteBuffer = write_buffer_mb * leveldb_opt.MiB ts.dbOpts.WriteBuffer = write_buffer_mb * opt.MiB
ts.hasher = sha1.New() ts.hasher = sha1.New()
ts.writeopts = &leveldb_opt.WriteOptions{ ts.writeopts = &opt.WriteOptions{
Sync: false, Sync: false,
} }
ts.readopts = &leveldb_opt.ReadOptions{} ts.readopts = &opt.ReadOptions{}
db, err := leveldb.OpenFile(ts.path, ts.dbOpts) db, err := leveldb.OpenFile(ts.path, ts.dbOpts)
if err != nil { if err != nil {
panic("Error, couldn't open! " + err.Error()) panic("Error, couldn't open! " + err.Error())
@ -378,7 +378,7 @@ func (ts *TripleStore) GetApproximateSizeForPrefix(pre []byte) (int64, error) {
copy(limit, pre) copy(limit, pre)
end := len(limit) - 1 end := len(limit) - 1
limit[end]++ limit[end]++
ranges := make([]leveldb_util.Range, 1) ranges := make([]util.Range, 1)
ranges[0].Start = pre ranges[0].Start = pre
ranges[0].Limit = limit ranges[0].Limit = limit
sizes, err := ts.db.GetApproximateSizes(ranges) sizes, err := ts.db.GetApproximateSizes(ranges)