示例#1
0
        private TsdbTableEntity Convert(BinaryWriter writer, MemoryStream stream, TEntry entry, string partitionKey)
        {
            var entity = new TsdbTableEntity();

            entity.RowKey       = AtsKeyCalculator.CalculateRowKey(entry.GetTimestamp());
            entity.PartitionKey = partitionKey;
            AtsSerializer.SerializeEntry <TKey, TEntry>(writer, entry);
            entity.P0 = stream.ToArray();
            return(entity);
        }
示例#2
0
 private IEnumerable <TEntry> Convert(IEnumerable <TsdbTableEntity> entities)
 {
     foreach (var entity in entities)
     {
         var stream = new MemoryStream(entity.P0);
         using (var reader = AtsSerializer.CreateReader(stream))
         {
             yield return(Convert(reader, entity));
         }
     }
 }
示例#3
0
        private IEnumerable <TsdbTableEntity> Convert(IEnumerable <TEntry> entries, string partitionKey)
        {
            var stream = new MemoryStream();

            using (var writer = AtsSerializer.CreateWriter(stream))
            {
                foreach (var entry in entries)
                {
                    yield return(Convert(writer, stream, entry, partitionKey));

                    stream.Seek(0, SeekOrigin.Begin);
                    stream.SetLength(0);
                }
            }
        }
示例#4
0
        private List <TsdbTableEntity> CreateTableEntitiesFor(TKey key, List <TEntry> entries)
        {
            List <TsdbTableEntity> tableEntities = new List <TsdbTableEntity>();
            var id = _keyConverter.Convert(key);

            var results = AtsSerializer.Serialize <TKey, TEntry>(entries, TsdbTableEntity.MaxByteCapacity);

            foreach (var result in results)
            {
                var entity = new TsdbTableEntity();
                entity.SetData(result.Data);
                entity.RowKey       = AtsKeyCalculator.CalculateRowKey(result.From);
                entity.PartitionKey = AtsKeyCalculator.CalculatePartitionKey(id, key, result.From, _partitioningProvider);

                tableEntities.Add(entity);
            }

            return(tableEntities);
        }
示例#5
0
 private TEntry Convert(BinaryReader reader, TsdbTableEntity entity)
 {
     return(AtsSerializer.DeserializeEntry <TKey, TEntry>(reader));
 }
示例#6
0
 public TEntry[] GetEntries <TKey, TEntry>(Sort sort)
     where TEntry : IAtsEntry, new()
 {
     return(AtsSerializer.Deserialize <TKey, TEntry>(P0, sort));
 }