congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
DAGNode.getLabel
Code IndexAdd Tabnine to your IDE (free)

How to use
getLabel
method
in
org.grouplens.grapht.graph.DAGNode

Best Java code snippets using org.grouplens.grapht.graph.DAGNode.getLabel (Showing top 20 results out of 315)

origin: lenskit/lenskit

private Visitor(DAGNode<Component, Dependency> nd, String id) {
  currentNode = nd;
  nodeId = id;
  if (currentNode == null) {
    throw new IllegalStateException("dumper not running");
  }
  Component csat = currentNode.getLabel();
  assert csat != null;
  satisfaction = csat.getSatisfaction();
}
origin: lenskit/lenskit

/**
 * Get the placeholder nodes from a graph.
 *
 * @param graph The graph.
 * @return The set of nodes that have placeholder satisfactions.
 */
public static Set<DAGNode<Component, Dependency>> getPlaceholderNodes(DAGNode<Component,Dependency> graph) {
  return graph.getReachableNodes()
        .stream()
        .filter(n -> n.getLabel().getSatisfaction() instanceof PlaceholderSatisfaction)
        .collect(Collectors.toSet());
}
origin: lenskit/lenskit

@Nonnull
@Override
public Object apply(@Nullable DAGNode<Component, Dependency> input) {
  Preconditions.checkNotNull(input, "input node");
  try {
    return instantiate(input);
  } catch (InjectionException e) {
    throw new RecommenderBuildException("cannot instantiate " + input.getLabel(), e);
  }
}
origin: lenskit/lenskit

@Nullable
private Optional<Object> getDiskCachedObject(Path file, DAGNode<Component,Dependency> node) {
  if (file != null && Files.exists(file)) {
    logger.debug("reading object for {} from cache (key {})",
           node.getLabel().getSatisfaction(), key);
    Object obj = readCompressedObject(file, node.getLabel().getSatisfaction().getErasedType());
    logger.debug("read object {} from key {}", obj, key);
    return Optional.fromNullable(obj);
  } else {
    return null;
  }
}
origin: lenskit/lenskit

  @Override
  public void describe(DAGNode<Component, Dependency> node, DescriptionWriter description) {
    node.getLabel().getSatisfaction().visit(new LabelDescriptionVisitor(description));
    description.putField("cachePolicy", node.getLabel().getCachePolicy().name());
    List<DAGNode<Component, Dependency>> edges =
        node.getOutgoingEdges()
        .stream()
        .sorted(GraphtUtils.DEP_EDGE_ORDER)
        .map(DAGEdge::getTail)
        .collect(Collectors.toList());
    description.putList("dependencies", edges, INSTANCE);
  }
}
origin: lenskit/lenskit

id = "N" + nodeIds.size();
nodeIds.put(node, id);
Component csat = node.getLabel();
assert csat != null;
Satisfaction sat = csat.getSatisfaction();
origin: lenskit/lenskit

/**
 * Get the component of a particular type, if one is already instantiated.  This is useful to extract pre-built
 * models from serialized recommender engines, for example.
 * @param type The required component type.
 * @param <T> The required component type.
 * @return The component instance, or {@code null} if no instance can be retreived (either because no such
 * component is configured, or it is not yet instantiated).
 */
@Nullable
public <T> T getComponent(Class<T> type) {
  DAGNode<Component, Dependency> node = GraphtUtils.findSatisfyingNode(graph, Qualifiers.matchDefault(), type);
  if (node == null) {
    return null;
  }
  Satisfaction sat = node.getLabel().getSatisfaction();
  if (sat instanceof InstanceSatisfaction) {
    return type.cast(((InstanceSatisfaction) sat).getInstance());
  } else {
    return null;
  }
}
origin: lenskit/lenskit

  /**
   * Find a node with a satisfaction for a specified type. Does a breadth-first
   * search to find the closest matching one.
   *
   * @param type The type to look for.
   * @return A node whose satisfaction is compatible with {@code type}.
   */
  @Nullable
  public static DAGNode<Component,Dependency> findSatisfyingNode(DAGNode<Component,Dependency> graph,
                                  final QualifierMatcher qmatch,
                                  final Class<?> type) {
    Optional<DAGEdge<Component, Dependency>> edge =
        graph.breadthFirstEdges()
           .filter(e -> type.isAssignableFrom(e.getTail()
                             .getLabel()
                             .getSatisfaction()
                             .getErasedType()))
           .filter(e -> qmatch.apply(e.getLabel()
                        .getInitialDesire()
                        .getInjectionPoint()
                        .getQualifier()))
        .findFirst();

    return edge.map(DAGEdge::getTail)
          .orElse(null);
  }
}
origin: lenskit/lenskit

Component label = node.getLabel();
origin: lenskit/lenskit

logger.debug("instantiating object for {}", node.getLabel().getSatisfaction());
Object result = instantiator.instantiate(node);
if (result == null) {
origin: lenskit/lenskit

/**
 * Check a graph for placeholder satisfactions.
 *
 * @param graph The graph to check.
 * @throws RecommenderConfigurationException if the graph has a placeholder satisfaction.
 */
public static void checkForPlaceholders(DAGNode<Component, Dependency> graph, Logger logger) throws RecommenderConfigurationException {
  Set<DAGNode<Component, Dependency>> placeholders = getPlaceholderNodes(graph);
  Satisfaction sat = null;
  for (DAGNode<Component,Dependency> node: placeholders) {
    Component csat = node.getLabel();
    // special-case DAOs for non-checking
    if (DataAccessObject.class.isAssignableFrom(csat.getSatisfaction().getErasedType())) {
      logger.debug("found DAO placeholder {}", csat.getSatisfaction());
    } else {
      // all other placeholders are bad
      if (sat == null) {
        sat = csat.getSatisfaction();
      }
      logger.error("placeholder {} not removed", csat.getSatisfaction());
    }
  }
  if (sat != null) {
    throw new RecommenderConfigurationException("placeholder " + sat + " not removed");
  }
}
origin: lenskit/lenskit

Component csat = target.getLabel();
if (!satIsNull(csat.getSatisfaction())) {
  logger.debug("processing node {}", csat.getSatisfaction());
origin: lenskit/lenskit

if (q != null && q.annotationType().getAnnotation(Parameter.class) != null) {
  logger.debug("dumping parameter {}", q);
  Component tcsat = targetNode.getLabel();
  assert tcsat != null;
  Satisfaction tsat = tcsat.getSatisfaction();
origin: lenskit/lenskit

  public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) {
    Component label = node.getLabel();
    if (!label.getSatisfaction().hasInstance()) {
      Satisfaction instanceSat = Satisfactions.nullOfType(label.getSatisfaction().getErasedType());
      Component newLbl = Component.create(instanceSat,
                        label.getCachePolicy());
      // build new node with replacement label
      DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLbl);
      // retain all non-transient edges
      for (DAGEdge<Component,Dependency> edge: node.getOutgoingEdges()) {
        if (!GraphtUtils.edgeIsTransient(edge)) {
          bld.addEdge(edge.getTail(), edge.getLabel());
        }
      }
      DAGNode<Component,Dependency> repl = bld.build();
      logger.debug("simulating instantiation of {}", node);
      return repl;
    } else {
      return node;
    }
  }
}
origin: lenskit/lenskit

Component label = node.getLabel();
Satisfaction satisfaction = label.getSatisfaction();
if (satisfaction.hasInstance()) {
origin: lenskit/lenskit

  public DAGNode<Component, Dependency> processNode(@Nonnull DAGNode<Component, Dependency> node, @Nonnull DAGNode<Component, Dependency> original) {
    Component label = node.getLabel();
    Satisfaction satisfaction = label.getSatisfaction();
    if (satisfaction.hasInstance()) {
      return node;
    }
    Object obj = instantiator.apply(node);

    Satisfaction instanceSat;
    if (obj == null) {
      instanceSat = Satisfactions.nullOfType(satisfaction.getErasedType());
    } else {
      instanceSat = Satisfactions.instance(obj);
    }
    Component newLabel = Component.create(instanceSat, label.getCachePolicy());
    // build new node with replacement label
    DAGNodeBuilder<Component,Dependency> bld = DAGNode.newBuilder(newLabel);
    // retain all non-transient edges
    for (DAGEdge<Component, Dependency> edge: node.getOutgoingEdges()) {
      if (!GraphtUtils.edgeIsTransient(edge)) {
        bld.addEdge(edge.getTail(), edge.getLabel());
      }
    }
    return bld.build();
  }
}
origin: org.grouplens.grapht/grapht

  @Override
  public boolean apply(@Nullable DAGNode<V, ?> input) {
    V lbl = input == null ? null : input.getLabel();
    return pred.apply(lbl);
  }
};
origin: org.grouplens.lenskit/lenskit-eval

private Visitor(DAGNode<Component, Dependency> nd, String id) {
  currentNode = nd;
  nodeId = id;
  if (currentNode == null) {
    throw new IllegalStateException("dumper not running");
  }
  Component csat = currentNode.getLabel();
  assert csat != null;
  satisfaction = csat.getSatisfaction();
}
origin: org.lenskit/lenskit-core

/**
 * Get the placeholder nodes from a graph.
 *
 * @param graph The graph.
 * @return The set of nodes that have placeholder satisfactions.
 */
public static Set<DAGNode<Component, Dependency>> getPlaceholderNodes(DAGNode<Component,Dependency> graph) {
  return graph.getReachableNodes()
        .stream()
        .filter(n -> n.getLabel().getSatisfaction() instanceof PlaceholderSatisfaction)
        .collect(Collectors.toSet());
}
origin: org.lenskit/lenskit-core

@Nonnull
@Override
public Object apply(@Nullable DAGNode<Component, Dependency> input) {
  Preconditions.checkNotNull(input, "input node");
  try {
    return instantiate(input);
  } catch (InjectionException e) {
    throw new RecommenderBuildException("cannot instantiate " + input.getLabel(), e);
  }
}
org.grouplens.grapht.graphDAGNodegetLabel

Javadoc

Get the label for this node.

Popular methods of DAGNode

  • getOutgoingEdges
    Get the outgoing edges of this node.
  • getReachableNodes
  • newBuilder
    Construct a new DAG node builder.
  • getOutgoingEdgeWithLabel
  • getSortedNodes
    Topographical sort all nodes reachable from the given root node. Nodes that are farther away, or mor
  • replaceNode
    Replace one node with another in this graph. All edges referencing node are replaced with edges refe
  • breadthFirstEdges
  • <init>
    Construct a new DAG node.
  • copyBuilder
    Create a new builder initialized to build a copy of the specified node.
  • getAdjacentNodes
    Get the nodes that are adjacent to this node (only considering outgoing edges).
  • getIncomingEdgeMap
    Get a multimap of incoming edges. For each node reachable from this node, the map will contain each
  • initializeCaches
    Initialize caches for traversing this node.
  • getIncomingEdgeMap,
  • initializeCaches,
  • singleton,
  • sortVisit,
  • transformEdges

Popular in Java

  • Finding current android device location
  • onCreateOptionsMenu (Activity)
  • getResourceAsStream (ClassLoader)
  • findViewById (Activity)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Notification (javax.management)
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now