Exemple #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);
        }
Exemple #2
0
        private string CreateSpecificPartitionFilter(TKey key, DateTime from, DateTime to, string partitionKeyRange)
        {
            var id           = _keyConverter.Convert(key);
            var fromRowKey   = AtsKeyCalculator.CalculateRowKey(from);
            var toRowKey     = AtsKeyCalculator.CalculateRowKey(to);
            var partitionKey = AtsKeyCalculator.CalculatePartitionKey(id, partitionKeyRange);

            return(TableQuery.CombineFilters(
                       TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey),
                       TableOperators.And,
                       TableQuery.CombineFilters(
                           TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.LessThanOrEqual, fromRowKey),
                           TableOperators.And,
                           TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThan, toRowKey))));
        }
Exemple #3
0
        private string CreateBeforeFilter(TKey key, DateTime to)
        {
            var id               = _keyConverter.Convert(key);
            var toRowKey         = AtsKeyCalculator.CalculateRowKey(to);
            var toPartitionKey   = AtsKeyCalculator.CalculatePartitionKey(id, key, to, _partitioningProvider); // 7125
            var fromPartitionKey = AtsKeyCalculator.CalculateMinPartitionKey(id, key, _partitioningProvider);  // 9999

            return(TableQuery.CombineFilters(
                       TableQuery.CombineFilters(
                           TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.LessThanOrEqual, fromPartitionKey),
                           TableOperators.And,
                           TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.GreaterThanOrEqual, toPartitionKey)),
                       TableOperators.And,
                       TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThan, toRowKey)));
        }
Exemple #4
0
        private string CreateGeneralFilter(TKey key, DateTime from, DateTime to)
        {
            var id               = _keyConverter.Convert(key);
            var fromRowKey       = AtsKeyCalculator.CalculateRowKey(from);
            var toRowKey         = AtsKeyCalculator.CalculateRowKey(to);
            var fromPartitionKey = AtsKeyCalculator.CalculatePartitionKey(id, key, from, _partitioningProvider);
            var toPartitionKey   = AtsKeyCalculator.CalculatePartitionKey(id, key, to.AddTicks(-1), _partitioningProvider); // -1 tick because it is an approximation value and we use gte operation

            return(TableQuery.CombineFilters(
                       TableQuery.CombineFilters(
                           TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.LessThanOrEqual, fromPartitionKey),
                           TableOperators.And,
                           TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.GreaterThanOrEqual, toPartitionKey)),
                       TableOperators.And,
                       TableQuery.CombineFilters(
                           TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.LessThanOrEqual, fromRowKey),
                           TableOperators.And,
                           TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThan, toRowKey))));
        }
Exemple #5
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);
        }