# Class ParallelResultRowSequence

java.lang.Object
uk.ac.starlink.ttools.cone.ParallelResultRowSequence

All Implemented Interfaces:
  `Closeable, AutoCloseable, uk.ac.starlink.table.RowData, uk.ac.starlink.table.RowSequence, ConeQueryRowSequence, ConeResultRowSequence, uk.ac.starlink.util.Sequence`

public class ParallelResultRowSequence extends Object implements ConeResultRowSequence
ConeResultRowSequence implementation which uses a fixed number of worker threads to dispatch cone queries in parallel. The result table has the same ordering as if they had been done in sequence.

Since:
  18 Jan 2008
Author:
  Mark Taylor

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`DEFAULT_MAXPAR`
Default maximum value for the number of threads that should be permitted for a query.
`static final String`
`MAXPAR_PROP`
Name of system property "service.maxparallel" which may be used to adjust the maximum parallelism.

## Constructor Summary

Constructors
Constructor
Description
`ParallelResultRowSequence(ConeQueryRowSequence querySeq, ConeSearcher coneSearcher, ConeErrorPolicy errAct, Coverage coverage, boolean bestOnly, boolean distFilter, String distanceCol, int parallelism)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`Object`
`getCell(int icol)`
`uk.ac.starlink.table.StarTable`
`getConeResult()`
Returns the result of the cone search for the current row of this sequence.
`double`
`getDec()`
Get central declination for the current row's cone search request in degrees.
`long`
`getIndex()`
Get the index in the underlying table to which the current row relates.
`static int`
`getMaxParallelism()`
Returns the maximum parallelism value which should permitted in this JVM.
`double`
`getRa()`
Get central right ascension for the current row's cone search request in degrees.
`double`
`getRadius()`
Get search radius for the current row's cone search request in degrees.
`Object[]`
`getRow()`
`boolean`
`next()`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_MAXPAR

public static final int DEFAULT_MAXPAR
Default maximum value for the number of threads that should be permitted for a query.

See Also:
  - `MAXPAR_PROP`
  - `getMaxParallelism()`
  - Constant Field Values

### MAXPAR_PROP

public static final String MAXPAR_PROP
Name of system property "service.maxparallel" which may be used to adjust the maximum parallelism. Only increase this value with great care since you run the risk of overloading servers and making yourself unpopular with data centres. As a rule, you should only increase this value if you have obtained permission from the data centres whose services on which you will be using the increased parallelism.

See Also:
  - `DEFAULT_MAXPAR`
  - `getMaxParallelism()`
  - Constant Field Values

## Constructor Details

### ParallelResultRowSequence

public ParallelResultRowSequence(ConeQueryRowSequence querySeq, ConeSearcher coneSearcher, ConeErrorPolicy errAct, Coverage coverage, boolean bestOnly, boolean distFilter, String distanceCol, int parallelism)
Constructor.

Parameters:
  `querySeq` - sequence providing cone search query parameters
  `coneSearcher` - cone search implementation
  `errAct` - defines action on cone search invocation error
  `coverage` - coverage for results, or null
  `bestOnly` - whether all results or just best are required
  `distFilter` - true to perform post-query filtering on results based on the distance between the query position and the result row position
  `distanceCol` - name of column to hold distance information in output table, or null
  `parallelism` - number of concurrent querying threads

## Method Details

### next

public boolean next() throws IOException

Specified by:
  `next` in interface `uk.ac.starlink.table.RowSequence`
Specified by:
  `next` in interface `uk.ac.starlink.util.Sequence`
Throws:
  `IOException`

### getCell

public Object getCell(int icol) throws IOException

Specified by:
  `getCell` in interface `uk.ac.starlink.table.RowData`
Specified by:
  `getCell` in interface `uk.ac.starlink.table.RowSequence`
Throws:
  `IOException`

### getRow

public Object[] getRow() throws IOException

Specified by:
  `getRow` in interface `uk.ac.starlink.table.RowData`
Specified by:
  `getRow` in interface `uk.ac.starlink.table.RowSequence`
Throws:
  `IOException`

### getRa

public double getRa() throws IOException
Description copied from interface: `ConeQueryRowSequence`
Get central right ascension for the current row's cone search request in degrees.

Specified by:
  `getRa` in interface `ConeQueryRowSequence`
Returns:
  right ascension
Throws:
  `IOException`

### getDec

public double getDec() throws IOException
Description copied from interface: `ConeQueryRowSequence`
Get central declination for the current row's cone search request in degrees.

Specified by:
  `getDec` in interface `ConeQueryRowSequence`
Returns:
  declination
Throws:
  `IOException`

### getRadius

public double getRadius() throws IOException
Description copied from interface: `ConeQueryRowSequence`
Get search radius for the current row's cone search request in degrees.

Specified by:
  `getRadius` in interface `ConeQueryRowSequence`
Returns:
  search radius
Throws:
  `IOException`

### getIndex

public long getIndex() throws IOException
Description copied from interface: `ConeQueryRowSequence`
Get the index in the underlying table to which the current row relates. The identity of this underlying table is not specified by this interface, but must be understood by the creator and user of instances. In particular, the return value does not necessarily increment by one for each call to `next`.

Specified by:
  `getIndex` in interface `ConeQueryRowSequence`
Returns:
  row index
Throws:
  `IOException`

### getConeResult

public uk.ac.starlink.table.StarTable getConeResult() throws IOException
Description copied from interface: `ConeResultRowSequence`
Returns the result of the cone search for the current row of this sequence. The work will typically be done using `ConeMatcher.getConeResult(ConeSearcher, ConeErrorPolicy, boolean, boolean, String, double, double, double)`.

If no records in the cone are found, the return value may either be null or (preferably) an empty table with the correct columns.

Specified by:
  `getConeResult` in interface `ConeResultRowSequence`
Returns:
  table giving rows strictly within the match criteria for the current row of this cone query sequence, or null
Throws:
  `IOException`

### close

public void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `uk.ac.starlink.table.RowSequence`
Throws:
  `IOException`

### getMaxParallelism

public static int getMaxParallelism()
Returns the maximum parallelism value which should permitted in this JVM. The purpose of this is to set a limit to the number of concurrent queries that an irresponsible/careless user can hit a server with. The value can be adjusted using the `MAXPAR_PROP` system property. Note that this method is not used by this class, i.e. the maximum is not imposed here, it should be imposed by calling code.

Returns:
  parallelism limit