From 8dfc3acba0066a6fdfee8c3dfba5c0de751719f4 Mon Sep 17 00:00:00 2001 From: kimchy Date: Sun, 19 Dec 2010 05:01:59 +0200 Subject: [PATCH] when using dates in scripts, initialize the dates (DateTime) with UTC --- .../elasticsearch/index/field/data/longs/LongFieldData.java | 3 ++- .../index/field/data/longs/MultiValueLongFieldData.java | 3 ++- .../index/field/data/longs/SingleValueLongFieldData.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java index a6b3c28c2a0..643f214515a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java @@ -21,6 +21,7 @@ package org.elasticsearch.index.field.data.longs; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldCache; +import org.elasticsearch.common.joda.time.DateTimeZone; import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.common.trove.TLongArrayList; @@ -40,7 +41,7 @@ public abstract class LongFieldData extends NumericFieldData { private ThreadLocal> dateTimeCache = new ThreadLocal>() { @Override protected ThreadLocals.CleanableValue initialValue() { - return new ThreadLocals.CleanableValue(new MutableDateTime()); + return new ThreadLocals.CleanableValue(new MutableDateTime(DateTimeZone.UTC)); } }; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java index 3dd9cd8bccc..e516542afb2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/MultiValueLongFieldData.java @@ -19,6 +19,7 @@ package org.elasticsearch.index.field.data.longs; +import org.elasticsearch.common.joda.time.DateTimeZone; import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; @@ -46,7 +47,7 @@ public class MultiValueLongFieldData extends LongFieldData { for (int i = 0; i < value.length; i++) { value[i] = new MutableDateTime[i]; for (int j = 0; j < i; j++) { - value[i][j] = new MutableDateTime(); + value[i][j] = new MutableDateTime(DateTimeZone.UTC); } } return new ThreadLocals.CleanableValue(value); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/SingleValueLongFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/SingleValueLongFieldData.java index 5249afc2fb1..9cd3bf78f51 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/SingleValueLongFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/SingleValueLongFieldData.java @@ -19,6 +19,7 @@ package org.elasticsearch.index.field.data.longs; +import org.elasticsearch.common.joda.time.DateTimeZone; import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.field.data.doubles.DoubleFieldData; @@ -37,7 +38,7 @@ public class SingleValueLongFieldData extends LongFieldData { private ThreadLocal> datesValuesCache = new ThreadLocal>() { @Override protected ThreadLocals.CleanableValue initialValue() { MutableDateTime[] date = new MutableDateTime[1]; - date[0] = new MutableDateTime(); + date[0] = new MutableDateTime(DateTimeZone.UTC); return new ThreadLocals.CleanableValue(date); } };