From 6b4c93a3f7b450bf5508b2c69cf879f4bb1a1dcd Mon Sep 17 00:00:00 2001 From: Chris Masone Date: Wed, 9 Mar 2016 12:45:45 -0800 Subject: [PATCH] Fix up DataStore comments If I'm going to start refactoring this code, it's important that I'm sure what all the methods do. So, update the comments --- datas/datastore.go | 4 ++-- datas/datastore_common.go | 2 +- datas/local_datastore.go | 2 +- datas/remote_datastore.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/datas/datastore.go b/datas/datastore.go index 513ef947e3..b90ac1ca2d 100644 --- a/datas/datastore.go +++ b/datas/datastore.go @@ -26,10 +26,10 @@ type DataStore interface { // Delete removes the Dataset named datasetID from the map at the root of the DataStore. The Dataset data is not necessarily cleaned up at this time, but may be garbage collected in the future. If the update cannot be performed, e.g., because of a conflict, error will non-nil. The newest snapshot of the datastore is always returned. Delete(datasetID string) (DataStore, error) - // Copies all chunks reachable from (and including) |r| but not reachable from (and including) |exclude| from this DataStore to |sink| + // CopyReachableChunksP copies to |sink| all chunks reachable from (and including) |r|, but that are not in the subtree rooted at |exclude| CopyReachableChunksP(r, exclude ref.Ref, sink chunks.ChunkSink, concurrency int) - // Copies all chunks reachable from (and including) |r| in |source| that aren't present in this DataStore + // CopyMissingChunksP copies to sink all chunks reachable from (and including) |r| that it does not already have CopyMissingChunksP(r ref.Ref, sink chunks.ChunkStore, concurrency int) } diff --git a/datas/datastore_common.go b/datas/datastore_common.go index 3c03f93022..2f734c39b5 100644 --- a/datas/datastore_common.go +++ b/datas/datastore_common.go @@ -55,7 +55,7 @@ func (ds *dataStoreCommon) Datasets() MapOfStringToRefOfCommit { return *ds.datasets } -// Copies all chunks reachable from (and including) |r| in |source| that aren't present in |sink| +// CopyMissingChunksP copies to |sink| all chunks in ds that are reachable from (and including) |r|, skipping chunks that |sink| already has func (ds *dataStoreCommon) CopyMissingChunksP(sourceRef ref.Ref, sink chunks.ChunkStore, concurrency int) { tcs := &teeChunkSource{ds, sink} diff --git a/datas/local_datastore.go b/datas/local_datastore.go index 7ecda2daba..7ca403290a 100644 --- a/datas/local_datastore.go +++ b/datas/local_datastore.go @@ -27,7 +27,7 @@ func (lds *LocalDataStore) Delete(datasetID string) (DataStore, error) { return newLocalDataStore(lds.ChunkStore), err } -// Copies all chunks reachable from (and including)|sourceRef| but not reachable from (and including) |exclude| in |source| to |sink| +// CopyReachableChunksP copies to |sink| all chunks reachable from (and including) |r|, but that are not in the subtree rooted at |exclude| func (lds *LocalDataStore) CopyReachableChunksP(sourceRef, exclude ref.Ref, sink chunks.ChunkSink, concurrency int) { excludeRefs := map[ref.Ref]bool{} diff --git a/datas/remote_datastore.go b/datas/remote_datastore.go index 07544c082f..9202b7da28 100644 --- a/datas/remote_datastore.go +++ b/datas/remote_datastore.go @@ -39,8 +39,8 @@ func (rds *RemoteDataStore) Delete(datasetID string) (DataStore, error) { return newRemoteDataStore(rds.ChunkStore), err } -// Asks remote server to figure out which chunks need to be copied and return them. -func (rds *RemoteDataStore) CopyReachableChunksP(r, exclude ref.Ref, cs chunks.ChunkSink, concurrency int) { +// CopyReachableChunksP copies to |sink| all chunks in rds that are reachable from (and including) |r|, but that are not in the subtree rooted at |exclude|.This implementation asks the remote server to return the desired chunks and writes them to |sink|. +func (rds *RemoteDataStore) CopyReachableChunksP(r, exclude ref.Ref, sink chunks.ChunkSink, concurrency int) { // POST http:///ref/sha1----?all=true&exclude=sha1----. Response will be chunk data if present, 404 if absent. u := rds.host() u.Path = path.Join(constants.RefPath, r.String()) @@ -69,7 +69,7 @@ func (rds *RemoteDataStore) CopyReachableChunksP(r, exclude ref.Ref, cs chunks.C reader = gr } - chunks.Deserialize(reader, cs, nil) + chunks.Deserialize(reader, sink, nil) } // In order for keep alive to work we must read to EOF on every response. We may want to add a timeout so that a server that left its connection open can't cause all of ports to be eaten up.