/// <summary> /// Advances the stream to the next value. /// If before the beginning of the stream, advances to the first value /// </summary> /// <returns>True if the advance was successful. False if the end of the stream was reached.</returns> protected override bool ReadNext(TKey key, TValue value) { if (!m_completed && m_encodingMethod.TryDecode(m_stream, key, value)) { return(true); } else { Complete(); return(false); } }
//unsafe private void ProcessReadWithPointers(TreeStream<TKey, TValue> scanner) //{ // int bytesForSerialization = m_encodingMethod.MaxCompressedSize; // byte[] buffer; // int position; // int bufferSize; // int origPosition; // m_stream.UnsafeGetInternalSendBuffer(out buffer, out position, out bufferSize); // origPosition = position; // fixed (byte* lp = buffer) // { // TKey key = new TKey(); // TValue value = new TValue(); // int loop = 0; // while (scanner.Read(key, value)) // { // if (bufferSize - position < bytesForSerialization) // { // m_stream.UnsafeAdvanceSendPosition(position - origPosition); // m_stream.Flush(); // position = 0; // origPosition = 0; // } // position += m_encodingMethod.Encode(lp + position, key, value); // loop++; // if (loop > 1000) // { // loop = 0; // if (m_stream.AvailableReadBytes > 0) // { // m_stream.UnsafeAdvanceSendPosition(position - origPosition); // return; // } // } // } // } // m_stream.UnsafeAdvanceSendPosition(position - origPosition); //} private void ProcessWrite() { TKey key = new TKey(); TValue value = new TValue(); m_encodingMethod.ResetEncoder(); while (m_encodingMethod.TryDecode(m_stream, key, value)) { m_sortedTreeEngine.Write(key, value); } }