/** * Make a DimensionRow by setting all of the field values to the given value. * * @param value Value for dimension fields * @return a DimensionRow */ private DimensionRow makeDimensionRow(String value) { LinkedHashMap<DimensionField, String> map = new LinkedHashMap<>(); for (DimensionField dimensionField: dimension.getDimensionFields()) { map.put(dimensionField, value); } return new DimensionRow(dimension.getKey(), map); }
return dimension.getDimensionFields().stream() .map(dimensionField -> dimensionFieldNameMapper.convert(dimension, dimensionField)) .allMatch(avroFields::contains);
/** * Transform an avro generic record into a set map of fields and values. * * @param genericRecord The avro record being read * @param dimension The dimension for the row being loaded * * @return A map of fields and values for a dimension row */ private Map<String, String> recordToMap(GenericRecord genericRecord, Dimension dimension) { return dimension.getDimensionFields() .stream() .collect( Collectors.toMap( DimensionField::getName, dimensionField -> resolveRecordValue( genericRecord, dimensionFieldNameMapper.convert(dimension, dimensionField) ) )); }
/** * Get the summary view of the dimension. * * @param dimension Dimension to get the view of * @param uriInfo UriInfo of the request * * @return Summary view of the dimension */ private static Map<String, Object> getDimensionSummaryViewWithFields(Dimension dimension, UriInfo uriInfo) { Map<String, Object> resultRow = new LinkedHashMap<>(); resultRow.put("category", dimension.getCategory()); resultRow.put("name", dimension.getApiName()); resultRow.put("longName", dimension.getLongName()); resultRow.put("uri", DimensionsServlet.getDimensionUrl(dimension, uriInfo)); resultRow.put("cardinality", dimension.getCardinality()); resultRow.put("fields", dimension.getDimensionFields()); resultRow.put("storageStrategy", dimension.getStorageStrategy()); return resultRow; } }
return dimension.getDimensionFields(); } else if (showFields.size() == 1 && showFields.contains(DimensionFieldSpecifierKeywords.NONE.toString())) {
Map<String, DimensionField> dimensionNameToFieldMap = dimension.getDimensionFields().stream() .collect(StreamUtils.toLinkedDictionary(DimensionField::getName));
Map<DimensionField, Field> dimFieldToLuceneField = new HashMap<>(dimension.getDimensionFields().size()); for (DimensionField dimensionField : dimension.getDimensionFields()) { Field luceneField = new StringField( DimensionStoreKeyUtils.getColumnKey(dimensionField.getName()),
resultRow.put("longName", dimension.getLongName()); resultRow.put("description", dimension.getDescription()); resultRow.put("fields", dimension.getDimensionFields()); resultRow.put("values", getDimensionValuesUrl(dimension, uriInfo)); resultRow.put("cardinality", dimension.getCardinality());
} else { for (DimensionField field : dimension.getDimensionFields()) {
/** * Make test DimensionRow using ID and DESC fields from provided Dimension. * * @param dimension provided dimension * @param values Values for dimension fields * * @return test DimensionRow */ public static DimensionRow makeDimensionRow(Dimension dimension, String...values) { LinkedHashMap<DimensionField, String> map = new LinkedHashMap<>(values.length); Iterator<DimensionField> fields = dimension.getDimensionFields().iterator(); for (String value : values) { DimensionField field = fields.next(); map.put(field, value); } return new DimensionRow(dimension.getKey(), map); } }
/** * Make test DimensionRow using ID and DESC fields from provided Dimension. * * @param dimension provided dimension * @param values Values for dimension fields * * @return test DimensionRow */ public static DimensionRow makeDimensionRow(Dimension dimension, String...values) { LinkedHashMap<DimensionField, String> map = new LinkedHashMap<>(values.length); Iterator<DimensionField> fields = dimension.getDimensionFields().iterator(); for (String value : values) { DimensionField field = fields.next(); map.put(field, value); } return new DimensionRow(dimension.getKey(), map); } }
try { for (DimensionField field : dimension.getDimensionFields()) {
/** * Update the dimension row in the index. * * @param luceneDimensionRowDoc Document to use for doing the update * @param fieldMap Mapping of DimensionFields to the Document's fields * @param writer Lucene IndexWriter to update the indexes of * @param newRow Row to update * * @throws IOException if there is a problem updating the document */ private void updateDimensionRow( Document luceneDimensionRowDoc, Map<DimensionField, Field> fieldMap, IndexWriter writer, DimensionRow newRow ) throws IOException { // Update the document fields with each field from the new dimension row for (DimensionField field : dimension.getDimensionFields()) { // Get the field to update from the lookup map Field fieldToUpdate = fieldMap.get(field); // Set field value to updated value fieldToUpdate.setStringValue(newRow.getOrDefault(field, "")); } // Build the term to delete the old document by the key value (which should be unique) Term keyTerm = new Term(fieldMap.get(dimension.getKey()).name(), newRow.getOrDefault(dimension.getKey(), "")); // Update the document by the key term writer.updateDocument(keyTerm, luceneDimensionRowDoc); }