func NewRAMCSV(file *os.File, rdr *csv.Reader) *RAMCSV {
	file.Seek(0, 0) // Make sure our current offset is at the start of the file

	ram := RAMCSV{
		m:    make([]locator, 0),
		rdr:  rdr,
		file: file,
	}

	// To initialize, scan through the entire file once to identify the offsets
	// at each line. Note that the UKBB header for CSV is ~112 kilobytes, and the
	// default max for Scanner is 64k. Therefore, set a larger buffer to prevent
	// issues.
	scanner := bufio.NewScanner(ram.file)

	maxCap := 10 * 1024 * 1024
	buf := make([]byte, maxCap) // 10 MB instead of 64k. ~100x the UKBB header.
	scanner.Buffer(buf, maxCap)

	scanner.Split(scanLinesNondestructive)
	var b []byte
	for scanner.Scan() {
		b = scanner.Bytes()

		ram.m = append(ram.m, locator{
			Offset: ram.offset,
			Length: len(b),
		})

		ram.offset += int64(len(b))
	}

	return &ram
}
// NewRAMCSV is optimized for very long lines such as those in the UK Biobank.
NewRAMCSV is optimized for very long lines such as those in the UK Biobank.
// NewRAMCSV is optimized for very long lines such as those in the UK Biobank .
func NewRAMCSV(file *os.File, rdr *csv.Reader) *RAMCSV {
	file.Seek(0, 0) 
	ram := RAMCSV{
		m:    make([]locator, 0),
		rdr:  rdr,
		file: file,
	}
	scanner := bufio.NewScanner(ram.file)
	maxCap := 10 * 1024 * 1024
	buf := make([]byte, maxCap) 
	scanner.Buffer(buf, maxCap)
	scanner.Split(scanLinesNondestructive)
	var b []byte
	for scanner.Scan() {
		b = scanner.Bytes()
		ram.m = append(ram.m, locator{
			Offset: ram.offset,
			Length: len(b),
		})
		ram.offset += int64(len(b))
	}
	return &ram
}
func NewRAMCSV ( file * os . File , rdr * csv . Reader ) * RAMCSV { file . Seek ( 0 , 0 ) ram := RAMCSV { m : make ( [ ] locator , 0 ) , rdr : rdr , file : file , } scanner := bufio . NewScanner ( ram . file ) maxCap := 10 * 1024 * 1024 buf := make ( [ ] byte , maxCap ) scanner . Buffer ( buf , maxCap ) scanner . Split ( scanLinesNondestructive ) var b [ ] byte for scanner . Scan ( ) { b = scanner . Bytes ( ) ram . m = append ( ram . m , locator { Offset : ram . offset , Length : len ( b ) , } ) ram . offset += int64 ( len ( b ) ) } return & ram }
NewRAMCSV is optimized for very long lines such as those in the UK Biobank.
NewRAMCSV is optimized for very long lines such as those in the UK Biobank .
// Make sure our current offset is at the start of the file // To initialize, scan through the entire file once to identify the offsets // at each line. Note that the UKBB header for CSV is ~112 kilobytes, and the // default max for Scanner is 64k. Therefore, set a larger buffer to prevent // issues. // 10 MB instead of 64k. ~100x the UKBB header.