<commit_before>package mil.nga.giat.geowave.format.nyctlc.query;

import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKBReader;
import com.vividsolutions.jts.io.WKBWriter;
import mil.nga.giat.geowave.core.geotime.store.filter.SpatialQueryFilter;
import mil.nga.giat.geowave.core.index.dimension.BasicDimensionDefinition;
import mil.nga.giat.geowave.core.index.dimension.NumericDimensionDefinition;
import mil.nga.giat.geowave.core.index.sfc.data.BasicNumericDataset;
import mil.nga.giat.geowave.core.index.sfc.data.MultiDimensionalNumericData;
import mil.nga.giat.geowave.core.index.sfc.data.NumericData;
import mil.nga.giat.geowave.core.index.sfc.data.NumericRange;
import mil.nga.giat.geowave.core.store.dimension.NumericDimensionField;
import mil.nga.giat.geowave.core.store.filter.DistributableFilterList;
import mil.nga.giat.geowave.core.store.filter.DistributableQueryFilter;
import mil.nga.giat.geowave.core.store.query.BasicQuery;
import mil.nga.giat.geowave.format.nyctlc.ingest.NYCTLCDimensionalityTypeProvider;
import mil.nga.giat.geowave.format.nyctlc.ingest.NYCTLCDimensionalityTypeProvider.TimeOfDayDefinition;

import org.apache.log4j.Logger;

import java.nio.ByteBuffer;
import java.util.*;

/**
 * Created by geowave on 4/28/16.
 */
public class NYCTLCQuery extends
		BasicQuery
{

	private final static Logger LOGGER = Logger.getLogger(NYCTLCQuery.class);
	private Geometry pickupGeometry;
	private Geometry dropoffGeometry;
	SpatialQueryFilter.CompareOperation compareOp = SpatialQueryFilter.CompareOperation.OVERLAPS;

	protected NYCTLCQuery() {}

	public NYCTLCQuery(
			final int startTime,
			final int endTime,
			final Geometry pickupGeometry,
			final Geometry dropoffGeometry ) {
		super(
				createNYCTLCConstraints(
						new ConstraintData(
								new NumericRange(
										startTime,
										endTime),
								false),
						pickupGeometry,
						dropoffGeometry));
		this.pickupGeometry = pickupGeometry;
		this.dropoffGeometry = dropoffGeometry;
	}

	public Geometry getPickupGeometry() {
		return pickupGeometry;
	}

	public Geometry getDropoffGeometry() {
		return dropoffGeometry;
	}

	@Override
	protected DistributableQueryFilter createQueryFilter(
			final MultiDimensionalNumericData constraints,
			final NumericDimensionField<?>[] dimensionFields ) {
		final List<NumericData> pickupConstraints = new ArrayList<NumericData>();
		final List<NumericData> dropoffConstraints = new ArrayList<NumericData>();
		final List<NumericDimensionField> pickupDimFields = new ArrayList<NumericDimensionField>();
		final List<NumericDimensionField> dropoffDimFields = new ArrayList<NumericDimensionField>();

		for (int dim = 0; dim < constraints.getDimensionCount() && dim < dimensionFields.length; dim++) {
			if (!dimensionFields[dim].getFieldId().equals(
					NYCTLCDimensionalityTypeProvider.DROPOFF_GEOMETRY_FIELD_ID)) {
				pickupConstraints.add(constraints.getDataPerDimension()[dim]);
				pickupDimFields.add(dimensionFields[dim]);
			}
			else if (!dimensionFields[dim].getFieldId().equals(
					NYCTLCDimensionalityTypeProvider.PICKUP_GEOMETRY_FIELD_ID)) {
				dropoffConstraints.add(constraints.getDataPerDimension()[dim]);
				dropoffDimFields.add(dimensionFields[dim]);
			}
		}

		return new DistributableFilterList(
				true,
				Arrays.asList(new DistributableQueryFilter[] {
					new SpatialQueryFilter(
							new BasicNumericDataset(
									pickupConstraints.toArray(new NumericData[pickupConstraints.size()])),
							pickupDimFields.toArray(new NumericDimensionField[pickupDimFields.size()]),
							pickupGeometry,
							compareOp),
					new SpatialQueryFilter(
							new BasicNumericDataset(
									dropoffConstraints.toArray(new NumericData[dropoffConstraints.size()])),
							dropoffDimFields.toArray(new NumericDimensionField[dropoffDimFields.size()]),
							dropoffGeometry,<commit_msg>updated queryfilter methods to comply with final build of 0.9.2<commit_after>package mil.nga.giat.geowave.format.nyctlc.query;

import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKBReader;
import com.vividsolutions.jts.io.WKBWriter;
import mil.nga.giat.geowave.core.geotime.store.filter.SpatialQueryFilter;
import mil.nga.giat.geowave.core.index.dimension.BasicDimensionDefinition;
import mil.nga.giat.geowave.core.index.dimension.NumericDimensionDefinition;
import mil.nga.giat.geowave.core.index.sfc.data.BasicNumericDataset;
import mil.nga.giat.geowave.core.index.sfc.data.MultiDimensionalNumericData;
import mil.nga.giat.geowave.core.index.sfc.data.NumericData;
import mil.nga.giat.geowave.core.index.sfc.data.NumericRange;
import mil.nga.giat.geowave.core.store.dimension.NumericDimensionField;
import mil.nga.giat.geowave.core.store.filter.DistributableFilterList;
import mil.nga.giat.geowave.core.store.filter.DistributableQueryFilter;
import mil.nga.giat.geowave.core.store.query.BasicQuery;
import mil.nga.giat.geowave.format.nyctlc.ingest.NYCTLCDimensionalityTypeProvider;
import mil.nga.giat.geowave.format.nyctlc.ingest.NYCTLCDimensionalityTypeProvider.TimeOfDayDefinition;

import org.apache.log4j.Logger;

import java.nio.ByteBuffer;
import java.util.*;

/**
 * Created by geowave on 4/28/16.
 */
public class NYCTLCQuery extends
		BasicQuery
{

	private final static Logger LOGGER = Logger.getLogger(NYCTLCQuery.class);
	private Geometry pickupGeometry;
	private Geometry dropoffGeometry;
	SpatialQueryFilter.CompareOperation compareOp = SpatialQueryFilter.CompareOperation.OVERLAPS;

	protected NYCTLCQuery() {}

	public NYCTLCQuery(
			final int startTime,
			final int endTime,
			final Geometry pickupGeometry,
			final Geometry dropoffGeometry ) {
		super(
				createNYCTLCConstraints(
						new ConstraintData(
								new NumericRange(
										startTime,
										endTime),
								false),
						pickupGeometry,
						dropoffGeometry));
		this.pickupGeometry = pickupGeometry;
		this.dropoffGeometry = dropoffGeometry;
	}

	public Geometry getPickupGeometry() {
		return pickupGeometry;
	}

	public Geometry getDropoffGeometry() {
		return dropoffGeometry;
	}

	@Override
	protected DistributableQueryFilter createQueryFilter(
			final MultiDimensionalNumericData constraints,
			final NumericDimensionField<?>[] dimensionFields,
			final NumericDimensionField<?>[] UCdimensionFields ) {
		final List<NumericData> pickupConstraints = new ArrayList<NumericData>();
		final List<NumericData> dropoffConstraints = new ArrayList<NumericData>();
		final List<NumericDimensionField> pickupDimFields = new ArrayList<NumericDimensionField>();
		final List<NumericDimensionField> dropoffDimFields = new ArrayList<NumericDimensionField>();
		final List<NumericDimensionField> UCpickupDimFields = new ArrayList<NumericDimensionField>();
		final List<NumericDimensionField> UCdropoffDimFields = new ArrayList<NumericDimensionField>();

		for (int dim = 0; dim < constraints.getDimensionCount() && dim < dimensionFields.length; dim++) {
			if (!dimensionFields[dim].getFieldId().equals(
					NYCTLCDimensionalityTypeProvider.DROPOFF_GEOMETRY_FIELD_ID)) {
				pickupConstraints.add(constraints.getDataPerDimension()[dim]);
				pickupDimFields.add(dimensionFields[dim]);
			}
			else if (!dimensionFields[dim].getFieldId().equals(
					NYCTLCDimensionalityTypeProvider.PICKUP_GEOMETRY_FIELD_ID)) {
				dropoffConstraints.add(constraints.getDataPerDimension()[dim]);
				dropoffDimFields.add(dimensionFields[dim]);
			}
		}

		for (int dim = 0; dim < UCdimensionFields.length; dim++) {
			if (!UCdimensionFields[dim].getFieldId().equals(
					NYCTLCDimensionalityTypeProvider.DROPOFF_GEOMETRY_FIELD_ID)) {
				UCpickupDimFields.add(UCdimensionFields[dim]);
			}
			else if (!UCdimensionFields[dim].getFieldId().equals(
					NYCTLCDimensionalityTypeProvider.PICKUP_GEOMETRY_FIELD_ID)) {
				UCdropoffDimFields.add(UCdimensionFields[dim]);
			}
		}

		return new DistributableFilterList(
				true,
				Arrays.asList(new DistributableQueryFilter[] {
					new SpatialQueryFilter(
							new BasicNumericDataset(
									pickupConstraints.toArray(new NumericData[pickupConstraints.size()])),
							pickupDimFields.toArray(new NumericDimensionField[pickupDimFields.size()]),
							UCpickupDimFields.toArray(new NumericDimensionField[UCpickupDimFields.size()]),
							pickupGeometry,
							compareOp),
					new SpatialQueryFilter(
							new BasicNumericDataset(
									dropoffConstraints.toArray(new NumericData[dropoffConstraints.size()])),
							dropoffDimFields.toArray(new NumericDimensionField[dropoffDimFields.size()]),
							UCdropoffDimFields.toArray(new NumericDimensionField[UCdropoffDimFields.size()]),
							dropoffGeometry,
{'fraction_non_alphanumeric': 0.09847371396269079, 'fraction_numerical': 0.002035048049745619, 'mean_word_length': 5.3548850574712645, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4745207', 'n_tokens_mistral': 3224, 'n_tokens_neox': 2789, 'n_words': 411}