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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations