com.bigdata.relation.rule.eval.pipeline
Class JoinTask.BindingSetConsumerTask

java.lang.Object
  extended by com.bigdata.relation.rule.eval.pipeline.JoinTask.BindingSetConsumerTask
All Implemented Interfaces:
Callable<Void>
Enclosing class:
JoinTask

protected class JoinTask.BindingSetConsumerTask
extends Object
implements Callable<Void>

Class consumes chunks from the source(s) until canceled, interrupted, or all source(s) are exhausted. For each IBindingSet in each chunk, an JoinTask.AccessPathTask is created which will consume that IBindingSet. The JoinTask.AccessPathTask for a given source chunk are sorted based on their fromKey so as to order the execution of those tasks in a manner that will maximize the efficiency of index reads. The ordered JoinTask.AccessPathTasks are then submitted to the caller's Executor.

Version:
$Id: JoinTask.java 3454 2010-08-20 19:00:43Z thompsonbry $
Author:
Bryan Thompson

Constructor Summary
JoinTask.BindingSetConsumerTask(Executor executor)
           
 
Method Summary
 Void call()
          Read chunks from one or more sources until canceled, interrupted, or all sources are exhausted and submits JoinTask.AccessPathTasks to the caller's ExecutorService -or- executes those tasks in the caller's thread if no ExecutorService was provided to the ctor.
protected  Map<IPredicate<?>,Collection<IBindingSet>> combineBindingSets(IBindingSet[] chunk)
          Populates a map of asBound predicates paired to a set of bindingSets.
protected  void executeTasks(JoinTask.AccessPathTask[] tasks)
          Either execute the tasks in the caller's thread or schedule them for execution on the supplied service.
protected  JoinTask.AccessPathTask[] getAccessPathTasks(Map<IPredicate<?>,Collection<IBindingSet>> map)
          Creates an JoinTask.AccessPathTask for each IBindingSet in the given chunk.
protected  void reorderTasks(JoinTask.AccessPathTask[] tasks)
          The tasks are ordered based on the fromKey for the associated IAccessPath as licensed by each IBindingSet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoinTask.BindingSetConsumerTask

public JoinTask.BindingSetConsumerTask(Executor executor)
Parameters:
executor - The service that will execute the generated JoinTask.AccessPathTasks -or- null IFF you want the JoinTask.AccessPathTasks to be executed in the caller's thread.
Method Detail

call

public Void call()
          throws Exception
Read chunks from one or more sources until canceled, interrupted, or all sources are exhausted and submits JoinTask.AccessPathTasks to the caller's ExecutorService -or- executes those tasks in the caller's thread if no ExecutorService was provided to the ctor.

Note: When running with an ExecutorService, the caller is responsible for waiting on that ExecutorService until the JoinTask.AccessPathTasks to complete and must verify all tasks completed successfully.

Specified by:
call in interface Callable<Void>
Returns:
null
Throws:
BufferClosedException - if there is an attempt to output a chunk of IBindingSets or ISolutions and the output buffer is an IBlockingBuffer (true for all join dimensions exception the lastJoin and also true for query on the lastJoin) and that IBlockingBuffer has been closed.
Exception

combineBindingSets

protected Map<IPredicate<?>,Collection<IBindingSet>> combineBindingSets(IBindingSet[] chunk)
Populates a map of asBound predicates paired to a set of bindingSets.

Note: The JoinTask.AccessPathTask will apply each bindingSet to each element visited by the IAccessPath obtained for the asBound IPredicate. This has the natural consequence of eliminating subqueries within the chunk.

Parameters:
chunk - A chunk of bindingSets from the source join dimension.
Returns:
A map which pairs the distinct asBound predicates to the bindingSets in the chunk from which the predicate was generated.

getAccessPathTasks

protected JoinTask.AccessPathTask[] getAccessPathTasks(Map<IPredicate<?>,Collection<IBindingSet>> map)
Creates an JoinTask.AccessPathTask for each IBindingSet in the given chunk.

Parameters:
chunk - A chunk of IBindingSets from one or more source JoinTasks.
Returns:
A chunk of JoinTask.AccessPathTask in a desirable execution order.
Throws:
Exception

reorderTasks

protected void reorderTasks(JoinTask.AccessPathTask[] tasks)
The tasks are ordered based on the fromKey for the associated IAccessPath as licensed by each IBindingSet. This order tends to focus the reads on the same parts of the index partitions with a steady progression in the fromKey as we process a chunk of IBindingSets.

Parameters:
tasks - The tasks.

executeTasks

protected void executeTasks(JoinTask.AccessPathTask[] tasks)
                     throws Exception
Either execute the tasks in the caller's thread or schedule them for execution on the supplied service.

Parameters:
tasks - The tasks.
Throws:
Exception


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.