当前位置: 首页>>代码示例>>C#>>正文


C# Etag.ToByteArray方法代码示例

本文整理汇总了C#中Etag.ToByteArray方法的典型用法代码示例。如果您正苦于以下问题:C# Etag.ToByteArray方法的具体用法?C# Etag.ToByteArray怎么用?C# Etag.ToByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Etag的用法示例。


在下文中一共展示了Etag.ToByteArray方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsIndexStale

		public bool IsIndexStale(string name, DateTime? cutOff, Etag cutoffEtag)
		{
			Api.JetSetCurrentIndex(session, IndexesStats, "by_key");
			Api.MakeKey(session, IndexesStats, name, Encoding.Unicode, MakeKeyGrbit.NewKey);
			if (Api.TrySeek(session, IndexesStats, SeekGrbit.SeekEQ) == false)
			{
				return false;
			}

			Api.JetSetCurrentIndex(session, IndexesStatsReduce, "by_key");
			Api.MakeKey(session, IndexesStatsReduce, name, Encoding.Unicode, MakeKeyGrbit.NewKey);
			var hasReduce = Api.TrySeek(session, IndexesStatsReduce, SeekGrbit.SeekEQ);

			if (IsMapStale(name) || hasReduce && IsReduceStale(name))
			{
				if (cutOff != null)
				{
					var indexedTimestamp = Api.RetrieveColumnAsInt64(session, IndexesStats, tableColumnsCache.IndexesStatsColumns["last_indexed_timestamp"]).Value;
					var lastIndexedTimestamp = DateTime.FromBinary(indexedTimestamp);
					if (cutOff.Value >= lastIndexedTimestamp)
						return true;

					if (hasReduce)
					{
						var lastReduceIndex = Api.RetrieveColumnAsInt64(session, IndexesStatsReduce, tableColumnsCache.IndexesStatsReduceColumns["last_reduced_timestamp"]);
						lastIndexedTimestamp = lastReduceIndex == null ? DateTime.MinValue : DateTime.FromBinary(lastReduceIndex.Value);
						if (cutOff.Value >= lastIndexedTimestamp)
							return true;
					}
				}
				else if (cutoffEtag != null)
				{
					var lastIndexedEtag = Api.RetrieveColumn(session, IndexesStats,
												  tableColumnsCache.IndexesStatsColumns["last_indexed_etag"]);

					if (Buffers.Compare(lastIndexedEtag, cutoffEtag.ToByteArray()) < 0)
						return true;
				}
				else
				{
					return true;
				}
			}

			Api.JetSetCurrentIndex(session, Tasks, "by_index");
			Api.MakeKey(session, Tasks, name, Encoding.Unicode, MakeKeyGrbit.NewKey);
			if (Api.TrySeek(session, Tasks, SeekGrbit.SeekEQ) == false)
			{
				return false;
			}
			if (cutOff == null)
				return true;
			// we are at the first row for this index
			var addedAt = Api.RetrieveColumnAsInt64(session, Tasks, tableColumnsCache.TasksColumns["added_at"]).Value;
			return cutOff.Value >= DateTime.FromBinary(addedAt);
		}
开发者ID:robashton,项目名称:ravendb,代码行数:56,代码来源:Staleness.cs

示例2: IsIndexStale

		public bool IsIndexStale(int view, DateTime? cutOff, Etag cutoffEtag)
		{
			Api.JetSetCurrentIndex(session, IndexesStats, "by_key");
			Api.MakeKey(session, IndexesStats, view, MakeKeyGrbit.NewKey);
			if (Api.TrySeek(session, IndexesStats, SeekGrbit.SeekEQ) == false)
			{
				return false;
			}

			Api.JetSetCurrentIndex(session, IndexesStatsReduce, "by_key");
			Api.MakeKey(session, IndexesStatsReduce, view, MakeKeyGrbit.NewKey);
			var hasReduce = Api.TrySeek(session, IndexesStatsReduce, SeekGrbit.SeekEQ);

			if (IsMapStale(view) || hasReduce && IsReduceStale(view))
			{
				if (cutOff != null)
				{
					var indexedTimestamp = Api.RetrieveColumnAsInt64(session, IndexesStats, tableColumnsCache.IndexesStatsColumns["last_indexed_timestamp"]).Value;
					var lastIndexedTimestamp = DateTime.FromBinary(indexedTimestamp);
					if (cutOff.Value >= lastIndexedTimestamp)
						return true;

					if (hasReduce)
					{
						var lastReduceIndex = Api.RetrieveColumnAsInt64(session, IndexesStatsReduce, tableColumnsCache.IndexesStatsReduceColumns["last_reduced_timestamp"]);
						lastIndexedTimestamp = lastReduceIndex == null ? DateTime.MinValue : DateTime.FromBinary(lastReduceIndex.Value);
						if (cutOff.Value >= lastIndexedTimestamp)
							return true;
					}
				}
				else if (cutoffEtag != null)
				{
					var lastIndexedEtag = Api.RetrieveColumn(session, IndexesStats,
												  tableColumnsCache.IndexesStatsColumns["last_indexed_etag"]);

					if (Buffers.Compare(lastIndexedEtag, cutoffEtag.ToByteArray()) < 0)
						return true;
				}
				else
				{
					return true;
				}
			}

			return IsIndexStaleByTask(view, cutOff);
		}
开发者ID:cocytus,项目名称:ravendb,代码行数:46,代码来源:Staleness.cs

示例3: IsIndexStale

		public bool IsIndexStale(string name, DateTime? cutOff, Etag cutoffEtag)
		{
			var indexingStatsReadResult = storage.IndexingStats.Read(name);
			var lastIndexedEtagsReadResult = storage.LastIndexedEtags.Read(name);

			if (indexingStatsReadResult == null)
				return false;// index does not exists


			if (IsMapStale(name) || IsReduceStale(name))
			{
				if (cutOff != null)
				{
					var lastIndexedTime = lastIndexedEtagsReadResult.Key.Value<DateTime>("lastTimestamp");
					if (cutOff.Value >= lastIndexedTime)
						return true;

					var lastReducedTime = indexingStatsReadResult.Key.Value<DateTime?>("lastReducedTimestamp");
					if (lastReducedTime != null && cutOff.Value >= lastReducedTime.Value)
						return true;
				}
				else if (cutoffEtag != null)
				{
					var lastIndexedEtag = lastIndexedEtagsReadResult.Key.Value<byte[]>("lastEtag");

					if (Buffers.Compare(lastIndexedEtag, cutoffEtag.ToByteArray()) < 0)
						return true;
				}
				else
				{
					return true;
				}
			}

			var tasksAfterCutoffPoint = storage.Tasks["ByIndexAndTime"].SkipTo(new RavenJObject { { "index", name } });
			if (cutOff != null)
				tasksAfterCutoffPoint = tasksAfterCutoffPoint
					.Where(x => x.Value<DateTime>("time") <= cutOff.Value);
			return tasksAfterCutoffPoint.Any();
		}
开发者ID:robashton,项目名称:ravendb,代码行数:40,代码来源:StalenessStorageActions.cs

示例4: UpdateLastReduced

		public void UpdateLastReduced(int id, Etag etag, DateTime timestamp)
		{
			var key = CreateKey(id);

			ushort version;
			var reduceStats = Load(tableStorage.ReduceStats, key, out version);

			if (Buffers.Compare(reduceStats.Value<byte[]>("lastReducedEtag"), etag.ToByteArray()) >= 0)
				return;

			reduceStats["lastReducedEtag"] = etag.ToByteArray();
			reduceStats["lastReducedTimestamp"] = timestamp;

			tableStorage.ReduceStats.Add(writeBatch.Value, key, reduceStats, version);
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:15,代码来源:IndexingStorageActions.cs

示例5: UpdateLastIndexed

		public void UpdateLastIndexed(int id, Etag etag, DateTime timestamp)
		{
			var key = CreateKey(id);

			ushort version;
			var indexStats = Load(tableStorage.LastIndexedEtags, key, out version);

			indexStats["lastEtag"] = etag.ToByteArray();
			indexStats["lastTimestamp"] = timestamp;

			tableStorage.LastIndexedEtags.Add(writeBatch.Value, key, indexStats, version);
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:12,代码来源:IndexingStorageActions.cs

示例6: UpdateLastReduced

		public void UpdateLastReduced(string index, Etag etag, DateTime timestamp)
		{
			using (storage.WriteLock())
			{
				var readResult = storage.IndexingStats.Read(index);
				if (readResult == null)
					throw new ArgumentException(string.Format("There is no index with the name: '{0}'", index));

				var ravenJObject = (RavenJObject) readResult.Key.CloneToken();
				ravenJObject["lastReducedEtag"] = etag.ToByteArray();
				ravenJObject["lastReducedTimestamp"] = timestamp;

				storage.IndexingStats.UpdateKey(ravenJObject);
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:15,代码来源:IndexingStorageActions.cs

示例7: UpdateLastIndexed

		public void UpdateLastIndexed(string index, Etag etag, DateTime timestamp)
		{
			using (storage.WriteLock())
			{
				bool updateOperationStatus = false;

				var sp = Stopwatch.StartNew();

				while (!updateOperationStatus)
				{
					var readResult = storage.LastIndexedEtags.Read(index);
					if (readResult == null)
						throw new ArgumentException("There is no index with the name: " + index);

					var ravenJObject = (RavenJObject) readResult.Key.CloneToken();

					if (Buffers.Compare(ravenJObject.Value<byte[]>("lastEtag"), etag.ToByteArray()) >= 0)
					{
						break;
					}

					ravenJObject["lastEtag"] = etag.ToByteArray();
					ravenJObject["lastTimestamp"] = timestamp;

					updateOperationStatus = storage.LastIndexedEtags.UpdateKey(ravenJObject);

					if (!updateOperationStatus)
					{
						Thread.Sleep(100);
					}

					if (sp.Elapsed > etagUpdateTimeout)
					{
						break;
					}
				}
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:38,代码来源:IndexingStorageActions.cs

示例8: Write

 public static void Write(this Stream stream, Etag etag)
 {
     var buffer = etag.ToByteArray();
     stream.Write(buffer, 0, 16);
 }
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:5,代码来源:StreamExtensions.cs

示例9: Touch

        public void Touch(string name, string key, UuidType uuidType, out Etag preTouchEtag, out Etag afterTouchEtag)
        {
            var item = Read(name, key);
            if (item == null)
            {
                afterTouchEtag = null;
                preTouchEtag = null;
                return;
            }

            preTouchEtag = item.Etag;

            Remove(name, key);

            afterTouchEtag = generator.CreateSequentialUuid(uuidType);
            var internalKey = afterTouchEtag.ToString();
            var internalKeyAsSlice = (Slice) internalKey;

            tableStorage.Lists.Add(
                writeBatch.Value,
                internalKeyAsSlice,
                new RavenJObject
                {
                    {"name", name},
                    {"key", key},
                    {"etag", afterTouchEtag.ToByteArray()},
                    {"data", item.Data},
                    {"createdAt", item.CreatedAt}
                });

            var listsByName = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByName);
            var listsByNameAndKey = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByNameAndKey);

            var nameKey = CreateKey(name);
            var nameKeySlice = (Slice) nameKey;
            var nameAndKeySlice = (Slice) AppendToKey(nameKey, key);

            listsByName.MultiAdd(writeBatch.Value, nameKeySlice, internalKeyAsSlice);
            listsByNameAndKey.Add(writeBatch.Value, nameAndKeySlice, internalKey);
        }
开发者ID:JudahGabriel,项目名称:ravendb,代码行数:40,代码来源:ListsStorageActions.cs

示例10: CreateBucketAndEtagKey

	    private Slice CreateBucketAndEtagKey(int bucket, Etag id)
	    {
	        var sliceWriter = new SliceWriter(20);
	        sliceWriter.WriteBigEndian(bucket);
            sliceWriter.Write(id.ToByteArray());
	        return sliceWriter.CreateSlice();
	    }
开发者ID:GorelH,项目名称:ravendb,代码行数:7,代码来源:MappedResultsStorageActions.cs

示例11: GetAttachmentsAfter

		public IEnumerable<AttachmentInformation> GetAttachmentsAfter(Etag value, int take, long maxTotalSize)
		{
			long totalSize = 0;
			return (from key in storage.Attachments["ByEtag"]
				        .SkipAfter(new RavenJObject {{"etag", value.ToByteArray()}})
				        .Take(take)
			        let attachment = GetAttachment(key.Value<string>("key"))
					let _ = totalSize += attachment.Size
					where totalSize <= maxTotalSize
			        select new AttachmentInformation
			        {
				        Key = key.Value<string>("key"),
				        Etag = Etag.Parse(key.Value<byte[]>("etag")),
				        Metadata = attachment.Metadata,
				        Size = attachment.Size
			        });
		}
开发者ID:925coder,项目名称:ravendb,代码行数:17,代码来源:AttachmentsStorageActions.cs


注:本文中的Etag.ToByteArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。