Ejemplo n.º 1
0
 /// <summary>
 /// Constructs a full blown Row2 object from supplied items withou the values (usually used for a reference row i.e. not local)
 /// </summary>
 /// <param name="rowId">The row id</param>
 /// <param name="isLocal">If the row is local or remote</param>
 /// <param name="columns">The column schema</param>
 /// <param name="participantId">The participant id</param>
 /// <param name="rowSize">The byte size of the data (does not include the preamble)</param>
 public Row2(int rowId, bool isLocal, Guid participantId, int rowSize, List <ColumnSchema> columns)
 {
     _preamble      = new RowPreamble(rowId, isLocal);
     _columns       = columns;
     _participantId = participantId;
     _rowSize       = rowSize;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs a full blown Row2 object from supplied values (does not try to parse from binary array)
 /// </summary>
 /// <param name="rowId">The row id</param>
 /// <param name="isLocal">If the row is local or remote</param>
 /// <param name="columns">The column schema</param>
 /// <param name="participantId">The participant id</param>
 /// <param name="values">A list of row values</param>
 /// <param name="rowSize">The byte size of the data (does not include the preamble)</param>
 public Row2(int rowId, bool isLocal, List <ColumnSchema> columns, Guid participantId, List <RowValue2> values, int rowSize)
 {
     _preamble      = new RowPreamble(rowId, isLocal);
     _columns       = columns;
     _participantId = participantId;
     _values        = values;
     _rowSize       = rowSize;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Iterates over this page's _data and populates the supplied array with structs representing the rows
        /// </summary>
        /// <param name="rows">An array of RowStruct to populate</param>
        private void IterateOverData(ref RowStruct[] rows)
        {
            var dataSpan      = new Span <byte>(_data);
            int currentOffset = DatabaseConstants.SIZE_OF_PAGE_PREAMBLE;
            int currentRowNum = 0;

            while (currentOffset < DatabaseConstants.PAGE_SIZE)
            {
                int  rowId;
                bool isLocal;
                int  sizeOfRow;

                RowPreamble.Parse(dataSpan.Slice(currentOffset, DatabaseConstants.SIZE_OF_ROW_PREAMBLE), out rowId, out isLocal);

                // check for end of data row identifier
                if (isLocal && rowId == DatabaseConstants.END_OF_ROW_DATA_ID)
                {
                    break;
                }

                if (currentRowNum >= _totalRows)
                {
                    break;
                }

                currentOffset += DatabaseConstants.SIZE_OF_ROW_PREAMBLE;

                if (isLocal)
                {
                    var values = new RowValue2[_schema.Columns.Length];

                    // we need the size of the row to parse how far along we should go in the array (span).
                    // we will however not adjust the offset since the method LocalRowBodyFromBinary includes parsing the rowSize prefix (an int32 size (4 bytes)).

                    sizeOfRow = BitConverter.ToInt32(dataSpan.Slice(currentOffset, DatabaseConstants.SIZE_OF_ROW_SIZE));
                    int rowSize; // this isn't really needed, but it's a required param of the method below
                    Row2.LocalRowBodyFromBinary(dataSpan.Slice(currentOffset, sizeOfRow), out rowSize, ref values, _schema.Columns);

                    //rows.Add(new Row2(rowId, isLocal, _schema.Columns, _process.Id.Value, values, sizeOfRow));
                    rows[currentRowNum] = new RowStruct {
                        IsLocal = isLocal, RowId = rowId, ParticipantId = Guid.Empty, RowSize = sizeOfRow, Values = values
                    };
                    currentOffset += sizeOfRow;
                    currentRowNum++;
                }
                else
                {
                    sizeOfRow = DatabaseConstants.PARTICIPANT_ID_SIZE;
                    Guid particpantId = DatabaseBinaryConverter.BinaryToGuid(dataSpan.Slice(currentOffset, sizeOfRow));
                    //rows.Add(new Row2(rowId, isLocal, particpantId, sizeOfRow, _schema.Columns));
                    rows[currentRowNum] = new RowStruct {
                        IsLocal = isLocal, ParticipantId = particpantId, RowSize = sizeOfRow, RowId = rowId, Values = null
                    };
                    currentOffset += sizeOfRow;
                    currentRowNum++;
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs a Row2 object based on the binary preamble and the specified column schema. The column schema will be used to
 /// parse the row binary data.
 /// </summary>
 /// <param name="preamble">The binrary preamble</param>
 /// <param name="columns">The column schema of the row</param>
 public Row2(byte[] preamble, List <ColumnSchema> columns)
 {
     _preamble = new RowPreamble(preamble);
     _columns  = columns;
 }