Skip to content

Commit

Permalink
Increase buffer (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
okieraised authored Apr 10, 2023
1 parent 4beda3a commit ca0cd21
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
69 changes: 69 additions & 0 deletions conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package go2com

import (
"fmt"
"github.com/okieraised/go2com/internal/utils"
"github.com/stretchr/testify/assert"
"os"
"testing"
Expand All @@ -26,3 +27,71 @@ func TestParser_Export(t *testing.T) {
mapTagVal := parser.Export(false)
fmt.Println(mapTagVal)
}

func TestParser_Buffer(t *testing.T) {
assert := assert.New(t)
InitTagDict()
file, err := os.Open("/home/tripg/workspace/dicom_buffer/D4CDC297.dcm")
assert.NoError(err)

defer file.Close()
info, err := file.Stat()
assert.NoError(err)
fileSize := info.Size()

parser, err := NewParser(file, fileSize, false, false)
assert.NoError(err)
err = parser.Parse()
assert.NoError(err)

mapTagVal := parser.Export(false)
fmt.Println(mapTagVal)
}

func TestParser_MultipleFiles(t *testing.T) {

assert := assert.New(t)

filePaths, err := utils.ReadDirRecursively("/home/tripg/workspace/dicom/test_data")
assert.NoError(err)
InitTagDict()
for _, fPath := range filePaths {
fmt.Println("process:", fPath)
file, err := os.Open(fPath)
assert.NoError(err)

defer file.Close()
info, err := file.Stat()
assert.NoError(err)
fileSize := info.Size()

parser, err := NewParser(file, fileSize, false, false)
assert.NoError(err)
err = parser.Parse()
assert.NoError(err)
}
}

func TestParser_MultipleFiles_2(t *testing.T) {

assert := assert.New(t)

filePaths, err := utils.ReadDirRecursively("/home/tripg/workspace/dicom/test_full")
assert.NoError(err)
InitTagDict()
for _, fPath := range filePaths {
fmt.Println("process:", fPath)
file, err := os.Open(fPath)
assert.NoError(err)

defer file.Close()
info, err := file.Stat()
assert.NoError(err)
fileSize := info.Size()

parser, err := NewParser(file, fileSize, false, false)
assert.NoError(err)
err = parser.Parse()
assert.NoError(err)
}
}
3 changes: 2 additions & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func InitTagDict() {

// NewParser returns a new dicom parser
func NewParser(fileReader io.Reader, fileSize int64, skipPixelData, skipDataset bool) (*Parser, error) {
dcmReader := reader.NewDcmReader(bufio.NewReader(fileReader), skipPixelData)
bufReader := bufio.NewReaderSize(fileReader, 4<<20)
dcmReader := reader.NewDcmReader(bufReader, skipPixelData)
parser := Parser{
skipPixelData: skipPixelData,
skipDataset: skipDataset,
Expand Down

0 comments on commit ca0cd21

Please sign in to comment.