@Deprecated public List<JodaCompatibleZonedDateTime> getDates() throws IOException { deprecated("scripting_get_date_deprecation", "getDates on numeric fields is deprecated. Use a date field to get dates."); if (dates == null) { dates = new Dates(in, deprecationCallback); dates.setNextDocId(docId); } return dates; }
/** * Fetch the first field value or 0 millis after epoch if there are no * in. */ public JodaCompatibleZonedDateTime getValue() { if (count == 0) { if (ScriptDocValues.EXCEPTION_FOR_MISSING_VALUE) { throw new IllegalStateException("A document doesn't have a value for a field! " + "Use doc[<field>].size()==0 to check if a document is missing a field!"); } deprecated("scripting_missing_value_deprecation", "returning default values for missing document values is deprecated. " + "Set system property '-Des.scripting.exception_for_missing_value=true' " + "to make behaviour compatible with future major versions!"); return EPOCH; } return get(0); }
/** * Fetch the first value. Added for backwards compatibility with 5.x when date fields were {@link Longs}. */ @Deprecated public JodaCompatibleZonedDateTime getDate() { deprecated("scripting_get_date_deprecation", "getDate is no longer necessary on date fields as the value is now a date."); return getValue(); }
@Override public final ScriptDocValues<?> getLegacyFieldValues() { switch (numericType) { case DATE: final ScriptDocValues.Dates realDV = new ScriptDocValues.Dates(getLongValues()); return new ScriptDocValues<DateTime>() { @Override public int size() { return realDV.size(); } @Override public DateTime get(int index) { JodaCompatibleZonedDateTime dt = realDV.get(index); return new DateTime(dt.toInstant().toEpochMilli(), DateTimeZone.UTC); } @Override public void setNextDocId(int docId) throws IOException { realDV.setNextDocId(docId); } }; default: return getScriptValues(); } }
/** * Fetch the first field value or 0 millis after epoch if there are no * in. */ public JodaCompatibleZonedDateTime getValue() { if (count == 0) { if (ScriptDocValues.EXCEPTION_FOR_MISSING_VALUE) { throw new IllegalStateException("A document doesn't have a value for a field! " + "Use doc[<field>].size()==0 to check if a document is missing a field!"); } deprecated("scripting_missing_value_deprecation", "returning default values for missing document values is deprecated. " + "Set system property '-Des.scripting.exception_for_missing_value=true' " + "to make behaviour compatible with future major versions!"); return EPOCH; } return get(0); }
@Override public void setNextDocId(int docId) throws IOException { this.docId = docId; if (in.advanceExact(docId)) { resize(in.docValueCount()); for (int i = 0; i < count; i++) { values[i] = in.nextValue(); } } else { resize(0); } if (dates != null) { dates.setNextDocId(docId); } }
@Override public void setNextDocId(int docId) throws IOException { this.docId = docId; if (in.advanceExact(docId)) { resize(in.docValueCount()); for (int i = 0; i < count; i++) { values[i] = in.nextValue(); } } else { resize(0); } if (dates != null) { dates.setNextDocId(docId); } }
/** * Fetch the first field value or 0 millis after epoch if there are no * in. */ public ReadableDateTime getValue() { if (count == 0) { if (ScriptModule.EXCEPTION_FOR_MISSING_VALUE) { throw new IllegalStateException("A document doesn't have a value for a field! " + "Use doc[<field>].size()==0 to check if a document is missing a field!"); } return EPOCH; } return get(0); }
@Override public int size() { return realDV.size(); }
@Override public void setNextDocId(int docId) throws IOException { if (in.advanceExact(docId)) { count = in.docValueCount(); } else { count = 0; } refreshArray(); }
@Deprecated public List<ReadableDateTime> getDates() throws IOException { deprecated("getDates on numeric fields is deprecated. Use a date field to get dates."); if (dates == null) { dates = new Dates(in); dates.setNextDocId(docId); } return dates; }
@Override public final ScriptDocValues<?> getScriptValues() { switch (numericType) { case DATE: return new ScriptDocValues.Dates(getLongValues()); case BOOLEAN: return new ScriptDocValues.Booleans(getLongValues()); default: return new ScriptDocValues.Longs(getLongValues()); } }
/** * Fetch the first field value or 0 millis after epoch if there are no values. */ public ReadableDateTime getValue() { if (values.count() == 0) { return EPOCH; } return get(0); }
/** * Fetch the first value. Added for backwards compatibility with 5.x when date fields were {@link Longs}. */ @Deprecated public ReadableDateTime getDate() { deprecated("getDate is no longer necessary on date fields as the value is now a date."); return getValue(); }
/** * Fetch all the values. Added for backwards compatibility with 5.x when date fields were {@link Longs}. */ @Deprecated public List<JodaCompatibleZonedDateTime> getDates() { deprecated("scripting_get_date_deprecation", "getDates is no longer necessary on date fields as the values are now dates."); return this; }
@Override public void setNextDocId(int docId) throws IOException { realDV.setNextDocId(docId); } };
@Override public DateTime get(int index) { JodaCompatibleZonedDateTime dt = realDV.get(index); return new DateTime(dt.toInstant().toEpochMilli(), DateTimeZone.UTC); }
@Deprecated public ReadableDateTime getDate() throws IOException { deprecated("getDate on numeric fields is deprecated. Use a date field to get dates."); if (dates == null) { dates = new Dates(in); dates.setNextDocId(docId); } return dates.getValue(); }
@Override public void setNextDocId(int docId) { values.setDocument(docId); refreshArray(); }
@Override public void setNextDocId(int docId) { values.setDocument(docId); if (dates != null) { dates.refreshArray(); } }