Search in sources :

Example 1 with QueryServices

use of org.apache.phoenix.query.QueryServices in project phoenix by apache.

the class RegexpReplaceParseNode method create.

@Override
public Expression create(List<Expression> children, StatementContext context) throws SQLException {
    QueryServices services = context.getConnection().getQueryServices();
    boolean useByteBasedRegex = services.getProps().getBoolean(QueryServices.USE_BYTE_BASED_REGEX_ATTRIB, QueryServicesOptions.DEFAULT_USE_BYTE_BASED_REGEX);
    if (useByteBasedRegex) {
        return new ByteBasedRegexpReplaceFunction(children);
    } else {
        return new StringBasedRegexpReplaceFunction(children);
    }
}
Also used : ByteBasedRegexpReplaceFunction(org.apache.phoenix.expression.function.ByteBasedRegexpReplaceFunction) StringBasedRegexpReplaceFunction(org.apache.phoenix.expression.function.StringBasedRegexpReplaceFunction) QueryServices(org.apache.phoenix.query.QueryServices)

Example 2 with QueryServices

use of org.apache.phoenix.query.QueryServices in project phoenix by apache.

the class RegexpSubstrParseNode method create.

@Override
public Expression create(List<Expression> children, StatementContext context) throws SQLException {
    QueryServices services = context.getConnection().getQueryServices();
    boolean useByteBasedRegex = services.getProps().getBoolean(QueryServices.USE_BYTE_BASED_REGEX_ATTRIB, QueryServicesOptions.DEFAULT_USE_BYTE_BASED_REGEX);
    if (useByteBasedRegex) {
        return new ByteBasedRegexpSubstrFunction(children);
    } else {
        return new StringBasedRegexpSubstrFunction(children);
    }
}
Also used : ByteBasedRegexpSubstrFunction(org.apache.phoenix.expression.function.ByteBasedRegexpSubstrFunction) QueryServices(org.apache.phoenix.query.QueryServices) StringBasedRegexpSubstrFunction(org.apache.phoenix.expression.function.StringBasedRegexpSubstrFunction)

Example 3 with QueryServices

use of org.apache.phoenix.query.QueryServices in project phoenix by apache.

the class PhoenixDriver method getQueryServices.

@Override
public QueryServices getQueryServices() throws SQLException {
    try {
        lockInterruptibly(LockMode.READ);
        checkClosed();
        // Lazy initialize QueryServices so that we only attempt to create an HBase Configuration
        // object upon the first attempt to connect to any cluster. Otherwise, an attempt will be
        // made at driver initialization time which is too early for some systems.
        QueryServices result = services;
        if (result == null) {
            synchronized (this) {
                result = services;
                if (result == null) {
                    services = result = new QueryServicesImpl(getDefaultProps());
                }
            }
        }
        return result;
    } finally {
        unlock(LockMode.READ);
    }
}
Also used : ConnectionlessQueryServicesImpl(org.apache.phoenix.query.ConnectionlessQueryServicesImpl) QueryServicesImpl(org.apache.phoenix.query.QueryServicesImpl) ConnectionQueryServicesImpl(org.apache.phoenix.query.ConnectionQueryServicesImpl) QueryServices(org.apache.phoenix.query.QueryServices) ConnectionQueryServices(org.apache.phoenix.query.ConnectionQueryServices)

Example 4 with QueryServices

use of org.apache.phoenix.query.QueryServices in project phoenix by apache.

the class PhoenixDriver method getConnectionQueryServices.

@Override
protected ConnectionQueryServices getConnectionQueryServices(String url, final Properties info) throws SQLException {
    try {
        lockInterruptibly(LockMode.READ);
        checkClosed();
        ConnectionInfo connInfo = ConnectionInfo.create(url);
        SQLException sqlE = null;
        boolean success = false;
        final QueryServices services = getQueryServices();
        ConnectionQueryServices connectionQueryServices = null;
        // Also performs the Kerberos login if the URL/properties request this
        final ConnectionInfo normalizedConnInfo = connInfo.normalize(services.getProps(), info);
        try {
            connectionQueryServices = connectionQueryServicesCache.get(normalizedConnInfo, new Callable<ConnectionQueryServices>() {

                @Override
                public ConnectionQueryServices call() throws Exception {
                    ConnectionQueryServices connectionQueryServices;
                    if (normalizedConnInfo.isConnectionless()) {
                        connectionQueryServices = new ConnectionlessQueryServicesImpl(services, normalizedConnInfo, info);
                    } else {
                        connectionQueryServices = new ConnectionQueryServicesImpl(services, normalizedConnInfo, info);
                    }
                    return connectionQueryServices;
                }
            });
            connectionQueryServices.init(url, info);
            success = true;
        } catch (ExecutionException ee) {
            if (ee.getCause() instanceof SQLException) {
                sqlE = (SQLException) ee.getCause();
            } else {
                throw new SQLException(ee);
            }
        } catch (SQLException e) {
            sqlE = e;
        } finally {
            if (!success) {
                // Remove from map, as initialization failed
                connectionQueryServicesCache.invalidate(normalizedConnInfo);
                if (sqlE != null) {
                    throw sqlE;
                }
            }
        }
        return connectionQueryServices;
    } finally {
        unlock(LockMode.READ);
    }
}
Also used : ConnectionlessQueryServicesImpl(org.apache.phoenix.query.ConnectionlessQueryServicesImpl) ConnectionQueryServicesImpl(org.apache.phoenix.query.ConnectionQueryServicesImpl) SQLException(java.sql.SQLException) QueryServices(org.apache.phoenix.query.QueryServices) ConnectionQueryServices(org.apache.phoenix.query.ConnectionQueryServices) ConnectionQueryServices(org.apache.phoenix.query.ConnectionQueryServices)

Example 5 with QueryServices

use of org.apache.phoenix.query.QueryServices in project phoenix by apache.

the class RegexpSplitParseNode method create.

@Override
public Expression create(List<Expression> children, StatementContext context) throws SQLException {
    QueryServices services = context.getConnection().getQueryServices();
    boolean useByteBasedRegex = services.getProps().getBoolean(QueryServices.USE_BYTE_BASED_REGEX_ATTRIB, QueryServicesOptions.DEFAULT_USE_BYTE_BASED_REGEX);
    if (useByteBasedRegex) {
        return new ByteBasedRegexpSplitFunction(children);
    } else {
        return new StringBasedRegexpSplitFunction(children);
    }
}
Also used : QueryServices(org.apache.phoenix.query.QueryServices) StringBasedRegexpSplitFunction(org.apache.phoenix.expression.function.StringBasedRegexpSplitFunction) ByteBasedRegexpSplitFunction(org.apache.phoenix.expression.function.ByteBasedRegexpSplitFunction)

Aggregations

QueryServices (org.apache.phoenix.query.QueryServices)7 ConnectionQueryServices (org.apache.phoenix.query.ConnectionQueryServices)2 ConnectionQueryServicesImpl (org.apache.phoenix.query.ConnectionQueryServicesImpl)2 ConnectionlessQueryServicesImpl (org.apache.phoenix.query.ConnectionlessQueryServicesImpl)2 SQLException (java.sql.SQLException)1 CompareOp (org.apache.hadoop.hbase.filter.CompareFilter.CompareOp)1 ImmutableBytesWritable (org.apache.hadoop.hbase.io.ImmutableBytesWritable)1 AndExpression (org.apache.phoenix.expression.AndExpression)1 ArrayConstructorExpression (org.apache.phoenix.expression.ArrayConstructorExpression)1 ByteBasedLikeExpression (org.apache.phoenix.expression.ByteBasedLikeExpression)1 CaseExpression (org.apache.phoenix.expression.CaseExpression)1 CoerceExpression (org.apache.phoenix.expression.CoerceExpression)1 ComparisonExpression (org.apache.phoenix.expression.ComparisonExpression)1 DateAddExpression (org.apache.phoenix.expression.DateAddExpression)1 DateSubtractExpression (org.apache.phoenix.expression.DateSubtractExpression)1 DecimalAddExpression (org.apache.phoenix.expression.DecimalAddExpression)1 DecimalDivideExpression (org.apache.phoenix.expression.DecimalDivideExpression)1 DecimalMultiplyExpression (org.apache.phoenix.expression.DecimalMultiplyExpression)1 DecimalSubtractExpression (org.apache.phoenix.expression.DecimalSubtractExpression)1 DoubleAddExpression (org.apache.phoenix.expression.DoubleAddExpression)1