Skip to content

Commit 5601349

Browse files
Apply suggestions from code review
Co-authored-by: kirkrodrigues <[email protected]>
1 parent ee4ea9b commit 5601349

File tree

5 files changed

+51
-60
lines changed

5 files changed

+51
-60
lines changed

presto-clp/src/main/java/com/facebook/presto/plugin/clp/split/filter/ClpCustomSplitFilterOptionsDeserializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import static com.facebook.presto.plugin.clp.split.filter.ClpSplitFilterConfig.CustomSplitFilterOptions;
2525

2626
/**
27-
* Uses the given implementation of {@link CustomSplitFilterOptions} to deserialize the
28-
* {@code "customOptions"} field in the filter. The implementation is originally chosen
29-
* by the {@code clp.split-filter-provider-type} config option.
27+
* Uses the given {@link CustomSplitFilterOptions} implementation to deserialize the
28+
* {@code "customOptions"} field in a {@link ClpSplitFilterConfig}. The implementation is determined
29+
* by the implemented {@link ClpSplitFilterProvider}.
3030
*/
3131
public class ClpCustomSplitFilterOptionsDeserializer
3232
extends JsonDeserializer<CustomSplitFilterOptions>

presto-clp/src/main/java/com/facebook/presto/plugin/clp/split/filter/ClpMySqlSplitFilterProvider.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
import static java.lang.String.format;
2929

3030
/**
31-
* Loads and manages split filter configurations of MySQL metadata database for the CLP
32-
* connector.
31+
* Implementation for the CLP package's MySQL metadata database.
3332
*/
3433
public class ClpMySqlSplitFilterProvider
3534
extends ClpSplitFilterProvider
@@ -41,19 +40,18 @@ public ClpMySqlSplitFilterProvider(ClpConfig config)
4140
}
4241

4342
/**
44-
* This method performs regex-based replacements according to the {@code "rangeMapping"} field
45-
* in {@link ClpMySqlCustomSplitFilterOptions} to convert numeric filter expressions. For
46-
* example:
43+
* Performs regex-based replacements to rewrite {@code pushDownExpression} according to the
44+
* {@code "rangeMapping"} field in {@link ClpMySqlCustomSplitFilterOptions}. For example:
4745
* <ul>
4846
* <li>{@code "msg.timestamp" >= 1234} → {@code end_timestamp >= 1234}</li>
4947
* <li>{@code "msg.timestamp" <= 5678} → {@code begin_timestamp <= 5678}</li>
5048
* <li>{@code "msg.timestamp" = 4567} →
5149
* {@code (begin_timestamp <= 4567 AND end_timestamp >= 4567)}</li>
5250
* </ul>
5351
*
54-
* @param scope the scope of the filter
55-
* @param pushDownExpression the MySQL SQL string that needs to be rewritten
56-
* @return the rewritten SQL string
52+
* @param scope the filter's scope
53+
* @param pushDownExpression the expression to be rewritten
54+
* @return the rewritten expression
5755
*/
5856
@Override
5957
public String remapSplitFilterPushDownExpression(String scope, String pushDownExpression)
@@ -107,15 +105,14 @@ private Map<String, ClpMySqlCustomSplitFilterOptions.RangeMapping> getAllMapping
107105
}
108106

109107
/**
110-
* The MySql-specific fields in the filter contains:
108+
* Custom options:
111109
* <ul>
112-
* <li><b>{@code rangeMapping}</b> <i>(optional)</i>: an object only for numeric type filter
113-
* with the following properties:
110+
* <li><b>{@code rangeMapping}</b> <i>(optional)</i>: an object with the following properties:
114111
* <ul>
115-
* <li>{@code lowerBound}: The metadata column that represents the lower bound of values
116-
* in a split for the data column.</li>
117-
* <li>{@code upperBound}: The metadata column that represents the upper bound of values
118-
* in a split for the data column.</li>
112+
* <li>{@code lowerBound}: The numeric metadata column that represents the lower bound
113+
* of values in a split for the numeric data column.</li>
114+
* <li>{@code upperBound}: The numeric metadata column that represents the upper bound
115+
* of values in a split for the numeric data column.</li>
119116
* </ul>
120117
* </li>
121118
* </ul>

presto-clp/src/main/java/com/facebook/presto/plugin/clp/split/filter/ClpSplitFilterConfig.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
import com.fasterxml.jackson.annotation.JsonProperty;
1717

1818
/**
19-
* Defines the basic filter JSON structure.
20-
* <p></p>
21-
* Here are the explanations for each field:
19+
* Options for a how a column in a Presto query should be pushed down into a query against CLP's
20+
* metadata database (during split pruning):
2221
* <ul>
23-
* <li><b>{@code columnName}</b>: the data column's name.</li>
22+
* <li><b>{@code columnName}</b>: The column's name in the Presto query.</li>
2423
*
25-
* <li><b>{@code customOptions}</b>: the split filter provider specific sub-object.</li>
24+
* <li><b>{@code customOptions}</b>: Options specific to the current
25+
* {@link ClpSplitFilterProvider}.</li>
2626
*
27-
* <li><b>{@code required}</b> (optional, defaults to {@code false}): indicates whether the
28-
* filter must be present in the pushed-down expression for split filtering. If a required
29-
* filter is missing or cannot be pushed down, the query will be rejected.</li>
27+
* <li><b>{@code required}</b> (optional, defaults to {@code false}): Whether the filter must be
28+
* present in the generated metadata query. If a required filter is missing or cannot be added to
29+
* the metadata query, the original query will be rejected.</li>
3030
* </ul>
3131
*/
3232
public class ClpSplitFilterConfig

presto-clp/src/main/java/com/facebook/presto/plugin/clp/split/filter/ClpSplitFilterProvider.java

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,16 @@
3636
import static java.util.Objects.requireNonNull;
3737

3838
/**
39-
* Loads and manages split filter configurations for the CLP connector.
39+
* Loads and manages {@link ClpSplitFilterConfig}s from a config file.
4040
* <p></p>
41-
* The configuration file is specified by the {@code clp.split-filter-config} property and defines
42-
* split filters used to optimize query execution through split filtering.
41+
* The config file is specified by the {@code clp.split-filter-config} property.
4342
* <p></p>
4443
* Filter configs can be declared at either a catalog, schema, or table scope. Filter configs under
4544
* a particular scope will apply to all child scopes (e.g., schema-level filter configs will apply
4645
* to all tables within that schema).
4746
* <p></p>
48-
* Different split filter providers can customize filter configurations through the
49-
* {@code "customOptions"} field within each {@link ClpSplitFilterConfig}.
47+
* Implementations of this class can customize filter configs through the {@code "customOptions"}
48+
* field within each {@link ClpSplitFilterConfig}.
5049
*/
5150
public abstract class ClpSplitFilterProvider
5251
{
@@ -77,30 +76,27 @@ public ClpSplitFilterProvider(ClpConfig config)
7776
}
7877

7978
/**
80-
* Rewrites the given {@code pushDownExpression} for split filtering to remap filter conditions
81-
* based on the custom configuration options stored defined in {@code "customOptions"} fields
82-
* of the given scope.
79+
* Rewrites {@code pushDownExpression} to remap filter conditions based on the
80+
* {@code "customOptions"} for the given scope.
8381
* <p></p>
84-
* The {@code scope} follows the format {@code catalog[.schema][.table]}, and determines
85-
* which filter mappings to apply, since mappings from more specific scopes (e.g., table-level)
82+
* {@code scope} follows the format {@code catalog[.schema][.table]}, and determines which
83+
* filter mappings to apply, since mappings from more specific scopes (e.g., table-level)
8684
* override or supplement those from broader scopes (e.g., catalog-level). For each scope
87-
* (catalog, schema, table), this method collects all range mappings defined in the split
88-
* filter configuration.
85+
* (catalog, schema, table), this method collects all mappings defined in
86+
* {@code "customOptions"}.
8987
*
9088
* @param scope the scope of the filter
91-
* @param pushDownExpression the {@code pushDownExpression} for split filtering that needs to
92-
* be rewritten
93-
* @return the rewritten {@code pushDownExpression} for split filtering
89+
* @param pushDownExpression the expression to be rewritten
90+
* @return the rewritten expression
9491
*/
9592
public abstract String remapSplitFilterPushDownExpression(String scope, String pushDownExpression);
9693

9794
/**
98-
* Checks for the given table, if the given {@code pushDownExpression} for split filtering
99-
* contains all required fields.
95+
* Checks for the given table, if {@code splitFilterPushDownExpression} contains all required
96+
* fields.
10097
*
10198
* @param tableScopeSet the set of scopes of the tables that are being queried
102-
* @param splitFilterPushDownExpression the remapped {@code pushDownExpression} for split
103-
* filtering to be checked
99+
* @param splitFilterPushDownExpression the expression to be checked
104100
*/
105101
public void checkContainsRequiredFilters(Set<String> tableScopeSet, String splitFilterPushDownExpression)
106102
{
@@ -127,11 +123,11 @@ public Set<String> getColumnNames(String scope)
127123
}
128124

129125
/**
130-
* Returns the {@link CustomSplitFilterOptions} class implemented by the user. To respect our
131-
* code style, we recommend implementing a {@code protected static class} as an inner class
132-
* in the user-implemented {@link ClpSplitFilterProvider} class.
126+
* Returns the implemented {@link CustomSplitFilterOptions} class. To respect our code style, we
127+
* recommend implementing a {@code protected static class} as an inner class in the implemented
128+
* {@link ClpSplitFilterProvider} class.
133129
*
134-
* @return the user-implemented {@link CustomSplitFilterOptions} class.
130+
* @return the implemented {@link CustomSplitFilterOptions} class
135131
*/
136132
protected abstract Class<? extends CustomSplitFilterOptions> getCustomSplitFilterOptionsClass();
137133

presto-docs/src/main/sphinx/connector/clp.rst

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ Property Name Description
7979
seconds. Set this to a lower value for frequently changing datasets or
8080
to a higher value to reduce load.
8181
``clp.split-filter-config`` The absolute path to an optional split filter config file. See the
82-
:ref:`Split Filter Config File<split-filter-config-file>` section
83-
for details.
82+
:ref:`Split Filter Config File<split-filter-config-file>` section for
83+
details.
8484
``clp.split-filter-provider-type`` Specifies the split filter provider type. Currently, the only supported ``mysql``
8585
type is a MySQL database, which is also used by the CLP package to
8686
store metadata. Additional providers can be supported by implementing
@@ -146,20 +146,18 @@ Each filter config has the following options:
146146

147147
- ``columnName``: The data column's name.
148148

149-
- ``customOptions`` *(optional)*: Custom config options for a split filter provider. Options for the default split
150-
filter provider (``ClpMySqlSplitFilterProvider``) are :ref:`below<clp-mysql-split-filter-provider-config>`.
149+
- ``customOptions`` *(optional)*: Custom options for a split filter provider. Options for the default split filter
150+
provider (``ClpMySqlSplitFilterProvider``) are :ref:`below<clp-mysql-split-filter-provider-config>`.
151151

152-
- ``required`` *(optional, defaults to false)*: Whether the filter **must** be present in the generated split filter
153-
query. If a required filter is missing or cannot be added to the split filter query, the original query will be
154-
rejected.
152+
- ``required`` *(optional, defaults to false)*: Whether the filter **must** be present in the generated metadata query.
153+
If a required filter is missing or cannot be added to the metadata query, the original query will be rejected.
155154

156155
.. _clp-mysql-split-filter-provider-config:
157156

158157
ClpMySqlSplitFilterProvider-Specific Filter Config
159158
-----------------------------------------------
160159

161-
For the ``ClpMySqlSplitFilterProvider``, the ``customOptions`` option of the filter config has the following
162-
sub-options:
160+
For ``ClpMySqlSplitFilterProvider``, the ``customOptions`` option of the filter config has the following sub-options:
163161

164162
- ``rangeMapping`` *(optional)*: an object with the following properties:
165163

@@ -171,7 +169,7 @@ sub-options:
171169
Filter Config Example
172170
---------------------
173171

174-
The code block shows an example split filter config file:
172+
The code block shows an example filter config file:
175173

176174
.. code-block:: json
177175
@@ -217,7 +215,7 @@ The code block shows an example split filter config file:
217215
``end_timestamp``, and is required to exist in every query.
218216
- The column ``file_name`` is used as-is without remapping.
219217

220-
If you prefer to use a different format for the ``customOptions``, you can provide your own implementations of the
218+
If you prefer to use a different format for ``customOptions``, you can provide your own implementation of the
221219
``ClpSplitFilterProvider`` interface, and configure the connector accordingly.
222220

223221
Supported SQL Expressions

0 commit comments

Comments
 (0)