[Gravity] Add defragment method to optimize tables

Review Request #1034 — Created Sept. 29, 2023 and submitted

d.cova
Lunr.Gravity
ML-744
6fd1331...
lunr

Add defragment method to optimize tables

Unit tests

  • 0
  • 0
  • 29
  • 0
  • 29
Description From Last Updated
There are no open issues
pprkut
  1. 
      
  2. src/Lunr/Gravity/MySQL/MySQLConnection.php (Diff revision 1)
     
     
     
     
    The issue has been resolved. Show all issues

    Need error handling here, and potentially a dedicated exception

  3. src/Lunr/Gravity/SQLite3/SQLite3Connection.php (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
    The issue has been resolved. Show all issues

    defragment works differently for sqlite

    1. SQLite apparently automatically reuses the space, it still has a VACUUM command that seems to be the closest to what we want, should I use that?

  4. 
      
d.cova
pprkut
  1. 
      
  2. src/Lunr/Gravity/MySQL/MySQLConnection.php (Diff revisions 1 - 2)
     
     
    The issue has been resolved. Show all issues

    The preg_match is not needed. Just use the escaper.

  3. src/Lunr/Gravity/MySQL/MySQLConnection.php (Diff revisions 1 - 2)
     
     
    The issue has been resolved. Show all issues

    I'd probably go for DefragmentationException, since "optimize" is a very mysql specific term.

  4. src/Lunr/Gravity/SQLite3/SQLite3Connection.php (Diff revisions 1 - 2)
     
     
    The issue has been resolved. Show all issues

    This should be ?string, only here, not in the parent.

  5. src/Lunr/Gravity/SQLite3/SQLite3Connection.php (Diff revisions 1 - 2)
     
     
    The issue has been resolved. Show all issues

    That's the query for when $table is NULL

    1. If we want this to run we should always set table to be null inside the method

  6. 
      
d.cova
d.mendes
  1. 
      
  2. The issue has been resolved. Show all issues

    i can't find where this is used,
    is it needed?

  3. 
      
d.mendes
  1. 
      
  2. The issue has been resolved. Show all issues

    null is missing

  3. 
      
d.mendes
  1. 
      
  2. The issue has been resolved. Show all issues

    missing description and @covers
    i don't think that is the position we usually use for @param and @dataProvider

  3. The issue has been resolved. Show all issues

    missing @covers

  4. 
      
d.mendes
  1. 
      
  2. The issue has been resolved. Show all issues

    missing @covers

  3. 
      
smillernl
  1. 
      
  2. src/Lunr/Gravity/DatabaseConnection.php (Diff revision 3)
     
     
    The issue has been resolved. Show all issues

    Please add a return type

  3. The issue has been resolved. Show all issues

    It can't the file is created in 2023

  4. The issue has been resolved. Show all issues

    Let's just return if it isn't

    1. Vacuum doesn't run on specific tables at all, I suppose it can just run, no matter what parameter it gets

  5. The issue has been resolved. Show all issues

    No, the file is too new for that.

  6. 
      
d.cova
pprkut
  1. 
      
  2. src/Lunr/Gravity/MySQL/MySQLConnection.php (Diff revision 4)
     
     
     
     
     
    The issue has been resolved. Show all issues

    This doesn't actually tell us why the query failed. We do this with the logger in the DatabaseAccessObject

  3. src/Lunr/Gravity/MySQL/Tests/MySQLConnectionDefragmentTest.php (Diff revision 4)
     
     
     
     
     
     
     
     
     
     
     
    The issue has been resolved. Show all issues

    Nothing in the defragment method checks for valid table names.

  4. The issue has been resolved. Show all issues

    If we don't care about the return of the method, there's no need to mock it.

  5. The issue has been resolved. Show all issues

    Don't really care about this here. Changing the logging in the query method shouldn't cause this test to fail

  6. The issue has been resolved. Show all issues

    ditto

  7. 
      
d.cova
smillernl
  1. 
      
  2. The issue has been resolved. Show all issues

    This shouldn't be here

  3. 
      
d.cova
smillernl
  1. 
      
  2. src/Lunr/Gravity/DatabaseConnection.php (Diff revision 6)
     
     
    The issue has been resolved. Show all issues

    This shouldn't be removed for existing files

  3. The issue has been resolved. Show all issues

    Probably good to log that passing a $table did nothing here.

  4. The issue has been resolved. Show all issues

    Shouldn't this represent the table too?

  5. 
      
d.cova
smillernl
  1. 
      
  2. The issue has been resolved. Show all issues

    The default will never be used since the parent method does not allow null.

  3. tests/phpunit.xml (Diff revision 7)
     
     
    The issue has been resolved. Show all issues

    No

  4. 
      
d.cova
smillernl
  1. 
      
  2. The issue has been resolved. Show all issues

    Let's just make it like:

         * @param string $table This parameter is ignored when using SQLite, as VACUUM operates on the entire database.
    
  3. 
      
pprkut
  1. 
      
  2. The issue has been resolved. Show all issues

    We know the complete message here so no need to do a substring only match

  3. The issue has been resolved. Show all issues

    We can come up with a better error message here. Don't need to end the string with : ;)

  4. 
      
d.cova
smillernl
  1. Ship It!
  2. 
      
pprkut
pprkut
Review request changed

Status: Closed (submitted)

Change Summary:

Merged into master

Loading...