Skip to content

Commit

Permalink
Phoenix Connector: Configure Page size while creating Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
virajjasani committed Jan 12, 2025
1 parent 223828d commit 2ea50e1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/main/sphinx/connector/phoenix.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The following Phoenix-specific configuration properties are available:
| `phoenix.connection-url` | Yes | `jdbc:phoenix[:zk_quorum][:zk_port][:zk_hbase_path]`. The `zk_quorum` is a comma separated list of ZooKeeper servers. The `zk_port` is the ZooKeeper port. The `zk_hbase_path` is the HBase root znode path, that is configurable using `hbase-site.xml`. By default the location is `/hbase` |
| `phoenix.config.resources` | No | Comma-separated list of configuration files (e.g. `hbase-site.xml`) to use for connection properties. These files must exist on the machines running Trino. |
| `phoenix.max-scans-per-split` | No | Maximum number of HBase scans that will be performed in a single split. Default is 20. Lower values will lead to more splits in Trino. Can also be set via session propery `max_scans_per_split`. For details see: [https://phoenix.apache.org/update_statistics.html](https://phoenix.apache.org/update_statistics.html). (This setting has no effect when guideposts are disabled in Phoenix.) |
| `phoenix.scan-page-size` | No | The time limit on the amount of work single RPC request can do before it times out. |

```{include} jdbc-common-configurations.fragment
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.apache.hadoop.fs.Path;
import org.apache.phoenix.jdbc.ConnectionInfo;
import org.apache.phoenix.jdbc.PhoenixDriver;
import org.apache.phoenix.query.QueryServices;

import java.sql.SQLException;
import java.util.Map;
Expand Down Expand Up @@ -209,6 +210,7 @@ public static Properties getConnectionProperties(PhoenixConfig config)

ConnectionInfo connectionInfo = ConnectionInfo.create(config.getConnectionUrl(), EMPTY_PROPS, new Properties());
connectionInfo.asProps().asMap().forEach(connectionProperties::setProperty);
connectionProperties.setProperty(QueryServices.PHOENIX_SERVER_PAGE_SIZE_MS, String.valueOf(config.getPageSize()));
return connectionProperties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public class PhoenixConfig
private int maxScansPerSplit = 20;
private boolean reuseConnection = true;

/**
* By default, let Phoenix client derive Page size from HBase RPC timeout configs.
*/
private int pageSize = -1;

@NotNull
public String getConnectionUrl()
{
Expand Down Expand Up @@ -94,4 +99,19 @@ public PhoenixConfig setReuseConnection(boolean reuseConnection)
this.reuseConnection = reuseConnection;
return this;
}

@Min(-1)
@Max(Integer.MAX_VALUE)
public int getPageSize()
{
return pageSize;
}

@Config("phoenix.scan-page-size")
@ConfigDescription("Phoenix Page size to reflect the time limit on the amount of work single RPC request can do")
public PhoenixConfig setPageSize(int pageSize)
{
this.pageSize = pageSize;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public void testDefaults()
.setConnectionUrl(null)
.setResourceConfigFiles(ImmutableList.of())
.setMaxScansPerSplit(20)
.setReuseConnection(true));
.setReuseConnection(true)
.setPageSize(-1));
}

@Test
Expand All @@ -49,12 +50,14 @@ public void testExplicitPropertyMappings()
.put("phoenix.config.resources", configFile.toString())
.put("phoenix.max-scans-per-split", "1")
.put("query.reuse-connection", "false")
.put("phoenix.scan-page-size", "11")
.buildOrThrow();

PhoenixConfig expected = new PhoenixConfig()
.setConnectionUrl("jdbc:phoenix:localhost:2181:/hbase")
.setResourceConfigFiles(ImmutableList.of(configFile.toString()))
.setMaxScansPerSplit(1)
.setPageSize(11)
.setReuseConnection(false);

assertFullMapping(properties, expected);
Expand Down

0 comments on commit 2ea50e1

Please sign in to comment.