コード例 #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 */);
  }
コード例 #2
0
  /**
   * The head relation is what we write on for mutation operations and is also responsible for
   * minting new elements from computed {@link ISolution}s. This method depends solely on the name
   * of the head relation and the timestamp of interest for the view.
   */
  public IRelation getHeadRelationView(final IPredicate pred) {

    if (pred.getRelationCount() != 1) throw new IllegalArgumentException();

    final String relationName = pred.getOnlyRelationName();

    final long timestamp =
        (getAction().isMutation() ? getWriteTimestamp() : getReadTimestamp(/*relationName*/ ));

    return (IRelation<?>) resourceLocator.locate(relationName, timestamp);
  }
コード例 #3
0
  @SuppressWarnings("unchecked")
  public IRelation getTailRelationView(final IPredicate pred) {

    final int nsources = pred.getRelationCount();

    if (nsources == 1) {

      return (IRelation) resourceLocator.locate(pred.getOnlyRelationName(), getReadTimestamp());

    } else if (nsources == 2) {

      final IRelation<?> relation0 =
          (IRelation) resourceLocator.locate(pred.getRelationName(0), readTimestamp);

      final IRelation<?> relation1 =
          (IRelation) resourceLocator.locate(pred.getRelationName(1), readTimestamp);

      return new RelationFusedView(relation0, relation1).init();

    } else {

      throw new UnsupportedOperationException();
    }
  }