@Override public byte[] createColumnKey(PlasmaDataObject dataObject, PlasmaProperty property) { PlasmaType type = (PlasmaType) dataObject.getType(); Integer seqNum = this.graphState.findSequence(dataObject); if (seqNum == null) seqNum = this.graphState.addSequence(dataObject); return getKey(type, seqNum, property); }
/** * Assembles a data object of the given target type by first forming a query using the given * key/property pairs. If an existing data object is mapped for the given key pairs, the existing * data object is linked. * * @param targetType the type for the data object to be assembled * @param source the source data object * @param sourceProperty the source property * @param childKeyPairs the key pairs for the data object to be assembled */ protected void assemble( PlasmaType targetType, PlasmaDataObject source, PlasmaProperty sourceProperty, List<PropertyPair> childKeyPairs, int level) { Set<Property> props = this.collector.getProperties(targetType, level); if (props == null) props = EMPTY_PROPERTY_SET; if (log.isDebugEnabled()) log.debug( String.valueOf(level) + ":assemble: " + source.getType().getName() + "." + sourceProperty.getName() + "->" + targetType.getName() + ": " + props); List<List<PropertyPair>> result = this.getPredicateResult(targetType, sourceProperty, props, childKeyPairs); if (log.isDebugEnabled()) log.debug(String.valueOf(level) + ":results: " + result.size()); Map<PlasmaDataObject, List<PropertyPair>> resultMap = this.collectResults(targetType, source, sourceProperty, result); // now traverse Iterator<PlasmaDataObject> iter = resultMap.keySet().iterator(); while (iter.hasNext()) { PlasmaDataObject target = iter.next(); List<PropertyPair> row = resultMap.get(target); // traverse singular results props for (PropertyPair pair : row) { if (pair.getProp().isMany() || pair.getProp().getType().isDataType()) continue; // only singular reference props if (!pair.isQueryProperty()) continue; // property is a key or other property not explicitly cited in the source query, // don't traverse it List<PropertyPair> nextKeyPairs = this.getNextKeyPairs(target, pair, level); if (log.isDebugEnabled()) log.debug( String.valueOf(level) + ":traverse: (" + pair.getProp().isMany() + ") " + pair.getProp().toString() + ":" + String.valueOf(pair.getValue())); assemble( (PlasmaType) pair.getProp().getType(), target, pair.getProp(), nextKeyPairs, level + 1); } // traverse multi props based, not on the results // row, but on keys within this data object for (Property p : props) { PlasmaProperty prop = (PlasmaProperty) p; if (!prop.isMany() || prop.getType().isDataType()) continue; // only many reference props List<PropertyPair> childKeyProps = this.getChildKeyProps(target, targetType, prop); if (log.isDebugEnabled()) log.debug( String.valueOf(level) + ":traverse: (" + prop.isMany() + ") " + prop.toString() + " - " + childKeyProps.toArray().toString()); assemble((PlasmaType) prop.getType(), target, prop, childKeyProps, level + 1); } } }