output.writeInt(encodeWeight(iterator.weight()));
break; case Type.WHITESPACE_TEXT: out.writeInt(alpha[i]); continue; case Type.PARENT_POINTER:
/** If the current segment has too many points then we switchover to temp files / offline sort. */ private void switchToOffline() throws IOException { // For each .add we just append to this input file, then in .finish we sort this input and resursively build the tree: tempInput = Files.createTempFile(OfflineSorter.getDefaultTempDir(), "in", ""); writer = new OfflineSorter.ByteSequencesWriter(tempInput); for(int i=0;i<pointCount;i++) { scratchBytesOutput.reset(scratchBytes); scratchBytesOutput.writeInt(heapWriter.xs[i]); scratchBytesOutput.writeInt(heapWriter.ys[i]); scratchBytesOutput.writeInt(heapWriter.zs[i]); scratchBytesOutput.writeVInt(heapWriter.docIDs[i]); scratchBytesOutput.writeVLong(i); // TODO: can/should OfflineSorter optimize the fixed-width case? writer.write(scratchBytes, 0, scratchBytes.length); } heapWriter = null; }
public void add(int x, int y, int z, int docID) throws IOException { if (pointCount >= maxPointsSortInHeap) { if (writer == null) { switchToOffline(); } scratchBytesOutput.reset(scratchBytes); scratchBytesOutput.writeInt(x); scratchBytesOutput.writeInt(y); scratchBytesOutput.writeInt(z); scratchBytesOutput.writeVInt(docID); scratchBytesOutput.writeVLong(pointCount); writer.write(scratchBytes, 0, scratchBytes.length); } else { // Not too many points added yet, continue using heap: heapWriter.append(x, y, z, pointCount, docID); } pointCount++; }
/** If the current segment has too many points then we switchover to temp files / offline sort. */ private void switchToOffline() throws IOException { // For each .add we just append to this input file, then in .finish we sort this input and resursively build the tree: tempInput = Files.createTempFile(OfflineSorter.getDefaultTempDir(), "in", ""); writer = new OfflineSorter.ByteSequencesWriter(tempInput); for(int i=0;i<pointCount;i++) { scratchBytesOutput.reset(scratchBytes); scratchBytesOutput.writeInt(heapWriter.latEncs[i]); scratchBytesOutput.writeInt(heapWriter.lonEncs[i]); scratchBytesOutput.writeVInt(heapWriter.docIDs[i]); scratchBytesOutput.writeVLong(i); // TODO: can/should OfflineSorter optimize the fixed-width case? writer.write(scratchBytes, 0, scratchBytes.length); } heapWriter = null; }
void add(int latEnc, int lonEnc, int docID) throws IOException { assert latEnc > Integer.MIN_VALUE; assert latEnc < Integer.MAX_VALUE; assert lonEnc > Integer.MIN_VALUE; assert lonEnc < Integer.MAX_VALUE; if (pointCount >= maxPointsSortInHeap) { if (writer == null) { switchToOffline(); } scratchBytesOutput.reset(scratchBytes); scratchBytesOutput.writeInt(latEnc); scratchBytesOutput.writeInt(lonEnc); scratchBytesOutput.writeVInt(docID); scratchBytesOutput.writeVLong(pointCount); writer.write(scratchBytes, 0, scratchBytes.length); } else { // Not too many points added yet, continue using heap: heapWriter.append(latEnc, lonEnc, pointCount, docID); } pointCount++; }
@Override protected void encode(ByteSequencesWriter writer, ByteArrayDataOutput output, byte[] buffer, BytesRef spare, BytesRef payload, Set<BytesRef> contexts, long weight) throws IOException { if (spare.length + 4 >= buffer.length) { buffer = ArrayUtil.grow(buffer, spare.length + 4); } output.reset(buffer); output.writeBytes(spare.bytes, spare.offset, spare.length); output.writeInt(encodeWeight(weight)); writer.write(buffer, 0, output.getPosition()); }
@Override protected void encode(ByteSequencesWriter writer, ByteArrayDataOutput output, byte[] buffer, BytesRef spare, long weight) throws IOException { if (spare.length + 5 >= buffer.length) { buffer = ArrayUtil.grow(buffer, spare.length + 5); } output.reset(buffer); output.writeBytes(spare.bytes, spare.offset, spare.length); output.writeByte((byte)0); // separator: not used, just for sort order output.writeInt(encodeWeight(weight)); writer.write(buffer, 0, output.getPosition()); }
output.writeInt(encodeWeight(tfit.weight())); output.writeBytes(spare.bytes, spare.offset, spare.length); writer.write(buffer, 0, output.getPosition());
output.writeInt(encodeWeight(iterator.weight())); output.writeBytes(spare.bytes, spare.offset, spare.length); writer.write(buffer, 0, output.getPosition());
output.writeInt(encodeWeight(iterator.weight()));
output.writeInt(encodeWeight(iterator.weight()));
output.writeInt(encodeWeight(iterator.weight()));
output.writeInt(encodeWeight(iterator.weight()));
output.writeInt(encodeWeight(iterator.weight()));