Permalink
Browse files

Stop exporting internal constants

  • Loading branch information...
1 parent 1a88380 commit cd12097993c8d0049179c0f17d477105ae310665 @brendonh committed Feb 9, 2013
Showing with 22 additions and 25 deletions.
  1. +11 −13 src/loge/leveldb.go
  2. +7 −2 src/loge/lock.go
  3. +0 −6 src/loge/objects.go
  4. +2 −2 src/loge/transactions.go
  5. +2 −2 src/logetest/main.go
View
@@ -11,12 +11,10 @@ import (
"github.com/jmhodges/levigo"
)
-const VERSION = 1
-
-const LINK_TAG uint16 = 2
-const LINK_INFO_TAG uint16 = 3
-const INDEX_TAG uint16 = 4
-const START_TAG uint16 = 8
+const ldb_LINK_TAG uint16 = 2
+const ldb_LINK_INFO_TAG uint16 = 3
+const ldb_INDEX_TAG uint16 = 4
+const ldb_START_TAG uint16 = 8
type levelDBStore struct {
basePath string
@@ -74,7 +72,7 @@ func NewLevelDBStore(basePath string) LogeStore {
linkInfoSpec: spack.MakeTypeSpec(linkInfo{}),
}
- store.types.LastTag = START_TAG
+ store.types.LastTag = ldb_START_TAG
store.loadTypeMetadata()
go store.writer()
@@ -151,7 +149,7 @@ func (store *levelDBStore) getLinks(typ *logeType, linkName string, objKey LogeK
panic(fmt.Sprintf("Link info missing for %s", linkName))
}
- var key = encodeTaggedKey([]uint16{LINK_TAG, vt.Tag, linkInfo.Tag}, string(objKey))
+ var key = encodeTaggedKey([]uint16{ldb_LINK_TAG, vt.Tag, linkInfo.Tag}, string(objKey))
val, err := store.db.Get(readOptions, key)
@@ -179,7 +177,7 @@ func (store *levelDBStore) find(typ *logeType, linkName string, target LogeKey)
var linkInfo = typ.Links[linkName]
var prefix = append(
- encodeTaggedKey([]uint16{INDEX_TAG, vt.Tag, linkInfo.Tag}, string(target)),
+ encodeTaggedKey([]uint16{ldb_INDEX_TAG, vt.Tag, linkInfo.Tag}, string(target)),
0)
var it = store.iteratePrefix(prefix)
@@ -280,12 +278,12 @@ func (batch *levelDBWriteBatch) StoreLinks(linkObj *logeObject) error {
var vt = batch.store.types.Type(linkObj.Type.Name)
var linkInfo = linkObj.Type.Links[linkObj.LinkName]
- var key = encodeTaggedKey([]uint16{LINK_TAG, vt.Tag, linkInfo.Tag}, string(linkObj.Key))
+ var key = encodeTaggedKey([]uint16{ldb_LINK_TAG, vt.Tag, linkInfo.Tag}, string(linkObj.Key))
val, _ := spack.EncodeToBytes(set.ReadKeys(), batch.store.linkSpec)
batch.Append(key, val)
- var prefix = encodeTaggedKey([]uint16{INDEX_TAG, vt.Tag, linkInfo.Tag}, "")
+ var prefix = encodeTaggedKey([]uint16{ldb_INDEX_TAG, vt.Tag, linkInfo.Tag}, "")
var source = string(linkObj.Key)
for _, target := range set.Removed {
@@ -352,7 +350,7 @@ func (store *levelDBStore) loadTypeMetadata() {
}
func (store *levelDBStore) tagVersions(vt *spack.VersionedType, typ *logeType) {
- var prefix = encodeTaggedKey([]uint16{LINK_INFO_TAG, vt.Tag}, "")
+ var prefix = encodeTaggedKey([]uint16{ldb_LINK_INFO_TAG, vt.Tag}, "")
var it = store.iteratePrefix(prefix)
defer it.Close()
@@ -378,7 +376,7 @@ func (store *levelDBStore) tagVersions(vt *spack.VersionedType, typ *logeType) {
for _, info := range missing {
maxTag++
info.Tag = maxTag
- var key = encodeTaggedKey([]uint16{LINK_INFO_TAG, vt.Tag}, info.Name)
+ var key = encodeTaggedKey([]uint16{ldb_LINK_INFO_TAG, vt.Tag}, info.Name)
enc, _ := spack.EncodeToBytes(info, store.linkInfoSpec)
fmt.Printf("Updating link: %s::%s (%d)\n", typ.Name, info.Name, info.Tag)
var err = store.db.Put(writeOptions, key, enc)
View
@@ -5,6 +5,11 @@ import (
"runtime"
)
+const (
+ lock_UNLOCKED = 0
+ lock_LOCKED = 1
+)
+
type lockToken struct{}
var _lock_token struct{}
@@ -15,7 +20,7 @@ type spinLock struct {
func (lock *spinLock) TryLock() bool {
return atomic.CompareAndSwapInt32(
- &lock.lock, UNLOCKED, LOCKED)
+ &lock.lock, lock_UNLOCKED, lock_LOCKED)
}
func (lock *spinLock) SpinLock() {
@@ -28,5 +33,5 @@ func (lock *spinLock) SpinLock() {
}
func (lock *spinLock) Unlock() {
- lock.lock = UNLOCKED
+ lock.lock = lock_UNLOCKED
}
View
@@ -4,12 +4,6 @@ import (
"reflect"
)
-const (
- UNLOCKED = 0
- LOCKED = 1
-)
-
-
type logeObject struct {
DB *LogeDB
Type *logeType
View
@@ -141,7 +141,7 @@ func (t *Transaction) getObj(ref objRef, forWrite bool, load bool) *objectVersio
}
-const BACKOFF_EXPONENT = 1.05
+const t_BACKOFF_EXPONENT = 1.05
func (t *Transaction) Commit() bool {
@@ -158,7 +158,7 @@ func (t *Transaction) Commit() bool {
}
var delay = time.Duration(delayFact - float64(rand.Intn(10)))
time.Sleep(delay * time.Millisecond)
- delayFact *= BACKOFF_EXPONENT
+ delayFact *= t_BACKOFF_EXPONENT
}
return t.state == FINISHED
View
@@ -12,9 +12,9 @@ type Pet struct {
}
func main() {
- //LinkBench()
+ LinkBench()
//LinkSandbox()
//WriteBench()
//Sandbox()
- Example()
+ //Example()
}

0 comments on commit cd12097

Please sign in to comment.