Add the cypher clause to create the node corresponding to the root of the aggregate
5411
private function createAggregate(
        Identity $identity,
        object $entity,
        Query $query
    ): Query {
        $meta = ($this->metadata)(\get_class($entity));
        $data = ($this->extract)($entity);
        $varName = $this->name->sprintf(\md5($identity->value()));

        $query = $query->create(
            (string) $varName,
            $meta->labels()->toPrimitive()
        );
        $paramKey = $varName->append('_props');
        $properties = $this->buildProperties(
            $meta->properties(),
            $paramKey
        );
        $keysToKeep = $data->keys()->intersect($properties->keys());

        $query = $query
            ->withProperty(
                $meta->identity()->property(),
                (string) $paramKey
                    ->prepend('{')
                    ->append('}.')
                    ->append($meta->identity()->property())
            )
            ->withProperties($properties->reduce(
                [],
                static function(array $carry, string $property, string $cypher): array {
                    $carry[$property] = $cypher;

                    return $carry;
                }
            ))
            ->withParameter(
                (string) $paramKey,
                $data
                    ->filter(static function(string $key) use ($keysToKeep): bool {
                        return $keysToKeep->contains($key);
                    })
                    ->put(
                        $meta->identity()->property(),
                        $identity->value()
                    )
                    ->reduce(
                        [],
                        static function(array $carry, string $key, $value): array {
                            $carry[$key] = $value;

                            return $carry;
                        }
                    )
            );

        $query = $meta
            ->children()
            ->reduce(
                $query,
                function(Query $carry, string $property, Child $child) use ($varName, $data): Query {
                    return $this->createAggregateChild(
                        $child,
                        $varName,
                        $data->get($property),
                        $carry
                    );
                }
            );
        $this->variables = $this->variables->add((string) $varName);

        return $query;
    }
943241
def _create_query(node, context):
    
    visited_nodes = [node]
    output_columns = _get_output_columns(visited_nodes, context)
    filters = _get_filters(visited_nodes, context)
    selectable = sql_context_helpers.get_node_selectable(node, context)
    query = select(output_columns).select_from(selectable).where(and_(*filters))
    return query
925676
def schema_root(self) -> "SchemaTreeNode":
        """"""
        sn = self
        while sn.parent:
            sn = sn.parent
        return sn
69270
def _augment_node(node: BaseEntity) -> BaseEntity:
    """"""
    rv = node.copy()
    rv['id'] = node.as_sha512()
    rv['bel'] = node.as_bel()
    for m in chain(node.get(MEMBERS, []), node.get(REACTANTS, []), node.get(PRODUCTS, [])):
        m.update(_augment_node(m))
    return rv
1227642
function addToGlobalNodes(node){
    var nodeToAdd = {
        "_id": node.id(),
        "_world": node.world(),
        "_time": node.time(),
        "_type": (node.nodeTypeName() ? node.nodeTypeName() : "default")
    };

    var containsRel = false;
    // add all the attributes of the node to the JSON
    graph.resolver().resolveState(node, false).each(function (attributeKey, elemType, elem) {
        var key = graph.resolver().hashToString(attributeKey);

        if(elemType == org.mwg.Type.BOOL || elemType == org.mwg.Type.STRING || elemType == org.mwg.Type.INT
            || elemType == org.mwg.Type.LONG || elemType == org.mwg.Type.DOUBLE) { //primitive types
            nodeToAdd[key] = elem;
        } else if(elemType == org.mwg.Type.RELATION) { //classic relation
            nodeToAdd[key] = [];
            for (var i = 0; i < elem.size(); ++i){
                nodeToAdd[key].push(elem.get(i));
            }
            containsRel = true;
        } else if(elemType == org.mwg.Type.LONG_TO_LONG_ARRAY_MAP) { //indexed relation
            nodeToAdd[key] = [];
            elem.each(function(relKey,relIdNode) {
                nodeToAdd[key].push(relIdNode);
            });
            containsRel = true;
        } else {
            throw "Type(" + elemType + ") is not yet managed. Please update the debugger."
        }
    });
    // if the node contains a relationship, we add them into a global variable to deal with the relationships later
    if (containsRel){
        gNodesWithRel.push(nodeToAdd);
    }

    // we sort the nodes per type
    if (gNodesPerType[nodeToAdd._type] == null){
        gNodesPerType[nodeToAdd._type] = [];
        colorsByNodeType[nodeToAdd._type] = getRandomColor(); // add the type of the node to the type list and assign a color to the type
    }
    gNodesPerType[nodeToAdd._type].push(nodeToAdd);

    // finally we add them to the global array containing all the nodes
    gAllNodes.push(nodeToAdd);

}
246154
private static void nodesTable(Statement st,
                                   TableLocation nodesName,
                                   double tolerance, boolean isH2, int srid) throws SQLException {
        LOGGER.info("Creating the nodes table...");
        // Creating nodes table by removing copies from the pts table.
        if (tolerance > 0) {
            if(isH2){
            st.execute("CREATE TABLE " + nodesName + "(" +
                    "NODE_ID SERIAL PRIMARY KEY, " +
                    "THE_GEOM POINT, " +
                    "EXP POLYGON" +
                    ") AS " +
                    "SELECT NULL, A.THE_GEOM, A.AREA FROM "+ PTS_TABLE + " as A," + PTS_TABLE +" as B " +
                    "WHERE A.AREA && B.AREA " +
                    "GROUP BY A.ID " +
                    "HAVING A.ID=MIN(B.ID);");
            }
            else{
               st.execute("CREATE TABLE " + nodesName + "(" +
                    "NODE_ID SERIAL PRIMARY KEY, " +
                    "THE_GEOM GEOMETRY(POINT, " + srid+"), "+
                    "EXP GEOMETRY(POLYGON," +srid+")"+
                    ") " );
                st.execute( "INSERT INTO "+nodesName +" (SELECT (row_number() over())::int , c.the_geom, c.area FROM (SELECT  A.THE_GEOM, A.AREA FROM "+ PTS_TABLE +" as  A, "+ PTS_TABLE +" as B " +
                    "WHERE A.AREA && B.AREA " +
                    "GROUP BY A.ID " +
                    "HAVING A.ID=MIN(B.ID)) as c);"); 
            }
        } else {
            
            if(isH2){
               // If the tolerance is zero, we can create the NODES table
            // by using = rather than &&.
            st.execute("CREATE TABLE " + nodesName + "(" +
                    "NODE_ID SERIAL PRIMARY KEY, " +
                    "THE_GEOM POINT" +
                    ") AS " +
                    "SELECT NULL, A.THE_GEOM FROM "+ PTS_TABLE + " as A," + PTS_TABLE + " as B " +
                    "WHERE A.THE_GEOM && B.THE_GEOM AND A.THE_GEOM=B.THE_GEOM " +
                    "GROUP BY A.ID " +
                    "HAVING A.ID=MIN(B.ID);"); 
            }
            else{
            // If the tolerance is zero, we can create the NODES table
            // by using = rather than &&.
            st.execute("CREATE TABLE " + nodesName + "(" +
                    "NODE_ID SERIAL PRIMARY KEY, " +
                    "THE_GEOM GEOMETRY(POINT, "+srid+")" +
                    ") " );            
            st.execute("INSERT INTO "+nodesName +" (SELECT (row_number() over())::int , c.the_geom FROM (SELECT A.THE_GEOM FROM "+ PTS_TABLE + " as A," + PTS_TABLE + " as B " +
                    "WHERE A.THE_GEOM && B.THE_GEOM AND A.THE_GEOM=B.THE_GEOM " +
                    "GROUP BY A.ID " +
                    "HAVING A.ID=MIN(B.ID)) as c);");
            }
        }
    }
785233
function createGlobal(expr, nodes, opt_namedPartial) {
    var exprs = [];
    while (t.isMemberExpression(expr)) {
      exprs.push(expr);
      expr = expr.object;
    }

    var currGlobalName = '';
    for (var i = exprs.length - 2; opt_namedPartial ? i >= 0 : i > 0; i--) {
      currGlobalName += '.' + exprs[i].property.value;
      if (!createdGlobals[currGlobalName]) {
        createdGlobals[currGlobalName] = true;
        nodes.push(t.expressionStatement(
          t.assignmentExpression('=', exprs[i], t.logicalExpression(
            '||',
            exprs[i],
            t.objectExpression([])
          ))
        ));
      }
    }
  }
339781
def assoc(self, index, value):
        ''''''
        newnode = LookupTreeNode(index, value)
        newtree = LookupTree()
        newtree.root = _assoc_down(self.root, newnode, 0)
        return newtree
978531
def build(self):
        
        self.order = MerkleTree.get_order(len(self.leaves))
        n = 2 ** self.order
        self.nodes = [b''] * 2 * n

        # populate lowest nodes with leaf hashes
        for j in range(0, n):
            if (j < len(self.leaves)):
                self.nodes[j + n - 1] = self.leaves[j].get_hash()
            else:
                break

        # now populate the entire tree
        for i in range(1, self.order + 1):
            p = 2 ** (self.order - i)
            for j in range(0, p):
                k = p + j - 1
                h = hashlib.sha256()
                l = self.nodes[MerkleTree.get_left_child(k)]
                if (len(l) > 0):
                    h.update(l)
                r = self.nodes[MerkleTree.get_right_child(k)]
                if (len(r) > 0):
                    h.update(r)
                self.nodes[k] = h.digest()
1003484
function (graph, opts, params) {
    var self = this;
    var updatedNodes = graph.allNodes;
    if (opts.restrictToComp) {
      updatedNodes = graph.allNodes.filter(function(node) {
        return node.comp && node.comp.name == opts.restrictToComp;
      });
    }

    function assign(statements, varName, hash) {
      params[varName] = hash;
      if (opts.additive) {
        _.forEach(hash, function(val, key) {
          statements.push(varName + '.`' + key + '`={' + varName + '}.`' + key + '`');
        });
      } else {
        statements.push(varName + '={' + varName + '}');
      }
    }

    return 'SET ' + updatedNodes.reduce(function(statements, node) {
      // set props
      var props = node.props;
      if (props[self.db.options.id]) props = _.omit(props, self.db.options.id);
      
      if (node.comp) assign(statements, '__rel_' + node.name, props._rel || {});
      
      props = _.omit(props, '_rel');
      assign(statements, node.name, props);

      // set timestamps
      if (!node.model.usingTimestamps) return statements;
      statements.push(getSetCreatedTimestampStatement(node));
      statements.push(node.name + '.' + node.model.updatedField + ' = timestamp()');

      return statements;
    }, []).join(',');
  }
1249506
public AggregationHashChain build(TreeNode leaf) throws KSIException {
        Util.notNull(leaf, "TreeNode");
        if (!leaf.isLeaf() || leaf.isRoot() || leaf instanceof MetadataNode) {
            throw new IllegalArgumentException("Aggregation hash chain can be built only from leaf nodes");
        }

        LinkedList<AggregationChainLink> links = new LinkedList<>();
        long levelCorrection = 0L;
        TreeNode node;
        if (leaf.getParent().getRightChildNode() instanceof MetadataNode) {
            links.add(createMetadataChainLink((MetadataNode) leaf.getParent().getRightChildNode(), leaf.getLevel()));
            node = leaf.getParent();
        } else {
            node = leaf;
            levelCorrection = node.getLevel();
        }
        createChainLinks(links, levelCorrection, node);
        LinkedList<Long> chainIndex = new LinkedList<>(singletonList(calculateIndex(links)));
        HashAlgorithm aggregationAlgorithm = new DataHash(leaf.getParent().getValue()).getAlgorithm();
        return SIGNATURE_COMPONENT_FACTORY.createAggregationHashChain(
                new DataHash(leaf.getValue()), new Date(), chainIndex, links, aggregationAlgorithm);
    }
1278450
function(root) {
      // establish $ instance variable
      var $ = this.$ = this.$ || {};
      // populate $ from nodes with ID from the LOCAL tree
      if (root) {
        var n$ = root.querySelectorAll("[id]");
        for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) {
          $[n.id] = n;
        };
      }
    }
1065423
private void createEdge(Node fromNode, ControlFlowGraph.Branch branch,
      Node toNode) {
    cfg.createNode(fromNode);
    cfg.createNode(toNode);
    cfg.connectIfNotFound(fromNode, branch, toNode);
  }
823114
function createHash(root) {
    // visit(root, function (node) {
    //     return node.data && node.data.hData && node.data.hData.hash;
    // }, function (node) {
    //     debugger
    // })

    var children = root.children;

    var hashs = children.map(function (node) {
        return (node.type === "paragraph" && node.data && node.data.hData && node.data.hData.hash)?node.data.hData.hash:0;
    });

    return [].concat(hashs).reduce(function (a, b) {
        return a+b;
    })

}
508326
def update_property_node(node_to_insert, field_uri):
  
  root = T.SetItemField(
            T.FieldURI(FieldURI=field_uri),
            T.CalendarItem(node_to_insert)
        )
  return root
266157
def add_node(self, node):
        """"""
        other_nodes = [n for n in self.nodes() if n.id != node.id]
        if len(self.nodes()) > 11:
            parents = [max(other_nodes, key=attrgetter("creation_time"))]
        else:
            parents = [n for n in other_nodes if isinstance(n, Source)]

        for parent in parents:
            parent.connect(whom=node)
664456
def ensure_node(self, tokens: ParseResults) -> BaseEntity:
        """"""
        if MODIFIER in tokens:
            return self.ensure_node(tokens[TARGET])

        node = parse_result_to_dsl(tokens)
        self.graph.add_node_from_data(node)
        return node