Skip to content

Commit

Permalink
Added more evil tests for different field data implementations
Browse files Browse the repository at this point in the history
s1monw committed Apr 5, 2013
1 parent 224faff commit 5e7ad98
Showing 9 changed files with 404 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -147,11 +147,11 @@ public int hash() {

static class Multi implements Iter {

private int innerOrd;
protected int innerOrd;
protected int ord;
private BytesValues.WithOrdinals withOrds;
private Ordinals.Docs.Iter ordsIter;
private final BytesRef scratch = new BytesRef();
protected BytesValues.WithOrdinals withOrds;
protected Ordinals.Docs.Iter ordsIter;
protected final BytesRef scratch = new BytesRef();
public Multi(WithOrdinals withOrds) {
this.withOrds = withOrds;
assert withOrds.isMultiValued();
@@ -237,7 +237,6 @@ protected Iter.Single newSingleIter() {
return new Iter.Single();
}


@Override
public boolean hasValue(int docId) {
return ordinals.getOrd(docId) != 0;
Original file line number Diff line number Diff line change
@@ -144,19 +144,6 @@ public BytesRef makeSafe(BytesRef bytes) {
return bytes;
}

@Override
public BytesRef getValueScratch(int docId, BytesRef ret) {
BytesRef value = values[ordinals.getOrd(docId)];
if (value == null) {
ret.length = 0;
} else {
ret.bytes = value.bytes;
ret.offset = value.offset;
ret.length = value.length;
}
return ret;
}

static class Single extends BytesValues {

private final Iter.Single iter;
@@ -207,6 +194,24 @@ static class Multi extends BytesValues {
assert ordinals.isMultiValued();
this.iter = newMultiIter();
}

@Override
protected Iter.Multi newMultiIter() {
return new Iter.Multi(this) {
private BytesRef current = null;
@Override
public BytesRef next() {
current = withOrds.getValueByOrd(innerOrd);
ord = innerOrd;
innerOrd = ordsIter.next();
return current;
}
public int hash() {
assert current != null;
return current.hashCode();
}
};
}

@Override
public Iter getIter(int docId) {
@@ -226,6 +231,15 @@ static final class MultiHashed extends Multi {
@Override
protected Iter.Multi newMultiIter() {
return new Iter.Multi(this) {
private BytesRef current = null;
@Override
public BytesRef next() {
current = withOrds.getValueByOrd(innerOrd);
ord = innerOrd;
innerOrd = ordsIter.next();
return current;
}

public int hash() {
return hashes[ord];
}
Original file line number Diff line number Diff line change
@@ -81,7 +81,11 @@ public Collector collector() {

@Override
public InternalFacet buildFacet(String facetName) {
return HashedAggregator.buildFacet(facetName, size, missing, total, comparatorType, aggregator);
try {
return HashedAggregator.buildFacet(facetName, size, missing, total, comparatorType, aggregator);
} finally {
aggregator.release();
}
}

class Collector extends FacetExecutor.Collector {
Loading

0 comments on commit 5e7ad98

Please sign in to comment.