예제 #1
0
파일: PATHS.java 프로젝트: kietly/database
  /**
   * The remote vertex is scheduled for activation unless it has already been visited.
   *
   * <p>Note: We are scattering to out-edges. Therefore, this vertex is {@link
   * Statement#getSubject()}. The remote vertex is {@link Statement#getObject()}.
   */
  @Override
  public void scatter(
      final IGASState<PATHS.VS, PATHS.ES, Void> state,
      final IGASScheduler sch,
      final Value u,
      final Statement e) {

    // remote vertex state.
    final Value v = state.getOtherVertex(u, e);

    final VS otherState = state.getState(v);

    final int otherDepth = otherState.depth();
    //        final VS otherState = state.getState(e.getObject()/* v */);

    // visit.

    if (otherState.visit(state.round() + 1, u /* predecessor */, e.getPredicate())) {

      /*
       * This is the first visit for the remote vertex. Add it to the
       * schedule for the next iteration.
       */

      sch.schedule(v);
    }
  }
예제 #2
0
파일: PATHS.java 프로젝트: kietly/database
  /*
   * TODO Do this in parallel for each specified target vertex.
   */
  @Override
  public void prunePaths(final IGASContext<VS, ES, Void> ctx, final Value[] targetVertices) {

    //    	if(true)
    //    	return;

    if (ctx == null) throw new IllegalArgumentException();

    if (targetVertices == null) throw new IllegalArgumentException();

    final IGASState<PATHS.VS, PATHS.ES, Void> gasState = ctx.getGASState();

    final Set<Value> retainSet = new HashSet<Value>();

    for (Value v : targetVertices) {

      if (!gasState.isVisited(v)) {

        // This target was not reachable.
        continue;
      }

      /*
       * Walk the precessors back to a starting vertex.
       */
      retainSet.add(v);

      visitPredecessors(gasState, v, retainSet);
    } // next target vertex.

    gasState.retainAll(retainSet);
  }
예제 #3
0
파일: PATHS.java 프로젝트: kietly/database
  /** Not used. */
  @Override
  public void initVertex(
      final IGASContext<PATHS.VS, PATHS.ES, Void> ctx,
      final IGASState<PATHS.VS, PATHS.ES, Void> state,
      final Value u) {

    state.getState(u).visit(0, null /* predecessor */, null /* edge */);
  }
예제 #4
0
파일: PATHS.java 프로젝트: kietly/database
  protected void visitPredecessors(
      final IGASState<PATHS.VS, PATHS.ES, Void> gasState,
      final Value v,
      final Set<Value> retainSet) {

    final PATHS.VS currentState = gasState.getState(v);

    //    	final int curDepth = currentState.depth.get();

    for (Value pred : currentState.predecessors().keySet()) {

      //        	if (pred == null) {
      //
      //        		continue;
      //
      //        	}

      //        	if (retainSet.contains(pred)) {
      //
      //        		continue;
      //
      //        	}

      //        	final int predDepth = gasState.getState(pred).depth.get();
      //
      //        	if (predDepth >= curDepth) {
      //
      //        		continue;
      //
      //        	}

      if (!retainSet.contains(pred)) {

        retainSet.add(pred);

        visitPredecessors(gasState, pred, retainSet);
      }
    }
  }