titan icon indicating copy to clipboard operation
titan copied to clipboard

fix file_size always = 0 bug

Open apple-ouyang opened this issue 2 years ago • 6 comments

#236

apple-ouyang avatar Apr 21 '22 09:04 apple-ouyang

Please add a test to cover it

I am a noob sorry. What a good test should be like? Is there a example or some docs? Or do you mean I should run the titan_*_test?

And how should I cover it? Is there a cover ratio or something that I can tell that I cover it?

apple-ouyang avatar Apr 22 '22 02:04 apple-ouyang

@apple-ouyang You can check TEST_F(TableBuilderTest, TargetSize), add a test for blob gc that it would fail without your change.

Connor1996 avatar Apr 22 '22 05:04 Connor1996

Thanks @Connor1996, I will check this code and figure out a cover test.

apple-ouyang avatar Apr 22 '22 05:04 apple-ouyang

I change the code. Referenced by TitanTableBuilder::AddBlob in the file table_build.cc::182. Here is the code written in table_build.cc::182:

  if (blob_handle_->GetFile()->GetFileSize() >=
      cf_options_.blob_file_target_size) {
    // if blob file hit the size limit, we have to finish it
    // in this case, when calling `BlobFileBuilder::Finish`, builder will be in
    // unbuffered state, so it will not trigger another `AddBlobResultsToBase`
    // call
    FinishBlobFile();
  }

I guess my change will work and don't need a test right? Because this is how you write in the table_build.cc. @Connor1996

apple-ouyang avatar Apr 23 '22 04:04 apple-ouyang

I change the code. Referenced by TitanTableBuilder::AddBlob in the file table_build.cc::182. Here is the code written in table_build.cc::182:

  if (blob_handle_->GetFile()->GetFileSize() >=
      cf_options_.blob_file_target_size) {
    // if blob file hit the size limit, we have to finish it
    // in this case, when calling `BlobFileBuilder::Finish`, builder will be in
    // unbuffered state, so it will not trigger another `AddBlobResultsToBase`
    // call
    FinishBlobFile();
  }

I guess my change will work and don't need a test right? Because this is how you write in the table_build.cc. @Connor1996

Adding a case is to make sure it won't be broken in the future. It is not about how you write the code.

Connor1996 avatar Apr 24 '22 05:04 Connor1996

@apple-ouyang friendly ping

Connor1996 avatar May 03 '22 15:05 Connor1996