Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: common/recordio/size.go

Issue 1904503003: LogDog: Fix archived log stream read errors. (Closed) Base URL: https://github.com/luci/luci-go@hierarchy-check-first
Patch Set: Delete "offset()" method. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/gcloud/gs/gs.go ('k') | common/recordio/size_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+}
« no previous file with comments | « common/gcloud/gs/gs.go ('k') | common/recordio/size_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698