or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration.mdexceptions.mdexecution.mdexpressions.mdindex.mdjdbc.mdmapreduce.mdmonitoring.mdquery-compilation.mdschema-metadata.mdserver.mdtransactions.mdtypes.md
tile.json

tessl/maven-org-apache-phoenix--phoenix-core

Apache Phoenix Core library providing SQL-on-HBase functionality with JDBC connectivity, query compilation, and transaction support

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.apache.phoenix/phoenix-core@5.2.x

To install, run

npx @tessl/cli install tessl/maven-org-apache-phoenix--phoenix-core@5.2.0

index.mddocs/

Apache Phoenix Core

Apache Phoenix Core is a SQL engine for Apache HBase that provides JDBC connectivity and SQL query capabilities over HBase. It enables users to interact with HBase using standard SQL syntax while leveraging HBase's scalability and performance characteristics.

Package Information

Package Name: org.apache.phoenix:phoenix-core Package Type: Maven Library Language: Java Version: 5.2.1

Maven Installation

<dependency>
    <groupId>org.apache.phoenix</groupId>
    <artifactId>phoenix-core</artifactId>
    <version>5.2.1</version>
</dependency>

Core Imports

The main entry points for Phoenix Core require these essential imports:

// Primary JDBC driver
import org.apache.phoenix.jdbc.PhoenixDriver;
import org.apache.phoenix.jdbc.PhoenixConnection;

// Query services
import org.apache.phoenix.query.ConnectionQueryServices;
import org.apache.phoenix.query.QueryServices;

// Schema management
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PMetaData;

// Data types
import org.apache.phoenix.schema.types.PDataType;

// Standard JDBC imports
import java.sql.*;

Basic Usage

Establishing a Connection

import org.apache.phoenix.jdbc.PhoenixDriver;
import java.sql.*;

// Register the Phoenix driver
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");

// Connect to HBase via Phoenix
String url = "jdbc:phoenix:localhost:2181";
Connection connection = DriverManager.getConnection(url);

// Create a statement
Statement stmt = connection.createStatement();

// Execute queries
ResultSet rs = stmt.executeQuery("SELECT * FROM my_table");
while (rs.next()) {
    String name = rs.getString("name");
    int value = rs.getInt("value");
    // Process results
}

Creating Tables

Statement stmt = connection.createStatement();

// Create a Phoenix table (maps to HBase table)
stmt.executeUpdate(
    "CREATE TABLE users (" +
    "  id BIGINT NOT NULL, " +
    "  name VARCHAR, " +
    "  email VARCHAR, " +
    "  created_date DATE " +
    "  CONSTRAINT pk PRIMARY KEY (id))"
);

Architecture

Phoenix Core provides a comprehensive SQL-on-HBase solution with several key architectural components:

SQL-on-HBase Layer

Phoenix translates SQL queries into native HBase operations, providing:

  • Query Optimization: Cost-based query optimization and execution planning
  • Predicate Pushdown: Filtering operations pushed to HBase region servers
  • Secondary Indexes: Global and local secondary index support
  • Statistics: Table and column statistics for query optimization

JDBC Compliance

Full JDBC 4.0 compliance including:

  • Standard Interfaces: Driver, Connection, Statement, PreparedStatement, ResultSet
  • Metadata Support: Complete database and result set metadata
  • Transaction Support: ACID transactions with Phoenix transaction manager

Distributed Architecture

  • Client-Server: Thin client with server-side processing via HBase coprocessors
  • High Availability: Connection failover and load balancing
  • Parallel Processing: Multi-threaded query execution and parallel scans

Capabilities

Phoenix Core provides extensive functionality across multiple domains:

JDBC API

Complete JDBC implementation with Phoenix-specific extensions for HBase integration.

Key Components:

// Driver registration and connection management
PhoenixDriver driver = new PhoenixDriver();
PhoenixConnection connection = driver.connect(url, properties);

// Statement execution with monitoring
PhoenixPreparedStatement stmt = connection.prepareStatement(sql);
PhoenixResultSet results = stmt.executeQuery();

Learn more: JDBC API Documentation →

Query Compilation and Services

Advanced query compilation framework that transforms SQL into optimized execution plans.

Key Components:

// Query services for metadata and execution
ConnectionQueryServices queryServices = connection.getQueryServices();

// Query compilation and planning
QueryCompiler compiler = new QueryCompiler();
QueryPlan plan = compiler.compile(statement, context);

Learn more: Query Compilation Documentation →

Schema and Metadata Management

Comprehensive schema management with strong typing and metadata caching.

Key Components:

// Table and column metadata
PTable table = connection.getTable(tableName);
PColumn column = table.getColumn(columnName);

// Metadata cache management
PMetaData metaData = connection.getMetaData();
PTableRef tableRef = metaData.getTableRef(tableName);

Learn more: Schema and Metadata Documentation →

Data Type System

Rich type system with Phoenix-specific types and array support.

Key Components:

// Core data types
PDataType varchar = PVarchar.INSTANCE;
PDataType integer = PInteger.INSTANCE;
PDataType decimal = PDecimal.INSTANCE;

// Array types
PDataType varcharArray = PVarcharArray.INSTANCE;
PDataType integerArray = PIntegerArray.INSTANCE;

Learn more: Data Types Documentation →

Exception Handling

Comprehensive exception hierarchy with detailed error codes and messages.

Key Components:

// Exception construction
SQLExceptionInfo.Builder builder = new SQLExceptionInfo.Builder(code);
SQLException exception = builder.setMessage(message).build().buildException();

// Schema-specific exceptions
throw new TableNotFoundException(tableName);
throw new ColumnNotFoundException(columnName);

Learn more: Exception Handling Documentation →

Expression Framework

Powerful expression system supporting functions, operators, and custom expressions.

Key Components:

// Expression evaluation
Expression expression = LiteralExpression.newConstant(value);
ImmutableBytesWritable result = new ImmutableBytesWritable();
boolean success = expression.evaluate(tuple, result);

// Function expressions
FunctionExpression function = new SomeScalarFunction(arguments);

Learn more: Expression Framework Documentation →

Query Execution

Optimized query execution with parallel processing and result iteration.

Key Components:

// Execution planning and iteration
ResultIterator iterator = queryPlan.iterator();
Tuple tuple = iterator.next();

// Mutation state management
MutationState mutationState = connection.getMutationState();
mutationState.commit();

Learn more: Query Execution Documentation →

Configuration and Utilities

Extensive configuration options and utility classes for Phoenix operations.

Key Components:

// Configuration properties
ConnectionProperty property = ConnectionProperty.QUERY_TIMEOUT;
String value = connection.getClientInfo(property.toString());

// Utility operations
byte[] bytes = ByteUtil.concat(array1, array2);
String formatted = SchemaUtil.getTableName(schemaName, tableName);

Learn more: Configuration and Utilities Documentation →

Server-Side Components

HBase coprocessors and server-side processing for distributed operations.

Key Components:

// Coprocessor interfaces
PhoenixCoprocessor coprocessor = new MetaDataEndpointImpl();

// Index building and management
IndexBuilder indexBuilder = new PhoenixIndexBuilder();
IndexWriter indexWriter = new ParallelWriterIndexCommitter();

Learn more: Server-Side Components Documentation →

MapReduce Integration

Native MapReduce support for bulk operations and data processing.

Key Components:

// MapReduce input/output formats
PhoenixInputFormat inputFormat = new PhoenixInputFormat();
PhoenixOutputFormat outputFormat = new PhoenixOutputFormat();

// Bulk loading tools
BulkLoadTool bulkLoader = new BulkLoadTool();

Learn more: MapReduce Integration Documentation →

Monitoring and Metrics

Comprehensive monitoring framework with detailed metrics collection.

Key Components:

// Metrics collection
MetricType metricType = MetricType.QUERY_TIME;
GlobalClientMetrics.GLOBAL_QUERY_TIME.increment(duration);

// Table-specific metrics
TableMetricsManager metricsManager = TableMetricsManager.getInstance();

Learn more: Monitoring and Metrics Documentation →

Transaction Support

ACID transaction support with Phoenix transaction management.

Key Components:

// Transaction client interfaces
PhoenixTransactionClient txClient = TransactionFactory.getTransactionClient();

// Transaction context management
TransactionContext txContext = txClient.newTransactionContext();

Learn more: Transaction Support Documentation →

Documentation Navigation

This documentation is organized into focused sections covering different aspects of Phoenix Core:

Each section provides comprehensive API documentation with practical examples and usage patterns.