private boolean addBindingNames(StringBuilder builder, boolean alreadyMapping, Map<String, String> bindings, ProjectionElemList list, String name) { boolean mapping = alreadyMapping; if (variables.containsKey(name)) { String var = variables.get(name); builder.append(" ?").append(var); bindings.put(name, var); list.addElement(new ProjectionElem(var, name)); if (!name.equals(var)) { mapping = true; } } return mapping; }
private ParsedGraphQuery createGraphQuery(AugurStatementNode node) { TupleExpr tupleExpr = node.getTupleExpr(); String subjName = node.getSubjectName(); String predName = node.getPredicateName(); String objName = node.getObjectName(); String ctxName = node.getContextName(); ProjectionElem projSubj = new ProjectionElem(subjName, "subject"); ProjectionElem projPred = new ProjectionElem(predName, "predicate"); ProjectionElem projObj = new ProjectionElem(objName, "object"); ProjectionElem projCtx = new ProjectionElem(ctxName, "context"); ProjectionElemList projElemList = new ProjectionElemList(projSubj, projPred, projObj, projCtx); Projection proj = new Projection(tupleExpr, projElemList); ParsedGraphQuery query = new ParsedGraphQuery(proj); if (logger.isDebugEnabled()) { logger.debug(proj.toString()); } return query; }
private UnaryTupleOperator projection() { if (!mProjectionPatterns.isEmpty()) { return multiProjection(); } else { Extension aExt = null; ProjectionElemList aList = new ProjectionElemList(); for (String aVar : mProjectionVars) { aList.addElement(new ProjectionElem(aVar)); } Projection aProjection = new Projection(); aProjection.setProjectionElemList(aList); if (aExt != null) { aProjection.setArg(aExt); } return aProjection; } }
sb.append(" ?").append(var); bindings.put(name, var); list.addElement(new ProjectionElem(var, name)); if (!name.equals(var)) { mapping = true;
@Override public TupleExpr visit(ASTDescribe node, Object data) throws VisitorException { TupleExpr tupleExpr = (TupleExpr)data; if (tupleExpr == null) { tupleExpr = new SingletonSet(); } Extension e = new Extension(); ProjectionElemList projectionElements = new ProjectionElemList(); for (int i = 0; i < node.jjtGetNumChildren(); i++) { ValueExpr resource = (ValueExpr)node.jjtGetChild(i).jjtAccept(this, null); if (resource instanceof Var) { projectionElements.addElement(new ProjectionElem(((Var)resource).getName())); } else { String alias = "_describe_" + UUID.randomUUID().toString().replaceAll("-", "_"); ExtensionElem elem = new ExtensionElem(resource, alias); e.addElement(elem); projectionElements.addElement(new ProjectionElem(alias)); } } if (!e.getElements().isEmpty()) { e.setArg(tupleExpr); tupleExpr = e; } Projection p = new Projection(tupleExpr, projectionElements); return new DescribeOperator(p); }
extension = extensions.get(projection.getSourceName()); final ProjectionElem newProjection = new ProjectionElem(); newProjection.setTargetName(variable); newProjection.setSourceExpression(extension); for (final String variableName : group.getGroupBindingNames()) { final ExtensionElem extension = extensions.get(variableName); final ProjectionElem projection = new ProjectionElem(); projection.setTargetName(variableName); projection.setSourceExpression(extension);
ProjectionElemList projElemList = new ProjectionElemList(); projElemList.addElement(new ProjectionElem(sp.getSubjectVar().getName(), "subject")); projElemList.addElement(new ProjectionElem(sp.getPredicateVar().getName(), "predicate")); projElemList.addElement(new ProjectionElem(sp.getObjectVar().getName(), "object")); if (sp.getContextVar() != null) { projElemList.addElement(new ProjectionElem(sp.getContextVar().getName(), "context"));
ValueExpr val = toValue(expr, md); if (val instanceof Var){ projection.addElement(new ProjectionElem(((Var)val).getName())); }else{ String extLabel = extNames.next(); projection.addElement(new ProjectionElem(extLabel)); extensions.add(new ExtensionElem(val, extLabel)); if (subject instanceof Var){ Var v = (Var)subject; p.addElement(new ProjectionElem(v.getName(),"subject")); if (v.getValue() != null){ extensions.add(new ExtensionElem(subject, v.getName())); projection.addElement(new ProjectionElem(extLabel, "subject")); extensions.add(new ExtensionElem(subject, extLabel)); if (predicate instanceof Var){ Var v = (Var)predicate; p.addElement(new ProjectionElem(v.getName(),"predicate")); if (v.getValue() != null){ extensions.add(new ExtensionElem(predicate, v.getName())); projection.addElement(new ProjectionElem(extLabel, "predicate")); extensions.add(new ExtensionElem(predicate, extLabel)); if (object instanceof Var){ Var v = (Var)object; p.addElement(new ProjectionElem(v.getName(),"object"));
ProjectionElem projElem = new ProjectionElem(varName, projName); projElem.setSourceExpression(new ExtensionElem(valueExpr, varName)); if (!aggregates.isEmpty()) {
extension = extensions.get(projection.getSourceName()); final ProjectionElem newProjection = new ProjectionElem(); newProjection.setTargetName(variable); newProjection.setSourceExpression(extension); for (final String variableName : group.getGroupBindingNames()) { final ExtensionElem extension = extensions.get(variableName); final ProjectionElem projection = new ProjectionElem(); projection.setTargetName(variableName); projection.setSourceExpression(extension);
projElemList.addElement(new ProjectionElem(var.getName())); ProjectionElemList projElemList = new ProjectionElemList(); projElemList.addElement(new ProjectionElem(sp.getSubjectVar().getName(), "subject")); projElemList.addElement(new ProjectionElem(sp.getPredicateVar().getName(), "predicate")); projElemList.addElement(new ProjectionElem(sp.getObjectVar().getName(), "object"));
@Override public void meet(final GroupElem n) { final ProjectionElem e = new ProjectionElem(); e.setTargetName(n.getName()); e.setSourceName(n.getName()); e.setSourceExpression(new ExtensionElem(n.getOperator(), n.getName())); meet(e); }
@Override public void meet(final GroupElem n) { final ProjectionElem e = new ProjectionElem(); e.setTargetName(n.getName()); e.setSourceName(n.getName()); e.setSourceExpression(new ExtensionElem(n.getOperator(), n.getName())); meet(e); }
projElemList.addElement(new ProjectionElem(var.getName())); ProjectionElemList projElemList = new ProjectionElemList(); projElemList.addElement(new ProjectionElem(sp.getSubjectVar().getName(), "subject")); projElemList.addElement(new ProjectionElem(sp.getPredicateVar().getName(), "predicate")); projElemList.addElement(new ProjectionElem(sp.getObjectVar().getName(), "object"));
ValueExpr val = toValue(expr, md); if (val instanceof Var) { projection.addElement(new ProjectionElem(((Var) val).getName())); } else { String extLabel = extNames.next(); projection.addElement(new ProjectionElem(extLabel)); extensions.add(new ExtensionElem(val, extLabel)); if (subject instanceof Var) { Var v = (Var) subject; p.addElement(new ProjectionElem(v.getName(), "subject")); if (v.getValue() != null) { extensions.add(new ExtensionElem(subject, v.getName())); projection.addElement(new ProjectionElem(extLabel, "subject")); extensions.add(new ExtensionElem(subject, extLabel)); if (predicate instanceof Var) { Var v = (Var) predicate; p.addElement(new ProjectionElem(v.getName(), "predicate")); if (v.getValue() != null) { extensions.add(new ExtensionElem(predicate, v.getName())); projection.addElement(new ProjectionElem(extLabel, "predicate")); extensions.add(new ExtensionElem(predicate, extLabel)); if (object instanceof Var) { Var v = (Var) object; p.addElement(new ProjectionElem(v.getName(), "object"));
ValueExpr val = toValue(expr, md); if (val instanceof Var) { projection.addElement(new ProjectionElem(((Var) val).getName())); } else { String extLabel = extNames.next(); projection.addElement(new ProjectionElem(extLabel)); extensions.add(new ExtensionElem(val, extLabel)); if (subject instanceof Var) { Var v = (Var) subject; p.addElement(new ProjectionElem(v.getName(), "subject")); if (v.getValue() != null) { extensions.add(new ExtensionElem(subject, v.getName())); projection.addElement(new ProjectionElem(extLabel, "subject")); extensions.add(new ExtensionElem(subject, extLabel)); if (predicate instanceof Var) { Var v = (Var) predicate; p.addElement(new ProjectionElem(v.getName(), "predicate")); if (v.getValue() != null) { extensions.add(new ExtensionElem(predicate, v.getName())); projection.addElement(new ProjectionElem(extLabel, "predicate")); extensions.add(new ExtensionElem(predicate, extLabel)); if (object instanceof Var) { Var v = (Var) object; p.addElement(new ProjectionElem(v.getName(), "object"));
projElemList.addElement(new ProjectionElem(alias)); projElemList.addElement(new ProjectionElem(projVar.getName()));
sourceName = ((ASTVar)child).getName(); ProjectionElem elem = new ProjectionElem(sourceName, targetName); projElemList.addElement(elem); ProjectionElem elem = new ProjectionElem(projVar.getName()); projElemList.addElement(elem);
ProjectionElemList aList = new ProjectionElemList(); aList.addElement(new ProjectionElem(aPattern.getSubjectVar().getName(), "subject")); aList.addElement(new ProjectionElem(aPattern.getPredicateVar().getName(), "predicate")); aList.addElement(new ProjectionElem(aPattern.getObjectVar().getName(), "object"));
ProjectionElem pe = new ProjectionElem(name); pelist.addElement(pe);