public class PopulationQuery
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private CensusData |
data
Array of census data parsed from the input file.
|
private static java.util.concurrent.ForkJoinPool |
fjPool
There should be only one fork/join pool per program, so this needs to be
a static variable.
|
static int |
LATITUDE_INDEX
For parsing - zero-based index of the field containing the latitude of
the current census group.
|
static int |
LONGITUDE_INDEX
For parsing - zero-based index of the field containing the longitude of
the current census group.
|
static int |
POPULATION_INDEX
For parsing - zero-based index of the field containing the population of
the current census group.
|
static int |
TOKENS_PER_LINE
For parsing - the number of comma-separated fields on a given line.
|
| Constructor and Description |
|---|
PopulationQuery(java.lang.String filename)
Initialize the query object by parsing the census data in the given file.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
main(java.lang.String[] args) |
private static CensusData |
parse(java.lang.String filename)
Parse the input file into a large array held in a CensusData object.
|
void |
preprocess(int cols,
int rows,
int versionNum)
Preprocess the census data for a run using the given parameters.
|
Pair<java.lang.Integer,java.lang.Float> |
singleInteraction(int w,
int s,
int e,
int n)
Query the population of a given rectangle.
|
public static final int TOKENS_PER_LINE
public static final int POPULATION_INDEX
public static final int LATITUDE_INDEX
public static final int LONGITUDE_INDEX
private static java.util.concurrent.ForkJoinPool fjPool
private CensusData data
public PopulationQuery(java.lang.String filename)
filename - name of the census data fileprivate static CensusData parse(java.lang.String filename)
filename - name of the file to be used as input.public void preprocess(int cols,
int rows,
int versionNum)
cols - Number of columns in the map grid.rows - Number of rows in the map grid.versionNum - implementation to usepublic Pair<java.lang.Integer,java.lang.Float> singleInteraction(int w, int s, int e, int n)
w - western edge of the rectangles - southern edge of the rectanglee - eastern edge of the rectanglen - northern edge of the rectanglepublic static void main(java.lang.String[] args)