mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 16:50:18 +01:00
s/SqliteBackend/SQLiteBackend/ s/SqliteSession/SQLiteSession/ in mtredisalize.
This commit is contained in:
parent
d21fa6c027
commit
14ae6d3873
@ -103,7 +103,7 @@ func main() {
|
||||
path := flag.Arg(0)
|
||||
|
||||
if driver == "sqlite" {
|
||||
if backend, err = NewSqliteBackend(path, changeTracker, interleaved); err != nil {
|
||||
if backend, err = NewSQLiteBackend(path, changeTracker, interleaved); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
|
@ -26,7 +26,7 @@ const (
|
||||
rangeSQL = "SELECT pos, data FROM blocks WHERE pos BETWEEN ? AND ? ORDER BY pos"
|
||||
)
|
||||
|
||||
type SqliteBackend struct {
|
||||
type SQLiteBackend struct {
|
||||
db *sql.DB
|
||||
encoder common.KeyEncoder
|
||||
decoder common.KeyDecoder
|
||||
@ -42,16 +42,16 @@ type SqliteBackend struct {
|
||||
rangeStmt *sql.Stmt
|
||||
}
|
||||
|
||||
type SqliteSession struct {
|
||||
backend *SqliteBackend
|
||||
type SQLiteSession struct {
|
||||
backend *SQLiteBackend
|
||||
tx *sql.Tx
|
||||
}
|
||||
|
||||
func (sqlb *SqliteBackend) NewSession() (Session, error) {
|
||||
return &SqliteSession{sqlb, nil}, nil
|
||||
func (sqlb *SQLiteBackend) NewSession() (Session, error) {
|
||||
return &SQLiteSession{sqlb, nil}, nil
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) Close() error {
|
||||
func (ss *SQLiteSession) Close() error {
|
||||
t := ss.tx
|
||||
if t != nil {
|
||||
ss.tx = nil
|
||||
@ -60,11 +60,11 @@ func (ss *SqliteSession) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewSqliteBackend(
|
||||
func NewSQLiteBackend(
|
||||
path string,
|
||||
changeTracker *changeTracker, interleaved bool) (sqlb *SqliteBackend, err error) {
|
||||
changeTracker *changeTracker, interleaved bool) (sqlb *SQLiteBackend, err error) {
|
||||
|
||||
res := SqliteBackend{interleaved: interleaved, changeTracker: changeTracker}
|
||||
res := SQLiteBackend{interleaved: interleaved, changeTracker: changeTracker}
|
||||
|
||||
if res.db, err = sql.Open("sqlite3", path); err != nil {
|
||||
return
|
||||
@ -123,7 +123,7 @@ func NewSqliteBackend(
|
||||
return
|
||||
}
|
||||
|
||||
func (sqlb *SqliteBackend) buildCoverage() (err error) {
|
||||
func (sqlb *SQLiteBackend) buildCoverage() (err error) {
|
||||
log.Println("INFO: Start building coverage index (this may take some time)...")
|
||||
sqlb.coverage = common.NewCoverage3D()
|
||||
|
||||
@ -163,7 +163,7 @@ func closeDB(db **sql.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sqlb *SqliteBackend) closeAll() error {
|
||||
func (sqlb *SQLiteBackend) closeAll() error {
|
||||
closeStmt(&sqlb.fetchStmt)
|
||||
closeStmt(&sqlb.insertStmt)
|
||||
closeStmt(&sqlb.updateStmt)
|
||||
@ -174,21 +174,21 @@ func (sqlb *SqliteBackend) closeAll() error {
|
||||
return closeDB(&sqlb.db)
|
||||
}
|
||||
|
||||
func (sqlb *SqliteBackend) Shutdown() error {
|
||||
func (sqlb *SQLiteBackend) Shutdown() error {
|
||||
globalLock.Lock()
|
||||
defer globalLock.Unlock()
|
||||
|
||||
return sqlb.closeAll()
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) txStmt(stmt *sql.Stmt) *sql.Stmt {
|
||||
func (ss *SQLiteSession) txStmt(stmt *sql.Stmt) *sql.Stmt {
|
||||
if ss.tx != nil {
|
||||
return ss.tx.Stmt(stmt)
|
||||
}
|
||||
return stmt
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) Fetch(hash, key []byte) (data []byte, err error) {
|
||||
func (ss *SQLiteSession) Fetch(hash, key []byte) (data []byte, err error) {
|
||||
var pos int64
|
||||
if pos, err = ss.backend.decoder(key); err != nil {
|
||||
return
|
||||
@ -206,11 +206,11 @@ func (ss *SqliteSession) Fetch(hash, key []byte) (data []byte, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) InTransaction() bool {
|
||||
func (ss *SQLiteSession) InTransaction() bool {
|
||||
return ss.tx != nil
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) Store(hash, key, value []byte) (exists bool, err error) {
|
||||
func (ss *SQLiteSession) Store(hash, key, value []byte) (exists bool, err error) {
|
||||
var pos int64
|
||||
if pos, err = ss.backend.decoder(key); err != nil {
|
||||
return
|
||||
@ -257,7 +257,7 @@ func (ss *SqliteSession) Store(hash, key, value []byte) (exists bool, err error)
|
||||
return
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) BeginTransaction() (err error) {
|
||||
func (ss *SQLiteSession) BeginTransaction() (err error) {
|
||||
if ss.tx != nil {
|
||||
log.Println("WARN: Already running transaction.")
|
||||
return nil
|
||||
@ -269,7 +269,7 @@ func (ss *SqliteSession) BeginTransaction() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) CommitTransaction() error {
|
||||
func (ss *SQLiteSession) CommitTransaction() error {
|
||||
|
||||
tx := ss.tx
|
||||
if tx == nil {
|
||||
@ -283,7 +283,7 @@ func (ss *SqliteSession) CommitTransaction() error {
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) AllKeys(
|
||||
func (ss *SQLiteSession) AllKeys(
|
||||
hash []byte,
|
||||
done <-chan struct{}) (<-chan []byte, int, error) {
|
||||
globalLock.RLock()
|
||||
@ -334,7 +334,7 @@ func (ss *SqliteSession) AllKeys(
|
||||
return keys, n, nil
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) SpatialQuery(
|
||||
func (ss *SQLiteSession) SpatialQuery(
|
||||
hash, first, second []byte,
|
||||
done <-chan struct{}) (<-chan Block, error) {
|
||||
|
||||
@ -345,7 +345,7 @@ func (ss *SqliteSession) SpatialQuery(
|
||||
return ss.plainSpatialQuery(first, second, done)
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) interleavedSpatialQuery(
|
||||
func (ss *SQLiteSession) interleavedSpatialQuery(
|
||||
first, second []byte,
|
||||
done <-chan struct{}) (<-chan Block, error) {
|
||||
|
||||
@ -425,7 +425,7 @@ func (ss *SqliteSession) interleavedSpatialQuery(
|
||||
return blocks, nil
|
||||
}
|
||||
|
||||
func (ss *SqliteSession) plainSpatialQuery(
|
||||
func (ss *SQLiteSession) plainSpatialQuery(
|
||||
first, second []byte,
|
||||
done <-chan struct{}) (<-chan Block, error) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user