public T run(boolean initTable) throws MetaException, NoSuchObjectException { try { start(initTable); if (doUseDirectSql) { try { directSql.prepareTxn(); this.results = getSqlResult(this); LOG.debug("Using direct SQL optimization."); } catch (Exception ex) { handleDirectSqlError(ex); this.results = getJdoResult(this); LOG.debug("Not using direct SQL optimization."); return commit(); } catch (NoSuchObjectException ex) { throw ex; throw new MetaException(ex.getMessage()); } finally { close();
private T commit() { success = commitTransaction(); if (doTrace) { double time = ((System.nanoTime() - start) / 1000000.0); String result = describeResult(); String retrieveType = doUseDirectSql ? "SQL" : "ORM"; LOG.debug("{} retrieved using {} in {}ms", result, retrieveType, time); } return results; }
@Override protected Integer getJdoResult( GetHelper<Integer> ctx) throws MetaException, NoSuchObjectException { Integer numPartitions = null; if (exprTree != null) { try { numPartitions = getNumPartitionsViaOrmFilter(ctx.getTable(), exprTree, true); } catch (MetaException e) { numPartitions = null; } } // if numPartitions could not be obtained from ORM filters, then get number partitions names, and count them if (numPartitions == null) { List<String> filteredPartNames = new ArrayList<>(); getPartitionNamesPrunedByExprNoTxn(ctx.getTable(), tempExpr, "", (short) -1, filteredPartNames); numPartitions = filteredPartNames.size(); } return numPartitions; } }.run(true);
public T run(boolean initTable) throws MetaException, NoSuchObjectException { try { start(initTable); if (doUseDirectSql) { try { directSql.prepareTxn(); this.results = getSqlResult(this); } catch (Exception ex) { handleDirectSqlError(ex); } } // Note that this will be invoked in 2 cases: // 1) DirectSQL was disabled to start with; // 2) DirectSQL threw and was disabled in handleDirectSqlError. if (!doUseDirectSql) { this.results = getJdoResult(this); } return commit(); } catch (NoSuchObjectException ex) { throw ex; } catch (MetaException ex) { throw ex; } catch (Exception ex) { LOG.error("", ex); throw new MetaException(ex.getMessage()); } finally { close(); } }
public T run(boolean initTable) throws MetaException, NoSuchObjectException { try { start(initTable); if (doUseDirectSql) { try { setResult(getSqlResult(this)); } catch (Exception ex) { handleDirectSqlError(ex); } } if (!doUseDirectSql) { setResult(getJdoResult(this)); } return commit(); } catch (NoSuchObjectException ex) { throw ex; } catch (MetaException ex) { throw ex; } catch (Exception ex) { LOG.error("", ex); throw new MetaException(ex.getMessage()); } finally { close(); } }
public T run(boolean initTable) throws MetaException, NoSuchObjectException { try { start(initTable); if (doUseDirectSql) { try { setResult(getSqlResult(this)); } catch (Exception ex) { handleDirectSqlError(ex); } } if (!doUseDirectSql) { setResult(getJdoResult(this)); } return commit(); } catch (NoSuchObjectException ex) { throw ex; } catch (MetaException ex) { throw ex; } catch (Exception ex) { LOG.error("", ex); throw new MetaException(ex.getMessage()); } finally { close(); } }
@Override protected Integer getJdoResult( GetHelper<Integer> ctx) throws MetaException, NoSuchObjectException { Integer numPartitions = null; if (exprTree != null) { try { numPartitions = getNumPartitionsViaOrmFilter(ctx.getTable(), exprTree, true); } catch (MetaException e) { numPartitions = null; } } // if numPartitions could not be obtained from ORM filters, then get number partitions names, and count them if (numPartitions == null) { List<String> filteredPartNames = new ArrayList<>(); getPartitionNamesPrunedByExprNoTxn(ctx.getTable(), tempExpr, "", (short) -1, filteredPartNames); numPartitions = filteredPartNames.size(); } return numPartitions; } }.run(true);
@Override protected List<Partition> getJdoResult( GetHelper<List<Partition>> ctx) throws MetaException, NoSuchObjectException { // If we have some sort of expression tree, try JDOQL filter pushdown. List<Partition> result = null; if (exprTree != null) { result = getPartitionsViaOrmFilter(ctx.getTable(), exprTree, maxParts, false); } if (result == null) { // We couldn't do JDOQL filter pushdown. Get names via normal means. List<String> partNames = new ArrayList<String>(); hasUnknownPartitions.set(getPartitionNamesPrunedByExprNoTxn( ctx.getTable(), expr, defaultPartitionName, maxParts, partNames)); result = getPartitionsViaOrmFilter(dbName, tblName, partNames); } return result; } }.run(true));
@Override protected List<Partition> getJdoResult( GetHelper<List<Partition>> ctx) throws MetaException, NoSuchObjectException { // If we have some sort of expression tree, try JDOQL filter pushdown. List<Partition> result = null; if (exprTree != null) { result = getPartitionsViaOrmFilter(ctx.getTable(), exprTree, maxParts, false); } if (result == null) { // We couldn't do JDOQL filter pushdown. Get names via normal means. List<String> partNames = new ArrayList<>(); hasUnknownPartitions.set(getPartitionNamesPrunedByExprNoTxn( ctx.getTable(), expr, defaultPartitionName, maxParts, partNames)); result = getPartitionsViaOrmFilter(catName, dbName, tblName, partNames); } return result; } }.run(true));
@Override protected List<Partition> getSqlResult(GetHelper<List<Partition>> ctx) throws MetaException { // If we have some sort of expression tree, try SQL filter pushdown. List<Partition> result = null; if (exprTree != null) { result = directSql.getPartitionsViaSqlFilter(ctx.getTable(), exprTree, null); } if (result == null) { // We couldn't do SQL filter pushdown. Get names via normal means. List<String> partNames = new LinkedList<String>(); hasUnknownPartitions.set(getPartitionNamesPrunedByExprNoTxn( ctx.getTable(), expr, defaultPartitionName, maxParts, partNames)); result = directSql.getPartitionsViaSqlFilter(dbName, tblName, partNames); } return result; } @Override
@Override protected List<Partition> getSqlResult(GetHelper<List<Partition>> ctx) throws MetaException { // If we have some sort of expression tree, try SQL filter pushdown. List<Partition> result = null; if (exprTree != null) { result = directSql.getPartitionsViaSqlFilter(ctx.getTable(), exprTree, null); } if (result == null) { // We couldn't do SQL filter pushdown. Get names via normal means. List<String> partNames = new LinkedList<String>(); hasUnknownPartitions.set(getPartitionNamesPrunedByExprNoTxn( ctx.getTable(), expr, defaultPartitionName, maxParts, partNames)); result = directSql.getPartitionsViaSqlFilter(dbName, tblName, partNames); } return result; } @Override
@Override protected List<Partition> getJdoResult( GetHelper<List<Partition>> ctx) throws MetaException, NoSuchObjectException { // If we have some sort of expression tree, try JDOQL filter pushdown. List<Partition> result = null; if (exprTree != null) { result = getPartitionsViaOrmFilter(ctx.getTable(), exprTree, maxParts, false); } if (result == null) { // We couldn't do JDOQL filter pushdown. Get names via normal means. List<String> partNames = new ArrayList<String>(); hasUnknownPartitions.set(getPartitionNamesPrunedByExprNoTxn( ctx.getTable(), expr, defaultPartitionName, maxParts, partNames)); result = getPartitionsViaOrmFilter(dbName, tblName, partNames); } return result; } }.run(true));
@Override protected List<Partition> getSqlResult(GetHelper<List<Partition>> ctx) throws MetaException { // If we have some sort of expression tree, try SQL filter pushdown. List<Partition> result = null; if (exprTree != null) { SqlFilterForPushdown filter = new SqlFilterForPushdown(); if (directSql.generateSqlFilterForPushdown(ctx.getTable(), exprTree, filter)) { return directSql.getPartitionsViaSqlFilter(filter, null); } } // We couldn't do SQL filter pushdown. Get names via normal means. List<String> partNames = new LinkedList<>(); hasUnknownPartitions.set(getPartitionNamesPrunedByExprNoTxn( ctx.getTable(), expr, defaultPartitionName, maxParts, partNames)); return directSql.getPartitionsViaSqlFilter(catName, dbName, tblName, partNames); }
@Override protected boolean canUseDirectSql(GetHelper<List<Partition>> ctx) throws MetaException { return directSql.generateSqlFilterForPushdown(ctx.getTable(), tree, filter); }
@Override protected boolean canUseDirectSql(GetHelper<Integer> ctx) throws MetaException { return directSql.generateSqlFilterForPushdown(ctx.getTable(), exprTree, filter); }
@Override protected boolean canUseDirectSql(GetHelper<Integer> ctx) throws MetaException { return directSql.generateSqlFilterForPushdown(ctx.getTable(), exprTree, filter); }
@Override protected List<Partition> getJdoResult( GetHelper<List<Partition>> ctx) throws MetaException, NoSuchObjectException { return getPartitionsViaOrmFilter(ctx.getTable(), tree, maxParts, true); } }.run(true);
@Override protected Integer getJdoResult( GetHelper<Integer> ctx) throws MetaException, NoSuchObjectException { return getNumPartitionsViaOrmFilter(ctx.getTable(), exprTree, true); } }.run(true);
@Override protected List<Partition> getJdoResult( GetHelper<List<Partition>> ctx) throws MetaException, NoSuchObjectException { return getPartitionsViaOrmFilter(ctx.getTable(), tree, maxParts, true); } }.run(true);
private T commit() { success = commitTransaction(); if (doTrace) { LOG.debug(describeResult() + " retrieved using " + (doUseDirectSql ? "SQL" : "ORM") + " in " + ((System.nanoTime() - start) / 1000000.0) + "ms"); } return results; }