Package org.jboss.dashboard.profiler

Examples of org.jboss.dashboard.profiler.CodeBlockTrace


        return Number.class.isAssignableFrom(type);
    }

    public double scalar(Collection values) {
        double ret;
        CodeBlockTrace trace = new ScalarFunctionTrace(CODE, values).begin();
        try {
            if (values == null || values.isEmpty()) return 0;

            // Get the max. value from the collection.
            Number min = null;
            Iterator it = values.iterator();
            while (it.hasNext()) {
                Number n = (Number) it.next();
                if (n == null) continue;
                if (min == null || n.doubleValue() < min.doubleValue()) min = n;
            }
            // Adjust to the specified precision.
            if (min == null) return 0;
            ret = round(min.doubleValue(), precission);
        } finally {
            trace.end();
        }
        return ret;
    }
View Full Code Here


        return Number.class.isAssignableFrom(type);
    }

    public double scalar(Collection values) {
        double ret;
        CodeBlockTrace trace = new ScalarFunctionTrace(CODE, values).begin();
        try {
            if (values == null || values.isEmpty()) return 0;

            // Sum the collection.
            double sum = 0;
            Iterator it = values.iterator();
            while (it.hasNext()) {
                Number n = (Number) it.next();
                if (n == null) continue;
                sum += n.doubleValue();
            }
            ret = round(sum, precission);
        } finally {
            trace.end();
        }
        // Adjust to the specified precision.
        return ret;
    }
View Full Code Here

    public boolean isTypeSupported(Class type) {
        return true;
    }

    public double scalar(Collection values) {
        CodeBlockTrace trace = new ScalarFunctionTrace(CODE, values).begin();
        try {
            if (values == null || values.isEmpty()) return 0;
            return values.size();
        } finally {
            trace.end();
        }
    }
View Full Code Here

        return Number.class.isAssignableFrom(type);
    }

    public double scalar(Collection values) {
        double ret;
        CodeBlockTrace trace = new ScalarFunctionTrace(CODE, values).begin();
        try {
            if (values == null || values.isEmpty()) return 0;

            // Get the max. value from the collection.
            Number max = null;
            Iterator it = values.iterator();
            while (it.hasNext()) {
                Number n = (Number) it.next();
                if (n == null) continue;
                if (max == null || n.doubleValue() > max.doubleValue()) max = n;
            }
            // Adjust to the specified precission.
            if (max == null) return 0;
            ret = round(max.doubleValue(), precission);
        } finally {
            trace.end();
        }
        return ret;
    }
View Full Code Here

    public boolean isTypeSupported(Class type) {
        return true;
    }

    public double scalar(Collection values) {
        CodeBlockTrace trace = new AbstractFunction.ScalarFunctionTrace(CODE, values).begin();
        try {
            if (values == null || values.isEmpty()) return 0;

            // Return the number of distinct items in the collection.
            Set distincts = new HashSet();
            Iterator it = values.iterator();
            while (it.hasNext()) {
                Object o = it.next();
                if (distincts.contains(o)) continue;
                distincts.add(o);
            }
            return distincts.size();
        } finally {
            trace.end();
        }
    }
View Full Code Here

    public DataSet buildXYDataSet() {
        DataSet targetDataSet = null;
        DataProperty domainProperty = getDomainProperty();
        DataProperty rangeProperty = getRangeProperty();
        ScalarFunction scalarFunction = getRangeScalarFunction();
        CodeBlockTrace trace = new BuildXYDataSetTrace(domainProperty, rangeProperty, scalarFunction).begin();
        try {
            if (domainProperty == null || domainProperty.getDomain() == null) return null;
            if (rangeProperty == null || scalarFunction == null) return null;

            // Group the original data set by the domain property. Thus the scalar function is applied to the range values.
            DataSet sourceDataSet = domainProperty.getDataSet();
            List<DataProperty> targetDataProps = Arrays.asList(new DataProperty[]{domainProperty, rangeProperty});
            List<String> targetFunctionCodes = Arrays.asList(new String[]{CountFunction.CODE, scalarFunction.getCode()});
            targetDataSet = sourceDataSet.groupBy(domainProperty, targetDataProps, targetFunctionCodes);

            // Sort the resulting data set according to the sort policy specified.
            if (intervalsSortOrder != INTERVALS_SORT_ORDER_NONE) {
                DataSetComparator comp = new DataSetComparator();
                comp.addSortCriteria(Integer.toString(intervalsSortCriteria), intervalsSortOrder);
                targetDataSet.sort(comp);
            }
        } finally {
            trace.end();
        }
        return targetDataSet;
    }
View Full Code Here

    public DataSet buildXYDataSet() {
        DataProperty domainProperty = getDomainProperty();
        DataProperty rangeProperty = getRangeProperty();
        ScalarFunction scalarFunction = getRangeScalarFunction();
        DataSet sourceDataSet = domainProperty.getDataSet();
        CodeBlockTrace trace = new BuildXYDataSetTrace(domainProperty, rangeProperty, scalarFunction).begin();
        try {
            if (domainProperty == null || domainProperty.getDomain() == null) return null;
            if (rangeProperty == null || scalarFunction == null) return null;

            // Group the original data set by the domain property.
            int pivot = sourceDataSet.getPropertyColumn(domainProperty);
            int range = sourceDataSet.getPropertyColumn(rangeProperty);
            int[] columns = new int[] {pivot, range};
            String[] functionCodes = new String[] {CountFunction.CODE, scalarFunction.getCode()};
            return sourceDataSet.groupBy(domainProperty, columns, functionCodes, intervalsSortCriteria, intervalsSortOrder);
        } finally {
            trace.end();
        }
    }
View Full Code Here

        if (targetDS == null) return;

        Connection conn = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        CodeBlockTrace trace = null;
        try {
            // Get the connection.
            conn = targetDS.getConnection();

            // Execute the query.
            lastExecutedStmt = createSQLStatament();
            trace = new SQLStatementTrace(lastExecutedStmt.getSQLSentence()).begin();
            trace.addRuntimeConstraint(new DataSetLoadConstraints(this));

            log.debug("Load data set from datasource=" + dataSource + " SQL=" + lastExecutedStmt.getSQLSentence());
            stmt = lastExecutedStmt.getPreparedStatement(conn);
            rs = stmt.executeQuery();

            // Get the properties definition.
            ResultSetMetaData meta = rs.getMetaData();
            int propsSize = meta.getColumnCount();
            SQLDataSet.this.setPropertySize(propsSize);
            for (int i = 0; i < propsSize; i++) {
                SQLDataProperty dp = createSQLProperty();
                String propId = StringUtils.isNotBlank(meta.getColumnLabel(i + 1)) ? meta.getColumnLabel(i + 1) : meta.getColumnName(i + 1);
                dp.setPropertyId(propId.toLowerCase());
//                dp.setPropertyId(meta.getColumnName(i + 1).toLowerCase());
                dp.setType(meta.getColumnType(i + 1));
                dp.setTableName(meta.getTableName(i + 1));
                dp.setColumnName(meta.getColumnName(i + 1));
                addProperty(dp, i);
            }

            // Get rows and populate the data set values.
            int index = 0;
            while (rs.next()) {
                Object[] row = new Object[propsSize];
                for (int i = 0; i < propsSize; i++) row[i] = rs.getObject(i + 1);
                SQLDataSet.this.addRowValues(row);

                // Check load constraints (every 10,000 rows)
                if (++index == 10000) {
                    trace.checkRuntimeConstraints();
                    index = 0;
                }
            }

            // Once we got the dataset initialized then calculate the domain for each property.
            for (int i = 0; i < properties.length; i++) {
                SQLDataProperty property = (SQLDataProperty) properties[i];
                property.calculateDomain();
            }
        }
        catch (Exception e) {
            if (lastExecutedStmt != null) {
                log.error("Error in load() SQLDataset. SQL = " + lastExecutedStmt.getSQLSentence(), e);
            }
            throw e;
        }
        finally {
            try {
                if (rs != null) rs.close();
            } catch (Exception e) {
                log.warn("Error closing ResultSet: ", e);
            }
            try {
                if (stmt != null) stmt.close();
            } catch (Exception e) {
                log.warn("Error closing PreparedStatement: ", e);
            }
            if (conn != null) {
                conn.close();
            }
            if (conn != null) {
                trace.end();
            }
        }
    }
View Full Code Here

    public void setFlush(Boolean flush) {
        this.flush = flush;
    }

    public int doStartTag() throws JspException {
        CodeBlockTrace trace = new JSPIncludeTrace(page).begin();
        try {
            pageContext.include(page);
        } catch (Throwable t) {
            handleError(t);
        } finally {
            trace.end();
        }
        return SKIP_BODY;
    }
View Full Code Here

        return true;
    }

    public double scalar(Collection values) {
        double ret;
        CodeBlockTrace trace = new ScalarFunctionTrace(CODE, values).begin();
        try {
            if (values == null || values.isEmpty()) return 0;
            if (!discardDuplicates) return values.size();

            // Return the number of distinct items in the collection.
            Set distincts = new HashSet();
            Iterator it = values.iterator();
            while (it.hasNext()) {
                Object o = it.next();
                if (distincts.contains(o)) continue;
                distincts.add(o);
            }
            ret = distincts.size();
        } finally {
            trace.end();
        }
        return ret;
    }
View Full Code Here

TOP

Related Classes of org.jboss.dashboard.profiler.CodeBlockTrace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.