예제 #1
0
        private string LabelValue(int recordOffset)
        {
            int labelLength = MetaDataBuffer.GetInt(recordOffset + LABEL_OFFSET);

            byte[] stringInBytes = new byte[labelLength];
            MetaDataBuffer.GetBytes(recordOffset + LABEL_OFFSET + BitUtil.SIZE_OF_INT, stringInBytes);

            return(LabelCharset.GetString(stringInBytes));
        }
예제 #2
0
        /// <summary>
        /// Iterate over all the metadata in the buffer.
        /// </summary>
        /// <param name="metaData"> function to be called for each metadata record. </param>
        public void ForEach(MetaData metaData)
        {
            var counterId = 0;

            for (int i = 0, capacity = MetaDataBuffer.Capacity; i < capacity; i += METADATA_LENGTH)
            {
                var recordStatus = MetaDataBuffer.GetIntVolatile(i);
                if (RECORD_UNUSED == recordStatus)
                {
                    break;
                }
                if (RECORD_ALLOCATED == recordStatus)
                {
                    var           typeId    = MetaDataBuffer.GetInt(i + TYPE_ID_OFFSET);
                    var           label     = MetaDataBuffer.GetStringUtf8(i + LABEL_OFFSET);
                    IDirectBuffer keyBuffer = new UnsafeBuffer(MetaDataBuffer, i + KEY_OFFSET, MAX_KEY_LENGTH);

                    metaData(counterId, typeId, keyBuffer, label);
                }

                counterId++;
            }
        }
예제 #3
0
        /// <summary>
        /// Get the type id for a given counter id.
        /// </summary>
        /// <param name="counterId"> to be read. </param>
        /// <returns> the type id for a given counter id. </returns>
        public int GetCounterTypeId(int counterId)
        {
            ValidateCounterId(counterId);

            return(MetaDataBuffer.GetInt(MetaDataOffset(counterId) + TYPE_ID_OFFSET));
        }