Search in sources :

Example 21 with ValueTuple

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

the class EvaluationPhaseFilterFunctions method afterDate.

/**
 * Searches for a date after start (exclusively)
 *
 * @param fieldValue
 *            A field value in the supplied format
 * @param pattern
 *            A date format to be supplied to java.text.SimpleDateFormat
 * @param start
 *            A start date in the supplied rangePattern format
 * @param rangePattern
 *            A date format to be supplied to java.text.SimpleDateFormat
 * @return True if the datetime occurs after the provided datetime value
 */
public static FunctionalSet<ValueTuple> afterDate(Object fieldValue, String pattern, String start, String rangePattern) {
    FunctionalSet<ValueTuple> matches = FunctionalSet.emptySet();
    if (fieldValue != null) {
        try {
            DateFormat format = newSimpleDateFormat(pattern);
            DateFormat rangeFormat = newSimpleDateFormat(rangePattern);
            int granularity = getGranularity(rangePattern);
            long lStart = getNextTime(start, rangeFormat, granularity);
            long lEnd = Long.MAX_VALUE;
            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 " + start + ": " + nfe.getMessage());
        }
    }
    return matches;
}
Also used : ValueTuple(datawave.query.attributes.ValueTuple) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException)

Example 22 with ValueTuple

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

the class EvaluationPhaseFilterFunctions method afterLoadDate.

/**
 * Searches for a load date after start (exclusively)
 *
 * @param fieldValue
 *            An iterable of field values as "time since epoch" longs: should be LOAD_DATE
 * @param start
 *            A start date in the supplied rangePattern format
 * @param rangePattern
 *            A date format to be supplied to java.text.SimpleDateFormat
 * @return True if the datetime occurs after the provided datetime value
 */
public static FunctionalSet<ValueTuple> afterLoadDate(Iterable<?> fieldValue, String start, String rangePattern) {
    FunctionalSet<ValueTuple> matches = FunctionalSet.emptySet();
    if (fieldValue != null) {
        try {
            DateFormat rangeFormat = newSimpleDateFormat(rangePattern);
            int granularity = getGranularity(rangePattern);
            for (Object o : fieldValue) {
                if (betweenInclusive(Long.parseLong(ValueTuple.getStringValue(o)), getNextTime(start, rangeFormat, granularity), Long.MAX_VALUE)) {
                    matches = FunctionalSet.singleton(getHitTerm(o));
                    break;
                }
            }
        } catch (ParseException pe) {
            log.error(pe.getMessage());
        } catch (NumberFormatException nfe) {
            log.error("Unable to numeric argument " + start + ": " + nfe.getMessage());
        }
    }
    return matches;
}
Also used : ValueTuple(datawave.query.attributes.ValueTuple) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException)

Example 23 with ValueTuple

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

the class EvaluationPhaseFilterFunctions method afterDate.

/**
 * Searches for a date after start (exclusively)
 *
 * @param fieldValue
 *            An iterable of field values in one of the formats above
 * @param start
 *            A start date in the supplied rangePattern format
 * @param rangePattern
 *            A date format to be supplied to java.text.SimpleDateFormat
 * @return True if the datetime occurs after the provided datetime value
 */
public static FunctionalSet<ValueTuple> afterDate(Iterable<?> fieldValue, String start, String rangePattern) {
    FunctionalSet<ValueTuple> matches = FunctionalSet.emptySet();
    if (fieldValue != null) {
        try {
            DateFormat rangeFormat = newSimpleDateFormat(rangePattern);
            int granularity = getGranularity(rangePattern);
            for (Object o : fieldValue) {
                if (betweenInclusive(getTime(o), getNextTime(start, rangeFormat, granularity), Long.MAX_VALUE)) {
                    matches = FunctionalSet.singleton(getHitTerm(o));
                    break;
                }
            }
        } catch (ParseException pe) {
            log.error(pe.getMessage());
        }
    }
    return matches;
}
Also used : ValueTuple(datawave.query.attributes.ValueTuple) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException)

Example 24 with ValueTuple

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

the class EvaluationPhaseFilterFunctions method betweenLoadDates.

/**
 * Searches for a load date between start and end (inclusively)
 *
 * @param fieldValue
 *            A field value as a "time since epoch" long: should be LOAD_DATE
 * @param start
 *            A start date in the supplied rangePattern format
 * @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 between the provided datetime values
 */
public static FunctionalSet<ValueTuple> betweenLoadDates(Object fieldValue, String start, String end, String rangePattern) {
    FunctionalSet<ValueTuple> matches = FunctionalSet.emptySet();
    if (fieldValue != null) {
        try {
            DateFormat rangeFormat = newSimpleDateFormat(rangePattern);
            int granularity = getGranularity(rangePattern);
            if (betweenInclusive(Long.parseLong(ValueTuple.getStringValue(fieldValue)), getTime(start, rangeFormat), getNextTime(end, rangeFormat, granularity) - 1)) {
                matches = FunctionalSet.singleton(getHitTerm(fieldValue));
            }
        } catch (ParseException pe) {
            log.error(pe.getMessage());
        } catch (NumberFormatException nfe) {
            log.error("Unable to numeric argument " + start + " or " + end + ": " + nfe.getMessage());
        }
    }
    return matches;
}
Also used : ValueTuple(datawave.query.attributes.ValueTuple) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException)

Example 25 with ValueTuple

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

the class EvaluationPhaseFilterFunctions method afterLoadDate.

/**
 * Searches for a load date after start (exclusively)
 *
 * @param fieldValue
 *            A field value as a "time since epoch" long: should be LOAD_DATE
 * @param start
 *            A start date in the supplied rangePattern format
 * @param rangePattern
 *            A date format to be supplied to java.text.SimpleDateFormat
 * @return True if the datetime occurs after the provided datetime value
 */
public static FunctionalSet<ValueTuple> afterLoadDate(Object fieldValue, String start, String rangePattern) {
    FunctionalSet<ValueTuple> matches = FunctionalSet.emptySet();
    if (fieldValue != null) {
        try {
            DateFormat rangeFormat = newSimpleDateFormat(rangePattern);
            int granularity = getGranularity(rangePattern);
            if (betweenInclusive(Long.parseLong(ValueTuple.getStringValue(fieldValue)), getNextTime(start, rangeFormat, granularity), Long.MAX_VALUE)) {
                matches = FunctionalSet.singleton(getHitTerm(fieldValue));
            }
        } catch (ParseException pe) {
            log.error(pe.getMessage());
        } catch (NumberFormatException nfe) {
            log.error("Unable to numeric argument " + start + ": " + 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