Search in sources :

Example 26 with ValueTuple

use of datawave.query.attributes.ValueTuple in project datawave by NationalSecurityAgency.

the class EvaluationPhaseFilterFunctions method beforeDate.

/**
 * Searches for a date before end (exclusively)
 *
 * @param fieldValue
 *            A field value in the supplied format
 * @param pattern
 *            A date format to be supplied to java.text.SimpleDateFormat
 * @param end
 *            An end date in the supplied rangePattern format
 * @param rangePattern
 *            A date format to be supplied to java.text.SimpleDateFormat
 * @return True if the datetime occurs before the provided datetime value
 */
public static FunctionalSet<ValueTuple> beforeDate(Object fieldValue, String pattern, String end, String rangePattern) {
    FunctionalSet<ValueTuple> matches = FunctionalSet.emptySet();
    if (fieldValue != null) {
        try {
            DateFormat format = newSimpleDateFormat(pattern);
            DateFormat rangeFormat = newSimpleDateFormat(rangePattern);
            long lStart = 0;
            long lEnd = getTime(end, rangeFormat) - 1;
            if (betweenInclusive(getTime(fieldValue, format), lStart, lEnd)) {
                matches = FunctionalSet.singleton(getHitTerm(fieldValue));
            }
        } catch (ParseException pe) {
            log.error(pe.getMessage());
        } catch (NumberFormatException nfe) {
            log.error("Unable to numeric argument " + end + ": " + nfe.getMessage());
        }
    }
    return matches;
}
Also used : ValueTuple(datawave.query.attributes.ValueTuple) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException)

Aggregations

ValueTuple (datawave.query.attributes.ValueTuple)26 DateFormat (java.text.DateFormat)10 ParseException (java.text.ParseException)10 SimpleDateFormat (java.text.SimpleDateFormat)10 HashSet (java.util.HashSet)5 NumberType (datawave.data.type.NumberType)3 Attributes (datawave.query.attributes.Attributes)2 TypeAttribute (datawave.query.attributes.TypeAttribute)2 FunctionalSet (datawave.query.collections.FunctionalSet)2 Key (org.apache.accumulo.core.data.Key)2 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)2 GeoNormalizer (datawave.data.normalizer.GeoNormalizer)1 AbstractGeometryType (datawave.data.type.AbstractGeometryType)1 GeoType (datawave.data.type.GeoType)1 LcNoDiacriticsType (datawave.data.type.LcNoDiacriticsType)1 Type (datawave.data.type.Type)1 AbstractGeometry (datawave.data.type.util.AbstractGeometry)1 MarkingFunctions (datawave.marking.MarkingFunctions)1 Content (datawave.query.attributes.Content)1 Document (datawave.query.attributes.Document)1