Skip to content

Commit

Permalink
Refactoring. Get rid of the util folder and move files.
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed Jan 26, 2024
1 parent 6904395 commit 711bf1c
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions v2/benchmark/Entropy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
kanzi "github.com/flanglet/kanzi-go/v2"
"github.com/flanglet/kanzi-go/v2/bitstream"
"github.com/flanglet/kanzi-go/v2/entropy"
"github.com/flanglet/kanzi-go/v2/util"
"github.com/flanglet/kanzi-go/v2/internal"
)

func BenchmarkExpGolomb(b *testing.B) {
Expand Down Expand Up @@ -112,7 +112,7 @@ func testEntropySpeed(b *testing.B, name string) error {
size := 50000
values1 := make([]byte, size)
values2 := make([]byte, size)
var bs util.BufferStream
var bs internal.BufferStream

for ii := 0; ii < iter; ii++ {
idx := jj
Expand Down
2 changes: 1 addition & 1 deletion v2/benchmark/Hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"fmt"
"testing"

"github.com/flanglet/kanzi-go/v2/util/hash"
"github.com/flanglet/kanzi-go/v2/hash"
)

func BenchmarkXXHash32b(b *testing.B) {
Expand Down
14 changes: 7 additions & 7 deletions v2/bitstream/DefaultBitstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"testing"

kanzi "github.com/flanglet/kanzi-go/v2"
"github.com/flanglet/kanzi-go/v2/util"
"github.com/flanglet/kanzi-go/v2/internal"
)

const (
Expand Down Expand Up @@ -58,7 +58,7 @@ func testCorrectnessAligned1() error {

// Check correctness of read() and written()
for t := 1; t <= 32; t++ {
var bs util.BufferStream
var bs internal.BufferStream
obs, _ := NewDefaultOutputBitStream(&bs, 16384)
fmt.Println()
obs.WriteBits(0x0123456789ABCDEF, uint(t))
Expand All @@ -85,7 +85,7 @@ func testCorrectnessAligned1() error {
}

for test := 1; test <= 10; test++ {
var bs util.BufferStream
var bs internal.BufferStream
obs, _ := NewDefaultOutputBitStream(&bs, 16384)
dbgobs, _ := NewDebugOutputBitStream(obs, os.Stdout)
dbgobs.ShowByte(true)
Expand Down Expand Up @@ -168,7 +168,7 @@ func testCorrectnessMisaligned1() error {

// Check correctness of read() and written()
for t := 1; t <= 32; t++ {
var bs util.BufferStream
var bs internal.BufferStream
obs, _ := NewDefaultOutputBitStream(&bs, 16384)
dbgobs, _ := NewDebugOutputBitStream(obs, os.Stdout)
dbgobs.ShowByte(true)
Expand Down Expand Up @@ -200,7 +200,7 @@ func testCorrectnessMisaligned1() error {
}

for test := 1; test <= 10; test++ {
var bs util.BufferStream
var bs internal.BufferStream
obs, _ := NewDefaultOutputBitStream(&bs, 16384)
dbgobs, _ := NewDebugOutputBitStream(obs, os.Stdout)
dbgobs.ShowByte(true)
Expand Down Expand Up @@ -288,7 +288,7 @@ func testCorrectnessAligned2() error {
output := make([]byte, 100)

for test := 1; test <= 10; test++ {
var bs util.BufferStream
var bs internal.BufferStream
obs, _ := NewDefaultOutputBitStream(&bs, 16384)
dbgobs, _ := NewDebugOutputBitStream(obs, os.Stdout)
dbgobs.ShowByte(true)
Expand Down Expand Up @@ -371,7 +371,7 @@ func testCorrectnessMisaligned2() error {
output := make([]byte, 100)

for test := 1; test <= 10; test++ {
var bs util.BufferStream
var bs internal.BufferStream
obs, _ := NewDefaultOutputBitStream(&bs, 16384)
dbgobs, _ := NewDebugOutputBitStream(obs, os.Stdout)
dbgobs.ShowByte(true)
Expand Down
4 changes: 2 additions & 2 deletions v2/entropy/Entropy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

kanzi "github.com/flanglet/kanzi-go/v2"
"github.com/flanglet/kanzi-go/v2/bitstream"
"github.com/flanglet/kanzi-go/v2/util"
"github.com/flanglet/kanzi-go/v2/internal"
)

func TestHuffman(b *testing.T) {
Expand Down Expand Up @@ -146,7 +146,7 @@ func testEntropyCorrectness(name string) error {

println()
fmt.Printf("\nEncoded: \n")
var bs util.BufferStream
var bs internal.BufferStream
obs, _ := bitstream.NewDefaultOutputBitStream(&bs, 16384)
dbgbs, _ := bitstream.NewDebugOutputBitStream(obs, os.Stdout)
dbgbs.ShowByte(true)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion v2/util/BufferStream.go → v2/internal/BufferStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package util
package internal

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion v2/internal/Global.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package kanzi
package internal

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion v2/internal/Magic.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package kanzi
package internal

import (
"encoding/binary"
Expand Down
9 changes: 4 additions & 5 deletions v2/io/CompressedStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ import (
kanzi "github.com/flanglet/kanzi-go/v2"
"github.com/flanglet/kanzi-go/v2/bitstream"
"github.com/flanglet/kanzi-go/v2/entropy"
internal "github.com/flanglet/kanzi-go/v2/internal"
"github.com/flanglet/kanzi-go/v2/internal"
"github.com/flanglet/kanzi-go/v2/transform"
"github.com/flanglet/kanzi-go/v2/util"
"github.com/flanglet/kanzi-go/v2/util/hash"
"github.com/flanglet/kanzi-go/v2/hash"
)

// Write to/read from bitstream using a 2 step process:
Expand Down Expand Up @@ -710,7 +709,7 @@ func (this *encodingTask) encode(res *encodingTaskResult) {
}

// Create a bitstream local to the task
bufStream := util.NewBufferStream(data[0:0:cap(data)])
bufStream := internal.NewBufferStream(data[0:0:cap(data)])
obs, _ := bitstream.NewDefaultOutputBitStream(bufStream, 16384)

// Write block 'header' (mode + compressed length)
Expand Down Expand Up @@ -1517,7 +1516,7 @@ func (this *decodingTask) decode(res *decodingTaskResult) {

// All the code below is concurrent
// Create a bitstream local to the task
bufStream := util.NewBufferStream(data[0:r])
bufStream := internal.NewBufferStream(data[0:r])
ibs, _ := bitstream.NewDefaultInputBitStream(bufStream, 16384)

mode := byte(ibs.ReadBits(8))
Expand Down
7 changes: 3 additions & 4 deletions v2/transform/ROLZCodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import (
kanzi "github.com/flanglet/kanzi-go/v2"
"github.com/flanglet/kanzi-go/v2/bitstream"
"github.com/flanglet/kanzi-go/v2/entropy"
internal "github.com/flanglet/kanzi-go/v2/internal"
"github.com/flanglet/kanzi-go/v2/util"
"github.com/flanglet/kanzi-go/v2/internal"
)

// Implementation of a Reduced Offset Lempel Ziv transform
Expand Down Expand Up @@ -522,7 +521,7 @@ func (this *rolzCodec1) Forward(src, dst []byte) (uint, uint, error) {
litIdx += litLen
}

var os util.BufferStream
var os internal.BufferStream

// Scope to deallocate resources early
{
Expand Down Expand Up @@ -621,7 +620,7 @@ func (this *rolzCodec1) Inverse(src, dst []byte) (uint, uint, error) {
sizeChunk = _ROLZ_CHUNK_SIZE
}

var is util.BufferStream
var is internal.BufferStream
dstEnd := int(binary.BigEndian.Uint32(src[0:])) - 4

if dstEnd <= 0 || dstEnd > len(dst) {
Expand Down

0 comments on commit 711bf1c

Please sign in to comment.