com.google.api.gbase.client.AttributeHistogram

Here are the examples of the java api class com.google.api.gbase.client.AttributeHistogram taken from open source projects.

1. MetadataExample#printMetadataEntry()

View license
/**
   * Prints a few relevant attributes and the values of the attribute histogram 
   * of a metadata GoogleBaseEntry item.
   * 
   * @param entry a Google Base data API metadata entry
   */
private static void printMetadataEntry(GoogleBaseEntry entry) {
    MetadataEntryExtension metadata = entry.getGoogleBaseMetadata();
    AttributeHistogram attributeHistogram = metadata.getAttributeHistogram();
    System.out.println(attributeHistogram.getAttributeName() + " (" + attributeHistogram.getAttributeType().getName() + "): " + "valueCount=" + attributeHistogram.getTotalValueCount() + " - " + entry.getId());
    for (UniqueValue value : attributeHistogram.getValues()) {
        System.out.println(value.getValueAsString() + " count=" + value.getCount());
    }
}

2. MostUsedValues#extractValuesFromEntry()

View license
/**
   * Caches a limited number of the values of a GoogleBaseEntry.
   * 
   * @param numValue maximum number of values to cache
   * @param attrName the name of the attribute that has the values
   * @param entry an entry with a MetadataEntryExtension
   */
private void extractValuesFromEntry(int numValue, String attrName, GoogleBaseEntry entry) {
    MetadataEntryExtension metadata = entry.getGoogleBaseMetadata();
    AttributeHistogram attributeHistogram = metadata.getAttributeHistogram();
    List<? extends UniqueValue> values = attributeHistogram.getValues();
    int valuesCount = Math.min(numValue, values.size());
    String[] usedValues = new String[valuesCount];
    for (int i = 0; i < valuesCount; i++) {
        usedValues[i] = values.get(i).getValueAsString();
    }
    updateMostUsedValue(attrName, usedValues);
}