ReadBytes() public abstract method

Reads a specified number of bytes into an array at the specified offset.
public abstract ReadBytes ( byte b, int offset, int len ) : void
b byte the array to read bytes into
offset int the offset in the array to start storing bytes
len int the number of bytes to read
return void
コード例 #1
0
        /// <summary>
        /// Copy numBytes bytes from input to ourself. </summary>
        public virtual void CopyBytes(DataInput input, long numBytes)
        {
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(numBytes >= 0, "numBytes={0}", numBytes);
            }
            long left = numBytes;

            if (copyBuffer == null)
            {
                copyBuffer = new byte[COPY_BUFFER_SIZE];
            }
            while (left > 0)
            {
                int toCopy;
                if (left > COPY_BUFFER_SIZE)
                {
                    toCopy = COPY_BUFFER_SIZE;
                }
                else
                {
                    toCopy = (int)left;
                }
                input.ReadBytes(copyBuffer, 0, toCopy);
                WriteBytes(copyBuffer, 0, toCopy);
                left -= toCopy;
            }
        }
コード例 #2
0
ファイル: DataOutput.cs プロジェクト: leotohill/lucene.net
        /// <summary>
        /// Copy numBytes bytes from input to ourself. </summary>
        public virtual void CopyBytes(DataInput input, long numBytes)
        {
            Debug.Assert(numBytes >= 0, "numBytes=" + numBytes);
            long left = numBytes;

            if (CopyBuffer == null)
            {
                CopyBuffer = new sbyte[COPY_BUFFER_SIZE];
            }
            while (left > 0)
            {
                int toCopy;
                if (left > COPY_BUFFER_SIZE)
                {
                    toCopy = COPY_BUFFER_SIZE;
                }
                else
                {
                    toCopy = (int)left;
                }
                input.ReadBytes(CopyBuffer, 0, toCopy);
                WriteBytes(CopyBuffer, 0, toCopy);
                left -= toCopy;
            }
        }
コード例 #3
0
 /// <summary>
 /// Copy numBytes bytes from input to ourself. </summary>
 public virtual void CopyBytes(DataInput input, long numBytes)
 {
     Debug.Assert(numBytes >= 0, "numBytes=" + numBytes);
     long left = numBytes;
     if (CopyBuffer == null)
     {
         CopyBuffer = new byte[COPY_BUFFER_SIZE];
     }
     while (left > 0)
     {
         int toCopy;
         if (left > COPY_BUFFER_SIZE)
         {
             toCopy = COPY_BUFFER_SIZE;
         }
         else
         {
             toCopy = (int)left;
         }
         input.ReadBytes(CopyBuffer, 0, toCopy);
         WriteBytes(CopyBuffer, 0, toCopy);
         left -= toCopy;
     }
 }
コード例 #4
0
        public override void DecodeTerm(long[] empty, DataInput input, FieldInfo fieldInfo, BlockTermState _termState,
            bool absolute)
        {
            PulsingTermState termState = (PulsingTermState) _termState;

            Debug.Debug.Assert((empty.Length == 0);
            termState.Absolute = termState.Absolute || absolute;
            // if we have positions, its total TF, otherwise its computed based on docFreq.
            // TODO Double check this is right..
            long count = FieldInfo.IndexOptions_e.DOCS_AND_FREQS_AND_POSITIONS.CompareTo(fieldInfo.IndexOptions) <= 0
                ? termState.TotalTermFreq
                : termState.DocFreq;
            //System.out.println("  count=" + count + " threshold=" + maxPositions);

            if (count <= maxPositions)
            {
                // Inlined into terms dict -- just read the byte[] blob in,
                // but don't decode it now (we only decode when a DocsEnum
                // or D&PEnum is pulled):
                termState.PostingsSize = input.ReadVInt();
                if (termState.Postings == null || termState.Postings.Length < termState.PostingsSize)
                {
                    termState.Postings = new byte[ArrayUtil.Oversize(termState.PostingsSize, 1)];
                }
                // TODO: sort of silly to copy from one big byte[]
                // (the blob holding all inlined terms' blobs for
                // current term block) into another byte[] (just the
                // blob for this term)...
                input.ReadBytes(termState.Postings, 0, termState.PostingsSize);
                //System.out.println("  inlined bytes=" + termState.postingsSize);
                termState.Absolute = termState.Absolute || absolute;
            }
            else
            {
                int longsSize = fields == null ? 0 : fields[fieldInfo.Number];
                if (termState.Longs == null)
                {
                    termState.Longs = new long[longsSize];
                }
                for (int i = 0; i < longsSize; i++)
                {
                    termState.Longs[i] = input.ReadVLong();
                }
                termState.PostingsSize = -1;
                termState.WrappedTermState.DocFreq = termState.DocFreq;
                termState.WrappedTermState.TotalTermFreq = termState.TotalTermFreq;
                _wrappedPostingsReader.DecodeTerm(termState.Longs, input, fieldInfo,
                    termState.WrappedTermState,
                    termState.Absolute);
                termState.Absolute = false;
            }
        }