mirror of https://github.com/apache/lucene.git
LUCENE-5157: Rename OrdinalMap methods to clarify API and internal structure.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1536605 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
03ed51acef
commit
1dd6d53c07
|
@ -190,6 +190,9 @@ API Changes:
|
||||||
with associated suggest/spell classes. (Areek Zillur via Mike
|
with associated suggest/spell classes. (Areek Zillur via Mike
|
||||||
McCandless)
|
McCandless)
|
||||||
|
|
||||||
|
* LUCENE-5157: Rename OrdinalMap methods to clarify API and internal structure.
|
||||||
|
(Boaz Leskes via Adrien Grand)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
|
|
||||||
* LUCENE-5225: The ToParentBlockJoinQuery only keeps tracks of the the child
|
* LUCENE-5225: The ToParentBlockJoinQuery only keeps tracks of the the child
|
||||||
|
|
|
@ -321,8 +321,8 @@ public abstract class DocValuesConsumer implements Closeable {
|
||||||
if (!hasNext()) {
|
if (!hasNext()) {
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
int segmentNumber = map.getSegmentNumber(currentOrd);
|
int segmentNumber = map.getFirstSegmentNumber(currentOrd);
|
||||||
int segmentOrd = (int)map.getSegmentOrd(segmentNumber, currentOrd);
|
int segmentOrd = (int)map.getFirstSegmentOrd(currentOrd);
|
||||||
dvs[segmentNumber].lookupOrd(segmentOrd, scratch);
|
dvs[segmentNumber].lookupOrd(segmentOrd, scratch);
|
||||||
currentOrd++;
|
currentOrd++;
|
||||||
return scratch;
|
return scratch;
|
||||||
|
@ -457,8 +457,8 @@ public abstract class DocValuesConsumer implements Closeable {
|
||||||
if (!hasNext()) {
|
if (!hasNext()) {
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
int segmentNumber = map.getSegmentNumber(currentOrd);
|
int segmentNumber = map.getFirstSegmentNumber(currentOrd);
|
||||||
long segmentOrd = map.getSegmentOrd(segmentNumber, currentOrd);
|
long segmentOrd = map.getFirstSegmentOrd(currentOrd);
|
||||||
dvs[segmentNumber].lookupOrd(segmentOrd, scratch);
|
dvs[segmentNumber].lookupOrd(segmentOrd, scratch);
|
||||||
currentOrd++;
|
currentOrd++;
|
||||||
return scratch;
|
return scratch;
|
||||||
|
|
|
@ -319,13 +319,13 @@ public class MultiDocValues {
|
||||||
// TODO: use more efficient packed ints structures?
|
// TODO: use more efficient packed ints structures?
|
||||||
// TODO: pull this out? its pretty generic (maps between N ord()-enabled TermsEnums)
|
// TODO: pull this out? its pretty generic (maps between N ord()-enabled TermsEnums)
|
||||||
public static class OrdinalMap {
|
public static class OrdinalMap {
|
||||||
// cache key of whoever asked for this aweful thing
|
// cache key of whoever asked for this awful thing
|
||||||
final Object owner;
|
final Object owner;
|
||||||
// globalOrd -> (globalOrd - segmentOrd)
|
// globalOrd -> (globalOrd - segmentOrd) where segmentOrd is the the ordinal in the first segment that contains this term
|
||||||
final MonotonicAppendingLongBuffer globalOrdDeltas;
|
final MonotonicAppendingLongBuffer globalOrdDeltas;
|
||||||
// globalOrd -> sub index
|
// globalOrd -> first segment container
|
||||||
final AppendingPackedLongBuffer subIndexes;
|
final AppendingPackedLongBuffer firstSegments;
|
||||||
// segmentOrd -> (globalOrd - segmentOrd)
|
// for every segment, segmentOrd -> (globalOrd - segmentOrd)
|
||||||
final MonotonicAppendingLongBuffer ordDeltas[];
|
final MonotonicAppendingLongBuffer ordDeltas[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -341,7 +341,7 @@ public class MultiDocValues {
|
||||||
// unique terms, and walking a multitermsenum over those
|
// unique terms, and walking a multitermsenum over those
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
globalOrdDeltas = new MonotonicAppendingLongBuffer(PackedInts.COMPACT);
|
globalOrdDeltas = new MonotonicAppendingLongBuffer(PackedInts.COMPACT);
|
||||||
subIndexes = new AppendingPackedLongBuffer(PackedInts.COMPACT);
|
firstSegments = new AppendingPackedLongBuffer(PackedInts.COMPACT);
|
||||||
ordDeltas = new MonotonicAppendingLongBuffer[subs.length];
|
ordDeltas = new MonotonicAppendingLongBuffer[subs.length];
|
||||||
for (int i = 0; i < ordDeltas.length; i++) {
|
for (int i = 0; i < ordDeltas.length; i++) {
|
||||||
ordDeltas[i] = new MonotonicAppendingLongBuffer();
|
ordDeltas[i] = new MonotonicAppendingLongBuffer();
|
||||||
|
@ -359,23 +359,23 @@ public class MultiDocValues {
|
||||||
while (mte.next() != null) {
|
while (mte.next() != null) {
|
||||||
TermsEnumWithSlice matches[] = mte.getMatchArray();
|
TermsEnumWithSlice matches[] = mte.getMatchArray();
|
||||||
for (int i = 0; i < mte.getMatchCount(); i++) {
|
for (int i = 0; i < mte.getMatchCount(); i++) {
|
||||||
int subIndex = matches[i].index;
|
int segmentIndex = matches[i].index;
|
||||||
long segmentOrd = matches[i].terms.ord();
|
long segmentOrd = matches[i].terms.ord();
|
||||||
long delta = globalOrd - segmentOrd;
|
long delta = globalOrd - segmentOrd;
|
||||||
// for each unique term, just mark the first subindex/delta where it occurs
|
// for each unique term, just mark the first segment index/delta where it occurs
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
subIndexes.add(subIndex);
|
firstSegments.add(segmentIndex);
|
||||||
globalOrdDeltas.add(delta);
|
globalOrdDeltas.add(delta);
|
||||||
}
|
}
|
||||||
// for each per-segment ord, map it back to the global term.
|
// for each per-segment ord, map it back to the global term.
|
||||||
while (segmentOrds[subIndex] <= segmentOrd) {
|
while (segmentOrds[segmentIndex] <= segmentOrd) {
|
||||||
ordDeltas[subIndex].add(delta);
|
ordDeltas[segmentIndex].add(delta);
|
||||||
segmentOrds[subIndex]++;
|
segmentOrds[segmentIndex]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globalOrd++;
|
globalOrd++;
|
||||||
}
|
}
|
||||||
subIndexes.freeze();
|
firstSegments.freeze();
|
||||||
globalOrdDeltas.freeze();
|
globalOrdDeltas.freeze();
|
||||||
for (int i = 0; i < ordDeltas.length; ++i) {
|
for (int i = 0; i < ordDeltas.length; ++i) {
|
||||||
ordDeltas[i].freeze();
|
ordDeltas[i].freeze();
|
||||||
|
@ -386,24 +386,24 @@ public class MultiDocValues {
|
||||||
* Given a segment number and segment ordinal, returns
|
* Given a segment number and segment ordinal, returns
|
||||||
* the corresponding global ordinal.
|
* the corresponding global ordinal.
|
||||||
*/
|
*/
|
||||||
public long getGlobalOrd(int subIndex, long segmentOrd) {
|
public long getGlobalOrd(int segmentIndex, long segmentOrd) {
|
||||||
return segmentOrd + ordDeltas[subIndex].get(segmentOrd);
|
return segmentOrd + ordDeltas[segmentIndex].get(segmentOrd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a segment number and global ordinal, returns
|
* Given global ordinal, returns the ordinal of the first segment which contains
|
||||||
* the corresponding segment ordinal.
|
* this ordinal (the corresponding to the segment return {@link #getFirstSegmentNumber}).
|
||||||
*/
|
*/
|
||||||
public long getSegmentOrd(int subIndex, long globalOrd) {
|
public long getFirstSegmentOrd(long globalOrd) {
|
||||||
return globalOrd - globalOrdDeltas.get(globalOrd);
|
return globalOrd - globalOrdDeltas.get(globalOrd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a global ordinal, returns the index of the first
|
* Given a global ordinal, returns the index of the first
|
||||||
* sub that contains this term.
|
* segment that contains this term.
|
||||||
*/
|
*/
|
||||||
public int getSegmentNumber(long globalOrd) {
|
public int getFirstSegmentNumber(long globalOrd) {
|
||||||
return (int) subIndexes.get(globalOrd);
|
return (int) firstSegments.get(globalOrd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,7 +417,7 @@ public class MultiDocValues {
|
||||||
* Returns total byte size used by this ordinal map.
|
* Returns total byte size used by this ordinal map.
|
||||||
*/
|
*/
|
||||||
public long ramBytesUsed() {
|
public long ramBytesUsed() {
|
||||||
long size = globalOrdDeltas.ramBytesUsed() + subIndexes.ramBytesUsed();
|
long size = globalOrdDeltas.ramBytesUsed() + firstSegments.ramBytesUsed();
|
||||||
for (int i = 0; i < ordDeltas.length; i++) {
|
for (int i = 0; i < ordDeltas.length; i++) {
|
||||||
size += ordDeltas[i].ramBytesUsed();
|
size += ordDeltas[i].ramBytesUsed();
|
||||||
}
|
}
|
||||||
|
@ -455,8 +455,8 @@ public class MultiDocValues {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lookupOrd(int ord, BytesRef result) {
|
public void lookupOrd(int ord, BytesRef result) {
|
||||||
int subIndex = mapping.getSegmentNumber(ord);
|
int subIndex = mapping.getFirstSegmentNumber(ord);
|
||||||
int segmentOrd = (int) mapping.getSegmentOrd(subIndex, ord);
|
int segmentOrd = (int) mapping.getFirstSegmentOrd(ord);
|
||||||
values[subIndex].lookupOrd(segmentOrd, result);
|
values[subIndex].lookupOrd(segmentOrd, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,8 +506,8 @@ public class MultiDocValues {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lookupOrd(long ord, BytesRef result) {
|
public void lookupOrd(long ord, BytesRef result) {
|
||||||
int subIndex = mapping.getSegmentNumber(ord);
|
int subIndex = mapping.getFirstSegmentNumber(ord);
|
||||||
long segmentOrd = mapping.getSegmentOrd(subIndex, ord);
|
long segmentOrd = mapping.getFirstSegmentOrd(ord);
|
||||||
values[subIndex].lookupOrd(segmentOrd, result);
|
values[subIndex].lookupOrd(segmentOrd, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue