-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
200 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package common | ||
package bboltutils | ||
|
||
import ( | ||
"os" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package common | ||
package logger | ||
|
||
import ( | ||
"time" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package storage | ||
|
||
type Modify struct { | ||
Data interface{} | ||
} | ||
|
||
type Put struct { | ||
CF string | ||
Key []byte | ||
Value []byte | ||
} | ||
|
||
type Append struct { | ||
CF string | ||
Key []byte | ||
Value []byte | ||
} | ||
|
||
type Delete struct { | ||
CF string | ||
Key []byte | ||
} | ||
|
||
type StorageItem interface { | ||
Key() []byte | ||
Value() []byte | ||
} | ||
|
||
type StorageIterator interface { | ||
Valid() bool | ||
Item() StorageItem | ||
Seek(key []byte) | ||
Next() | ||
Close() | ||
} | ||
|
||
type StorageReader interface { | ||
GetCF(cf string, key []byte) ([]byte, error) | ||
IterCF(cf string) StorageIterator | ||
Close() | ||
} | ||
|
||
type Storage interface { | ||
Write(batch []Modify) error | ||
Reader() (StorageReader, error) | ||
Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package common | ||
package utils | ||
|
||
import ( | ||
"crypto/rand" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package mvcc | ||
|
||
import "sync" | ||
|
||
type Latches struct { | ||
latchMap map[string]*sync.WaitGroup | ||
latchGuard sync.Mutex | ||
} | ||
|
||
func NewLatches() *Latches { | ||
l := &Latches{} | ||
l.latchMap = make(map[string]*sync.WaitGroup) | ||
return l | ||
} | ||
|
||
func (l *Latches) AcquireLatches(keys [][]byte) *sync.WaitGroup { | ||
l.latchGuard.Lock() | ||
defer l.latchGuard.Unlock() | ||
for _, key := range keys { | ||
if latchWg, ok := l.latchMap[string(key)]; ok { | ||
return latchWg | ||
} | ||
} | ||
wg := &sync.WaitGroup{} | ||
wg.Add(1) | ||
for _, key := range keys { | ||
l.latchMap[string(key)] = wg | ||
} | ||
return nil | ||
} | ||
|
||
func (l *Latches) ReleaseLatches(keys [][]byte) { | ||
l.latchGuard.Lock() | ||
defer l.latchGuard.Unlock() | ||
first := true | ||
for _, key := range keys { | ||
if first { | ||
wg := l.latchMap[string(key)] | ||
wg.Done() | ||
first = false | ||
} | ||
delete(l.latchMap, string(key)) | ||
} | ||
} | ||
|
||
func (l *Latches) WaitForLatches(keys [][]byte) { | ||
for { | ||
wg := l.AcquireLatches(keys) | ||
if wg == nil { | ||
return | ||
} | ||
wg.Wait() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
package mvcc | ||
|
||
type Modify struct { | ||
Kind WriteKind | ||
} | ||
|
||
type MvccTxn struct { | ||
StartTs int64 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.