Skip to content

Commit

Permalink
Fixes to allow caching of the flat file for faster access.
Browse files Browse the repository at this point in the history
  • Loading branch information
IPQualityScore committed Aug 23, 2024
1 parent 51a8e76 commit 6a516ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
18 changes: 9 additions & 9 deletions FileReader.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package GoIPQSDBReader;

import (
"os";
"net";
"fmt";
"math";
"strconv";
"errors";
"strings";
"encoding/binary";
"bytes"
"encoding/binary"
"errors"
"fmt"
"math"
"net"
"strconv"
"strings"
);

type FileReader struct {
Handler *os.File;
Handler bytes.Reader;
TotalBytes uint64;
RecordBytes uint64;

Expand Down
8 changes: 5 additions & 3 deletions GoIPQSDBReader.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ func Open(filename string) (*FileReader, error) {
file := &FileReader{Columns: make(map[int]*Column)};

var ferr error;
file.Handler, ferr = os.Open(filename);
if(ferr != nil){
return file, ferr;
fileBytes, ferr := os.ReadFile(filename)
if ferr != nil {
return file, ferr
}

file.Handler = *bytes.NewReader(fileBytes)

header := make([]byte, 11);
bl, err := file.Handler.Read(header);
Expand Down

0 comments on commit 6a516ff

Please sign in to comment.