This commit is contained in:
Chris Lu 2020-08-29 22:28:33 -07:00
parent ef75ce8a34
commit 99ecf63276
16 changed files with 64 additions and 68 deletions

View file

@ -73,7 +73,7 @@ func (store *AbstractSqlStore) InsertEntry(ctx context.Context, entry *filer2.En
}
affectedRows, err := res.RowsAffected()
if err == nil && affectedRows > 0{
if err == nil && affectedRows > 0 {
return nil
}

View file

@ -37,7 +37,6 @@ func SeparateManifestChunks(chunks []*filer_pb.FileChunk) (manifestChunks, nonMa
return
}
func ResolveChunkManifest(lookupFileIdFn LookupFileIdFunctionType, chunks []*filer_pb.FileChunk) (dataChunks, manifestChunks []*filer_pb.FileChunk, manefestResolveErr error) {
// TODO maybe parallel this
for _, chunk := range chunks {

View file

@ -11,17 +11,17 @@ import (
func TestCompactFileChunksRealCase(t *testing.T) {
chunks := []*filer_pb.FileChunk{
{FileId:"2,512f31f2c0700a", Offset: 0, Size: 25- 0, Mtime: 5320497},
{FileId:"6,512f2c2e24e9e8", Offset: 868352, Size: 917585- 868352, Mtime: 5320492},
{FileId:"7,514468dd5954ca", Offset: 884736, Size: 901120- 884736, Mtime: 5325928},
{FileId:"5,5144463173fe77", Offset: 917504, Size: 2297856- 917504, Mtime: 5325894},
{FileId:"4,51444c7ab54e2d", Offset: 2301952, Size: 2367488-2301952, Mtime: 5325900},
{FileId:"4,514450e643ad22", Offset: 2371584, Size: 2420736-2371584, Mtime: 5325904},
{FileId:"6,514456a5e9e4d7", Offset: 2449408, Size: 2490368-2449408, Mtime: 5325910},
{FileId:"3,51444f8d53eebe", Offset: 2494464, Size: 2555904-2494464, Mtime: 5325903},
{FileId:"4,5144578b097c7e", Offset: 2560000, Size: 2596864-2560000, Mtime: 5325911},
{FileId:"3,51445500b6b4ac", Offset: 2637824, Size: 2678784-2637824, Mtime: 5325909},
{FileId:"1,51446285e52a61", Offset: 2695168, Size: 2715648-2695168, Mtime: 5325922},
{FileId: "2,512f31f2c0700a", Offset: 0, Size: 25 - 0, Mtime: 5320497},
{FileId: "6,512f2c2e24e9e8", Offset: 868352, Size: 917585 - 868352, Mtime: 5320492},
{FileId: "7,514468dd5954ca", Offset: 884736, Size: 901120 - 884736, Mtime: 5325928},
{FileId: "5,5144463173fe77", Offset: 917504, Size: 2297856 - 917504, Mtime: 5325894},
{FileId: "4,51444c7ab54e2d", Offset: 2301952, Size: 2367488 - 2301952, Mtime: 5325900},
{FileId: "4,514450e643ad22", Offset: 2371584, Size: 2420736 - 2371584, Mtime: 5325904},
{FileId: "6,514456a5e9e4d7", Offset: 2449408, Size: 2490368 - 2449408, Mtime: 5325910},
{FileId: "3,51444f8d53eebe", Offset: 2494464, Size: 2555904 - 2494464, Mtime: 5325903},
{FileId: "4,5144578b097c7e", Offset: 2560000, Size: 2596864 - 2560000, Mtime: 5325911},
{FileId: "3,51445500b6b4ac", Offset: 2637824, Size: 2678784 - 2637824, Mtime: 5325909},
{FileId: "1,51446285e52a61", Offset: 2695168, Size: 2715648 - 2695168, Mtime: 5325922},
}
printChunks("before", chunks)

View file

@ -74,7 +74,7 @@ func TestRandomFileChunksCompact(t *testing.T) {
if start > stop {
start, stop = stop, start
}
if start + 16 < stop {
if start+16 < stop {
stop = start + 16
}
chunk := &filer_pb.FileChunk{

View file

@ -109,7 +109,7 @@ func (c *ChunkReadAt) doReadAt(p []byte, offset int64) (n int, err error) {
glog.V(4).Infof("doReadAt [%d,%d), n:%v, err:%v", offset, offset+int64(len(p)), n, err)
if err == nil && remaining > 0 && c.fileSize > startOffset {
delta := int(min(remaining, c.fileSize - startOffset))
delta := int(min(remaining, c.fileSize-startOffset))
glog.V(4).Infof("zero2 [%d,%d) of file size %d bytes", startOffset, startOffset+int64(delta), c.fileSize)
n += delta
}

View file

@ -73,14 +73,14 @@ func TestRandomWrites(t *testing.T) {
data := make([]byte, 1024)
for i:=0;i<1024;i++ {
for i := 0; i < 1024; i++ {
start, stop := rand.Intn(len(data)), rand.Intn(len(data))
if start > stop {
start,stop = stop, start
start, stop = stop, start
}
rand.Read(data[start:stop+1])
rand.Read(data[start : stop+1])
c.AddInterval(data[start:stop+1], int64(start))

View file

@ -95,7 +95,6 @@ func TestFsCacheMove(t *testing.T) {
}
func TestFsCacheMove2(t *testing.T) {
cache := newFsCache(nil)
@ -114,4 +113,3 @@ func TestFsCacheMove2(t *testing.T) {
}
}

View file

@ -148,7 +148,6 @@ func (fs *FilerServer) saveMetaData(ctx context.Context, r *http.Request, fileNa
crTime = existingEntry.Crtime
}
glog.V(4).Infoln("saving", path)
entry := &filer2.Entry{
FullPath: util.FullPath(path),

View file

@ -116,7 +116,7 @@ func (cs *CompactSection) deleteOverflowEntry(key SectionalNeedleId) {
})
if deleteCandidate != length && cs.overflow[deleteCandidate].Key == key {
if cs.overflow[deleteCandidate].Size.IsValid() {
cs.overflow[deleteCandidate].Size = - cs.overflow[deleteCandidate].Size
cs.overflow[deleteCandidate].Size = -cs.overflow[deleteCandidate].Size
}
}
}

View file

@ -18,7 +18,7 @@ func (s Size) IsDeleted() bool {
return s < 0 || s == TombstoneFileSize
}
func (s Size) IsValid() bool {
return s >0 && s != TombstoneFileSize
return s > 0 && s != TombstoneFileSize
}
type OffsetLower struct {