public Write ( byte buffer, int offset, int size ) : void | ||
buffer | byte | |
offset | int | |
size | int | |
Результат | void |
public void CommitTo(SequentialFileWriter dataFile, SequentialFileWriter indexFile) { Flush(); var memLength = (int)_memStream.Position; if (memLength > 0) { byte[] memBuffer = _memStream.GetBuffer(); long actualPosition = dataFile.Position; dataFile.Write(memBuffer, 0, memLength); //The buffer contains the data from many items. //Console.WriteLine("Writing {0} bytes starting at {1}, with {2} things", memLength, actualPosition, _orderedIndexInfo.Count); var indexBuffer = new byte[20]; //int indexWritten = _orderedIndexInfo.Count * indexBuffer.Length; //int totalWritten = memLength + indexWritten foreach (IndexInfo info in _orderedIndexInfo) { /* int typeCode = info.typeCode; int serial = info.serial; int length = info.size; */ indexBuffer[0] = (byte)(info.typeCode); indexBuffer[1] = (byte)(info.typeCode >> 8); indexBuffer[2] = (byte)(info.typeCode >> 16); indexBuffer[3] = (byte)(info.typeCode >> 24); indexBuffer[4] = (byte)(info.serial); indexBuffer[5] = (byte)(info.serial >> 8); indexBuffer[6] = (byte)(info.serial >> 16); indexBuffer[7] = (byte)(info.serial >> 24); indexBuffer[8] = (byte)(actualPosition); indexBuffer[9] = (byte)(actualPosition >> 8); indexBuffer[10] = (byte)(actualPosition >> 16); indexBuffer[11] = (byte)(actualPosition >> 24); indexBuffer[12] = (byte)(actualPosition >> 32); indexBuffer[13] = (byte)(actualPosition >> 40); indexBuffer[14] = (byte)(actualPosition >> 48); indexBuffer[15] = (byte)(actualPosition >> 56); indexBuffer[16] = (byte)(info.size); indexBuffer[17] = (byte)(info.size >> 8); indexBuffer[18] = (byte)(info.size >> 16); indexBuffer[19] = (byte)(info.size >> 24); indexFile.Write(indexBuffer, 0, indexBuffer.Length); actualPosition += info.size; } } Close(); //We're done with this writer. }
private void WriteCount(SequentialFileWriter indexFile, int count) { //Equiv to GenericWriter.Write( (int)count ); byte[] buffer = new byte[4]; buffer[0] = (byte)(count); buffer[1] = (byte)(count >> 8); buffer[2] = (byte)(count >> 16); buffer[3] = (byte)(count >> 24); indexFile.Write(buffer, 0, buffer.Length); }
public int CommitTo(SequentialFileWriter dataFile, SequentialFileWriter indexFile, int typeCode, int serial) { Flush(); byte[] buffer = stream.GetBuffer(); int length = ( int )stream.Length; long position = dataFile.Position; dataFile.Write(buffer, 0, length); if (indexBuffer == null) { indexBuffer = new byte[20]; } indexBuffer[0] = ( byte )typeCode; indexBuffer[1] = ( byte )(typeCode >> 8); indexBuffer[2] = ( byte )(typeCode >> 16); indexBuffer[3] = ( byte )(typeCode >> 24); indexBuffer[4] = ( byte )serial; indexBuffer[5] = ( byte )(serial >> 8); indexBuffer[6] = ( byte )(serial >> 16); indexBuffer[7] = ( byte )(serial >> 24); indexBuffer[8] = ( byte )position; indexBuffer[9] = ( byte )(position >> 8); indexBuffer[10] = ( byte )(position >> 16); indexBuffer[11] = ( byte )(position >> 24); indexBuffer[12] = ( byte )(position >> 32); indexBuffer[13] = ( byte )(position >> 40); indexBuffer[14] = ( byte )(position >> 48); indexBuffer[15] = ( byte )(position >> 56); indexBuffer[16] = ( byte )length; indexBuffer[17] = ( byte )(length >> 8); indexBuffer[18] = ( byte )(length >> 16); indexBuffer[19] = ( byte )(length >> 24); indexFile.Write(indexBuffer, 0, indexBuffer.Length); stream.SetLength(0); return(length); }
public int CommitTo(SequentialFileWriter dataFile, SequentialFileWriter indexFile, int typeCode, int serial) { this.Flush(); byte[] buffer = this.stream.GetBuffer(); int length = (int)this.stream.Length; long position = dataFile.Position; dataFile.Write(buffer, 0, length); if (indexBuffer == null) { indexBuffer = new byte[20]; } indexBuffer[0] = (byte)(typeCode); indexBuffer[1] = (byte)(typeCode >> 8); indexBuffer[2] = (byte)(typeCode >> 16); indexBuffer[3] = (byte)(typeCode >> 24); indexBuffer[4] = (byte)(serial); indexBuffer[5] = (byte)(serial >> 8); indexBuffer[6] = (byte)(serial >> 16); indexBuffer[7] = (byte)(serial >> 24); indexBuffer[8] = (byte)(position); indexBuffer[9] = (byte)(position >> 8); indexBuffer[10] = (byte)(position >> 16); indexBuffer[11] = (byte)(position >> 24); indexBuffer[12] = (byte)(position >> 32); indexBuffer[13] = (byte)(position >> 40); indexBuffer[14] = (byte)(position >> 48); indexBuffer[15] = (byte)(position >> 56); indexBuffer[16] = (byte)(length); indexBuffer[17] = (byte)(length >> 8); indexBuffer[18] = (byte)(length >> 16); indexBuffer[19] = (byte)(length >> 24); indexFile.Write(indexBuffer, 0, indexBuffer.Length); this.stream.SetLength(0); return length; }
private void WriteCount(SequentialFileWriter indexFile, int count) { //Equiv to GenericWriter.Write( (int)count ); var buffer = new byte[4]; buffer[0] = (byte)(count); buffer[1] = (byte)(count >> 8); buffer[2] = (byte)(count >> 16); buffer[3] = (byte)(count >> 24); indexFile.Write(buffer, 0, buffer.Length); }
public void CommitTo(SequentialFileWriter dataFile, SequentialFileWriter indexFile) { this.Flush(); int memLength = (int)this._memStream.Position; if (memLength > 0) { byte[] memBuffer = this._memStream.GetBuffer(); long actualPosition = dataFile.Position; dataFile.Write(memBuffer, 0, memLength); //The buffer contains the data from many items. //Console.WriteLine("Writing {0} bytes starting at {1}, with {2} things", memLength, actualPosition, _orderedIndexInfo.Count); byte[] indexBuffer = new byte[20]; //int indexWritten = _orderedIndexInfo.Count * indexBuffer.Length; //int totalWritten = memLength + indexWritten for (int i = 0; i < this._orderedIndexInfo.Count; i++) { IndexInfo info = this._orderedIndexInfo[i]; int typeCode = info.typeCode; int serial = info.serial; int length = info.size; indexBuffer[0] = (byte)(info.typeCode); indexBuffer[1] = (byte)(info.typeCode >> 8); indexBuffer[2] = (byte)(info.typeCode >> 16); indexBuffer[3] = (byte)(info.typeCode >> 24); indexBuffer[4] = (byte)(info.serial); indexBuffer[5] = (byte)(info.serial >> 8); indexBuffer[6] = (byte)(info.serial >> 16); indexBuffer[7] = (byte)(info.serial >> 24); indexBuffer[8] = (byte)(actualPosition); indexBuffer[9] = (byte)(actualPosition >> 8); indexBuffer[10] = (byte)(actualPosition >> 16); indexBuffer[11] = (byte)(actualPosition >> 24); indexBuffer[12] = (byte)(actualPosition >> 32); indexBuffer[13] = (byte)(actualPosition >> 40); indexBuffer[14] = (byte)(actualPosition >> 48); indexBuffer[15] = (byte)(actualPosition >> 56); indexBuffer[16] = (byte)(info.size); indexBuffer[17] = (byte)(info.size >> 8); indexBuffer[18] = (byte)(info.size >> 16); indexBuffer[19] = (byte)(info.size >> 24); indexFile.Write(indexBuffer, 0, indexBuffer.Length); actualPosition += info.size; } } this.Close(); //We're done with this writer. }