| Index: common/recordio/size.go
|
| diff --git a/common/recordio/size.go b/common/recordio/size.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..73e058abccfbf5503d8ee5c0c3d4ab078a7cc1b8
|
| --- /dev/null
|
| +++ b/common/recordio/size.go
|
| @@ -0,0 +1,18 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package recordio
|
| +
|
| +// FrameHeaderSize calculates the size of the RecordIO frame header for a given
|
| +// amount of data.
|
| +//
|
| +// A RecordIO frame header is a Uvarint containing the length. Uvarint values
|
| +// contain 7 bits of size data and 1 continuation bit (see encoding/binary).
|
| +func FrameHeaderSize(s int64) int {
|
| + size := 1
|
| + for s >>= 7; s > 0; s >>= 7 {
|
| + size++
|
| + }
|
| + return size
|
| +}
|
|
|