private void test(List<TLongSet> values) throws Exception { StringField id = new StringField("_id", "", Field.Store.NO); for (int i = 0; i < values.size(); ++i) { Document doc = new Document(); id.setStringValue("" + i); doc.add(id); final TLongSet v = values.get(i); for (TLongIterator it = v.iterator(); it.hasNext(); ) { LongField value = new LongField("value", it.next(), Field.Store.NO); doc.add(value); } writer.addDocument(doc); } writer.forceMerge(1); final IndexNumericFieldData indexFieldData = getForField("value"); final AtomicNumericFieldData atomicFieldData = indexFieldData.load(refreshReader()); final LongValues data = atomicFieldData.getLongValues(); final DoubleValues doubleData = atomicFieldData.getDoubleValues(); final TLongSet set = new TLongHashSet(); final TDoubleSet doubleSet = new TDoubleHashSet(); for (int i = 0; i < values.size(); ++i) { final TLongSet v = values.get(i); assertThat(data.hasValue(i), equalTo(!v.isEmpty())); assertThat(doubleData.hasValue(i), equalTo(!v.isEmpty())); if (v.isEmpty()) { assertThat(data.getValue(i), equalTo(0L)); assertThat(doubleData.getValue(i), equalTo(0d)); } set.clear(); for (LongValues.Iter iter = data.getIter(i); iter.hasNext(); ) { set.add(iter.next()); } assertThat(set, equalTo(v)); final TDoubleSet doubleV = new TDoubleHashSet(); for (TLongIterator it = v.iterator(); it.hasNext(); ) { doubleV.add((double) it.next()); } doubleSet.clear(); for (DoubleValues.Iter iter = doubleData.getIter(i); iter.hasNext(); ) { doubleSet.add(iter.next()); } assertThat(doubleSet, equalTo(doubleV)); } }
@Override public boolean equals(Object other) { if (!(other instanceof TDoubleSet)) { return false; } final TDoubleSet that = (TDoubleSet) other; if (that.size() != this.size()) { return false; } for (int i = _states.length; i-- > 0; ) { if (_states[i] == FULL) { if (!that.contains(_set[i])) { return false; } } } return true; }