Example #1
0
 @Override
 public void run() {
   OntologyHelper helper = helpers.get(threadKey);
   if (helper != null) {
     // Check if the last call time was longer ago than the maximum
     if (System.currentTimeMillis() - DELETE_CHECK_DELAY_MS > helper.getLastCallTime()) {
       // Assume helper is out of use - dispose of it to allow memory to be freed
       helper.dispose();
       helpers.remove(threadKey);
     }
   }
 }
Example #2
0
 public long parseToMilliseconds(
     String value,
     boolean inclusive,
     @Nullable DateTimeZone zone,
     @Nullable DateMathParser forcedDateParser) {
   SearchContext sc = SearchContext.current();
   long now = sc == null ? System.currentTimeMillis() : sc.nowInMillis();
   DateMathParser dateParser = dateMathParser;
   if (forcedDateParser != null) {
     dateParser = forcedDateParser;
   }
   return dateParser.parse(value, now, inclusive, zone);
 }
Example #3
0
 @Override
 public Query fuzzyQuery(
     String value,
     Fuzziness fuzziness,
     int prefixLength,
     int maxExpansions,
     boolean transpositions) {
   long iValue = dateMathParser.parse(value, System.currentTimeMillis());
   long iSim;
   try {
     iSim = fuzziness.asTimeValue().millis();
   } catch (Exception e) {
     // not a time format
     iSim = fuzziness.asLong();
   }
   return NumericRangeQuery.newLongRange(
       names.indexName(), precisionStep, iValue - iSim, iValue + iSim, true, true);
 }