refactoring

This commit is contained in:
Chris Lu
2020-04-12 21:00:55 -07:00
parent 8e23dc078b
commit 7764e0465c
16 changed files with 186 additions and 187 deletions

View File

@@ -131,4 +131,4 @@ func (c *ChunkCache) Shutdown() {
for _, diskCache := range c.diskCaches {
diskCache.Shutdown()
}
}
}

View File

@@ -21,11 +21,11 @@ func TestOnDisk(t *testing.T) {
writeCount := 5
type test_data struct {
data []byte
data []byte
fileId string
}
testData := make([]*test_data, writeCount)
for i:=0;i<writeCount;i++{
for i := 0; i < writeCount; i++ {
buff := make([]byte, 1024*1024)
rand.Read(buff)
testData[i] = &test_data{
@@ -35,7 +35,7 @@ func TestOnDisk(t *testing.T) {
cache.SetChunk(testData[i].fileId, testData[i].data)
}
for i:=0;i<writeCount;i++{
for i := 0; i < writeCount; i++ {
data := cache.GetChunk(testData[i].fileId)
if bytes.Compare(data, testData[i].data) != 0 {
t.Errorf("failed to write to and read from cache: %d", i)
@@ -46,7 +46,7 @@ func TestOnDisk(t *testing.T) {
cache = NewChunkCache(0, tmpDir, totalDiskSizeMb, segmentCount)
for i:=0;i<writeCount;i++{
for i := 0; i < writeCount; i++ {
data := cache.GetChunk(testData[i].fileId)
if bytes.Compare(data, testData[i].data) != 0 {
t.Errorf("failed to write to and read from cache: %d", i)