Library/PackageCache/com.unity.quicksearch@1.6.0-preview.8/Editor/Indexing/SearchIndexer.cs
/// <summary>
/// Write a binary representation of the the index on a stream.
/// </summary>
/// <param name="stream">Stream where to write the index.</param>
/// <param name="tag">Identification tag to write in the header of the index.</param>
Write a binary representation of the the index on a stream.
Write a binary representation of the the index on a stream .
public void Write(Stream stream, string tag)
        {
            using (var indexWriter = new BinaryWriter(stream))
            {
                indexWriter.Write(SearchIndexEntry.version);
                indexWriter.Write(tag);
                indexWriter.Write(m_Documents.Count);
                foreach (var p in m_Documents)
                {
                    indexWriter.Write(p.id);
                    bool writeMetadata = !String.IsNullOrEmpty(p.metadata);
                    indexWriter.Write(writeMetadata);
                    if (writeMetadata)
                        indexWriter.Write(p.metadata);
                }
                indexWriter.Write(m_DocumentHashes.Count);
                foreach (var kvp in m_DocumentHashes)
                {
                    indexWriter.Write(kvp.Key);
                    indexWriter.Write(kvp.Value.ToString());
                }
                indexWriter.Write(m_Indexes.Length);
                foreach (var p in m_Indexes)
                {
                    indexWriter.Write(p.key);
                    indexWriter.Write(p.crc);
                    indexWriter.Write((int)p.type);
                    indexWriter.Write(p.index);
                    indexWriter.Write(p.score);
                }
                indexWriter.Write(m_Keywords.Count);
                foreach (var t in m_Keywords)
                    indexWriter.Write(t);
            }
        }
public void Write ( Stream stream , string tag ) { using ( var indexWriter = new BinaryWriter ( stream ) ) { indexWriter . Write ( SearchIndexEntry . version ) ; indexWriter . Write ( tag ) ; indexWriter . Write ( m_Documents . Count ) ; foreach ( var p in m_Documents ) { indexWriter . Write ( p . id ) ; bool writeMetadata = ! String . IsNullOrEmpty ( p . metadata ) ; indexWriter . Write ( writeMetadata ) ; if ( writeMetadata ) indexWriter . Write ( p . metadata ) ; } indexWriter . Write ( m_DocumentHashes . Count ) ; foreach ( var kvp in m_DocumentHashes ) { indexWriter . Write ( kvp . Key ) ; indexWriter . Write ( kvp . Value . ToString ( ) ) ; } indexWriter . Write ( m_Indexes . Length ) ; foreach ( var p in m_Indexes ) { indexWriter . Write ( p . key ) ; indexWriter . Write ( p . crc ) ; indexWriter . Write ( ( int ) p . type ) ; indexWriter . Write ( p . index ) ; indexWriter . Write ( p . score ) ; } indexWriter . Write ( m_Keywords . Count ) ; foreach ( var t in m_Keywords ) indexWriter . Write ( t ) ; } }
Write a binary representation of the the index on a stream.
Write a binary representation of the the index on a stream .
// Documents // Hashes // Indexes // Keywords
stream
Stream
Stream where to write the index.
Stream where to write the index .
tag
string
Identification tag to write in the header of the index.
Identification tag to write in the header of the index .