Skip to content

Commit

Permalink
Embed const and change first value check variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
notbdu committed Dec 21, 2018
1 parent fafaf4c commit 4e1b044
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
3 changes: 2 additions & 1 deletion encoding/delta_int_encode.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func encodeDeltaInt(
}

firstValue := valuesIt.Current()
if err := bitWriter.WriteBits(asUint64Fn(firstValue), uint64NumBits); err != nil {
// Need 64 bits to write out uint64 values.
if err := bitWriter.WriteBits(asUint64Fn(firstValue), 64); err != nil {
return err
}

Expand Down
11 changes: 6 additions & 5 deletions encoding/delta_int_iterator.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type DeltaIntIterator struct {
curr int
err error
closed bool
isFirstValue bool
isDeltaValue bool
}

func newDeltaIntIterator(
Expand All @@ -55,7 +55,6 @@ func newDeltaIntIterator(
subFn: subFn,
addFn: addFn,
negativeBit: 1 << uint(bitsPerEncodedValue-1),
isFirstValue: true,
}
}

Expand All @@ -66,14 +65,16 @@ func (it *DeltaIntIterator) Next() bool {
}

// First value is special and written as 64 bits.
if it.isFirstValue {
if !it.isDeltaValue {
var firstValue uint64
firstValue, it.err = it.bitReader.ReadBits(uint64NumBits)
// Read 64 bits to read in a uint64 value.
firstValue, it.err = it.bitReader.ReadBits(64)
if it.err != nil {
return false
}
it.curr = int(firstValue)
it.isFirstValue = false
// The remaining values are delta values.
it.isDeltaValue = true
return true
}

Expand Down
3 changes: 2 additions & 1 deletion encoding/delta_time_encode.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func encodeDeltaTime(
}

firstValue := valuesIt.Current()
if err := bitWriter.WriteBits(asUint64Fn(firstValue), uint64NumBits); err != nil {
// Need 64 bits to write out uint64 values.
if err := bitWriter.WriteBits(asUint64Fn(firstValue), 64); err != nil {
return err
}

Expand Down
11 changes: 6 additions & 5 deletions encoding/delta_time_iterator.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type DeltaTimeIterator struct {
curr int64
err error
closed bool
isFirstValue bool
isDeltaValue bool
}

func newDeltaTimeIterator(
Expand All @@ -55,7 +55,6 @@ func newDeltaTimeIterator(
subFn: subFn,
addFn: addFn,
negativeBit: 1 << uint(bitsPerEncodedValue-1),
isFirstValue: true,
}
}

Expand All @@ -66,14 +65,16 @@ func (it *DeltaTimeIterator) Next() bool {
}

// First value is special and written as 64 bits.
if it.isFirstValue {
if !it.isDeltaValue {
var firstValue uint64
firstValue, it.err = it.bitReader.ReadBits(uint64NumBits)
// Read 64 bits to read in a uint64 value.
firstValue, it.err = it.bitReader.ReadBits(64)
if it.err != nil {
return false
}
it.curr = int64(firstValue)
it.isFirstValue = false
// The remaining values are delta values.
it.isDeltaValue = true
return true
}

Expand Down
1 change: 0 additions & 1 deletion encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ package encoding
// For allocating a buffer large enough to hold uint64 values.
const (
uint64SizeBytes = 8
uint64NumBits = 64
)
3 changes: 2 additions & 1 deletion encoding/template/delta_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func encodeDeltaValue(
}

firstValue := valuesIt.Current()
if err := bitWriter.WriteBits(asUint64Fn(firstValue), uint64NumBits); err != nil {
// Need 64 bits to write out uint64 values.
if err := bitWriter.WriteBits(asUint64Fn(firstValue), 64); err != nil {
return err
}

Expand Down
11 changes: 6 additions & 5 deletions encoding/template/delta_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type DeltaValueIterator struct {
curr GenericValue
err error
closed bool
isFirstValue bool
isDeltaValue bool
}

func newValueIteratorDelta(
Expand All @@ -31,7 +31,6 @@ func newValueIteratorDelta(
subFn: subFn,
addFn: addFn,
negativeBit: 1 << uint(bitsPerEncodedValue-1),
isFirstValue: true,
}
}

Expand All @@ -42,14 +41,16 @@ func (it *DeltaValueIterator) Next() bool {
}

// First value is special and written as 64 bits.
if it.isFirstValue {
if !it.isDeltaValue {
var firstValue uint64
firstValue, it.err = it.bitReader.ReadBits(uint64NumBits)
// Read 64 bits to read in a uint64 value.
firstValue, it.err = it.bitReader.ReadBits(64)
if it.err != nil {
return false
}
it.curr = GenericValue(firstValue)
it.isFirstValue = false
// The remaining values are delta values.
it.isDeltaValue = true
return true
}

Expand Down
3 changes: 0 additions & 3 deletions encoding/template/template.go

This file was deleted.

0 comments on commit 4e1b044

Please sign in to comment.