forked from mfvanek/pg-index-health
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check for not valid constraints (mfvanek#383)
* Add check for not valid constraints * fix :: check style * modify :: request * fix :: check * fix :: coverage * A fix for Constraint code coverage * Improve tests and update README.md * ForeignKey now extends Constraint * Add IndexWithSingleColumnExtractor --------- Co-authored-by: BLoHny <113517233+BLoHny@users.noreply.github.com>
- Loading branch information
Showing
11 changed files
with
113 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
.../src/main/java/io/github/mfvanek/pg/checks/extractors/IndexWithSingleColumnExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2019-2024. Ivan Vakhrushev and others. | ||
* https://github.com/mfvanek/pg-index-health | ||
* | ||
* This file is a part of "pg-index-health" - a Java library for | ||
* analyzing and maintaining indexes health in PostgreSQL databases. | ||
* | ||
* Licensed under the Apache License 2.0 | ||
*/ | ||
|
||
package io.github.mfvanek.pg.checks.extractors; | ||
|
||
import io.github.mfvanek.pg.common.maintenance.ResultSetExtractor; | ||
import io.github.mfvanek.pg.model.column.Column; | ||
import io.github.mfvanek.pg.model.index.IndexWithColumns; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import javax.annotation.Nonnull; | ||
|
||
import static io.github.mfvanek.pg.checks.extractors.TableExtractor.TABLE_NAME; | ||
|
||
/** | ||
* A mapper from raw data to {@link IndexWithColumns} model. | ||
* | ||
* @author Ivan Vahrushev | ||
* @since 0.10.4 | ||
*/ | ||
public class IndexWithSingleColumnExtractor implements ResultSetExtractor<IndexWithColumns> { | ||
|
||
public static final String INDEX_NAME = "index_name"; | ||
public static final String INDEX_SIZE = "index_size"; | ||
|
||
private final ResultSetExtractor<Column> columnExtractor; | ||
|
||
private IndexWithSingleColumnExtractor() { | ||
this.columnExtractor = ColumnExtractor.of(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Nonnull | ||
@Override | ||
public IndexWithColumns extractData(@Nonnull final ResultSet resultSet) throws SQLException { | ||
final String tableName = resultSet.getString(TABLE_NAME); | ||
final String indexName = resultSet.getString(INDEX_NAME); | ||
final long indexSize = resultSet.getLong(INDEX_SIZE); | ||
final Column column = columnExtractor.extractData(resultSet); | ||
return IndexWithColumns.ofSingle(tableName, indexName, indexSize, column); | ||
} | ||
|
||
@Nonnull | ||
public static ResultSetExtractor<IndexWithColumns> of() { | ||
return new IndexWithSingleColumnExtractor(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters