protected boolean isStoredInValue(final String propertyName, final SchemaElementDefinition elementDef) { return !elementDef.getGroupBy().contains(propertyName) && !propertyName.equals(schema.getVisibilityProperty()) && !propertyName.equals(timestampProperty); }
private void addToGroupByMap(final String group) { final SchemaElementDefinition sed = schema.getElement(group); groupToGroupByProperties.put(group, sed.getGroupBy()); if (!aggregatedGroups.contains(group)) { groupsWithNoAggregation.add(group); } final Set<String> nonGroupByProperties = new HashSet<>(sed.getProperties()); nonGroupByProperties.removeAll(sed.getGroupBy()); groupToNonGroupByProperties.put(group, nonGroupByProperties); } }
@Override public byte[] buildColumnQualifier(final String group, final Properties properties) { final ByteArrayOutputStream stream = new ByteArrayOutputStream(); final SchemaElementDefinition elementDefinition = getSchemaElementDefinition(group); for (final String groupByPropertyName : elementDefinition.getGroupBy()) { serialiseSizeAndPropertyValue(groupByPropertyName, elementDefinition, properties, stream); } return stream.toByteArray(); }
@Override public Properties getPropertiesFromColumnQualifier(final String group, final byte[] bytes) { final Properties properties = new Properties(); if (null != bytes && bytes.length != 0) { int delimiterPosition = 0; final int arrayLength = bytes.length; final SchemaElementDefinition elementDefinition = getSchemaElementDefinition(group); final Iterator<String> propertyNames = elementDefinition.getGroupBy().iterator(); while (propertyNames.hasNext() && delimiterPosition < arrayLength) { final String propertyName = propertyNames.next(); try { delimiterPosition = addDeserialisedProperty(bytes, delimiterPosition, properties, elementDefinition, propertyName); } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to deserialise property " + propertyName, e); } } } return properties; }
@Override public Tuple2<List<Object>, Element> call(final Element element) throws Exception { if (null == gafferSchema) { gafferSchema = Schema.fromJson(jsonGafferSchema); } final String group = element.getGroup(); final List<Object> list = new ArrayList<>(); list.add(group); if (gafferSchema.getEntityGroups().contains(group)) { final Entity entity = (Entity) element; list.add(entity.getVertex()); } else { final Edge edge = (Edge) element; list.add(edge.getSource()); list.add(edge.getDestination()); list.add(edge.getDirectedType()); } for (final String property : gafferSchema.getElement(group).getGroupBy()) { list.add(element.getProperty(property)); } return new Tuple2<>(list, element); } }
/** * Constructs an iterator over {@link Value}s whose {@link Key}s are * versions of the current topKey of the source * {@link SortedKeyValueIterator}. * * @param source The {@link SortedKeyValueIterator} of {@link Key}, * {@link Value} pairs from which to read data. * @param group the element group * @param elementConverter the elementConverter to use * @param schema the schema * @param groupBy the groupBy properties */ public KeyValueIterator(final SortedKeyValueIterator<Key, Value> source, final String group, final AccumuloElementConverter elementConverter, final Schema schema, final Set<String> groupBy) { this.source = source; this.group = group; this.elementConverter = elementConverter; final Key unsafeRef = source.getTopKey(); topKey = new Key(unsafeRef.getRow().getBytes(), unsafeRef.getColumnFamily().getBytes(), unsafeRef.getColumnQualifier().getBytes(), unsafeRef.getColumnVisibility().getBytes(), unsafeRef.getTimestamp(), unsafeRef.isDeleted(), true); schemaGroupBy = schema.getElement(this.group).getGroupBy(); this.groupBy = groupBy; hasNext = _hasNext(); }
@Override public Object getProperty(final String name, final Properties lazyProperties) { if (null == eDef) { eDef = schema.getElement(group); if (null == eDef) { throw new IllegalArgumentException("Element definition for " + group + " could not be found in the schema"); } } final Properties props; if (eDef.getGroupBy().contains(name)) { props = elementConverter.getPropertiesFromColumnQualifier(group, key.getColumnQualifierData().getBackingArray()); } else if (name.equals(schema.getVisibilityProperty())) { props = elementConverter.getPropertiesFromColumnVisibility(group, key.getColumnVisibilityData().getBackingArray()); } else if (name.equals(timestampProperty)) { props = elementConverter.getPropertiesFromTimestamp(group, key.getTimestamp()); } else { props = elementConverter.getPropertiesFromValue(group, value); } lazyProperties.putAll(props); return props.get(name); } }
Set<String> groupBy = elementDef.getGroupBy(); if (null == groupBy) { groupBy = schema.getElement(group).getGroupBy();