text:
package it.agilelab.bigdata.spark.search

import it.agilelab.bigdata.spark.search.dsl.DslQuery
import it.agilelab.bigdata.spark.search.utils._
import org.apache.spark.{Dependency, SparkContext}
import org.apache.spark.rdd.RDD
import scala.reflect.ClassTag

/** Indexed RDD that provides search functionality.
	*
	* ==Principle of operation==
	*
	* The elements of the input RDD must implement the [[Indexable]] trait; an advanced mechanism
	* based on implicit conversion using code generation is available that supports common data
	* types and classes built from them, so no work at all is required in many cases; see [[Indexable]]
	* for details.
	*
	* For each partition of the input RDD, an [[IndexedPartition]] is built, which contains both the
	* [[Index]] for the data in the partition and the data itself.
	*
	* Thus, the number of indices built is the same as the number of partitions of the input RDD; every
	* operation must interrogate all the indices, so the number of indices directly affects performance.
	*
	* This means a compromise must be made between efficient operation and partition number/size; this
	* is an important concern as big partitions can easily wreak havoc and cause OOM errors, especially
	* during shuffles.
	*
	* Work is underway to decouple the data partitioning from the indexes using different RDDs and/or
	* broadcast variables, in order to alleviate this problem.
	*
	* ==Queries==
	*
	* The queries can either be of type [[dsl.DslQuery DslQuery]] or of type [[RawQuery]]. In the latter
	* case the way they are interpreted is implementation-dependent.
	*
	* ==Functionalities==
	*
	* The functionalities provided are broadly separable in two categories:
	*  - '''search'''
	*  - '''query join'''
	*
	* '''Search''' functionalities are implemented with methods with `search` in their name, and are
	* of two kinds:
	*  - those that return results directly, similar to a `collect()`
	*  - those that return RDDs
	*
	* Obviously, the latter ones are much more suited when many queries are to be executed or when results
	* contain many and/or large elements.
	*
	* '''Query join''' functionalities allow the execution of a join operation on an RDD and a
	* SearchableRDD, in which the join predicate is a query which is built from each of the elements
	* of the other RDD and executed on the SearchableRDD.
	* The other RDD can be the SearchableRDD itself.
	*
	* ==Variations==
	*
	* For methods of both functionalities, two variations are available:
	*  - '''light'''
	*  - '''transformer''' which returns the result of applying the provided transformer function to the results
	*
	* '''Light''' variations are indicated by a `light` prefix to the corresponding base method. They
	* return `Long` ids instead of elements as results; this means that results use much less memory.
	*
	* '''Transformer''' variations specify an additional transformer function which is applied to the
	* elements; this allows the extraction of the relevant information from reults to be done as soon
	* as possible, again helping with memory usage.
	*
	* @note $consistentRDD
	*
	* @see [[org.apache.spark.rdd.RDD#zipWithUniqueId]]
	*
	* @tparam T the type of the elements.
	*
	* @define consistentRDD  Some operations use zipWithUniqueId internally; as such, the same caveats
	*                        apply, namely that the assigned id is order-dependent. This means that
	*                        '''the input RDD must be consistent upon reevaluation''', that is, the
	*                        elements inside the partitions and their ordering must be guaranteed to not
	*                        change between reevaluations. Otherwise, the behaviour is undefined.
	*
	* @define ephemeralIDs These ids are ephemeral, and can change between instances of this RDD;
	*                      they are only meaningful when used in combination with the same RDD that
	*                      provided them.
	*
	* @define intermediateResults Setting the maximum number of intermediate results to be lower than
	*                             the maximum number of results can lead to good results not being
	*                             returned, especially with non-uniform data distributions.
	* @groupdesc Search These operations provide search functionality.
	* @groupprio Search 1
	* @groupname QueryJoin Query Join
	* @groupdesc QueryJoin  These operations provide query join functionality.
	* @groupprio QueryJoin 2
	*/
abstract class SearchableRDD[T](
    @transient private var _sc: SparkContext,
    @transient private var deps: Seq[Dependency[_]])
   (implicit ct: ClassTag[T])
	extends RDD[T](_sc, deps) {
	import SearchableRDD.sameAsMaxHits
	import IDFUtils.calculateTermIDFs

	/** Returns an `Array` of elements matching the `query` with their scores, returning at most
		* `maxHits` results.
		*
		* Setting `maxHitsPerIndex` limits the size of intermediate results. It must be a positive value
		* between `1` and `maxHits` (both inclusive). The (internally handled) default is `maxHits`.
		*
		* The resulting `Array` is produced by efficiently aggregating partial results in a tree-level
		* pattern.
		*
		* @note $intermediateResults
		*
		* @see [[org.apache.spark.rdd.RDD#treeAggregate]]
		*
		* @group Search
		*/
	def aggregatingSearch(query: Query,
	                      maxHits: Int,
	                      maxHitsPerIndex: Int = sameAsMaxHits)
	                     : Array[(T, Double)]

	/** Like [[aggregatingSearchWithResultsTransformer(query:it\.agilelab\.bigdata\.spark\.search\.Query,maxHits:Int,maxHitsPerIndex:Int)* aggregatingSearch(Query,Int,Int)]],
		* but specifying a `transformer` function to be applied to the result elements.
		*
		* @group Search
		*/
	def aggregatingSearchWithResultsTransformer[V](query: Query,
	                                               maxHits: Int,
	                                               resultsTransformer: T => V,
	                                               maxHitsPerIndex: Int = sameAsMaxHits)
	                                       : Array[(V, Double)]

	/** Like [[aggregatingSearchWithResultsTransformer(query:it\.agilelab\.bigdata\.spark\.search\.Query,maxHits:Int,maxHitsPerIndex:Int)* aggregatingSearch(Query,Int,Int)]],
		* but returns the ids of the resulting elements.
		*
		* @note $ephemeralIDs
		* @group Search
		*/
	def lightAggregatingSearch(query: Query,
	                           maxHits: Int,
	                           maxHitsPerIndex: Int = sameAsMaxHits)
	                          : Array[(Long, Double)]

	/** Returns an `RDD` of elements matching the `query`, returning at most `maxHits` results.
	  *
	  * Setting `maxHitsPerIndex` limits the size of intermediate results. It must be a positive value
	  * between `1` and `maxHits` (both inclusive). The (internally handled) default is `maxHits`.
	  *
	  * @note $intermediateResults
		*
		* @group Search
	  */
	def search(query: Query,
	           maxHits: Int,
	           maxHitsPerIndex: Int = sameAsMaxHits)
	          : RDD[(T, Double)]

	/** Like [[searchWithResultsTransformer(query:it\.agilelab\.bigdata\.spark\.search\.Query,maxHits:Int,maxHitsPerIndex:Int)* search(Query,Int,Int)]],
	  * but specifying a `transformer` function to be applied to the result elements.
		*
		* @group Search
	  */
	def searchWithResultsTransformer[V](query: DslQuery,
	                                    maxHits: Int,
	                                    resultsTransformer: T => V,
	                                    maxHitsPerIndex: Int = sameAsMaxHits)
	                                   : RDD[(V, Double)]

	/** Like [[searchWithResultsTransformer(query:it\.agilelab\.bigdata\.spark\.search\.Query,maxHits:Int,maxHitsPerIndex:Int)* search(Query,Int,Int)]],
	  * but returns the ids of the resulting elements.
	  *
	  * @note $ephemeralIDs
		* @group Search
	  */
	def lightSearch(query: Query,
	                maxHits: Int,
	                maxHitsPerIndex: Int = sameAsMaxHits)
	               : RDD[(Long, Double)]

	/** Returns an `RDD` of elements matching the `queries`, returning at most `maxHits` results for
	  * each query.
	  *
	  * The queries must be provided with a unique id for each query, as an `Iterator` of `(id, query)`
	  * pairs. The results of each query are returned associated with this unique id as `(id, results)`
	  * pairs in the returned RDD; each `results` is an `Array` of `(element, score)` pairs.
	  *
	  * Setting `maxHitsPerIndex` limits the size of intermediate results. It must be a positive value
	  * between `1` and `maxHits` (both inclusive). The (internally handled) default is `maxHits`.
	  *
	  * @note $intermediateResults
		*
		* @group Search
	  */
	def batchSearch(queries: Iterable[(Long, DslQuery)],
	                maxHits: Int,
	                maxHitsPerIndex: Int = sameAsMaxHits)
	               : RDD[(Long, Array[(T, Double)])]

	/** Like [[batchSearchWithResultsTransformer(queries:Iterator[(Long,it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery)],maxHits:Int,maxHitsPerIndex:Int)* batchSearch(Iterator[(Long,DslQuery)],Int,Int)]],
	  * but specifying a `transformer` function to be applied to the result elements.
		*
		* @group Search
	  */
	def batchSearchWithResultsTransformer[V](queries: Iterator[(Long, DslQuery)],
	                                         maxHits: Int,
	                                         resultsTransformer: T => V,
	                                         maxHitsPerIndex: Int = sameAsMaxHits)
	                                        : RDD[(Long, Array[(V, Double)])]

	/** Like [[batchSearchWithResultsTransformer(queries:Iterator[(Long,it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery)],maxHits:Int,maxHitsPerIndex:Int)* batchSearch(Iterator[(Long,DslQuery)],Int,Int)]],
	  * but returns the ids of the resulting elements.
	  *
	  * @note $ephemeralIDs
		* @group Search
	  */
	def lightBatchSearch(queries: Iterator[(Long, DslQuery)],
	                     maxHits: Int,
	                     maxHitsPerIndex: Int = sameAsMaxHits)
	                    : RDD[(Long, Array[(Long, Double)])]

	/** Like [[batchSearchWithResultsTransformer(queries:Iterator[(Long,it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery)],maxHits:Int,maxHitsPerIndex:Int)* batchSearch(Iterator[(Long,DslQuery)],Int,Int)]],
	  * but uses [[RawQuery]] type queries instead of [[dsl.DslQuery]].
		*
		* @group Search
	  */
	def batchSearchRaw(queries: Iterator[(Long, RawQuery)],
	                   maxHits: Int,
	                   maxHitsPerIndex: Int = sameAsMaxHits)
	                  : RDD[(Long, Array[(T, Double)])]

	/** Like [[batchSearchWithResultsTransformer[V](queries:Iterator[(Long,it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery)],maxHits:Int,transformer:T=>V,maxHitsPerIndex:Int)* batchSearch(Iterator[(Long,DslQuery)],Int,T=>V,Int)]],
	  * but uses [[RawQuery]] type queries instead of [[dsl.DslQuery]].
		*
		* @group Search
	  */
	def batchSearchRawWithResultsTransformer[V](queries: Iterator[(Long, RawQuery)],
	                                            maxHits: Int,
	                                            resultsTransformer: T => V,
	                                            maxHitsPerIndex: Int = sameAsMaxHits)
	                                           : RDD[(Long, Array[(V, Double)])]

	/** Like [[lightBatchSearch(queries:Iterator[(Long,it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery)],maxHits:Int,maxHitsPerIndex:Int)* lightBatchSearch(Iterator[(Long,DslQuery)],Int,Int)]],
	  * but uses [[RawQuery]] type queries instead of [[dsl.DslQuery]].
		*
		* @group Search
	  */
	def lightBatchSearchRaw(queries: Iterator[(Long, RawQuery)],
	                        maxHits: Int,
	                        maxHitsPerIndex: Int = sameAsMaxHits)
	                       : RDD[(Long, Array[(Long, Double)])]

	/** Like [[queryJoinWithResultsTransformer[U](other:org\.apache\.spark\.rdd\.RDD[U],queryGenerator:U=>it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery,maxHits:Int)* queryJoin[U](RDD[U],U=>DslQuery,Int)]],
	  * but with `this` as the `other` RDD; that is, a query self join.
		*
		* @group QueryJoin
	  */
	def queryJoin(queryGenerator: T => DslQuery, maxHits: Int): RDD[(T, Array[(T, Double)])] = queryJoin(this, queryGenerator, maxHits)

	/** Returns an `RDD` that contains the result of the query join between `this` and `other`.
	  *
	  * A query join is a join in which the predicate is a query. From each element of `other`, a query
	  * is obtained by applying `queryGenerator`. Then each query is ran against `this`, and the
	  * `maxHits` results produced are joined with the element originating the query.
	  *
	  * Queries are executed in batches, with a batch for each partition of `other`.
		*
		* @group QueryJoin
	  */
	def queryJoin[U: ClassTag](other: RDD[U], queryGenerator: U => DslQuery, maxHits: Int): RDD[(U, Array[(T, Double)])]

	/** Like [[queryJoinWithResultsTransformer[U,V](other:org\.apache\.spark\.rdd\.RDD[U],queryGenerator:U=>it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery,maxHits:Int,transformer:T=>V)* queryJoin[U,V](RDD[U],U=>DslQuery,Int,T=>V)]],
	  * but with `this` as the `other` RDD; that is, a query self join.
		*
		* @group QueryJoin
	  */
	def queryJoinWithResultsTransformer[V: ClassTag](queryGenerator: T => DslQuery, maxHits: Int, resultsTransformer: T => V): RDD[(T, Array[(V, Double)])] = queryJoinWithResultsTransformer(this, queryGenerator, maxHits, resultsTransformer)

	/** Like [[queryJoinWithResultsTransformer[U](other:org\.apache\.spark\.rdd\.RDD[U],queryGenerator:U=>it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery,maxHits:Int)* queryJoin[U](RDD[U],U=>DslQuery,Int)]],
	  * but specifying a `transformer` function to be applied to the result elements.
		*
		* @group QueryJoin
	  */
	def queryJoinWithResultsTransformer[U: ClassTag, V: ClassTag](other: RDD[U], queryGenerator: U => DslQuery, maxHits: Int, resultsTransformer: T => V): RDD[(U, Array[(V, Double)])]

	/** Like [[lightQueryJoin[U](other:org\.apache\.spark\.rdd\.RDD[U],queryGenerator:U=>it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery,maxHits:Int)* lightQueryJoin[U](RDD[U],U=>DslQuery,Int)]],
	  * but with `this` as the `other` RDD; that is, a query self join.
		*
		* @group QueryJoin
	  */
	def lightQueryJoin(queryGenerator: T => DslQuery, maxHits: Int): RDD[(T, Array[(Long, Double)])] = lightQueryJoin(this, queryGenerator, maxHits)

	/** Like [[queryJoinWithResultsTransformer[U](other:org\.apache\.spark\.rdd\.RDD[U],queryGenerator:U=>it\.agilelab\.bigdata\.spark\.search\.dsl\.DslQuery,maxHits:Int)* queryJoin[U](RDD[U],U=>DslQuery,Int)]],
	  * but returns the ids of the resulting elements.
	  *
	  * @note $ephemeralIDs
		* @group QueryJoin
	  */
	def lightQueryJoin[U: ClassTag](other: RDD[U], queryGenerator: U => DslQuery, maxHits: Int): RDD[(U, Array[(Long, Double)])]

	/** Returns the element of this `SearchableRDD` with corresponds to the provided `id`, if it exists. */
	def getElement(id: Long): Option[T]

	/** Like [[getElement(id:Long)* getElement(Long)]], but for an `Array` of ids. */
	def getElements(ids: Array[Long]): Array[(Long, Option[T])]

	/**
		* Returns the document counts for this SearchableRDD.
		* The key for the map is the field name; the value is the number of documents.
		*/
	def getDocumentCounts: Map[String, Long]

	/**
		* Returns the terms counts for this SearchableRDD.
		* The key for the first map is the field name; the one for the second map is the term; the value is the number of
		* occurrences of the term in that field across all documents.
		*/
	def getTermCounts: Map[String, Map[String, Long]]

	/**
		* Returns the term IDFs for this SearchableRDD.
		* The key for the first map is the field name; the one for the second map is the term; the value is the IDF of
		* of the term in that field.
		*/
	def getTermIDFs: Map[String, Map[String, Float]] = {
		// obtain document and term counts
		val docCounts = getDocumentCounts
		val termCounts = getTermCounts

		calculateTermIDFs(docCounts, termCounts)
	}

	/** Returns information about the indices.
		*
		*/
	def getIndicesInfo: IndicesInfo
}
object SearchableRDD {
	/** Constant for default value of `maxHitsPerIndex`. */
	final val sameAsMaxHits = Int.MinValue

	/** Returns a new RDD created from `results` by sorting by their score (descending) and truncating
		* it to the top `maxHits` by filtering it.
		*/
	def sortResults[E](results: RDD[(E, Double)], maxHits: Int): RDD[(E, Double)] = {
		results.sortBy({ case (doc, score) => score }, false)
			.zipWithIndex
			.filter { case (res, index) => index < maxHits } // indices start at 0
			.map { case (res, index) => res }
	}

	/** Returns an `RDD` built by aggregating the `Iterator`s with the same key in `result` into `Array`s
		* by repetitively choosing the top `maxHits` results in descending score order.
		*/
	def aggregateResultsByKey[E](results: RDD[(Long, Iterator[(E, Double)])], maxHits: Int): RDD[(Long, Array[(E, Double)])] = {
		results.aggregateByKey(Array[(E, Double)]())(
			{
				case (res1, res2) => merge(res1, res2.toArray, maxHits)
			},
			{
				case (res1, res2) => merge(res1, res2, maxHits)
			})
	}

	/** Returns the actual value to be used as `maxHitsPerIndex` if it is different from the constant
		* [[sameAsMaxHits]] and it is valid; if it is not valid, throws an exception. If it is equal to
		* [[sameAsMaxHits]], it simply returns `maxHits`.
		*/
	def getMHPIActual(maxHitsPerIndex: Int, maxHits: Int): Int = {
		if (maxHitsPerIndex == sameAsMaxHits)
			maxHits
		else {
			require(maxHitsPerIndex > 0 && maxHitsPerIndex <= maxHits)
			maxHitsPerIndex
		}
	}

	/** Combine two maps by summing the values.
		*/
	def combineDocumentCountsMaps(m1: Map[String, Long], m2: Map[String, Long]) = {
		// ++ combines maps replacing items with the same key with the ones form the right-side map
		// the map on termsMap2 makes sure the items on the right of ++ are the sum of any items with the same key
		val docCounts = m1 ++ m2 map {
			case (field, count) => field -> (count + m1.getOrElse(field, 0l))
		}

		docCounts
	}

	/** Combine two maps-of-maps, assuming the outer maps have the same keyset, by combining each inner map by summing
		* the values.
 		*/
	def combineTermCountsMaps(m1: Map[String, Map[String, Long]], m2: Map[String, Map[String, Long]]) = {
		// map on items from first map
		m1 map {
			case (fieldName, termsMap1) =>
				// get corresponding terms map from second map
				val termsMap2 = m2(fieldName)

				// ++ combines maps replacing items with the same key with the ones form the right-side map
				// the map on termsMap2 makes sure the items on the right of ++ are the sum of any items with the same key
				val termsMap = termsMap1 ++ termsMap2 map {
					case (term, count) => term -> (count + termsMap1.getOrElse(term, 0l))
				}

				// return new mapping
				fieldName -> termsMap
		}
	}
}


text:
<?php

namespace DTS\eBaySDK\BulkDataExchange\Services;

class BulkDataExchangeService extends \DTS\eBaySDK\BulkDataExchange\Services\BulkDataExchangeBaseService
{
    /**
     * @param array $config Optional configuration option values.
     * @param \DTS\eBaySDK\Interfaces\HttpClientInterface $httpClient The object that will handle sending requests to the API.
     */
    public function __construct($config = array(), \DTS\eBaySDK\Interfaces\HttpClientInterface $httpClient = null)
    {
        parent::__construct($config, $httpClient);
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\CreateUploadJobRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\CreateUploadJobResponse
     */
    public function createUploadJob(\DTS\eBaySDK\BulkDataExchange\Types\CreateUploadJobRequest $request)
    {
        return $this->callOperation(
            'createUploadJob',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\CreateUploadJobResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\StartUploadJobRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\StartUploadJobResponse
     */
    public function startUploadJob(\DTS\eBaySDK\BulkDataExchange\Types\StartUploadJobRequest $request)
    {
        return $this->callOperation(
            'startUploadJob',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\StartUploadJobResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\AbortJobRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\AbortJobResponse
     */
    public function abortJob(\DTS\eBaySDK\BulkDataExchange\Types\AbortJobRequest $request)
    {
        return $this->callOperation(
            'abortJob',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\AbortJobResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\GetJobsRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\GetJobsResponse
     */
    public function getJobs(\DTS\eBaySDK\BulkDataExchange\Types\GetJobsRequest $request)
    {
        return $this->callOperation(
            'getJobs',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\GetJobsResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\GetJobStatusRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\GetJobStatusResponse
     */
    public function getJobStatus(\DTS\eBaySDK\BulkDataExchange\Types\GetJobStatusRequest $request)
    {
        return $this->callOperation(
            'getJobStatus',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\GetJobStatusResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\StartDownloadJobRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\StartDownloadJobResponse
     */
    public function startDownloadJob(\DTS\eBaySDK\BulkDataExchange\Types\StartDownloadJobRequest $request)
    {
        return $this->callOperation(
            'startDownloadJob',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\StartDownloadJobResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\CreateRecurringJobRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\CreateRecurringJobResponse
     */
    public function createRecurringJob(\DTS\eBaySDK\BulkDataExchange\Types\CreateRecurringJobRequest $request)
    {
        return $this->callOperation(
            'createRecurringJob',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\CreateRecurringJobResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\DeleteRecurringJobRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\DeleteRecurringJobResponse
     */
    public function deleteRecurringJob(\DTS\eBaySDK\BulkDataExchange\Types\DeleteRecurringJobRequest $request)
    {
        return $this->callOperation(
            'deleteRecurringJob',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\DeleteRecurringJobResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobsRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobsResponse
     */
    public function getRecurringJobs(\DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobsRequest $request)
    {
        return $this->callOperation(
            'getRecurringJobs',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobsResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobExecutionStatusRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobExecutionStatusResponse
     */
    public function getRecurringJobExecutionStatus(\DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobExecutionStatusRequest $request)
    {
        return $this->callOperation(
            'getRecurringJobExecutionStatus',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobExecutionStatusResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobExecutionHistoryRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobExecutionHistoryResponse
     */
    public function getRecurringJobExecutionHistory(\DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobExecutionHistoryRequest $request)
    {
        return $this->callOperation(
            'getRecurringJobExecutionHistory',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\GetRecurringJobExecutionHistoryResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\ActivateRecurringJobRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\ActivateRecurringJobResponse
     */
    public function activateRecurringJob(\DTS\eBaySDK\BulkDataExchange\Types\ActivateRecurringJobRequest $request)
    {
        return $this->callOperation(
            'activateRecurringJob',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\ActivateRecurringJobResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\SuspendRecurringJobRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\SuspendRecurringJobResponse
     */
    public function suspendRecurringJob(\DTS\eBaySDK\BulkDataExchange\Types\SuspendRecurringJobRequest $request)
    {
        return $this->callOperation(
            'suspendRecurringJob',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\SuspendRecurringJobResponse'
        );
    }

    /**
     * @param \DTS\eBaySDK\BulkDataExchange\Types\AbortRecurringJobExecutionRequest $request
     * @return \DTS\eBaySDK\BulkDataExchange\Types\AbortRecurringJobExecutionResponse
     */
    public function abortRecurringJobExecution(\DTS\eBaySDK\BulkDataExchange\Types\AbortRecurringJobExecutionRequest $request)
    {
        return $this->callOperation(
            'abortRecurringJobExecution',
            $request,
            '\DTS\eBaySDK\BulkDataExchange\Types\AbortRecurringJobExecutionResponse'
        );
    }
}

redpajama_set_name: RedPajamaGithub


text:
import pytest

from plenum.test.helper import sdk_send_random_and_check, waitForViewChange
from plenum.test.node_catchup.helper import ensure_all_nodes_have_same_data
from plenum.test.test_node import ensureElectionsDone
from plenum.test.view_change.helper import restart_node, nodes_received_ic
from plenum.test.view_change_service.helper import send_test_instance_change
from stp_core.loop.eventually import eventually

@pytest.fixture(scope="module")
def tconf(tconf):
    old_val = tconf.ToleratePrimaryDisconnection
    tconf.ToleratePrimaryDisconnection = 1000
    yield tconf
    tconf.ToleratePrimaryDisconnection = old_val

def test_vc_finished_when_less_than_quorum_started(looper, txnPoolNodeSet,
                                                   sdk_wallet_client, sdk_pool_handle,
                                                   tconf, tdir, allPluginsPath):

    alpha, beta, gamma, delta = txnPoolNodeSet

    # Delta and Gamma send InstanceChange for all nodes.
    for node in [gamma, delta]:
        send_test_instance_change(node)
        looper.run(
            eventually(nodes_received_ic, txnPoolNodeSet, node, 1))

    # Restart Alpha, Beta, Gamma
    for node in [alpha, beta, gamma]:
        restart_node(looper, txnPoolNodeSet, node, tconf, tdir, allPluginsPath)
    alpha, beta, gamma, delta = txnPoolNodeSet

    # Send InstanceChange from Beta for all nodes
    send_test_instance_change(beta)

    # Ensure that pool is still functional
    sdk_send_random_and_check(looper, txnPoolNodeSet,
                              sdk_pool_handle, sdk_wallet_client, 1)

    # Alpha and Gamma send InstanceChange for all nodes.
    for node in [gamma, alpha]:
        send_test_instance_change(node)

    ensureElectionsDone(looper, txnPoolNodeSet)
    waitForViewChange(looper, txnPoolNodeSet, expectedViewNo=1,
                      customTimeout=tconf.NEW_VIEW_TIMEOUT)

    # Ensure that pool is still functional
    sdk_send_random_and_check(looper, txnPoolNodeSet,
                              sdk_pool_handle, sdk_wallet_client, 1)
    ensure_all_nodes_have_same_data(looper, txnPoolNodeSet)


text:
module RelationsHelper

  def null_relation
    klass.null_relation
  end

  def any_relation
    ActiveRecord::Relation.any_instance
  end

  def mock_relation
    @mock_relation ||= mock('relation')
  end
end

ActiveRecord::Base.instance_eval do
  # Soon to be replaced by actual functionality in Rails 4.
  def null_relation
    limit(0)
  end
end

RSpec.lazy_configure { |c| c.include RelationsHelper }


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Debugging with GDB: system</title>

<meta name="description" content="Debugging with GDB: system">
<meta name="keywords" content="Debugging with GDB: system">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="List-of-Supported-Calls.html#List-of-Supported-Calls" rel="up" title="List of Supported Calls">
<link href="Protocol_002dspecific-Representation-of-Datatypes.html#Protocol_002dspecific-Representation-of-Datatypes" rel="next" title="Protocol-specific Representation of Datatypes">
<link href="isatty.html#isatty" rel="prev" title="isatty">

Previous: isatty, Up: List of Supported Calls   [Contents][Index]

system

Synopsis:

int system(const char *command);

Request:

‘<samp>Fsystem,<var>commandptr</var>/<var>len</var></samp>’

Return value:

If <var>len</var> is zero, the return value indicates whether a shell is
available.  A zero return value indicates a shell is not available.
For non-zero <var>len</var>, the value returned is -1 on error and the
return status of the command otherwise.  Only the exit status of the
command is returned, which is extracted from the host’s system
return value by calling WEXITSTATUS(retval).  In case
<samp>/bin/sh</samp> could not be executed, 127 is returned.

Errors:

EINTR

The call was interrupted by the user.

GDB takes over the full task of calling the necessary host calls
to perform the system call.  The return value of system on
the host is simplified before it’s returned
to the target.  Any termination signal information from the child process
is discarded, and the return value consists
entirely of the exit status of the called command.

Due to security concerns, the system call is by default refused
by GDB.  The user has to allow this call explicitly with the
set remote system-call-allowed 1 command.

set remote system-call-allowed

Control whether to allow the system calls in the File I/O
protocol for the remote target.  The default is zero (disabled).

show remote system-call-allowed

Show whether the system calls are allowed in the File I/O
protocol.


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Mycologia 23(5): 379 (1931)

#### Original name
Cercospora calopogonii F. Stevens & Solheim

### Remarks
null


text:
using namespace mcld;

ARMPLT0::ARMPLT0(SectionData& pParent)
  : PLT::Entry<sizeof(arm_plt0)>(pParent) {}

ARMPLT1::ARMPLT1(SectionData& pParent)
  : PLT::Entry<sizeof(arm_plt1)>(pParent) {}

//===----------------------------------------------------------------------===//
// ARMPLT

ARMPLT::ARMPLT(LDSection& pSection,
               ARMGOT &pGOTPLT)
  : PLT(pSection), m_GOT(pGOTPLT), m_PLTEntryIterator() {
  new ARMPLT0(*m_SectionData);
  m_PLTEntryIterator = m_SectionData->begin();
}

ARMPLT::~ARMPLT()
{
}

bool ARMPLT::hasPLT1() const
{
  return (m_SectionData->size() > 1);
}

void ARMPLT::finalizeSectionSize()
{
  uint64_t size = (m_SectionData->size() - 1) * sizeof(arm_plt1) +
                     sizeof(arm_plt0);
  m_Section.setSize(size);

  uint32_t offset = 0;
  SectionData::iterator frag, fragEnd = m_SectionData->end();
  for (frag = m_SectionData->begin(); frag != fragEnd; ++frag) {
    frag->setOffset(offset);
    offset += frag->size();
  }
}

void ARMPLT::reserveEntry(size_t pNum)
{
  ARMPLT1* plt1_entry = 0;

  for (size_t i = 0; i < pNum; ++i) {
    plt1_entry = new (std::nothrow) ARMPLT1(*m_SectionData);

    if (!plt1_entry)
      fatal(diag::fail_allocate_memory_plt);

    m_GOT.reserveGOTPLT();
  }
}

ARMPLT1* ARMPLT::consume()
{
  ++m_PLTEntryIterator;
  assert(m_PLTEntryIterator != m_SectionData->end() &&
         "The number of PLT Entries and ResolveInfo doesn't match");

  return llvm::cast<ARMPLT1>(&(*m_PLTEntryIterator));
}

ARMPLT0* ARMPLT::getPLT0() const {

  iterator first = m_SectionData->getFragmentList().begin();

  assert(first != m_SectionData->getFragmentList().end() &&
         "FragmentList is empty, getPLT0 failed!");

  ARMPLT0* plt0 = &(llvm::cast<ARMPLT0>(*first));

  return plt0;
}

void ARMPLT::applyPLT0() {

  uint64_t plt_base = m_Section.addr();
  assert(plt_base && ".plt base address is NULL!");

  uint64_t got_base = m_GOT.addr();
  assert(got_base && ".got base address is NULL!");

  uint32_t offset = 0;

  if (got_base > plt_base)
    offset = got_base - (plt_base + 16);
  else
    offset = (plt_base + 16) - got_base;

  iterator first = m_SectionData->getFragmentList().begin();

  assert(first != m_SectionData->getFragmentList().end() &&
         "FragmentList is empty, applyPLT0 failed!");

  ARMPLT0* plt0 = &(llvm::cast<ARMPLT0>(*first));

  uint32_t* data = 0;
  data = static_cast<uint32_t*>(malloc(ARMPLT0::EntrySize));

  if (!data)
    fatal(diag::fail_allocate_memory_plt);

  memcpy(data, arm_plt0, ARMPLT0::EntrySize);
  data[4] = offset;

  plt0->setValue(reinterpret_cast<unsigned char*>(data));
}

void ARMPLT::applyPLT1() {

  uint64_t plt_base = m_Section.addr();
  assert(plt_base && ".plt base address is NULL!");

  uint64_t got_base = m_GOT.addr();
  assert(got_base && ".got base address is NULL!");

  ARMPLT::iterator it = m_SectionData->begin();
  ARMPLT::iterator ie = m_SectionData->end();
  assert(it != ie && "FragmentList is empty, applyPLT1 failed!");

  uint32_t GOTEntrySize = ARMGOTEntry::EntrySize;
  uint32_t GOTEntryAddress =
    got_base +  GOTEntrySize * 3;

  uint64_t PLTEntryAddress =
    plt_base + ARMPLT0::EntrySize; //Offset of PLT0

  ++it; //skip PLT0
  uint64_t PLT1EntrySize = ARMPLT1::EntrySize;
  ARMPLT1* plt1 = NULL;

  uint32_t* Out = NULL;
  while (it != ie) {
    plt1 = &(llvm::cast<ARMPLT1>(*it));
    Out = static_cast<uint32_t*>(malloc(ARMPLT1::EntrySize));

    if (!Out)
      fatal(diag::fail_allocate_memory_plt);

    // Offset is the distance between the last PLT entry and the associated
    // GOT entry.
    int32_t Offset = (GOTEntryAddress - (PLTEntryAddress + 8));

    Out[0] = arm_plt1[0] | ((Offset >> 20) & 0xFF);
    Out[1] = arm_plt1[1] | ((Offset >> 12) & 0xFF);
    Out[2] = arm_plt1[2] | (Offset & 0xFFF);

    plt1->setValue(reinterpret_cast<unsigned char*>(Out));
    ++it;

    GOTEntryAddress += GOTEntrySize;
    PLTEntryAddress += PLT1EntrySize;
  }

  m_GOT.applyGOTPLT(plt_base);
}

uint64_t ARMPLT::emit(MemoryRegion& pRegion)
{
  uint64_t result = 0x0;
  iterator it = begin();

  unsigned char* buffer = pRegion.getBuffer();
  memcpy(buffer, llvm::cast<ARMPLT0>((*it)).getValue(), ARMPLT0::EntrySize);
  result += ARMPLT0::EntrySize;
  ++it;

  ARMPLT1* plt1 = 0;
  ARMPLT::iterator ie = end();
  while (it != ie) {
    plt1 = &(llvm::cast<ARMPLT1>(*it));
    memcpy(buffer + result, plt1->getValue(), ARMPLT1::EntrySize);
    result += ARMPLT1::EntrySize;
    ++it;
  }
  return result;
}


text:
@interface YR_GuideViewController : UIViewController

@end


text:
package q154869;

import org.junit.Test;

import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static q154869.Disease.Death;
import static q154869.Disease.Diabetes;
import static q154869.Disease.Fever;
import static q154869.Disease.Healthy;
import static q154869.Disease.Tuberculosis;
import static q154869.Medicine.Antibiotic;
import static q154869.Medicine.Aspirin;
import static q154869.Medicine.Insulin;
import static q154869.Medicine.None;
import static q154869.Medicine.Paracetamol;

public class MedicineTest {
    Patients tuberculous = spy(new Patients(Tuberculosis, 1));
    Patients diabetics = spy(new Patients(Diabetes, 1));
    Patients healthy = spy(new Patients(Healthy, 1));
    Patients feverish = spy(new Patients(Fever, 1));
    Patients death = spy(new Patients(Death, 1));

    Quarantine quarantine = new Quarantine(tuberculous, diabetics, healthy, feverish, death);

    @Test
    public void none_kill_diabetics() {
        None.on(quarantine);
        verify(diabetics).becomes(death);
    }

    @Test
    public void aspirin_cure_feverish() {
        Aspirin.on(quarantine);
        verify(feverish).becomes(healthy);
    }

    @Test
    public void antibiotic_cure_tuberculosis() {
        Antibiotic.on(quarantine);
        verify(tuberculous).becomes(healthy);
    }

    @Test
    public void insuline_prevent_diabetic_to_die() {
        Insulin.on(quarantine);
        verify(diabetics, never()).becomes(death);
    }

    @Test
    public void paracetamol_cure_feverish() {
        Paracetamol.on(quarantine);
        verify(feverish).becomes(healthy);
    }

}


text:
Example package using `@babel/parser` instead of the default Acorn parser.

## Installation

```sh
cd packages/babel-parser-example
npm install
```

## Usage

```js
> require("./index.js")
{ __esModule: true, name: "module.js" }
```


text:
title: Alternative lyrics to "Poison And Wine" by The Civil Wars
category: Misc
tags:
- YouTube
- poem
- Civil Wars
- John Paul White
- Joy Williams
- lyrics
- music
- Poison & Wine
- video
---
I ran across "Poison and Wine" by The Civil Wars yesterday in a YouTube playlist and instantly knew I'd found the song that'll haunt me for the rest of the week (if not longer). Such intense emotions and spirit, not the mention the meaning behind the words.
Anyhow, the song is an inspiring one and below are alternate lyrics, composed by yours truly... that convey a slightly different message.

Alternative lyrics to "Poison And Wine" by The Civil Wars

```
[John]: The saddest part you don't even know
[Joy]: What used to be is gone somehow
[John]: I don't see you, you don't see me
[Joy]: I keep wishing we could just be
Oh, do you love me, how can I tell?
Oh do you love me, how can I tell?
Oh, do you love me, how can I tell?
How can I tell?
[Joy]: I wish you'd come and hug me tight
[John]: Why must it always be fight or flight?
[Joy]: Oh, your love could save me, you could be mine
[John]: Why do you fear of what's been always thine?
Oh, do you love me, how can I tell?
Oh, do you love me, how can I tell?
Oh, do you love me, how can I tell?
Oh, do you love me, how can I tell?
Oh, do you love me, how can I tell?
Oh, do you love me, how can I tell?
Oh, do you love me, how can I tell?
How can I tell?
How can I tell?
How can I tell?
How can I tell?
How can I tell?
```
Another song/video to watch out for: Taylor Swift "Safe and Sound" Official Music Video ft. The Civil Wars that recently themed The Hunger Games (movie).


text:
<?php

class HTMLPurifier_AttrDef_HTML_NmtokensTest extends HTMLPurifier_AttrDefHarness
{

    public function setUp()
    {
        parent::setUp();
        $this->def = new HTMLPurifier_AttrDef_HTML_Nmtokens();
    }

    public function testDefault()
    {
        $this->assertDef('valid');
        $this->assertDef('a0-_');
        $this->assertDef('-valid');
        $this->assertDef('_valid');
        $this->assertDef('double valid');

        $this->assertDef('0invalid', false);
        $this->assertDef('-0', false);

        // test conditional replacement
        $this->assertDef('validassoc 0invalid', 'validassoc');

        // test whitespace leniency
        $this->assertDef(" double\nvalid\r", 'double valid');

        // test case sensitivity
        $this->assertDef('VALID');

    }

}

// vim: et sw=4 sts=4


text:
<?php comment_form_title(__('Leave a Reply', 'roots'), __('Leave a Reply to %s', 'roots')); ?>

<?php cancel_comment_reply_link(); ?>

    <?php if (get_option('comment_registration') && !is_user_logged_in()) : ?>

<?php printf(__('You must be logged in to post a comment.', 'roots'), wp_login_url(get_permalink())); ?>

    <?php else : ?>
        <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
            <?php if (is_user_logged_in()) : ?>

                    <?php printf(__('Logged in as %s.', 'roots'), get_option('siteurl'), $user_identity); ?>
                    <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php __('Log out of this account', 'roots'); ?>"><?php _e('Log out »', 'roots'); ?>

            <?php else : ?>

                    <?php _e('Name', 'roots'); echo $req ? __(' (required)', 'roots') : '' ?>
                    <input type="text" class="form-control" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" <?php echo $req ? 'aria-required="true"' : '' ?>>

                    <?php _e('Email (will not be published)', 'roots'); echo $req ? __(' (required)', 'roots') : '' ?>
                    <input type="email" class="form-control" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" <?php echo $req ? 'aria-required="true"' : '' ?>>

                    <?php _e('Website', 'roots'); ?>
                    <input type="url" class="form-control" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22">

            <?php endif; ?>

                <?php _e('Comment', 'roots'); ?>
                <textarea name="comment" id="comment" class="form-control" rows="5" aria-required="true"></textarea>

<input name="submit" class="btn btn-primary" type="submit" id="submit" value="<?php _e('Submit Comment', 'roots'); ?>">

            <?php comment_id_fields(); ?>
            <?php do_action('comment_form', $post->ID); ?>
        </form>
    <?php endif; ?>


text:
composer
storage/logs/*
!important storage/logs/index.html
storage/session/*
!important storage/session/index.html
storage/resourches/*
!important storage/resourches/index.html


text:
This short semester's project includes android and web interface, here is the core training code, most for experiment so could be hard to read. This repo will be reorganized when there is time avalable.

## some examples


text:
#pragma once

#include "il2cpp-config.h"

#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif

#include <stdint.h>

#include "mscorlib_System_Collections_Generic_Comparer_1_gen2320268068.h"

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif

// System.Collections.Generic.GenericComparer`1<System.TimeSpan>
struct  GenericComparer_1_t1168234453  : public Comparer_1_t2320268068
{
public:

public:
};

#ifdef __clang__
#pragma clang diagnostic pop
#endif


text:
class CreateUserGroups < ActiveRecord::Migration
  def self.up
    create_table :user_groups do |t|
      t.string :name, :null => false
      t.string :description
      # membership_source will be 'ldap' or 'local'
      t.string :membership_source, :null => false
      t.integer :lock_version, :default => 0

      t.timestamps
    end
    create_table :members_user_groups, :id => false do |t|
      t.integer :user_group_id, :null => false
      t.integer :member_id, :null => false
    end
  end

  def self.down
    drop_table :members_user_groups
    drop_table :user_groups
  end
end


text:
package ircmodbot.module;

import java.io.IOException;
import java.util.ArrayList;
import java.util.NoSuchElementException;

import org.apache.commons.lang3.RandomStringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import ircmodbot.Module;
import ircmodbot.OpHelp;

public class ZoraelMod extends Module
{
   Document doc;
   final String YES_MSG = "is the innovator of this work.";
   final String NO_MSG = "is not the innovator of this work.";
   final int DEF_TRIES = 25;
   final int DEF_DEEP_TRIES = 100;

   public ZoraelMod()
   {
      super("ZOR");
      moduleName = "Zo Zo Mod";
   }

   public void onMessage(String channel, String sender,
      String login, String hostname, String message, ArrayList<String> cmd)
   {
      int linkSize = 5;
      int tries = DEF_TRIES;
      String link = "";

      if(cmd.size() >= 2 && cmd.get(1).equalsIgnoreCase("Youtube"))
      {
         try
         {
            link = generateRandILink("http://youtube.com/watch?v=",
               11, tries);
         }
         catch(NoSuchElementException e)
         {
            bot.sendMessage(channel, "Unable to determine the creator.");
            return;
         }
      }
      else
      {
         if(cmd.size() >= 2 && cmd.get(1).equalsIgnoreCase("deepsearch"))
         {
            linkSize = 7;
            bot.sendMessage(channel,
               "Going into the deep reaches to find his potential work."
               + " This may take some time.");
            tries = DEF_DEEP_TRIES;
         }

         try
         {
            link = generateRandILink("http://i.imgur.com/",linkSize, tries);
         }
         catch(NoSuchElementException e)
         {
            bot.sendMessage(channel, "Unable to determine the creator.");
            return;
         }
      }

      // Create confirmation message.
      String confirmMessage = sender + " ";
      if(Math.random() < 0.5)
         confirmMessage += YES_MSG;
      else
         confirmMessage += NO_MSG;
      // Send all info!
      bot.sendMessage(channel, confirmMessage);
      bot.sendMessage(channel, "PSST... Here is the link... " + link);
   }

   public void onJoin(String channel,String sender,
      String login,String hostname)
   {
      return ;
   }

   public void onPrivateMessage(String sender, String login,
      String hostname, String message, ArrayList<String> cmd)
   {
      onMessage(sender,sender, login, hostname, message, cmd);
   }

   /**
    * Generates a random imgur like link with the link size which represents
    * the imgur like link rand strings in the back of url.
    */
   private String generateRandILink(String startLink, int linkSize, int tries)
      throws NoSuchElementException
   {
      if(linkSize < 0 || tries <= 0 || startLink.length() <= 0)
         return startLink+"random";

      String link = "";
      Elements checker;
      int counter = 0;
      while(true)
      {
         link =  RandomStringUtils.random(linkSize, true, true);
         try
         {
            doc = Jsoup.connect(startLink + link).get();
         }
         catch(IOException e)
         {
            ++counter;
            if(counter >= tries)
               throw new NoSuchElementException();
            continue;
         }
         checker = doc.select("#hallway");
         // Found the link! use it!
         if(checker.size() <= 0)
            break;
      }
      return startLink + link;
   }
}


text:
<?php

/**
 * Base static class for performing query and update operations on the 'consultaanticipo' table.
 *
 *
 *
 * @package propel.generator.hva.om
 */
abstract class BaseConsultaanticipoPeer
{

    /** the default database name for this class */
    const DATABASE_NAME = 'hva';

    /** the table name for this class */
    const TABLE_NAME = 'consultaanticipo';

    /** the related Propel class for this table */
    const OM_CLASS = 'Consultaanticipo';

    /** the related TableMap class for this table */
    const TM_CLASS = 'ConsultaanticipoTableMap';

    /** The total number of columns. */
    const NUM_COLUMNS = 6;

    /** The number of lazy-loaded columns. */
    const NUM_LAZY_LOAD_COLUMNS = 0;

    /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
    const NUM_HYDRATE_COLUMNS = 6;

    /** the column name for the idconsultaanticipo field */
    const IDCONSULTAANTICIPO = 'consultaanticipo.idconsultaanticipo';

    /** the column name for the idconsulta field */
    const IDCONSULTA = 'consultaanticipo.idconsulta';

    /** the column name for the consultaanticipo_fecha field */
    const CONSULTAANTICIPO_FECHA = 'consultaanticipo.consultaanticipo_fecha';

    /** the column name for the consultaanticipo_cantidad field */
    const CONSULTAANTICIPO_CANTIDAD = 'consultaanticipo.consultaanticipo_cantidad';

    /** the column name for the consultaanticipo_nota field */
    const CONSULTAANTICIPO_NOTA = 'consultaanticipo.consultaanticipo_nota';

    /** the column name for the consultaanticipo_tipo field */
    const CONSULTAANTICIPO_TIPO = 'consultaanticipo.consultaanticipo_tipo';

    /** The enumerated values for the consultaanticipo_tipo field */
    const CONSULTAANTICIPO_TIPO_EFECTIVO = 'Efectivo';
    const CONSULTAANTICIPO_TIPO_TARJETA_DE_DEBITO = 'Tarjeta de debito';
    const CONSULTAANTICIPO_TIPO_TARJETA_DE_CREDITO = 'Tarjeta de credito';
    const CONSULTAANTICIPO_TIPO_CHEQUE = 'Cheque';
    const CONSULTAANTICIPO_TIPO_NO_IDENTIFICADO = 'No identificado';
    const CONSULTAANTICIPO_TIPO_SPEI = 'SPEI';

    /** The default string format for model objects of the related table **/
    const DEFAULT_STRING_FORMAT = 'YAML';

    /**
     * An identity map to hold any loaded instances of Consultaanticipo objects.
     * This must be public so that other peer classes can access this when hydrating from JOIN
     * queries.
     * @var        array Consultaanticipo[]
     */
    public static $instances = array();

    /**
     * holds an array of fieldnames
     *
     * first dimension keys are the type constants
     * e.g. ConsultaanticipoPeer::$fieldNames[ConsultaanticipoPeer::TYPE_PHPNAME][0] = 'Id'
     */
    protected static $fieldNames = array (
        BasePeer::TYPE_PHPNAME => array ('Idconsultaanticipo', 'Idconsulta', 'ConsultaanticipoFecha', 'ConsultaanticipoCantidad', 'ConsultaanticipoNota', 'ConsultaanticipoTipo', ),
        BasePeer::TYPE_STUDLYPHPNAME => array ('idconsultaanticipo', 'idconsulta', 'consultaanticipoFecha', 'consultaanticipoCantidad', 'consultaanticipoNota', 'consultaanticipoTipo', ),
        BasePeer::TYPE_COLNAME => array (ConsultaanticipoPeer::IDCONSULTAANTICIPO, ConsultaanticipoPeer::IDCONSULTA, ConsultaanticipoPeer::CONSULTAANTICIPO_FECHA, ConsultaanticipoPeer::CONSULTAANTICIPO_CANTIDAD, ConsultaanticipoPeer::CONSULTAANTICIPO_NOTA, ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO, ),
        BasePeer::TYPE_RAW_COLNAME => array ('IDCONSULTAANTICIPO', 'IDCONSULTA', 'CONSULTAANTICIPO_FECHA', 'CONSULTAANTICIPO_CANTIDAD', 'CONSULTAANTICIPO_NOTA', 'CONSULTAANTICIPO_TIPO', ),
        BasePeer::TYPE_FIELDNAME => array ('idconsultaanticipo', 'idconsulta', 'consultaanticipo_fecha', 'consultaanticipo_cantidad', 'consultaanticipo_nota', 'consultaanticipo_tipo', ),
        BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
    );

    /**
     * holds an array of keys for quick access to the fieldnames array
     *
     * first dimension keys are the type constants
     * e.g. ConsultaanticipoPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
     */
    protected static $fieldKeys = array (
        BasePeer::TYPE_PHPNAME => array ('Idconsultaanticipo' => 0, 'Idconsulta' => 1, 'ConsultaanticipoFecha' => 2, 'ConsultaanticipoCantidad' => 3, 'ConsultaanticipoNota' => 4, 'ConsultaanticipoTipo' => 5, ),
        BasePeer::TYPE_STUDLYPHPNAME => array ('idconsultaanticipo' => 0, 'idconsulta' => 1, 'consultaanticipoFecha' => 2, 'consultaanticipoCantidad' => 3, 'consultaanticipoNota' => 4, 'consultaanticipoTipo' => 5, ),
        BasePeer::TYPE_COLNAME => array (ConsultaanticipoPeer::IDCONSULTAANTICIPO => 0, ConsultaanticipoPeer::IDCONSULTA => 1, ConsultaanticipoPeer::CONSULTAANTICIPO_FECHA => 2, ConsultaanticipoPeer::CONSULTAANTICIPO_CANTIDAD => 3, ConsultaanticipoPeer::CONSULTAANTICIPO_NOTA => 4, ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO => 5, ),
        BasePeer::TYPE_RAW_COLNAME => array ('IDCONSULTAANTICIPO' => 0, 'IDCONSULTA' => 1, 'CONSULTAANTICIPO_FECHA' => 2, 'CONSULTAANTICIPO_CANTIDAD' => 3, 'CONSULTAANTICIPO_NOTA' => 4, 'CONSULTAANTICIPO_TIPO' => 5, ),
        BasePeer::TYPE_FIELDNAME => array ('idconsultaanticipo' => 0, 'idconsulta' => 1, 'consultaanticipo_fecha' => 2, 'consultaanticipo_cantidad' => 3, 'consultaanticipo_nota' => 4, 'consultaanticipo_tipo' => 5, ),
        BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
    );

    /** The enumerated values for this table */
    protected static $enumValueSets = array(
        ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO => array(
            ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO_EFECTIVO,
            ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO_TARJETA_DE_DEBITO,
            ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO_TARJETA_DE_CREDITO,
            ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO_CHEQUE,
            ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO_NO_IDENTIFICADO,
            ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO_SPEI,
        ),
    );

    /**
     * Translates a fieldname to another type
     *
     * @param      string $name field name
     * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
     * @param      string $toType   One of the class type constants
     * @return string          translated name of the field.
     * @throws PropelException - if the specified name could not be found in the fieldname mappings.
     */
    public static function translateFieldName($name, $fromType, $toType)
    {
        $toNames = ConsultaanticipoPeer::getFieldNames($toType);
        $key = isset(ConsultaanticipoPeer::$fieldKeys[$fromType][$name]) ? ConsultaanticipoPeer::$fieldKeys[$fromType][$name] : null;
        if ($key === null) {
            throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ConsultaanticipoPeer::$fieldKeys[$fromType], true));
        }

        return $toNames[$key];
    }

    /**
     * Returns an array of field names.
     *
     * @param      string $type The type of fieldnames to return:
     *                      One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
     * @return array           A list of field names
     * @throws PropelException - if the type is not valid.
     */
    public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
    {
        if (!array_key_exists($type, ConsultaanticipoPeer::$fieldNames)) {
            throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
        }

        return ConsultaanticipoPeer::$fieldNames[$type];
    }

    /**
     * Gets the list of values for all ENUM columns
     * @return array
     */
    public static function getValueSets()
    {
      return ConsultaanticipoPeer::$enumValueSets;
    }

    /**
     * Gets the list of values for an ENUM column
     *
     * @param string $colname The ENUM column name.
     *
     * @return array list of possible values for the column
     */
    public static function getValueSet($colname)
    {
        $valueSets = ConsultaanticipoPeer::getValueSets();

        if (!isset($valueSets[$colname])) {
            throw new PropelException(sprintf('Column "%s" has no ValueSet.', $colname));
        }

        return $valueSets[$colname];
    }

    /**
     * Gets the SQL value for the ENUM column value
     *
     * @param string $colname ENUM column name.
     * @param string $enumVal ENUM value.
     *
     * @return int SQL value
     */
    public static function getSqlValueForEnum($colname, $enumVal)
    {
        $values = ConsultaanticipoPeer::getValueSet($colname);
        if (!in_array($enumVal, $values)) {
            throw new PropelException(sprintf('Value "%s" is not accepted in this enumerated column', $colname));
        }

        return array_search($enumVal, $values);
    }

    /**
     * Convenience method which changes table.column to alias.column.
     *
     * Using this method you can maintain SQL abstraction while using column aliases.
     * <code>
     *		$c->addAlias("alias1", TablePeer::TABLE_NAME);
     *		$c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
     * </code>
     * @param      string $alias The alias for the current table.
     * @param      string $column The column name for current table. (i.e. ConsultaanticipoPeer::COLUMN_NAME).
     * @return string
     */
    public static function alias($alias, $column)
    {
        return str_replace(ConsultaanticipoPeer::TABLE_NAME.'.', $alias.'.', $column);
    }

    /**
     * Add all the columns needed to create a new object.
     *
     * Note: any columns that were marked with lazyLoad="true" in the
     * XML schema will not be added to the select list and only loaded
     * on demand.
     *
     * @param      Criteria $criteria object containing the columns to add.
     * @param      string   $alias    optional table alias
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function addSelectColumns(Criteria $criteria, $alias = null)
    {
        if (null === $alias) {
            $criteria->addSelectColumn(ConsultaanticipoPeer::IDCONSULTAANTICIPO);
            $criteria->addSelectColumn(ConsultaanticipoPeer::IDCONSULTA);
            $criteria->addSelectColumn(ConsultaanticipoPeer::CONSULTAANTICIPO_FECHA);
            $criteria->addSelectColumn(ConsultaanticipoPeer::CONSULTAANTICIPO_CANTIDAD);
            $criteria->addSelectColumn(ConsultaanticipoPeer::CONSULTAANTICIPO_NOTA);
            $criteria->addSelectColumn(ConsultaanticipoPeer::CONSULTAANTICIPO_TIPO);
        } else {
            $criteria->addSelectColumn($alias . '.idconsultaanticipo');
            $criteria->addSelectColumn($alias . '.idconsulta');
            $criteria->addSelectColumn($alias . '.consultaanticipo_fecha');
            $criteria->addSelectColumn($alias . '.consultaanticipo_cantidad');
            $criteria->addSelectColumn($alias . '.consultaanticipo_nota');
            $criteria->addSelectColumn($alias . '.consultaanticipo_tipo');
        }
    }

    /**
     * Returns the number of rows matching criteria.
     *
     * @param      Criteria $criteria
     * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     * @param      PropelPDO $con
     * @return int Number of matching rows.
     */
    public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
    {
        // we may modify criteria, so copy it first
        $criteria = clone $criteria;

        // We need to set the primary table name, since in the case that there are no WHERE columns
        // it will be impossible for the BasePeer::createSelectSql() method to determine which
        // tables go into the FROM clause.
        $criteria->setPrimaryTableName(ConsultaanticipoPeer::TABLE_NAME);

        if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
            $criteria->setDistinct();
        }

        if (!$criteria->hasSelectClause()) {
            ConsultaanticipoPeer::addSelectColumns($criteria);
        }

        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
        $criteria->setDbName(ConsultaanticipoPeer::DATABASE_NAME); // Set the correct dbName

        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        // BasePeer returns a PDOStatement
        $stmt = BasePeer::doCount($criteria, $con);

        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $count = (int) $row[0];
        } else {
            $count = 0; // no rows returned; we infer that means 0 matches.
        }
        $stmt->closeCursor();

        return $count;
    }
    /**
     * Selects one object from the DB.
     *
     * @param      Criteria $criteria object used to create the SELECT statement.
     * @param      PropelPDO $con
     * @return Consultaanticipo
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
    {
        $critcopy = clone $criteria;
        $critcopy->setLimit(1);
        $objects = ConsultaanticipoPeer::doSelect($critcopy, $con);
        if ($objects) {
            return $objects[0];
        }

        return null;
    }
    /**
     * Selects several row from the DB.
     *
     * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
     * @param      PropelPDO $con
     * @return array           Array of selected Objects
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function doSelect(Criteria $criteria, PropelPDO $con = null)
    {
        return ConsultaanticipoPeer::populateObjects(ConsultaanticipoPeer::doSelectStmt($criteria, $con));
    }
    /**
     * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
     *
     * Use this method directly if you want to work with an executed statement directly (for example
     * to perform your own object hydration).
     *
     * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
     * @param      PropelPDO $con The connection to use
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     * @return PDOStatement The executed PDOStatement object.
     * @see        BasePeer::doSelect()
     */
    public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }

        if (!$criteria->hasSelectClause()) {
            $criteria = clone $criteria;
            ConsultaanticipoPeer::addSelectColumns($criteria);
        }

        // Set the correct dbName
        $criteria->setDbName(ConsultaanticipoPeer::DATABASE_NAME);

        // BasePeer returns a PDOStatement
        return BasePeer::doSelect($criteria, $con);
    }
    /**
     * Adds an object to the instance pool.
     *
     * Propel keeps cached copies of objects in an instance pool when they are retrieved
     * from the database.  In some cases -- especially when you override doSelect*()
     * methods in your stub classes -- you may need to explicitly add objects
     * to the cache in order to ensure that the same objects are always returned by doSelect*()
     * and retrieveByPK*() calls.
     *
     * @param Consultaanticipo $obj A Consultaanticipo object.
     * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
     */
    public static function addInstanceToPool($obj, $key = null)
    {
        if (Propel::isInstancePoolingEnabled()) {
            if ($key === null) {
                $key = (string) $obj->getIdconsultaanticipo();
            } // if key === null
            ConsultaanticipoPeer::$instances[$key] = $obj;
        }
    }

    /**
     * Removes an object from the instance pool.
     *
     * Propel keeps cached copies of objects in an instance pool when they are retrieved
     * from the database.  In some cases -- especially when you override doDelete
     * methods in your stub classes -- you may need to explicitly remove objects
     * from the cache in order to prevent returning objects that no longer exist.
     *
     * @param      mixed $value A Consultaanticipo object or a primary key value.
     *
     * @return void
     * @throws PropelException - if the value is invalid.
     */
    public static function removeInstanceFromPool($value)
    {
        if (Propel::isInstancePoolingEnabled() && $value !== null) {
            if (is_object($value) && $value instanceof Consultaanticipo) {
                $key = (string) $value->getIdconsultaanticipo();
            } elseif (is_scalar($value)) {
                // assume we've been passed a primary key
                $key = (string) $value;
            } else {
                $e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or Consultaanticipo object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
                throw $e;
            }

            unset(ConsultaanticipoPeer::$instances[$key]);
        }
    } // removeInstanceFromPool()

    /**
     * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
     *
     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     * a multi-column primary key, a serialize()d version of the primary key will be returned.
     *
     * @param      string $key The key (@see getPrimaryKeyHash()) for this instance.
     * @return Consultaanticipo Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
     * @see        getPrimaryKeyHash()
     */
    public static function getInstanceFromPool($key)
    {
        if (Propel::isInstancePoolingEnabled()) {
            if (isset(ConsultaanticipoPeer::$instances[$key])) {
                return ConsultaanticipoPeer::$instances[$key];
            }
        }

        return null; // just to be explicit
    }

    /**
     * Clear the instance pool.
     *
     * @return void
     */
    public static function clearInstancePool($and_clear_all_references = false)
    {
      if ($and_clear_all_references) {
        foreach (ConsultaanticipoPeer::$instances as $instance) {
          $instance->clearAllReferences(true);
        }
      }
        ConsultaanticipoPeer::$instances = array();
    }

    /**
     * Method to invalidate the instance pool of all tables related to consultaanticipo
     * by a foreign key with ON DELETE CASCADE
     */
    public static function clearRelatedInstancePool()
    {
    }

    /**
     * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
     *
     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     * a multi-column primary key, a serialize()d version of the primary key will be returned.
     *
     * @param      array $row PropelPDO resultset row.
     * @param      int $startcol The 0-based offset for reading from the resultset row.
     * @return string A string version of PK or null if the components of primary key in result array are all null.
     */
    public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
    {
        // If the PK cannot be derived from the row, return null.
        if ($row[$startcol] === null) {
            return null;
        }

        return (string) $row[$startcol];
    }

    /**
     * Retrieves the primary key from the DB resultset row
     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
     * a multi-column primary key, an array of the primary key columns will be returned.
     *
     * @param      array $row PropelPDO resultset row.
     * @param      int $startcol The 0-based offset for reading from the resultset row.
     * @return mixed The primary key of the row
     */
    public static function getPrimaryKeyFromRow($row, $startcol = 0)
    {

        return (int) $row[$startcol];
    }

    /**
     * The returned array will contain objects of the default type or
     * objects that inherit from the default.
     *
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function populateObjects(PDOStatement $stmt)
    {
        $results = array();

        // set the class once to avoid overhead in the loop
        $cls = ConsultaanticipoPeer::getOMClass();
        // populate the object(s)
        while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $key = ConsultaanticipoPeer::getPrimaryKeyHashFromRow($row, 0);
            if (null !== ($obj = ConsultaanticipoPeer::getInstanceFromPool($key))) {
                // We no longer rehydrate the object, since this can cause data loss.
                // See http://www.propelorm.org/ticket/509
                // $obj->hydrate($row, 0, true); // rehydrate
                $results[] = $obj;
            } else {
                $obj = new $cls();
                $obj->hydrate($row);
                $results[] = $obj;
                ConsultaanticipoPeer::addInstanceToPool($obj, $key);
            } // if key exists
        }
        $stmt->closeCursor();

        return $results;
    }
    /**
     * Populates an object of the default type or an object that inherit from the default.
     *
     * @param      array $row PropelPDO resultset row.
     * @param      int $startcol The 0-based offset for reading from the resultset row.
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     * @return array (Consultaanticipo object, last column rank)
     */
    public static function populateObject($row, $startcol = 0)
    {
        $key = ConsultaanticipoPeer::getPrimaryKeyHashFromRow($row, $startcol);
        if (null !== ($obj = ConsultaanticipoPeer::getInstanceFromPool($key))) {
            // We no longer rehydrate the object, since this can cause data loss.
            // See http://www.propelorm.org/ticket/509
            // $obj->hydrate($row, $startcol, true); // rehydrate
            $col = $startcol + ConsultaanticipoPeer::NUM_HYDRATE_COLUMNS;
        } else {
            $cls = ConsultaanticipoPeer::OM_CLASS;
            $obj = new $cls();
            $col = $obj->hydrate($row, $startcol);
            ConsultaanticipoPeer::addInstanceToPool($obj, $key);
        }

        return array($obj, $col);
    }

    /**
     * Returns the number of rows matching criteria, joining the related Consulta table
     *
     * @param      Criteria $criteria
     * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     * @param      PropelPDO $con
     * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     * @return int Number of matching rows.
     */
    public static function doCountJoinConsulta(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        // we're going to modify criteria, so copy it first
        $criteria = clone $criteria;

        // We need to set the primary table name, since in the case that there are no WHERE columns
        // it will be impossible for the BasePeer::createSelectSql() method to determine which
        // tables go into the FROM clause.
        $criteria->setPrimaryTableName(ConsultaanticipoPeer::TABLE_NAME);

        if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
            $criteria->setDistinct();
        }

        if (!$criteria->hasSelectClause()) {
            ConsultaanticipoPeer::addSelectColumns($criteria);
        }

        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count

        // Set the correct dbName
        $criteria->setDbName(ConsultaanticipoPeer::DATABASE_NAME);

        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }

        $criteria->addJoin(ConsultaanticipoPeer::IDCONSULTA, ConsultaPeer::IDCONSULTA, $join_behavior);

        $stmt = BasePeer::doCount($criteria, $con);

        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $count = (int) $row[0];
        } else {
            $count = 0; // no rows returned; we infer that means 0 matches.
        }
        $stmt->closeCursor();

        return $count;
    }

    /**
     * Selects a collection of Consultaanticipo objects pre-filled with their Consulta objects.
     * @param      Criteria  $criteria
     * @param      PropelPDO $con
     * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     * @return array           Array of Consultaanticipo objects.
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function doSelectJoinConsulta(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $criteria = clone $criteria;

        // Set the correct dbName if it has not been overridden
        if ($criteria->getDbName() == Propel::getDefaultDB()) {
            $criteria->setDbName(ConsultaanticipoPeer::DATABASE_NAME);
        }

        ConsultaanticipoPeer::addSelectColumns($criteria);
        $startcol = ConsultaanticipoPeer::NUM_HYDRATE_COLUMNS;
        ConsultaPeer::addSelectColumns($criteria);

        $criteria->addJoin(ConsultaanticipoPeer::IDCONSULTA, ConsultaPeer::IDCONSULTA, $join_behavior);

        $stmt = BasePeer::doSelect($criteria, $con);
        $results = array();

        while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $key1 = ConsultaanticipoPeer::getPrimaryKeyHashFromRow($row, 0);
            if (null !== ($obj1 = ConsultaanticipoPeer::getInstanceFromPool($key1))) {
                // We no longer rehydrate the object, since this can cause data loss.
                // See http://www.propelorm.org/ticket/509
                // $obj1->hydrate($row, 0, true); // rehydrate
            } else {

                $cls = ConsultaanticipoPeer::getOMClass();

                $obj1 = new $cls();
                $obj1->hydrate($row);
                ConsultaanticipoPeer::addInstanceToPool($obj1, $key1);
            } // if $obj1 already loaded

            $key2 = ConsultaPeer::getPrimaryKeyHashFromRow($row, $startcol);
            if ($key2 !== null) {
                $obj2 = ConsultaPeer::getInstanceFromPool($key2);
                if (!$obj2) {

                    $cls = ConsultaPeer::getOMClass();

                    $obj2 = new $cls();
                    $obj2->hydrate($row, $startcol);
                    ConsultaPeer::addInstanceToPool($obj2, $key2);
                } // if obj2 already loaded

                // Add the $obj1 (Consultaanticipo) to $obj2 (Consulta)
                $obj2->addConsultaanticipo($obj1);

            } // if joined row was not null

            $results[] = $obj1;
        }
        $stmt->closeCursor();

        return $results;
    }

    /**
     * Returns the number of rows matching criteria, joining all related tables
     *
     * @param      Criteria $criteria
     * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
     * @param      PropelPDO $con
     * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     * @return int Number of matching rows.
     */
    public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        // we're going to modify criteria, so copy it first
        $criteria = clone $criteria;

        // We need to set the primary table name, since in the case that there are no WHERE columns
        // it will be impossible for the BasePeer::createSelectSql() method to determine which
        // tables go into the FROM clause.
        $criteria->setPrimaryTableName(ConsultaanticipoPeer::TABLE_NAME);

        if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
            $criteria->setDistinct();
        }

        if (!$criteria->hasSelectClause()) {
            ConsultaanticipoPeer::addSelectColumns($criteria);
        }

        $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count

        // Set the correct dbName
        $criteria->setDbName(ConsultaanticipoPeer::DATABASE_NAME);

        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }

        $criteria->addJoin(ConsultaanticipoPeer::IDCONSULTA, ConsultaPeer::IDCONSULTA, $join_behavior);

        $stmt = BasePeer::doCount($criteria, $con);

        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $count = (int) $row[0];
        } else {
            $count = 0; // no rows returned; we infer that means 0 matches.
        }
        $stmt->closeCursor();

        return $count;
    }

    /**
     * Selects a collection of Consultaanticipo objects pre-filled with all related objects.
     *
     * @param      Criteria  $criteria
     * @param      PropelPDO $con
     * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
     * @return array           Array of Consultaanticipo objects.
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    {
        $criteria = clone $criteria;

        // Set the correct dbName if it has not been overridden
        if ($criteria->getDbName() == Propel::getDefaultDB()) {
            $criteria->setDbName(ConsultaanticipoPeer::DATABASE_NAME);
        }

        ConsultaanticipoPeer::addSelectColumns($criteria);
        $startcol2 = ConsultaanticipoPeer::NUM_HYDRATE_COLUMNS;

        ConsultaPeer::addSelectColumns($criteria);
        $startcol3 = $startcol2 + ConsultaPeer::NUM_HYDRATE_COLUMNS;

        $criteria->addJoin(ConsultaanticipoPeer::IDCONSULTA, ConsultaPeer::IDCONSULTA, $join_behavior);

        $stmt = BasePeer::doSelect($criteria, $con);
        $results = array();

        while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $key1 = ConsultaanticipoPeer::getPrimaryKeyHashFromRow($row, 0);
            if (null !== ($obj1 = ConsultaanticipoPeer::getInstanceFromPool($key1))) {
                // We no longer rehydrate the object, since this can cause data loss.
                // See http://www.propelorm.org/ticket/509
                // $obj1->hydrate($row, 0, true); // rehydrate
            } else {
                $cls = ConsultaanticipoPeer::getOMClass();

                $obj1 = new $cls();
                $obj1->hydrate($row);
                ConsultaanticipoPeer::addInstanceToPool($obj1, $key1);
            } // if obj1 already loaded

            // Add objects for joined Consulta rows

            $key2 = ConsultaPeer::getPrimaryKeyHashFromRow($row, $startcol2);
            if ($key2 !== null) {
                $obj2 = ConsultaPeer::getInstanceFromPool($key2);
                if (!$obj2) {

                    $cls = ConsultaPeer::getOMClass();

                    $obj2 = new $cls();
                    $obj2->hydrate($row, $startcol2);
                    ConsultaPeer::addInstanceToPool($obj2, $key2);
                } // if obj2 loaded

                // Add the $obj1 (Consultaanticipo) to the collection in $obj2 (Consulta)
                $obj2->addConsultaanticipo($obj1);
            } // if joined row not null

            $results[] = $obj1;
        }
        $stmt->closeCursor();

        return $results;
    }

    /**
     * Returns the TableMap related to this peer.
     * This method is not needed for general use but a specific application could have a need.
     * @return TableMap
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function getTableMap()
    {
        return Propel::getDatabaseMap(ConsultaanticipoPeer::DATABASE_NAME)->getTable(ConsultaanticipoPeer::TABLE_NAME);
    }

    /**
     * Add a TableMap instance to the database for this peer class.
     */
    public static function buildTableMap()
    {
      $dbMap = Propel::getDatabaseMap(BaseConsultaanticipoPeer::DATABASE_NAME);
      if (!$dbMap->hasTable(BaseConsultaanticipoPeer::TABLE_NAME)) {
        $dbMap->addTableObject(new \ConsultaanticipoTableMap());
      }
    }

    /**
     * The class that the Peer will make instances of.
     *
     *
     * @return string ClassName
     */
    public static function getOMClass($row = 0, $colnum = 0)
    {
        return ConsultaanticipoPeer::OM_CLASS;
    }

    /**
     * Performs an INSERT on the database, given a Consultaanticipo or Criteria object.
     *
     * @param      mixed $values Criteria or Consultaanticipo object containing data that is used to create the INSERT statement.
     * @param      PropelPDO $con the PropelPDO connection to use
     * @return mixed           The new primary key.
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function doInsert($values, PropelPDO $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
        }

        if ($values instanceof Criteria) {
            $criteria = clone $values; // rename for clarity
        } else {
            $criteria = $values->buildCriteria(); // build Criteria from Consultaanticipo object
        }

        if ($criteria->containsKey(ConsultaanticipoPeer::IDCONSULTAANTICIPO) && $criteria->keyContainsValue(ConsultaanticipoPeer::IDCONSULTAANTICIPO) ) {
            throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConsultaanticipoPeer::IDCONSULTAANTICIPO.')');
        }

        // Set the correct dbName
        $criteria->setDbName(ConsultaanticipoPeer::DATABASE_NAME);

        try {
            // use transaction because $criteria could contain info
            // for more than one table (I guess, conceivably)
            $con->beginTransaction();
            $pk = BasePeer::doInsert($criteria, $con);
            $con->commit();
        } catch (Exception $e) {
            $con->rollBack();
            throw $e;
        }

        return $pk;
    }

    /**
     * Performs an UPDATE on the database, given a Consultaanticipo or Criteria object.
     *
     * @param      mixed $values Criteria or Consultaanticipo object containing data that is used to create the UPDATE statement.
     * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
     * @return int             The number of affected rows (if supported by underlying database driver).
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function doUpdate($values, PropelPDO $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
        }

        $selectCriteria = new Criteria(ConsultaanticipoPeer::DATABASE_NAME);

        if ($values instanceof Criteria) {
            $criteria = clone $values; // rename for clarity

            $comparison = $criteria->getComparison(ConsultaanticipoPeer::IDCONSULTAANTICIPO);
            $value = $criteria->remove(ConsultaanticipoPeer::IDCONSULTAANTICIPO);
            if ($value) {
                $selectCriteria->add(ConsultaanticipoPeer::IDCONSULTAANTICIPO, $value, $comparison);
            } else {
                $selectCriteria->setPrimaryTableName(ConsultaanticipoPeer::TABLE_NAME);
            }

        } else { // $values is Consultaanticipo object
            $criteria = $values->buildCriteria(); // gets full criteria
            $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
        }

        // set the correct dbName
        $criteria->setDbName(ConsultaanticipoPeer::DATABASE_NAME);

        return BasePeer::doUpdate($selectCriteria, $criteria, $con);
    }

    /**
     * Deletes all rows from the consultaanticipo table.
     *
     * @param      PropelPDO $con the connection to use
     * @return int             The number of affected rows (if supported by underlying database driver).
     * @throws PropelException
     */
    public static function doDeleteAll(PropelPDO $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
        }
        $affectedRows = 0; // initialize var to track total num of affected rows
        try {
            // use transaction because $criteria could contain info
            // for more than one table or we could emulating ON DELETE CASCADE, etc.
            $con->beginTransaction();
            $affectedRows += BasePeer::doDeleteAll(ConsultaanticipoPeer::TABLE_NAME, $con, ConsultaanticipoPeer::DATABASE_NAME);
            // Because this db requires some delete cascade/set null emulation, we have to
            // clear the cached instance *after* the emulation has happened (since
            // instances get re-added by the select statement contained therein).
            ConsultaanticipoPeer::clearInstancePool();
            ConsultaanticipoPeer::clearRelatedInstancePool();
            $con->commit();

            return $affectedRows;
        } catch (Exception $e) {
            $con->rollBack();
            throw $e;
        }
    }

    /**
     * Performs a DELETE on the database, given a Consultaanticipo or Criteria object OR a primary key value.
     *
     * @param      mixed $values Criteria or Consultaanticipo object or primary key or array of primary keys
     *              which is used to create the DELETE statement
     * @param      PropelPDO $con the connection to use
     * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
     *				if supported by native driver or if emulated using Propel.
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
     public static function doDelete($values, PropelPDO $con = null)
     {
        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
        }

        if ($values instanceof Criteria) {
            // invalidate the cache for all objects of this type, since we have no
            // way of knowing (without running a query) what objects should be invalidated
            // from the cache based on this Criteria.
            ConsultaanticipoPeer::clearInstancePool();
            // rename for clarity
            $criteria = clone $values;
        } elseif ($values instanceof Consultaanticipo) { // it's a model object
            // invalidate the cache for this single object
            ConsultaanticipoPeer::removeInstanceFromPool($values);
            // create criteria based on pk values
            $criteria = $values->buildPkeyCriteria();
        } else { // it's a primary key, or an array of pks
            $criteria = new Criteria(ConsultaanticipoPeer::DATABASE_NAME);
            $criteria->add(ConsultaanticipoPeer::IDCONSULTAANTICIPO, (array) $values, Criteria::IN);
            // invalidate the cache for this object(s)
            foreach ((array) $values as $singleval) {
                ConsultaanticipoPeer::removeInstanceFromPool($singleval);
            }
        }

        // Set the correct dbName
        $criteria->setDbName(ConsultaanticipoPeer::DATABASE_NAME);

        $affectedRows = 0; // initialize var to track total num of affected rows

        try {
            // use transaction because $criteria could contain info
            // for more than one table or we could emulating ON DELETE CASCADE, etc.
            $con->beginTransaction();

            $affectedRows += BasePeer::doDelete($criteria, $con);
            ConsultaanticipoPeer::clearRelatedInstancePool();
            $con->commit();

            return $affectedRows;
        } catch (Exception $e) {
            $con->rollBack();
            throw $e;
        }
    }

    /**
     * Validates all modified columns of given Consultaanticipo object.
     * If parameter $columns is either a single column name or an array of column names
     * than only those columns are validated.
     *
     * NOTICE: This does not apply to primary or foreign keys for now.
     *
     * @param Consultaanticipo $obj The object to validate.
     * @param      mixed $cols Column name or array of column names.
     *
     * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
     */
    public static function doValidate($obj, $cols = null)
    {
        $columns = array();

        if ($cols) {
            $dbMap = Propel::getDatabaseMap(ConsultaanticipoPeer::DATABASE_NAME);
            $tableMap = $dbMap->getTable(ConsultaanticipoPeer::TABLE_NAME);

            if (! is_array($cols)) {
                $cols = array($cols);
            }

            foreach ($cols as $colName) {
                if ($tableMap->hasColumn($colName)) {
                    $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
                    $columns[$colName] = $obj->$get();
                }
            }
        } else {

        }

        return BasePeer::doValidate(ConsultaanticipoPeer::DATABASE_NAME, ConsultaanticipoPeer::TABLE_NAME, $columns);
    }

    /**
     * Retrieve a single object by pkey.
     *
     * @param int $pk the primary key.
     * @param      PropelPDO $con the connection to use
     * @return Consultaanticipo
     */
    public static function retrieveByPK($pk, PropelPDO $con = null)
    {

        if (null !== ($obj = ConsultaanticipoPeer::getInstanceFromPool((string) $pk))) {
            return $obj;
        }

        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }

        $criteria = new Criteria(ConsultaanticipoPeer::DATABASE_NAME);
        $criteria->add(ConsultaanticipoPeer::IDCONSULTAANTICIPO, $pk);

        $v = ConsultaanticipoPeer::doSelect($criteria, $con);

        return !empty($v) > 0 ? $v[0] : null;
    }

    /**
     * Retrieve multiple objects by pkey.
     *
     * @param      array $pks List of primary keys
     * @param      PropelPDO $con the connection to use
     * @return Consultaanticipo[]
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function retrieveByPKs($pks, PropelPDO $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection(ConsultaanticipoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }

        $objs = null;
        if (empty($pks)) {
            $objs = array();
        } else {
            $criteria = new Criteria(ConsultaanticipoPeer::DATABASE_NAME);
            $criteria->add(ConsultaanticipoPeer::IDCONSULTAANTICIPO, $pks, Criteria::IN);
            $objs = ConsultaanticipoPeer::doSelect($criteria, $con);
        }

        return $objs;
    }

} // BaseConsultaanticipoPeer

// This is the static code needed to register the TableMap for this table with the main Propel class.
//
BaseConsultaanticipoPeer::buildTableMap();