add specific doc object, DocFieldData and specific types extension to allow in the future for simpler doc level operations
This commit is contained in:
parent
497b4a4f10
commit
668e84a99e
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.field;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class DocFieldData<T extends FieldData> {
|
||||
|
||||
protected final T fieldData;
|
||||
|
||||
protected int docId;
|
||||
|
||||
protected DocFieldData(T fieldData) {
|
||||
this.fieldData = fieldData;
|
||||
}
|
||||
|
||||
void setDocId(int docId) {
|
||||
this.docId = docId;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldData.fieldName();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return !fieldData.hasValue(docId);
|
||||
}
|
||||
|
||||
public String stringValue() {
|
||||
return fieldData.stringValue(docId);
|
||||
}
|
||||
|
||||
public FieldData.Type getType() {
|
||||
return fieldData.type();
|
||||
}
|
||||
|
||||
public boolean isMultiValued() {
|
||||
return fieldData.multiValued();
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.index.field.ints.IntFieldData;
|
|||
import org.elasticsearch.index.field.longs.LongFieldData;
|
||||
import org.elasticsearch.index.field.shorts.ShortFieldData;
|
||||
import org.elasticsearch.index.field.strings.StringFieldData;
|
||||
import org.elasticsearch.util.ThreadLocals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -35,7 +36,7 @@ import java.io.IOException;
|
|||
*/
|
||||
// General TODOs on FieldData
|
||||
// TODO Optimize the order (both int[] and int[][] when they are sparse, create an Order abstraction)
|
||||
public abstract class FieldData {
|
||||
public abstract class FieldData<Doc extends DocFieldData> {
|
||||
|
||||
public static enum Type {
|
||||
STRING(StringFieldData.class, false),
|
||||
|
@ -59,6 +60,12 @@ public abstract class FieldData {
|
|||
}
|
||||
}
|
||||
|
||||
private final ThreadLocal<ThreadLocals.CleanableValue<Doc>> cachedDocFieldData = new ThreadLocal<ThreadLocals.CleanableValue<Doc>>() {
|
||||
@Override protected ThreadLocals.CleanableValue<Doc> initialValue() {
|
||||
return new ThreadLocals.CleanableValue<Doc>(createFieldData());
|
||||
}
|
||||
};
|
||||
|
||||
private final String fieldName;
|
||||
|
||||
private final FieldDataOptions options;
|
||||
|
@ -75,6 +82,14 @@ public abstract class FieldData {
|
|||
return fieldName;
|
||||
}
|
||||
|
||||
public Doc docFieldData(int docId) {
|
||||
Doc docFieldData = cachedDocFieldData.get().get();
|
||||
docFieldData.setDocId(docId);
|
||||
return docFieldData;
|
||||
}
|
||||
|
||||
protected abstract Doc createFieldData();
|
||||
|
||||
/**
|
||||
* Is the field data a multi valued one (has multiple values / terms per document id) or not.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.field;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class NumericDocFieldData<T extends NumericFieldData> extends DocFieldData<T> {
|
||||
|
||||
public NumericDocFieldData(T fieldData) {
|
||||
super(fieldData);
|
||||
}
|
||||
|
||||
public int getIntValue() {
|
||||
return fieldData.intValue(docId);
|
||||
}
|
||||
|
||||
public long getLongValue() {
|
||||
return fieldData.longValue(docId);
|
||||
}
|
||||
|
||||
public float getFloatValue() {
|
||||
return fieldData.floatValue(docId);
|
||||
}
|
||||
|
||||
public double getDoubleValue() {
|
||||
return fieldData.doubleValue(docId);
|
||||
}
|
||||
|
||||
public short getShortValue() {
|
||||
return fieldData.shortValue(docId);
|
||||
}
|
||||
|
||||
public byte getByteValue() {
|
||||
return fieldData.byteValue(docId);
|
||||
}
|
||||
|
||||
public double[] getDoubleValues() {
|
||||
return fieldData.doubleValues(docId);
|
||||
}
|
||||
}
|
|
@ -20,9 +20,9 @@
|
|||
package org.elasticsearch.index.field;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class NumericFieldData extends FieldData {
|
||||
public abstract class NumericFieldData<Doc extends NumericDocFieldData> extends FieldData<Doc> {
|
||||
|
||||
protected NumericFieldData(String fieldName, FieldDataOptions options) {
|
||||
super(fieldName, options);
|
||||
|
@ -86,6 +86,10 @@ public abstract class NumericFieldData extends FieldData {
|
|||
return (short) intValue(docId);
|
||||
}
|
||||
|
||||
@Override public Doc docFieldData(int docId) {
|
||||
return super.docFieldData(docId);
|
||||
}
|
||||
|
||||
public abstract double[] doubleValues(int docId);
|
||||
|
||||
public abstract void forEachValueInDoc(int docId, DoubleValueInDocProc proc);
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.field.doubles;
|
||||
|
||||
import org.elasticsearch.index.field.NumericDocFieldData;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class DoubleDocFieldData extends NumericDocFieldData<DoubleFieldData> {
|
||||
|
||||
public DoubleDocFieldData(DoubleFieldData fieldData) {
|
||||
super(fieldData);
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return fieldData.value(docId);
|
||||
}
|
||||
|
||||
public double[] getValues() {
|
||||
return fieldData.values(docId);
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class DoubleFieldData extends NumericFieldData {
|
||||
public abstract class DoubleFieldData extends NumericFieldData<DoubleDocFieldData> {
|
||||
|
||||
public static final double[] EMPTY_DOUBLE_ARRAY = new double[0];
|
||||
|
||||
|
@ -48,6 +48,14 @@ public abstract class DoubleFieldData extends NumericFieldData {
|
|||
|
||||
abstract public double[] values(int docId);
|
||||
|
||||
@Override public DoubleDocFieldData docFieldData(int docId) {
|
||||
return super.docFieldData(docId);
|
||||
}
|
||||
|
||||
@Override protected DoubleDocFieldData createFieldData() {
|
||||
return new DoubleDocFieldData(this);
|
||||
}
|
||||
|
||||
@Override public String stringValue(int docId) {
|
||||
return Double.toString(value(docId));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.field.floats;
|
||||
|
||||
import org.elasticsearch.index.field.NumericDocFieldData;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FloatDocFieldData extends NumericDocFieldData<FloatFieldData> {
|
||||
|
||||
public FloatDocFieldData(FloatFieldData fieldData) {
|
||||
super(fieldData);
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return fieldData.value(docId);
|
||||
}
|
||||
|
||||
public float[] getValues() {
|
||||
return fieldData.values(docId);
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*/
|
||||
public abstract class FloatFieldData extends NumericFieldData {
|
||||
public abstract class FloatFieldData extends NumericFieldData<FloatDocFieldData> {
|
||||
|
||||
static final float[] EMPTY_FLOAT_ARRAY = new float[0];
|
||||
|
||||
|
@ -48,6 +48,14 @@ public abstract class FloatFieldData extends NumericFieldData {
|
|||
|
||||
abstract public float[] values(int docId);
|
||||
|
||||
@Override public FloatDocFieldData docFieldData(int docId) {
|
||||
return super.docFieldData(docId);
|
||||
}
|
||||
|
||||
@Override protected FloatDocFieldData createFieldData() {
|
||||
return new FloatDocFieldData(this);
|
||||
}
|
||||
|
||||
@Override public String stringValue(int docId) {
|
||||
return Float.toString(value(docId));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.field.ints;
|
||||
|
||||
import org.elasticsearch.index.field.NumericDocFieldData;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class IntDocFieldData extends NumericDocFieldData<IntFieldData> {
|
||||
|
||||
public IntDocFieldData(IntFieldData fieldData) {
|
||||
super(fieldData);
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return fieldData.value(docId);
|
||||
}
|
||||
|
||||
public int[] getValues() {
|
||||
return fieldData.values(docId);
|
||||
}
|
||||
}
|
|
@ -29,9 +29,9 @@ import org.elasticsearch.util.gnu.trove.TIntArrayList;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class IntFieldData extends NumericFieldData {
|
||||
public abstract class IntFieldData extends NumericFieldData<IntDocFieldData> {
|
||||
|
||||
static final int[] EMPTY_INT_ARRAY = new int[0];
|
||||
|
||||
|
@ -48,6 +48,14 @@ public abstract class IntFieldData extends NumericFieldData {
|
|||
|
||||
abstract public int[] values(int docId);
|
||||
|
||||
@Override public IntDocFieldData docFieldData(int docId) {
|
||||
return super.docFieldData(docId);
|
||||
}
|
||||
|
||||
@Override protected IntDocFieldData createFieldData() {
|
||||
return new IntDocFieldData(this);
|
||||
}
|
||||
|
||||
@Override public String stringValue(int docId) {
|
||||
return Integer.toString(value(docId));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.field.longs;
|
||||
|
||||
import org.elasticsearch.index.field.NumericDocFieldData;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class LongDocFieldData extends NumericDocFieldData<LongFieldData> {
|
||||
|
||||
public LongDocFieldData(LongFieldData fieldData) {
|
||||
super(fieldData);
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return fieldData.value(docId);
|
||||
}
|
||||
|
||||
public long[] getValues() {
|
||||
return fieldData.values(docId);
|
||||
}
|
||||
}
|
|
@ -29,9 +29,9 @@ import org.elasticsearch.util.gnu.trove.TLongArrayList;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class LongFieldData extends NumericFieldData {
|
||||
public abstract class LongFieldData extends NumericFieldData<LongDocFieldData> {
|
||||
|
||||
static final long[] EMPTY_LONG_ARRAY = new long[0];
|
||||
|
||||
|
@ -49,6 +49,14 @@ public abstract class LongFieldData extends NumericFieldData {
|
|||
|
||||
abstract public long[] values(int docId);
|
||||
|
||||
@Override public LongDocFieldData docFieldData(int docId) {
|
||||
return super.docFieldData(docId);
|
||||
}
|
||||
|
||||
@Override protected LongDocFieldData createFieldData() {
|
||||
return new LongDocFieldData(this);
|
||||
}
|
||||
|
||||
@Override public void forEachValue(StringValueProc proc) {
|
||||
if (freqs == null) {
|
||||
for (int i = 1; i < values.length; i++) {
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.field.shorts;
|
||||
|
||||
import org.elasticsearch.index.field.NumericDocFieldData;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ShortDocFieldData extends NumericDocFieldData<ShortFieldData> {
|
||||
|
||||
public ShortDocFieldData(ShortFieldData fieldData) {
|
||||
super(fieldData);
|
||||
}
|
||||
|
||||
public short getValue() {
|
||||
return fieldData.value(docId);
|
||||
}
|
||||
|
||||
public short[] getValues() {
|
||||
return fieldData.values(docId);
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*/
|
||||
public abstract class ShortFieldData extends NumericFieldData {
|
||||
public abstract class ShortFieldData extends NumericFieldData<ShortDocFieldData> {
|
||||
|
||||
static final short[] EMPTY_SHORT_ARRAY = new short[0];
|
||||
|
||||
|
@ -48,6 +48,14 @@ public abstract class ShortFieldData extends NumericFieldData {
|
|||
|
||||
abstract public short[] values(int docId);
|
||||
|
||||
@Override public ShortDocFieldData docFieldData(int docId) {
|
||||
return super.docFieldData(docId);
|
||||
}
|
||||
|
||||
@Override protected ShortDocFieldData createFieldData() {
|
||||
return new ShortDocFieldData(this);
|
||||
}
|
||||
|
||||
@Override public void forEachValue(StringValueProc proc) {
|
||||
if (freqs == null) {
|
||||
for (int i = 1; i < values.length; i++) {
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.field.strings;
|
||||
|
||||
import org.elasticsearch.index.field.DocFieldData;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class StringDocFieldData extends DocFieldData<StringFieldData> {
|
||||
|
||||
public StringDocFieldData(StringFieldData fieldData) {
|
||||
super(fieldData);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return fieldData.value(docId);
|
||||
}
|
||||
|
||||
public String[] getValues() {
|
||||
return fieldData.values(docId);
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import java.util.ArrayList;
|
|||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*/
|
||||
public abstract class StringFieldData extends FieldData {
|
||||
public abstract class StringFieldData extends FieldData<StringDocFieldData> {
|
||||
|
||||
protected final String[] values;
|
||||
protected final int[] freqs;
|
||||
|
@ -45,10 +45,18 @@ public abstract class StringFieldData extends FieldData {
|
|||
|
||||
abstract public String[] values(int docId);
|
||||
|
||||
@Override public StringDocFieldData docFieldData(int docId) {
|
||||
return super.docFieldData(docId);
|
||||
}
|
||||
|
||||
@Override public String stringValue(int docId) {
|
||||
return value(docId);
|
||||
}
|
||||
|
||||
@Override protected StringDocFieldData createFieldData() {
|
||||
return new StringDocFieldData(this);
|
||||
}
|
||||
|
||||
@Override public Type type() {
|
||||
return Type.STRING;
|
||||
}
|
||||
|
|
|
@ -88,20 +88,27 @@ public class DoubleFieldDataTests {
|
|||
// svalue
|
||||
assertThat(sFieldData.hasValue(0), equalTo(true));
|
||||
assertThat(sFieldData.value(0), equalTo(4d));
|
||||
assertThat(sFieldData.docFieldData(0).getValue(), equalTo(4d));
|
||||
assertThat(sFieldData.values(0).length, equalTo(1));
|
||||
assertThat(sFieldData.values(0)[0], equalTo(4d));
|
||||
assertThat(sFieldData.docFieldData(0).getValues()[0], equalTo(4d));
|
||||
|
||||
assertThat(sFieldData.hasValue(1), equalTo(true));
|
||||
assertThat(sFieldData.value(1), equalTo(3d));
|
||||
assertThat(sFieldData.docFieldData(1).getValue(), equalTo(3d));
|
||||
assertThat(sFieldData.values(1).length, equalTo(1));
|
||||
assertThat(sFieldData.values(1)[0], equalTo(3d));
|
||||
assertThat(sFieldData.docFieldData(1).getValues()[0], equalTo(3d));
|
||||
|
||||
assertThat(sFieldData.hasValue(2), equalTo(true));
|
||||
assertThat(sFieldData.value(2), equalTo(7d));
|
||||
assertThat(sFieldData.docFieldData(2).getValue(), equalTo(7d));
|
||||
assertThat(sFieldData.values(2).length, equalTo(1));
|
||||
assertThat(sFieldData.values(2)[0], equalTo(7d));
|
||||
assertThat(sFieldData.docFieldData(2).getValues()[0], equalTo(7d));
|
||||
|
||||
assertThat(sFieldData.hasValue(3), equalTo(false));
|
||||
assertThat(sFieldData.docFieldData(3).isEmpty(), equalTo(true));
|
||||
|
||||
assertThat(sFieldData.hasValue(4), equalTo(true));
|
||||
assertThat(sFieldData.value(4), equalTo(4d));
|
||||
|
@ -129,9 +136,12 @@ public class DoubleFieldDataTests {
|
|||
|
||||
// mvalue
|
||||
assertThat(mFieldData.hasValue(0), equalTo(true));
|
||||
assertThat(mFieldData.docFieldData(0).isEmpty(), equalTo(false));
|
||||
assertThat(mFieldData.value(0), equalTo(104d));
|
||||
assertThat(mFieldData.docFieldData(0).getValue(), equalTo(104d));
|
||||
assertThat(mFieldData.values(0).length, equalTo(1));
|
||||
assertThat(mFieldData.values(0)[0], equalTo(104d));
|
||||
assertThat(mFieldData.docFieldData(0).getValues()[0], equalTo(104d));
|
||||
|
||||
assertThat(mFieldData.hasValue(1), equalTo(true));
|
||||
assertThat(mFieldData.value(1), equalTo(104d));
|
||||
|
|
|
@ -87,9 +87,12 @@ public class FloatFieldDataTests {
|
|||
|
||||
// svalue
|
||||
assertThat(sFieldData.hasValue(0), equalTo(true));
|
||||
assertThat(sFieldData.docFieldData(0).isEmpty(), equalTo(false));
|
||||
assertThat(sFieldData.value(0), equalTo(4f));
|
||||
assertThat(sFieldData.docFieldData(0).getValue(), equalTo(4f));
|
||||
assertThat(sFieldData.values(0).length, equalTo(1));
|
||||
assertThat(sFieldData.values(0)[0], equalTo(4f));
|
||||
assertThat(sFieldData.docFieldData(0).getValues().length, equalTo(1));
|
||||
assertThat(sFieldData.docFieldData(0).getValues()[0], equalTo(4f));
|
||||
|
||||
assertThat(sFieldData.hasValue(1), equalTo(true));
|
||||
assertThat(sFieldData.value(1), equalTo(3f));
|
||||
|
@ -129,15 +132,21 @@ public class FloatFieldDataTests {
|
|||
|
||||
// mvalue
|
||||
assertThat(mFieldData.hasValue(0), equalTo(true));
|
||||
assertThat(mFieldData.docFieldData(0).isEmpty(), equalTo(false));
|
||||
assertThat(mFieldData.value(0), equalTo(104f));
|
||||
assertThat(mFieldData.docFieldData(0).getValue(), equalTo(104f));
|
||||
assertThat(mFieldData.values(0).length, equalTo(1));
|
||||
assertThat(mFieldData.docFieldData(0).getValues().length, equalTo(1));
|
||||
assertThat(mFieldData.values(0)[0], equalTo(104f));
|
||||
assertThat(mFieldData.docFieldData(0).getValues()[0], equalTo(104f));
|
||||
|
||||
assertThat(mFieldData.hasValue(1), equalTo(true));
|
||||
assertThat(mFieldData.value(1), equalTo(104f));
|
||||
assertThat(mFieldData.values(1).length, equalTo(2));
|
||||
assertThat(mFieldData.docFieldData(1).getValues().length, equalTo(2));
|
||||
assertThat(mFieldData.values(1)[0], equalTo(104f));
|
||||
assertThat(mFieldData.values(1)[1], equalTo(105f));
|
||||
assertThat(mFieldData.docFieldData(1).getValues()[0], equalTo(104f));
|
||||
assertThat(mFieldData.docFieldData(1).getValues()[1], equalTo(105f));
|
||||
|
||||
assertThat(mFieldData.hasValue(2), equalTo(false));
|
||||
|
||||
|
|
|
@ -87,9 +87,12 @@ public class IntFieldDataTests {
|
|||
|
||||
// svalue
|
||||
assertThat(sFieldData.hasValue(0), equalTo(true));
|
||||
assertThat(sFieldData.docFieldData(0).isEmpty(), equalTo(false));
|
||||
assertThat(sFieldData.value(0), equalTo(4));
|
||||
assertThat(sFieldData.docFieldData(0).getValue(), equalTo(4));
|
||||
assertThat(sFieldData.values(0).length, equalTo(1));
|
||||
assertThat(sFieldData.values(0)[0], equalTo(4));
|
||||
assertThat(sFieldData.docFieldData(0).getValues().length, equalTo(1));
|
||||
assertThat(sFieldData.docFieldData(0).getValues()[0], equalTo(4));
|
||||
|
||||
assertThat(sFieldData.hasValue(1), equalTo(true));
|
||||
assertThat(sFieldData.value(1), equalTo(3));
|
||||
|
|
|
@ -89,9 +89,13 @@ public class LongFieldDataTests {
|
|||
|
||||
// svalue
|
||||
assertThat(sFieldData.hasValue(0), equalTo(true));
|
||||
assertThat(sFieldData.docFieldData(0).isEmpty(), equalTo(false));
|
||||
assertThat(sFieldData.value(0), equalTo(4l));
|
||||
assertThat(sFieldData.docFieldData(0).getValue(), equalTo(4l));
|
||||
assertThat(sFieldData.values(0).length, equalTo(1));
|
||||
assertThat(sFieldData.docFieldData(0).getValues().length, equalTo(1));
|
||||
assertThat(sFieldData.values(0)[0], equalTo(4l));
|
||||
assertThat(sFieldData.docFieldData(0).getValues()[0], equalTo(4l));
|
||||
|
||||
assertThat(sFieldData.hasValue(1), equalTo(true));
|
||||
assertThat(sFieldData.value(1), equalTo(3l));
|
||||
|
|
|
@ -87,9 +87,13 @@ public class ShortFieldDataTests {
|
|||
|
||||
// svalue
|
||||
assertThat(sFieldData.hasValue(0), equalTo(true));
|
||||
assertThat(sFieldData.docFieldData(0).isEmpty(), equalTo(false));
|
||||
assertThat(sFieldData.value(0), equalTo((short) 4));
|
||||
assertThat(sFieldData.docFieldData(0).getValue(), equalTo((short) 4));
|
||||
assertThat(sFieldData.values(0).length, equalTo(1));
|
||||
assertThat(sFieldData.docFieldData(0).getValues().length, equalTo(1));
|
||||
assertThat(sFieldData.values(0)[0], equalTo((short) 4));
|
||||
assertThat(sFieldData.docFieldData(0).getValues()[0], equalTo((short) 4));
|
||||
|
||||
assertThat(sFieldData.hasValue(1), equalTo(true));
|
||||
assertThat(sFieldData.value(1), equalTo((short) 3));
|
||||
|
@ -135,9 +139,12 @@ public class ShortFieldDataTests {
|
|||
|
||||
assertThat(mFieldData.hasValue(1), equalTo(true));
|
||||
assertThat(mFieldData.value(1), equalTo((short) 104));
|
||||
assertThat(mFieldData.docFieldData(1).getValue(), equalTo((short) 104));
|
||||
assertThat(mFieldData.values(1).length, equalTo(2));
|
||||
assertThat(mFieldData.docFieldData(1).getValues().length, equalTo(2));
|
||||
assertThat(mFieldData.values(1)[0], equalTo((short) 104));
|
||||
assertThat(mFieldData.values(1)[1], equalTo((short) 105));
|
||||
assertThat(mFieldData.docFieldData(1).getValues()[0], equalTo((short) 104));
|
||||
assertThat(mFieldData.docFieldData(1).getValues()[1], equalTo((short) 105));
|
||||
|
||||
assertThat(mFieldData.hasValue(2), equalTo(false));
|
||||
|
||||
|
|
|
@ -81,8 +81,11 @@ public class StringFieldDataTests {
|
|||
// svalue
|
||||
assertThat(sFieldData.hasValue(0), equalTo(true));
|
||||
assertThat(sFieldData.value(0), equalTo("zzz"));
|
||||
assertThat(sFieldData.docFieldData(0).getValue(), equalTo("zzz"));
|
||||
assertThat(sFieldData.values(0).length, equalTo(1));
|
||||
assertThat(sFieldData.docFieldData(0).getValues().length, equalTo(1));
|
||||
assertThat(sFieldData.values(0)[0], equalTo("zzz"));
|
||||
assertThat(sFieldData.docFieldData(0).getValues()[0], equalTo("zzz"));
|
||||
|
||||
assertThat(sFieldData.hasValue(1), equalTo(true));
|
||||
assertThat(sFieldData.value(1), equalTo("xxx"));
|
||||
|
|
Loading…
Reference in New Issue