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

Unified Diff: server/logdog/storage/bigtable/rowKey.go

Issue 1909943003: LogDog: Add project support to Storage. (Closed) Base URL: https://github.com/luci/luci-go@logdog-project-coordinator-services
Patch Set: Rebase? 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 | « server/logdog/storage/archive/storage.go ('k') | server/logdog/storage/bigtable/rowKey_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: server/logdog/storage/bigtable/rowKey.go
diff --git a/server/logdog/storage/bigtable/rowKey.go b/server/logdog/storage/bigtable/rowKey.go
index f9d6c9ae7b13d166a1eab1c584c1f6285dbb4995..505159b9864caa04c3cf7723cedc0a195ef76db9 100644
--- a/server/logdog/storage/bigtable/rowKey.go
+++ b/server/logdog/storage/bigtable/rowKey.go
@@ -107,10 +107,18 @@ type rowKey struct {
}
// newRowKey generates the row key matching a given entry path and index.
-func newRowKey(path string, index, count int64) *rowKey {
- pathHash := sha256.Sum256([]byte(path))
+func newRowKey(project, path string, index, count int64) *rowKey {
+ h := sha256.New()
+
+ // TODO(dnj): Remove this conditional when non-project data is aged off.
+ if project != "" {
+ _, _ = h.Write([]byte(project))
+ _, _ = h.Write([]byte("/"))
+ }
+
+ _, _ = h.Write([]byte(path))
return &rowKey{
- pathHash: pathHash[:],
+ pathHash: h.Sum(nil),
index: index,
count: count,
}
@@ -129,7 +137,7 @@ func decodeRowKey(v string) (*rowKey, error) {
return nil, errMalformedRowKey
}
- // Decode encoded path hash.
+ // Decode encoded project/path hash.
var err error
rk := rowKey{}
rk.pathHash, err = base64.URLEncoding.DecodeString(hashEnc)
@@ -174,7 +182,8 @@ func (rk *rowKey) encode() (v string) {
return
}
-// prefix returns the encoded path prefix for the row key.
+// prefix returns the encoded path prefix for the row key, which is the hash of
+// that row's project/path.
func (rk *rowKey) pathPrefix() (v string) {
withRowKeyBuffers(func(rkb *rowKeyBuffers) {
rkb.appendPathPrefix(rk.pathHash)
« no previous file with comments | « server/logdog/storage/archive/storage.go ('k') | server/logdog/storage/bigtable/rowKey_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698