if (!labelCounter.containsKey(label)) {
labelCounter.put(label, labelIndex.get(label));
}
labelIndex.get(label).inc();
} else {
labelIndex.put(label, new Counter());
}
}
// Reset the counter for labels that occur more than once
Iterator<Counter> elements = labelCounter.values().iterator();
while (elements.hasNext()) {
elements.next().reset(1);
}
try {
_resultSchema = new GroupSchemaNode(-1, "result", null, new TimeSequence(1));
for (SubTreeSelectStatement stmt : _statements) {
SchemaNode schema = stmt.targetPath().lastElement().entity();
String label = null;
if (stmt.label() != null) {
label = stmt.label();
} else {
label = schema.label();
}
if (labelCounter.containsKey(label)) {
Counter counter = labelCounter.get(label);
label = label + Integer.toString(counter.value());
stmt.setLabel(label);
counter.inc();
}
SchemaNode renamedSchema = null;
if (schema.isAttribute()) {
renamedSchema = new AttributeSchemaNode(-1, label, _resultSchema, schema.getTimestamp());
//renamedSchema = new AttributeSchemaNode(schema.id(), label, _resultSchema, schema.getTimestamp());