You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Paddle/paddle/go/recordio
Helin Wang a868d01065
add cgo wrapper for recordio, make go_cmake automatically download go dependency
8 years ago
..
README.md add cgo wrapper for recordio, make go_cmake automatically download go dependency 8 years ago
chunk.go move recordio to Paddle from github.com/wangkuiyi/recordio 8 years ago
header.go move recordio to Paddle from github.com/wangkuiyi/recordio 8 years ago
reader.go move recordio to Paddle from github.com/wangkuiyi/recordio 8 years ago
recordio_internal_test.go move recordio to Paddle from github.com/wangkuiyi/recordio 8 years ago
recordio_test.go move recordio to Paddle from github.com/wangkuiyi/recordio 8 years ago
writer.go move recordio to Paddle from github.com/wangkuiyi/recordio 8 years ago

README.md

RecordIO

Write

f, e := os.Create("a_file.recordio")
w := recordio.NewWriter(f)
w.Write([]byte("Hello"))
w.Write([]byte("World!"))
w.Close()
f.Close()

Read

  1. Load chunk index:

    f, e := os.Open("a_file.recordio")
    idx, e := recordio.LoadIndex(f)
    fmt.Println("Total records: ", idx.Len())
    f.Close()
    
  2. Create one or more scanner to read a range of records. The following example reads the range [1, 3), i.e., the second and the third records:

    f, e := os.Open("a_file.recordio")
    s := recrodio.NewScanner(f, idx, 1, 3)
    for s.Scan() {
       fmt.Println(string(s.Record()))
    }
    if s.Error() != nil && s.Error() != io.EOF {
       log.Fatalf("Something wrong with scanning: %v", e)
    }
    f.Close()