Search in sources :

Example 1 with FieldStat

use of datawave.webservice.query.result.istat.FieldStat in project datawave by NationalSecurityAgency.

the class IndexStatsQueryLogic method setupQuery.

@Override
public void setupQuery(GenericQueryConfiguration config) throws Exception {
    ShardQueryConfiguration qConf = (ShardQueryConfiguration) config;
    HashSet<String> fields = new HashSet<>();
    Collections.addAll(fields, config.getQueryString().split(" "));
    StatsMonkey monkey = new StatsMonkey();
    monkey.con = connector;
    monkey.table = TableName.INDEX_STATS;
    List<FieldStat> stats = monkey.getStat(fields, qConf.getDatatypeFilter(), qConf.getBeginDate(), qConf.getEndDate());
    this.iterator = stats.iterator();
}
Also used : FieldStat(datawave.webservice.query.result.istat.FieldStat) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) HashSet(java.util.HashSet)

Example 2 with FieldStat

use of datawave.webservice.query.result.istat.FieldStat in project datawave by NationalSecurityAgency.

the class QueryWizardResultResponse method getMainContent.

@Override
public String getMainContent() {
    StringBuilder builder = new StringBuilder();
    builder.append("<br/><br/>");
    builder.append("<H2>Query ID : " + queryId + "</H2><br/><br/>");
    if (response == null || !response.getHasResults()) {
        builder.append("<H2>There aren't anymore results</H2>");
        return builder.toString();
    }
    builder.append("<div>\n");
    builder.append("<div id=\"myTable_wrapper\" class=\"dataTables_wrapper no-footer\">\n");
    builder.append("<table id=\"myTable\" class=\"dataTable no-footer\" role=\"grid\" aria-describedby=\"myTable_info\">\n");
    if (response instanceof DefaultEventQueryResponse) {
        DefaultEventQueryResponse tempResponse = (DefaultEventQueryResponse) response;
        HashSet<String> fieldnameSet = buildTableColumnHeadings(builder, tempResponse);
        HashMap<String, String> fieldNameToValueMap = new HashMap<>();
        builder.append("<tbody>");
        String dataType = "";
        for (EventBase event : tempResponse.getEvents()) {
            dataType = event.getMetadata().getDataType();
            builder.append("<tr>");
            putTableCell(builder, dataType);
            for (Object field : event.getFields()) {
                if (field instanceof DefaultField) {
                    DefaultField defaultField = (DefaultField) field;
                    fieldNameToValueMap.put(defaultField.getName(), defaultField.getValueString());
                }
            }
            for (String fieldStr : fieldnameSet) {
                String fieldValue = fieldNameToValueMap.get(fieldStr);
                if (fieldValue != null && fieldValue.length() > 255)
                    putTableCell(builder, fieldValue.substring(0, 254));
                else
                    putTableCell(builder, fieldValue == null ? "" : fieldValue);
            }
            fieldNameToValueMap.clear();
            builder.append("</tr>");
        }
    } else if (response instanceof DefaultEdgeQueryResponse) {
        DefaultEdgeQueryResponse tempResponse = (DefaultEdgeQueryResponse) response;
        builder.append("<thead><tr><th>Source</th><th>Sink</th><th>Edge Type</th><th>Activity Date</th><th>Edge Relationship</th></tr></thead>");
        builder.append("<tbody>");
        for (EdgeBase edge : tempResponse.getEdges()) {
            builder.append("<tr>");
            putTableCell(builder, edge.getSource());
            putTableCell(builder, edge.getSink());
            putTableCell(builder, edge.getEdgeType());
            putTableCell(builder, edge.getActivityDate());
            putTableCell(builder, edge.getEdgeRelationship());
            builder.append("</tr>");
        }
    } else if (response instanceof DefaultMetadataQueryResponse) {
        DefaultMetadataQueryResponse tempResponse = (DefaultMetadataQueryResponse) response;
        builder.append("<thead><tr><th>Field Name</th><th>Internal Field Name</th><th>Data Type</th><th>Last Updated</th><th>Index only</th></tr></thead>");
        builder.append("<tbody>");
        for (MetadataFieldBase field : tempResponse.getFields()) {
            builder.append("<tr>");
            putTableCell(builder, field.getFieldName());
            putTableCell(builder, field.getInternalFieldName());
            putTableCell(builder, field.getDataType());
            putTableCell(builder, field.getLastUpdated());
            putTableCell(builder, field.isIndexOnly().toString());
            builder.append("</tr>");
        }
    } else if (response instanceof IndexStatsResponse) {
        IndexStatsResponse tempResponse = (IndexStatsResponse) response;
        builder.append("<thead><tr><th>Field Name</th><th>Observed</th><th>Selectivity</th><th>Unique</th></tr></thead>");
        builder.append("<tbody>");
        for (FieldStat stat : tempResponse.getFieldStats()) {
            builder.append("<tr>");
            putTableCell(builder, stat.field);
            putTableCell(builder, String.valueOf(stat.observed));
            putTableCell(builder, String.valueOf(stat.selectivity));
            putTableCell(builder, String.valueOf(stat.unique));
        }
    }
    builder.append("</tbody>");
    builder.append("</table><br/><br/>");
    builder.append("  <div class=\"dataTables_info\" id=\"myTable_info\" role=\"status\" aria-live=\"polite\"></div>\n");
    builder.append("</div>\n");
    builder.append("</div>");
    builder.append("<FORM id=\"queryform\" action=\"/DataWave/BasicQuery/" + queryId + "/showQueryWizardResults\"  method=\"get\" target=\"_self\" enctype=\"application/x-www-form-urlencoded\">");
    builder.append("<center><input type=\"submit\" value=\"Next\" align=\"left\" width=\"50\" /></center>");
    builder.append("</FORM>");
    return builder.toString();
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) HashMap(java.util.HashMap) FieldStat(datawave.webservice.query.result.istat.FieldStat) DefaultField(datawave.webservice.query.result.event.DefaultField) EdgeBase(datawave.webservice.query.result.edge.EdgeBase) MetadataFieldBase(datawave.webservice.query.result.metadata.MetadataFieldBase) IndexStatsResponse(datawave.webservice.query.result.istat.IndexStatsResponse)

Aggregations

FieldStat (datawave.webservice.query.result.istat.FieldStat)2 ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)1 EdgeBase (datawave.webservice.query.result.edge.EdgeBase)1 DefaultField (datawave.webservice.query.result.event.DefaultField)1 EventBase (datawave.webservice.query.result.event.EventBase)1 IndexStatsResponse (datawave.webservice.query.result.istat.IndexStatsResponse)1 MetadataFieldBase (datawave.webservice.query.result.metadata.MetadataFieldBase)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1