refactoring: add type for needle id, offset
later the type size can possibly be adjusted
This commit is contained in:
@@ -2,16 +2,17 @@ package needle
|
||||
|
||||
import (
|
||||
"testing"
|
||||
. "github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||
)
|
||||
|
||||
func TestIssue52(t *testing.T) {
|
||||
m := NewCompactMap()
|
||||
m.Set(Key(10002), 10002, 10002)
|
||||
if element, ok := m.Get(Key(10002)); ok {
|
||||
m.Set(NeedleId(10002), 10002, 10002)
|
||||
if element, ok := m.Get(NeedleId(10002)); ok {
|
||||
println("key", 10002, "ok", ok, element.Key, element.Offset, element.Size)
|
||||
}
|
||||
m.Set(Key(10001), 10001, 10001)
|
||||
if element, ok := m.Get(Key(10002)); ok {
|
||||
m.Set(NeedleId(10001), 10001, 10001)
|
||||
if element, ok := m.Get(NeedleId(10002)); ok {
|
||||
println("key", 10002, "ok", ok, element.Key, element.Offset, element.Size)
|
||||
} else {
|
||||
t.Fatal("key 10002 missing after setting 10001")
|
||||
@@ -21,15 +22,15 @@ func TestIssue52(t *testing.T) {
|
||||
func TestXYZ(t *testing.T) {
|
||||
m := NewCompactMap()
|
||||
for i := uint32(0); i < 100*batch; i += 2 {
|
||||
m.Set(Key(i), i, i)
|
||||
m.Set(NeedleId(i), i, i)
|
||||
}
|
||||
|
||||
for i := uint32(0); i < 100*batch; i += 37 {
|
||||
m.Delete(Key(i))
|
||||
m.Delete(NeedleId(i))
|
||||
}
|
||||
|
||||
for i := uint32(0); i < 10*batch; i += 3 {
|
||||
m.Set(Key(i), i+11, i+5)
|
||||
m.Set(NeedleId(i), i+11, i+5)
|
||||
}
|
||||
|
||||
// for i := uint32(0); i < 100; i++ {
|
||||
@@ -39,7 +40,7 @@ func TestXYZ(t *testing.T) {
|
||||
// }
|
||||
|
||||
for i := uint32(0); i < 10*batch; i++ {
|
||||
v, ok := m.Get(Key(i))
|
||||
v, ok := m.Get(NeedleId(i))
|
||||
if i%3 == 0 {
|
||||
if !ok {
|
||||
t.Fatal("key", i, "missing!")
|
||||
@@ -59,7 +60,7 @@ func TestXYZ(t *testing.T) {
|
||||
}
|
||||
|
||||
for i := uint32(10 * batch); i < 100*batch; i++ {
|
||||
v, ok := m.Get(Key(i))
|
||||
v, ok := m.Get(NeedleId(i))
|
||||
if i%37 == 0 {
|
||||
if ok && v.Size > 0 {
|
||||
t.Fatal("key", i, "should have been deleted needle value", v)
|
||||
|
||||
Reference in New Issue
Block a user