Esempio n. 1
0
		public ScheduledReductionInfo DeleteScheduledReduction(List<object> itemsToDelete)
		{
			if (itemsToDelete == null)
				return null;
			
			var hasResult = false;
			var result = new ScheduledReductionInfo();
			
			var currentEtagBinary = Guid.Empty.ToByteArray();
			foreach (OptimizedDeleter reader in itemsToDelete)
			{
				foreach (var sortedBookmark in reader.GetSortedBookmarks())
				{
					Api.JetGotoBookmark(session, ScheduledReductions, sortedBookmark.Item1, sortedBookmark.Item2);
					var etagBinary = Api.RetrieveColumn(session, ScheduledReductions,
					                                    tableColumnsCache.ScheduledReductionColumns["etag"]);
					if (new ComparableByteArray(etagBinary).CompareTo(currentEtagBinary) > 0)
					{
						hasResult = true;
						var timestamp =
							Api.RetrieveColumnAsInt64(session, ScheduledReductions,
							                          tableColumnsCache.ScheduledReductionColumns["timestamp"]).Value;
						result.Etag = Etag.Parse(etagBinary);
						result.Timestamp = DateTime.FromBinary(timestamp);
					}

					Api.JetDelete(session, ScheduledReductions);
				}
			}
			return hasResult ? result : null;
		}
		public ScheduledReductionInfo DeleteScheduledReduction(List<object> itemsToDelete)
		{
			var result = new ScheduledReductionInfo();
			var hasResult = false;
			var currentEtagBinary = Guid.Empty.ToByteArray();
			foreach (RavenJToken token in itemsToDelete)
			{
				var readResult = storage.ScheduleReductions.Read(token);
				if (readResult == null)
					continue;

				var etagBinary = readResult.Key.Value<byte[]>("etag");
				if (new ComparableByteArray(etagBinary).CompareTo(currentEtagBinary) > 0)
				{
					hasResult = true;
					var timestamp = readResult.Key.Value<DateTime>("timestamp");
					result.Etag = etagBinary.TransfromToGuidWithProperSorting();
					result.Timestamp = timestamp;
				}

				storage.ScheduleReductions.Remove(token);
			}
			return hasResult ? result : null;
		}
Esempio n. 3
0
		public ScheduledReductionInfo DeleteScheduledReduction(List<object> itemsToDelete)
		{
			var hasResult = false;
			var result = new ScheduledReductionInfo();
			var currentEtagBinary = Guid.Empty.ToByteArray();
			foreach (var sortedBookmark in itemsToDelete.Cast<OptimizedIndexReader>().SelectMany(reader => reader.GetSortedBookmarks()))
			{
				Api.JetGotoBookmark(session, ScheduledReductions, sortedBookmark, sortedBookmark.Length);
				var etagBinary = Api.RetrieveColumn(session, ScheduledReductions, tableColumnsCache.ScheduledReductionColumns["etag"]);
				if (new ComparableByteArray(etagBinary).CompareTo(currentEtagBinary) > 0)
				{
					hasResult = true;
					var timestamp = Api.RetrieveColumnAsDateTime(session, ScheduledReductions, tableColumnsCache.ScheduledReductionColumns["timestamp"]).Value;
					result.Etag = etagBinary.TransfromToGuidWithProperSorting();
					result.Timestamp = timestamp;
				}

				Api.JetDelete(session, ScheduledReductions);
			}
			return hasResult ? result : null;
		}