Ejemplo n.º 1
0
 internal void decodeMetaData()
 {
     if (!didDecode)
     {
         buffer.reset(current.output.bytes, current.output.offset, current.output.length);
         docFreq_Renamed = buffer.readVInt();
         if (field.IndexOptions != IndexOptions.DOCS_ONLY)
         {
             totalTermFreq_Renamed = docFreq_Renamed + buffer.readVLong();
         }
         else
         {
             totalTermFreq_Renamed = -1;
         }
         postingsSpare.bytes  = current.output.bytes;
         postingsSpare.offset = buffer.Position;
         postingsSpare.length = current.output.length - (buffer.Position - current.output.offset);
         //System.out.println("  df=" + docFreq + " totTF=" + totalTermFreq + " offset=" + buffer.getPosition() + " len=" + current.output.length);
         didDecode = true;
     }
 }
Ejemplo n.º 2
0
            public override int nextDoc()
            {
                while (true)
                {
                    //System.out.println("  nextDoc cycle docUpto=" + docUpto + " numDocs=" + numDocs + " fp=" + in.getPosition() + " this=" + this);
                    if (docUpto == numDocs)
                    {
                        // System.out.println("    END");
                        return(docID_Renamed = NO_MORE_DOCS);
                    }
                    docUpto++;
                    if (indexOptions == IndexOptions.DOCS_ONLY)
                    {
                        accum += @in.readVInt();
                    }
                    else
                    {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int code = in.readVInt();
                        int code = @in.readVInt();
                        accum += (int)((uint)code >> 1);
                        //System.out.println("  docID=" + accum + " code=" + code);
                        if ((code & 1) != 0)
                        {
                            freq_Renamed = 1;
                        }
                        else
                        {
                            freq_Renamed = @in.readVInt();
                            Debug.Assert(freq_Renamed > 0);
                        }

                        if (indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
                        {
                            // Skip positions/payloads
                            for (int posUpto = 0; posUpto < freq_Renamed; posUpto++)
                            {
                                if (!storePayloads)
                                {
                                    @in.readVInt();
                                }
                                else
                                {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int posCode = in.readVInt();
                                    int posCode = @in.readVInt();
                                    if ((posCode & 1) != 0)
                                    {
                                        payloadLen = @in.readVInt();
                                    }
                                    @in.skipBytes(payloadLen);
                                }
                            }
                        }
                        else if (indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS)
                        {
                            // Skip positions/offsets/payloads
                            for (int posUpto = 0; posUpto < freq_Renamed; posUpto++)
                            {
                                int posCode = @in.readVInt();
                                if (storePayloads && ((posCode & 1) != 0))
                                {
                                    payloadLen = @in.readVInt();
                                }
                                if ((@in.readVInt() & 1) != 0)
                                {
                                    // new offset length
                                    @in.readVInt();
                                }
                                if (storePayloads)
                                {
                                    @in.skipBytes(payloadLen);
                                }
                            }
                        }
                    }

                    if (liveDocs == null || liveDocs.get(accum))
                    {
                        //System.out.println("    return docID=" + accum + " freq=" + freq);
                        return(docID_Renamed = accum);
                    }
                }
            }
Ejemplo n.º 3
0
            public override int nextDoc()
            {
                while (posPending > 0)
                {
                    nextPosition();
                }
                while (true)
                {
                    //System.out.println("  nextDoc cycle docUpto=" + docUpto + " numDocs=" + numDocs + " fp=" + in.getPosition() + " this=" + this);
                    if (docUpto == numDocs)
                    {
                        //System.out.println("    END");
                        return(docID_Renamed = NO_MORE_DOCS);
                    }
                    docUpto++;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int code = in.readVInt();
                    int code = @in.readVInt();
                    accum += (int)((uint)code >> 1);
                    if ((code & 1) != 0)
                    {
                        freq_Renamed = 1;
                    }
                    else
                    {
                        freq_Renamed = @in.readVInt();
                        Debug.Assert(freq_Renamed > 0);
                    }

                    if (liveDocs == null || liveDocs.get(accum))
                    {
                        pos = 0;
                        startOffset_Renamed = storeOffsets ? 0 : -1;
                        posPending          = freq_Renamed;
                        //System.out.println("    return docID=" + accum + " freq=" + freq);
                        return(docID_Renamed = accum);
                    }

                    // Skip positions
                    for (int posUpto = 0; posUpto < freq_Renamed; posUpto++)
                    {
                        if (!storePayloads)
                        {
                            @in.readVInt();
                        }
                        else
                        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int skipCode = in.readVInt();
                            int skipCode = @in.readVInt();
                            if ((skipCode & 1) != 0)
                            {
                                payloadLength = @in.readVInt();
                                //System.out.println("    new payloadLen=" + payloadLength);
                            }
                        }

                        if (storeOffsets)
                        {
                            if ((@in.readVInt() & 1) != 0)
                            {
                                // new offset length
                                offsetLength = @in.readVInt();
                            }
                        }

                        if (storePayloads)
                        {
                            @in.skipBytes(payloadLength);
                        }
                    }
                }
            }
Ejemplo n.º 4
0
        // Interleaves all output tokens onto the futureOutputs:
        private void addOutput(BytesRef bytes, int matchInputLength, int matchEndOffset)
        {
            bytesReader.reset(bytes.bytes, bytes.offset, bytes.length);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int code = bytesReader.readVInt();
            int code = bytesReader.readVInt();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final boolean keepOrig = (code & 0x1) == 0;
            bool keepOrig = (code & 0x1) == 0;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int count = code >>> 1;
            int count = (int)((uint)code >> 1);

            //System.out.println("  addOutput count=" + count + " keepOrig=" + keepOrig);
            for (int outputIDX = 0; outputIDX < count; outputIDX++)
            {
                synonyms.words.get(bytesReader.readVInt(), scratchBytes);
                //System.out.println("    outIDX=" + outputIDX + " bytes=" + scratchBytes.length);
                UnicodeUtil.UTF8toUTF16(scratchBytes, scratchChars);
                int lastStart = scratchChars.offset;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int chEnd = lastStart + scratchChars.length;
                int chEnd      = lastStart + scratchChars.length;
                int outputUpto = nextRead;
                for (int chIDX = lastStart; chIDX <= chEnd; chIDX++)
                {
                    if (chIDX == chEnd || scratchChars.chars[chIDX] == SynonymMap.WORD_SEPARATOR)
                    {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int outputLen = chIDX - lastStart;
                        int outputLen = chIDX - lastStart;
                        // Caller is not allowed to have empty string in
                        // the output:
                        Debug.Assert(outputLen > 0, "output contains empty string: " + scratchChars);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int endOffset;
                        int endOffset;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int posLen;
                        int posLen;
                        if (chIDX == chEnd && lastStart == scratchChars.offset)
                        {
                            // This rule had a single output token, so, we set
                            // this output's endOffset to the current
                            // endOffset (ie, endOffset of the last input
                            // token it matched):
                            endOffset = matchEndOffset;
                            posLen    = keepOrig ? matchInputLength : 1;
                        }
                        else
                        {
                            // This rule has more than one output token; we
                            // can't pick any particular endOffset for this
                            // case, so, we inherit the endOffset for the
                            // input token which this output overlaps:
                            endOffset = -1;
                            posLen    = 1;
                        }
                        futureOutputs[outputUpto].add(scratchChars.chars, lastStart, outputLen, endOffset, posLen);
                        //System.out.println("      " + new String(scratchChars.chars, lastStart, outputLen) + " outputUpto=" + outputUpto);
                        lastStart = 1 + chIDX;
                        //System.out.println("  slot=" + outputUpto + " keepOrig=" + keepOrig);
                        outputUpto = rollIncr(outputUpto);
                        Debug.Assert(futureOutputs[outputUpto].posIncr == 1, "outputUpto=" + outputUpto + " vs nextWrite=" + nextWrite);
                    }
                }
            }

            int upto = nextRead;

            for (int idx = 0; idx < matchInputLength; idx++)
            {
                futureInputs[upto].keepOrig |= keepOrig;
                futureInputs[upto].matched   = true;
                upto = rollIncr(upto);
            }
        }