Beispiel #1
0
  public Iterator<PartitionLocator> locatorScan(
      final AbstractScaleOutFederation<?> fed, final IPredicate<?> predicate) {

    final long timestamp = getReadTimestamp();

    // Note: assumes that we are NOT using a view of two relations.
    final IRelation<?> relation =
        (IRelation<?>) fed.getResourceLocator().locate(predicate.getOnlyRelationName(), timestamp);

    /*
     * Find the best access path for the predicate for that relation.
     *
     * Note: All we really want is the [fromKey] and [toKey] for that
     * predicate and index. This MUST NOT layer on expanders since the
     * layering also hides the [fromKey] and [toKey].
     */
    @SuppressWarnings("unchecked")
    final AccessPath<?> accessPath = (AccessPath<?>) relation.getAccessPath((IPredicate) predicate);

    // Note: assumes scale-out (EDS or JDS).
    final IClientIndex ndx = (IClientIndex) accessPath.getIndex();

    /*
     * Note: could also be formed from relationName + "." +
     * keyOrder.getIndexName(), which is cheaper unless the index metadata
     * is cached.
     */
    final String name = ndx.getIndexMetadata().getName();

    return fed.locatorScan(
        name, timestamp, accessPath.getFromKey(), accessPath.getToKey(), false /* reverse */);
  }
Beispiel #2
0
  /**
   * Constructs the element iff requested, saves the rule reference iff requested, and clones and
   * saves the bindingSet iff requested. The requested behavior depends on {@link
   * IJoinNexus#solutionFlags()}. When requested, the element is created using {@link
   * IRelation#newElement(IPredicate, IBindingSet)} for the {@link IRelation} that is named by the
   * head of the rule.
   *
   * @param e The element.
   * @param rule The rule.
   * @param bindingSet The binding set for this solution. If {@link IJoinNexus#BINDINGS} was
   *     specified, then the binding set will be <em>cloned</em> by this ctor.
   * @throws IllegalArgumentException if any parameter is <code>null</code>.
   */
  @SuppressWarnings("unchecked")
  public Solution(final IJoinNexus joinNexus, final IRule<E> rule, final IBindingSet bindingSet) {

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

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

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

    final int flags = joinNexus.solutionFlags();

    if ((flags & IJoinNexus.ELEMENT) != 0) {

      /*
       * The relation is responsible for how the elements are materialized
       * from the bindings.
       *
       * Note: Caching for this relation is very important!
       */

      // the head of the rule.
      final IPredicate head = rule.getHead();

      // the relation for the head of the rule.
      final IRelation relation = joinNexus.getHeadRelationView(head);

      // use the relation's element factory.
      this.e =
          (E) relation.newElement(head.args(), bindingSet); // TODO BOp.args() is not efficient!

      //            // use the relation's element factory.
      //            this.e = (E) relation.newElement(head, bindingSet);

    } else {

      this.e = null;
    }

    if ((flags & IJoinNexus.BINDINGS) != 0) {

      this.bindingSet = bindingSet.clone();

    } else {

      this.bindingSet = null;
    }

    if ((flags & IJoinNexus.RULE) != 0) {

      this.rule = rule;

    } else {

      this.rule = null;
    }
  }
Beispiel #3
0
  public IAccessPath getTailAccessPath(final IRelation relation, final IPredicate predicate) {

    return relation.getAccessPath(
        indexManager /* localIndexManager */, relation.getKeyOrder(predicate), predicate);

    //        if (predicate.getPartitionId() != -1) {
    //
    //            /*
    //             * Note: This handles a read against a local index partition. For
    //             * scale-out, the [indexManager] will be the data service's local
    //             * index manager.
    //             *
    //             * Note: Expanders ARE NOT applied in this code path. Expanders
    //             * require a total view of the relation, which is not available
    //             * during scale-out pipeline joins. Likewise, the [backchain]
    //             * property will be ignored since it is handled by an expander.
    //             */
    //
    //            return ((AbstractRelation<?>) relation)
    //                    .getAccessPathForIndexPartition(indexManager, predicate);
    //
    //        }
    //
    //        // Find the best access path for the predicate for that relation.
    //        final IAccessPath<?> accessPath = relation.getAccessPath(predicate);
    //
    //        // Note: No expander's for bops, at least not right now.
    ////        final ISolutionExpander expander = predicate.getSolutionExpander();
    ////
    ////        if (expander != null) {
    ////
    ////            // allow the predicate to wrap the access path
    ////            accessPath = expander.getAccessPath(accessPath);
    ////
    ////        }
    //
    //        // return that access path.
    //        return accessPath;
  }