use of org.talend.dataquality.common.inference.ValueQualityStatistics in project data-prep by Talend.
the class StatisticsAdapter method injectValueQuality.
private void injectValueQuality(final ColumnMetadata column, final Analyzers.Result result) {
if (result.exist(ValueQualityStatistics.class)) {
final Statistics statistics = column.getStatistics();
final Quality quality = column.getQuality();
final ValueQualityStatistics valueQualityStatistics = result.get(ValueQualityStatistics.class);
final long allCount = valueQualityStatistics.getCount();
final long emptyCount = valueQualityStatistics.getEmptyCount();
final long validCount = valueQualityStatistics.getValidCount();
final long invalidCount = allCount - emptyCount - validCount;
// Set in column quality...
quality.setEmpty((int) emptyCount);
quality.setValid((int) validCount);
quality.setInvalid((int) invalidCount);
// ... and statistics
statistics.setCount(allCount);
statistics.setEmpty((int) emptyCount);
statistics.setInvalid((int) invalidCount);
statistics.setValid(validCount);
}
}
use of org.talend.dataquality.common.inference.ValueQualityStatistics in project data-prep by Talend.
the class BackgroundAnalysis method updateNbRecords.
/**
* Update the number of records for the dataset.
*
* @param metadata the dataset metadata to update.
* @param results the
*/
private void updateNbRecords(DataSetMetadata metadata, List<Analyzers.Result> results) {
// defensive programming
if (results.isEmpty()) {
return;
}
// get the analyzer of the first column
final Analyzers.Result result = results.get(0);
if (result.exist(ValueQualityStatistics.class)) {
final ValueQualityStatistics valueQualityStatistics = result.get(ValueQualityStatistics.class);
metadata.getContent().setNbRecords(valueQualityStatistics.getCount());
}
LOGGER.debug("nb records for {} is updated to {}", metadata.getId(), metadata.getContent().getNbRecords());
}
use of org.talend.dataquality.common.inference.ValueQualityStatistics in project data-prep by Talend.
the class StatisticsUtilsTest method adaptColumn.
private void adaptColumn(final ColumnMetadata column, final DataTypeEnum type) {
Analyzers.Result result = new Analyzers.Result();
// Data type
DataTypeOccurences dataType = new DataTypeOccurences();
dataType.increment(type);
result.add(dataType);
// Semantic type
SemanticType semanticType = new SemanticType();
CategoryFrequency category1 = new CategoryFrequency("category 1", "category 1");
category1.setScore(99);
semanticType.increment(category1, 1);
result.add(semanticType);
// Suggested types
CategoryFrequency category2 = new CategoryFrequency("category 2", "category 2");
category2.setScore(81);
semanticType.increment(category2, 1);
CategoryFrequency category3 = new CategoryFrequency("category 3", "category 3");
category3.setScore(50);
semanticType.increment(category3, 1);
// Value quality
ValueQualityStatistics valueQualityStatistics = new ValueQualityStatistics();
valueQualityStatistics.setEmptyCount(10);
valueQualityStatistics.setInvalidCount(20);
valueQualityStatistics.setValidCount(30);
result.add(valueQualityStatistics);
// Cardinality
CardinalityStatistics cardinalityStatistics = new CardinalityStatistics();
cardinalityStatistics.incrementCount();
cardinalityStatistics.add("distinctValue");
result.add(cardinalityStatistics);
// Data frequency
DataTypeFrequencyStatistics dataFrequencyStatistics = new DataTypeFrequencyStatistics();
dataFrequencyStatistics.add("frequentValue1");
dataFrequencyStatistics.add("frequentValue1");
dataFrequencyStatistics.add("frequentValue2");
dataFrequencyStatistics.add("frequentValue2");
result.add(dataFrequencyStatistics);
// Pattern frequency
PatternFrequencyStatistics patternFrequencyStatistics = new PatternFrequencyStatistics();
patternFrequencyStatistics.add("999a999");
patternFrequencyStatistics.add("999a999");
patternFrequencyStatistics.add("999aaaa");
patternFrequencyStatistics.add("999aaaa");
result.add(patternFrequencyStatistics);
// Quantiles
QuantileStatistics quantileStatistics = new QuantileStatistics();
quantileStatistics.add(1d);
quantileStatistics.add(2d);
quantileStatistics.endAddValue();
result.add(quantileStatistics);
// Summary
SummaryStatistics summaryStatistics = new SummaryStatistics();
summaryStatistics.addData(1d);
summaryStatistics.addData(2d);
result.add(summaryStatistics);
// Histogram
StreamNumberHistogramStatistics histogramStatistics = new StreamNumberHistogramStatistics();
histogramStatistics.setNumberOfBins(2);
histogramStatistics.add(1);
histogramStatistics.add(2);
result.add(histogramStatistics);
// Text length
TextLengthStatistics textLengthStatistics = new TextLengthStatistics();
textLengthStatistics.setMaxTextLength(30);
textLengthStatistics.setMinTextLength(10);
textLengthStatistics.setSumTextLength(40);
textLengthStatistics.setCount(5);
result.add(textLengthStatistics);
StatisticsAdapter adapter = new StatisticsAdapter(40);
adapter.adapt(Collections.singletonList(integerColumn), Collections.singletonList(result));
adapter.adapt(Collections.singletonList(stringColumn), Collections.singletonList(result));
}
Aggregations