fixed swapped order of flags and file version bytes on unmarshal

also fix tests to use correct flags for bsi fields
This commit is contained in:
Matt Jaffee 2019-05-30 11:10:03 -05:00
parent dfbb666f9d
commit 1515ddaf14
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF
2 changed files with 17 additions and 8 deletions

View file

@ -708,12 +708,12 @@ func BenchmarkFragment_ImportValue(b *testing.B) {
depths := []uint{4, 8, 16}
for _, bitDepth := range depths {
name := fmt.Sprintf("Depth%d", bitDepth)
f := mustOpenFragment("i", "f", viewBSIGroupPrefix+"foo", 0, "none")
f := mustOpenBSIFragment("i", "f", viewBSIGroupPrefix+"foo", 0)
b.Run(name+"_Sparse", func(b *testing.B) {
benchmarkImportValues(b, bitDepth, f, func(u uint64) uint64 { return (u + 70000) & (ShardWidth - 1) })
})
f.Clean(b)
f = mustOpenFragment("i", "f", viewBSIGroupPrefix+"foo", 0, "none")
f = mustOpenBSIFragment("i", "f", viewBSIGroupPrefix+"foo", 0)
b.Run(name+"_Dense", func(b *testing.B) {
benchmarkImportValues(b, bitDepth, f, func(u uint64) uint64 { return (u + 1) & (ShardWidth - 1) })
})
@ -832,7 +832,7 @@ func BenchmarkFragment_RepeatedSmallValueImports(b *testing.B) {
b.Run(fmt.Sprintf("Updates%dVals%dOpN%d", numUpdates, valsPerUpdate, opN), func(b *testing.B) {
for i := 0; i < b.N; i++ {
b.StopTimer()
f := mustOpenFragment("i", "f", viewBSIGroupPrefix+"foo", 0, CacheTypeNone)
f := mustOpenBSIFragment("i", "f", viewBSIGroupPrefix+"foo", 0)
f.MaxOpN = opN
err := f.importValue(initialCols, initialVals, 21, false)
if err != nil {
@ -2457,6 +2457,15 @@ func (f *fragment) CleanKeep(t testing.TB) {
// mustOpenFragment returns a new instance of Fragment with a temporary path.
func mustOpenFragment(index, field, view string, shard uint64, cacheType string) *fragment {
return mustOpenFragmentFlags(index, field, view, shard, cacheType, 0)
}
func mustOpenBSIFragment(index, field, view string, shard uint64) *fragment {
return mustOpenFragmentFlags(index, field, view, shard, "", 1)
}
// mustOpenFragment returns a new instance of Fragment with a temporary path.
func mustOpenFragmentFlags(index, field, view string, shard uint64, cacheType string, flags byte) *fragment {
file, err := ioutil.TempFile(*TempDir, "pilosa-fragment-")
if err != nil {
panic(err)
@ -2467,7 +2476,7 @@ func mustOpenFragment(index, field, view string, shard uint64, cacheType string)
cacheType = DefaultCacheType
}
f := newFragment(file.Name(), index, field, view, shard, 0)
f := newFragment(file.Name(), index, field, view, shard, flags)
f.CacheType = cacheType
f.RowAttrStore = &memAttrStore{
store: make(map[uint64]map[string]interface{}),
@ -3227,7 +3236,7 @@ func check(t *testing.T, f *fragment, exp map[uint64]map[uint64]struct{}) {
}
func TestImportValueConcurrent(t *testing.T) {
f := mustOpenFragment("i", "f", viewBSIGroupPrefix+"foo", 0, "none")
f := mustOpenBSIFragment("i", "f", viewBSIGroupPrefix+"foo", 0)
eg := &errgroup.Group{}
for i := 0; i < 4; i++ {
i := i
@ -3267,7 +3276,7 @@ func TestImportMultipleValues(t *testing.T) {
for i, test := range tests {
for _, maxOpN := range []int{0, 10000} { // test small/large write
t.Run(fmt.Sprintf("%dLowOpN", i), func(t *testing.T) {
f := mustOpenFragment("i", "f", viewBSIGroupPrefix+"foo", 0, CacheTypeNone)
f := mustOpenBSIFragment("i", "f", viewBSIGroupPrefix+"foo", 0)
f.MaxOpN = maxOpN
defer f.Clean(t)
err := f.importValue(test.cols, test.vals, test.depth, false)

View file

@ -1103,8 +1103,8 @@ func (b *Bitmap) unmarshalPilosaRoaring(data []byte) error {
// Verify the first two bytes are a valid MagicNumber, and second two bytes match current storageVersion.
fileMagic := uint32(binary.LittleEndian.Uint16(data[0:2]))
b.Flags = data[2]
fileVersion := uint32(data[3])
fileVersion := uint32(data[2])
b.Flags = data[3]
if fileMagic != MagicNumber {
return fmt.Errorf("invalid roaring file, magic number %v is incorrect", fileMagic)
}