public Element shallowClone() { final Element element = emptyClone(); element.setProperties(getProperties().clone()); return element; }
Stream<Element> getAllAggElements(final Set<String> groups) { return aggElements.entrySet().stream() .filter(entry -> groups.contains(entry.getKey())) .map(Map.Entry::getValue) .flatMap(map -> map.entrySet().stream()) .map(x -> { final Element element = x.getKey().emptyClone(); element.copyProperties(x.getKey().getProperties()); element.copyProperties(x.getValue()); return cloneElement(element, schema); }); }
Element getAggElement(final Element element) { final Element clone = element.emptyClone(); clone.copyProperties(element.getProperties()); clone.copyProperties(aggElements.get(element.getGroup()).get(element)); return clone; }
@Override public Element next() { final double prob = random.nextDouble(); if (prob < repeatProb) { final Element element = cache.get(); return element == null ? elementIterator.next() : element; } final Element element = elementIterator.next(); final Element clonedElement = element.emptyClone(); clonedElement.copyProperties(element.getProperties()); cache.add(clonedElement); return element; } }
public Element shallowClone() { final Element element = emptyClone(); element.setProperties(getProperties().clone()); return element; }
private Element addNonAggElement(final Element element, final Schema schema, final MapImpl mapImpl) { final Element elementClone = element.emptyClone(); // Copy properties that exist in the schema final SchemaElementDefinition elementDef = schema.getElement(element.getGroup()); for (final String property : elementDef.getProperties()) { elementClone.putProperty(property, element.getProperty(property)); } mapImpl.addNonAggElement(elementClone); return elementClone; }
private Element addAggElement(final Element element, final Schema schema, final MapImpl mapImpl) { final String group = element.getGroup(); final Element elementWithGroupByProperties = element.emptyClone(); final GroupedProperties properties = new GroupedProperties(element.getGroup()); for (final String propertyName : mapImpl.getGroupByProperties(group)) { elementWithGroupByProperties.putProperty(propertyName, element.getProperty(propertyName)); } for (final String propertyName : mapImpl.getNonGroupByProperties(group)) { properties.put(propertyName, element.getProperty(propertyName)); } mapImpl.addAggElement(elementWithGroupByProperties, properties); return elementWithGroupByProperties; }
/** * Clone an {@link Element}, based on a target {@link Schema}. * * @param element the element to clone * @param schema the schema * @return the cloned element */ public Element cloneElement(final Element element, final Schema schema) { try { final Element clone = element.emptyClone(); final SchemaElementDefinition sed = schema.getElement(clone.getGroup()); for (final String propertyName : element.getProperties().keySet()) { final Object property = element.getProperty(propertyName); if (null == sed.getPropertyTypeDef(propertyName) || null == sed.getPropertyTypeDef(propertyName).getSerialiser()) { // This can happen if transient properties are derived - they will not have serialisers. LOGGER.warn("Can't find Serialisation for {}, returning uncloned property", propertyName); clone.putProperty(propertyName, property); } else if (null != property) { final Serialiser serialiser = sed.getPropertyTypeDef(propertyName).getSerialiser(); clone.putProperty(propertyName, serialiser.deserialise(serialiser.serialise(property))); } else { clone.putProperty(propertyName, null); } } return clone; } catch (final SerialisationException e) { throw new RuntimeException("SerialisationException converting elements", e); } } }