private void initLabelsToNodes() { if (this.labelsToNodes != null) { return; } GetLabelsToNodesResponseProtoOrBuilder p = viaProto ? proto : builder; List<LabelsToNodeIdsProto> list = p.getLabelsToNodesList(); this.labelsToNodes = new HashMap<String, Set<NodeId>>(); for (LabelsToNodeIdsProto c : list) { Set<NodeId> setNodes = new HashSet<NodeId>(); for(NodeIdProto n : c.getNodeIdList()) { NodeId node = new NodeIdPBImpl(n); setNodes.add(node); } if(!setNodes.isEmpty()) { this.labelsToNodes.put(c.getNodeLabels(), setNodes); } } }
private void initLabelsToNodes() { if (this.labelsToNodes != null) { return; } GetLabelsToNodesResponseProtoOrBuilder p = viaProto ? proto : builder; List<LabelsToNodeIdsProto> list = p.getLabelsToNodesList(); this.labelsToNodes = new HashMap<NodeLabel, Set<NodeId>>(); for (LabelsToNodeIdsProto c : list) { Set<NodeId> setNodes = new HashSet<NodeId>(); for(NodeIdProto n : c.getNodeIdList()) { NodeId node = new NodeIdPBImpl(n); setNodes.add(node); } if (!setNodes.isEmpty()) { this.labelsToNodes .put(new NodeLabelPBImpl(c.getNodeLabels()), setNodes); } } }
private void initLabelsToNodes() { if (this.labelsToNodes != null) { return; } GetLabelsToNodesResponseProtoOrBuilder p = viaProto ? proto : builder; List<LabelsToNodeIdsProto> list = p.getLabelsToNodesList(); this.labelsToNodes = new HashMap<String, Set<NodeId>>(); for (LabelsToNodeIdsProto c : list) { Set<NodeId> setNodes = new HashSet<NodeId>(); for(NodeIdProto n : c.getNodeIdList()) { NodeId node = new NodeIdPBImpl(n); setNodes.add(node); } if (!setNodes.isEmpty()) { this.labelsToNodes .put(c.getNodeLabels(), setNodes); } } }
private void addLabelsToNodesToProto() { maybeInitBuilder(); builder.clearLabelsToNodes(); if (labelsToNodes == null) { return; } Iterable<LabelsToNodeIdsProto> iterable = new Iterable<LabelsToNodeIdsProto>() { @Override public Iterator<LabelsToNodeIdsProto> iterator() { return new Iterator<LabelsToNodeIdsProto>() { Iterator<Entry<String, Set<NodeId>>> iter = labelsToNodes.entrySet().iterator(); @Override public void remove() { throw new UnsupportedOperationException(); } @Override public LabelsToNodeIdsProto next() { Entry<String, Set<NodeId>> now = iter.next(); Set<NodeIdProto> nodeProtoSet = new HashSet<NodeIdProto>(); for(NodeId n : now.getValue()) { nodeProtoSet.add(convertToProtoFormat(n)); } return LabelsToNodeIdsProto.newBuilder() .setNodeLabels(now.getKey()).addAllNodeId(nodeProtoSet) .build(); } @Override public boolean hasNext() { return iter.hasNext(); } }; } }; builder.addAllLabelsToNodes(iterable); }
private void addLabelsToNodesToProto() { maybeInitBuilder(); builder.clearLabelsToNodes(); if (labelsToNodes == null) { return; } Iterable<LabelsToNodeIdsProto> iterable = new Iterable<LabelsToNodeIdsProto>() { @Override public Iterator<LabelsToNodeIdsProto> iterator() { return new Iterator<LabelsToNodeIdsProto>() { Iterator<Entry<NodeLabel, Set<NodeId>>> iter = labelsToNodes.entrySet().iterator(); @Override public void remove() { throw new UnsupportedOperationException(); } @Override public LabelsToNodeIdsProto next() { Entry<NodeLabel, Set<NodeId>> now = iter.next(); Set<NodeIdProto> nodeProtoSet = new HashSet<NodeIdProto>(); for(NodeId n : now.getValue()) { nodeProtoSet.add(convertToProtoFormat(n)); } return LabelsToNodeIdsProto.newBuilder() .setNodeLabels(convertToProtoFormat(now.getKey())) .addAllNodeId(nodeProtoSet) .build(); } @Override public boolean hasNext() { return iter.hasNext(); } }; } }; builder.addAllLabelsToNodes(iterable); }
private void addLabelsToNodesToProto() { maybeInitBuilder(); builder.clearLabelsToNodes(); if (labelsToNodes == null) { return; } Iterable<LabelsToNodeIdsProto> iterable = new Iterable<LabelsToNodeIdsProto>() { @Override public Iterator<LabelsToNodeIdsProto> iterator() { return new Iterator<LabelsToNodeIdsProto>() { Iterator<Entry<String, Set<NodeId>>> iter = labelsToNodes.entrySet().iterator(); @Override public void remove() { throw new UnsupportedOperationException(); } @Override public LabelsToNodeIdsProto next() { Entry<String, Set<NodeId>> now = iter.next(); Set<NodeIdProto> nodeProtoSet = new HashSet<NodeIdProto>(); for(NodeId n : now.getValue()) { nodeProtoSet.add(convertToProtoFormat(n)); } return LabelsToNodeIdsProto.newBuilder() .setNodeLabels(now.getKey()) .addAllNodeId(nodeProtoSet) .build(); } @Override public boolean hasNext() { return iter.hasNext(); } }; } }; builder.addAllLabelsToNodes(iterable); }