Ejemplo n.º 1
0
 public Energizer(Bitmap bitmap, ReduceType reduceType)
 {
     this.Bitmap     = bitmap;
     this.ReduceType = reduceType;
     this.Width      = bitmap.Width;
     this.Height     = bitmap.Height;
 }
Ejemplo n.º 2
0
 public RavingContent(Bitmap bitmap, ReduceType reduceType)
 {
     this.ReduceType = reduceType;
     this.Width      = bitmap.Width;
     this.Height     = bitmap.Height;
     this.Deep       = 1;
     this.Map        = Me.ToMap <RavingPixel>(bitmap);
 }
        public void UpdatePerformedReduceType(int view, string reduceKey, ReduceType reduceType)
        {
            var reduceKeyHash = HashKey(reduceKey);
            var key           = CreateKey(view, reduceKey, reduceKeyHash);
            var version       = tableStorage.ReduceKeyTypes.ReadVersion(Snapshot, key);

            AddReduceKeyType(key, view, reduceKey, reduceType, version);
        }
Ejemplo n.º 4
0
 private void UpdatePerformedReduceType(int indexId,
                                        HashSet <string> reduceKeys, ReduceType reduceType, bool skipAdd = false)
 {
     foreach (var reduceKey in reduceKeys)
     {
         string localReduceKey = reduceKey;
         transactionalStorage.Batch(actions =>
                                    actions.MapReduce.UpdatePerformedReduceType(indexId, localReduceKey,
                                                                                reduceType, skipAdd: skipAdd));
     }
 }
Ejemplo n.º 5
0
        public MySeamCarving(Bitmap bitmap, int deep, ReduceType type)
        {
            IList <IPixel> map = new List <IPixel>();

            this.ReduceType = type;
            this.Deep       = deep;
            this.Width      = bitmap.Width;
            this.Height     = bitmap.Height;
            this.Map        = this.Deep <= 1 ? Me.ToMap <MySeamPixel>(bitmap) : Me.ToMap <MyClusterPixel>(bitmap);
            Me.EnergyCalculationOnMap();
        }
Ejemplo n.º 6
0
        public void UpdatePerformedReduceType(string indexName, string reduceKey, ReduceType performedReduceType)
        {
            ExecuteOnReduceKey(indexName, reduceKey, ReduceKeysStatus, tableColumnsCache.ReduceKeysStatusColumns, () =>
            {
                using (var update = new Update(session, ReduceKeysStatus, JET_prep.Replace))
                {
                    Api.SetColumn(session, ReduceKeysStatus, tableColumnsCache.ReduceKeysStatusColumns["reduce_type"],
                                  (int)performedReduceType);

                    update.Save();
                }
            },
                               createIfMissing: true);
        }
Ejemplo n.º 7
0
        private void UpdatePerformedReduceType(int indexId,
                                               HashSet <string> reduceKeys, ReduceType reduceType,
                                               CancellationToken token, bool skipAdd = false)
        {
            foreach (var reduceKey in reduceKeys)
            {
                token.ThrowIfCancellationRequested();

                string localReduceKey = reduceKey;
                transactionalStorage.Batch(actions =>
                                           actions.MapReduce.UpdatePerformedReduceType(indexId, localReduceKey,
                                                                                       reduceType, skipAdd: skipAdd));
            }
        }
        private void AddReduceKeyType(string key, int view, string reduceKey, ReduceType status, ushort?expectedVersion)
        {
            var reduceKeyTypesByView = tableStorage.ReduceKeyTypes.GetIndex(Tables.ReduceKeyTypes.Indices.ByView);

            tableStorage.ReduceKeyTypes.Add(
                writeBatch.Value,
                key,
                new RavenJObject
            {
                { "view", view },
                { "reduceKey", reduceKey },
                { "reduceType", (int)status }
            }, expectedVersion);

            reduceKeyTypesByView.MultiAdd(writeBatch.Value, CreateKey(view), key);
        }
Ejemplo n.º 9
0
        public void UpdatePerformedReduceType(string indexName, string reduceKey, ReduceType reduceType)
        {
            var readResult = storage.ReduceKeys.Read(new RavenJObject {
                { "view", indexName }, { "reduceKey", reduceKey }
            });

            if (readResult == null)
            {
                throw new ArgumentException(string.Format("There is no reduce key '{0}' for index '{1}'", reduceKey, indexName));
            }

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

            key["reduceType"] = (int)reduceType;
            storage.ReduceKeys.UpdateKey(key);
        }
Ejemplo n.º 10
0
        public void UpdatePerformedReduceType(string indexName, string reduceKey, ReduceType reduceType)
        {
            var readResult = storage.ReduceKeys.Read(new RavenJObject {
                { "view", indexName }, { "reduceKey", reduceKey }
            });

            if (readResult == null)
            {
                storage.ReduceKeys.Put(new RavenJObject
                {
                    { "view", indexName },
                    { "reduceKey", reduceKey },
                    { "reduceType", (int)reduceType },
                    { "mappedItemsCount", 0 }
                }, null);
                return;
            }

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

            key["reduceType"] = (int)reduceType;
            storage.ReduceKeys.UpdateKey(key);
        }
Ejemplo n.º 11
0
        static public Point GetXYPixelSumCenter(Mat img, ReduceType reduceType = ReduceType.ReduceSum)
        {
            Mat imgGray = img;

            if (img.NumberOfChannels > 1)
            {
                imgGray = new Mat();
                CvInvoke.CvtColor(img, imgGray, ColorConversion.Bgr2Gray);
            }

            Mat histX = new Mat(1, imgGray.Cols, DepthType.Cv32F, 1);
            Mat histY = new Mat(imgGray.Rows, 1, DepthType.Cv32F, 1);

            CvInvoke.Reduce(imgGray, histX, ReduceDimension.SingleRow, reduceType, DepthType.Cv32F);
            CvInvoke.Reduce(imgGray, histY, ReduceDimension.SingleCol, reduceType, DepthType.Cv32F);

            //---------- XVal
            double minVal, maxVal;

            int[] minIds = new int[2]; // размерность dim of shape
            int[] maxIds = new int[2];

            CvInvoke.MinMaxIdx(histX, out minVal, out maxVal, minIds, maxIds);
            int xx = maxIds[1];

            CvInvoke.MinMaxIdx(histY, out minVal, out maxVal, minIds, maxIds);
            int yy = maxIds[0];

            histX.Dispose();
            histY.Dispose();
            if (img.NumberOfChannels > 1)
            {
                imgGray.Dispose();
            }

            return(new Point(xx, yy));
        }
Ejemplo n.º 12
0
 public ReduceTypePerKey(string reduceKey, ReduceType type)
 {
     ReduceKey = reduceKey;
     OperationTypeToPerform = type;
 }
Ejemplo n.º 13
0
 public ReducingPerformanceStats(ReduceType reduceType)
 {
     ReduceType = reduceType;
     LevelStats = new List <ReduceLevelPeformanceStats>();
 }
Ejemplo n.º 14
0
 public ReducingPerformanceStats(ReduceType reduceType)
 {
     ReduceType = reduceType;
     LevelStats = new List<ReduceLevelPeformanceStats>();
 }
Ejemplo n.º 15
0
		public void UpdatePerformedReduceType(string indexName, string reduceKey, ReduceType reduceType)
		{
			var readResult = storage.ReduceKeys.Read(new RavenJObject { { "view", indexName }, { "reduceKey", reduceKey } });

			if (readResult == null)
			{
				storage.ReduceKeys.Put(new RavenJObject
				{
					                       {"view", indexName},
					                       {"reduceKey", reduceKey},
					                       {"reduceType", (int) reduceType},
					                       {"mappedItemsCount", 0}
				                       }, null);
				return;
			}

			var key = (RavenJObject)readResult.Key.CloneToken();
			key["reduceType"] = (int)reduceType;
			storage.ReduceKeys.UpdateKey(key);
		}
Ejemplo n.º 16
0
        public void UpdatePerformedReduceType(int view, string reduceKey, ReduceType performedReduceType, bool skipAdd = false)
        {
            var reduceKeyExists = false;

            ExecuteOnReduceKey(view, reduceKey, ReduceKeysCounts, tableColumnsCache.ReduceKeysCountsColumns,
                () =>
                {
                    reduceKeyExists = true;
                }, null);

            if (reduceKeyExists == false)
            {
                // the reduce key doesn't exist anymore,
                // we can delete the reduce key type for this reduce key
                ExecuteOnReduceKey(view, reduceKey, ReduceKeysStatus, tableColumnsCache.ReduceKeysStatusColumns,
                    () =>
                    {
                        Api.JetDelete(session, ReduceKeysStatus);
                    }, null);
                return;
            }

            if (skipAdd)
                return;

            ExecuteOnReduceKey(view, reduceKey, ReduceKeysStatus, tableColumnsCache.ReduceKeysStatusColumns, () =>
            {
                using (var update = new Update(session, ReduceKeysStatus, JET_prep.Replace))
                {
                    Api.SetColumn(session, ReduceKeysStatus, tableColumnsCache.ReduceKeysStatusColumns["reduce_type"],
                                  (int)performedReduceType);

                    update.Save();
                }
            }, () => Api.SetColumn(session, ReduceKeysStatus, tableColumnsCache.ReduceKeysStatusColumns["reduce_type"],
                                  (int)performedReduceType));
        }
		private void AddReduceKeyType(Slice key, int view, string reduceKey, ReduceType status, ushort? expectedVersion)
		{
			var reduceKeyTypesByView = tableStorage.ReduceKeyTypes.GetIndex(Tables.ReduceKeyTypes.Indices.ByView);

			tableStorage.ReduceKeyTypes.AddStruct(
				writeBatch.Value,
				key,
				new Structure<ReduceKeyTypeFields>(tableStorage.ReduceKeyTypes.Schema)
					.Set(ReduceKeyTypeFields.IndexId, view)
					.Set(ReduceKeyTypeFields.ReduceType, (int) status)
					.Set(ReduceKeyTypeFields.ReduceKey, reduceKey),
				expectedVersion);

            reduceKeyTypesByView.MultiAdd(writeBatch.Value, (Slice)CreateKey(view), key);
		}
Ejemplo n.º 18
0
 private void UpdatePerformedReduceType(int indexId, 
     HashSet<string> reduceKeys, ReduceType reduceType, bool skipAdd = false)
 {
     foreach (var reduceKey in reduceKeys)
     {
         string localReduceKey = reduceKey;
         transactionalStorage.Batch(actions =>
             actions.MapReduce.UpdatePerformedReduceType(indexId, localReduceKey,
                 reduceType, skipAdd: skipAdd));
     }
 }
		public void UpdatePerformedReduceType(int view, string reduceKey, ReduceType reduceType)
		{
            var reduceKeyHash = HashKey(reduceKey);
            var key = (Slice)CreateKey(view, ReduceKeySizeLimited(reduceKey), reduceKeyHash);
			var version = tableStorage.ReduceKeyTypes.ReadVersion(Snapshot, key, writeBatch.Value);

			AddReduceKeyType(key, view, reduceKey, reduceType, version);
		}
Ejemplo n.º 20
0
        public void UpdatePerformedReduceType(int view, string reduceKey, ReduceType reduceType, bool skipAdd = false)
        {
            var reduceKeySlice = CreateMappedResultKey(view, reduceKey);
            var reduceKeyTypeVersion = tableStorage.ReduceKeyTypes.ReadVersion(Snapshot, reduceKeySlice, writeBatch.Value);
            if (GetNumberOfMappedItemsPerReduceKey(reduceKeySlice) == 0)
            {
                // the reduce key doesn't exist anymore,
                // we can delete the reduce key type for this reduce key
                DeleteReduceKeyType(reduceKeySlice, CreateViewKey(view), reduceKeyTypeVersion);
                return;
            }

            if (skipAdd)
                return;

            AddReduceKeyType(reduceKeySlice, view, reduceKey, reduceType, reduceKeyTypeVersion);
        }
Ejemplo n.º 21
0
		public void UpdatePerformedReduceType(string indexName, string reduceKey, ReduceType performedReduceType)
		{
			ExecuteOnReduceKey(indexName, reduceKey, ReduceKeysStatus, tableColumnsCache.ReduceKeysStatusColumns, () =>
			{
				using (var update = new Update(session, ReduceKeysStatus, JET_prep.Replace))
				{
					Api.SetColumn(session, ReduceKeysStatus, tableColumnsCache.ReduceKeysStatusColumns["reduce_type"],
								  (int)performedReduceType);

					update.Save();
				}
			}, () => Api.SetColumn(session, ReduceKeysStatus, tableColumnsCache.ReduceKeysStatusColumns["reduce_type"],
								  (int)performedReduceType));
		}
Ejemplo n.º 22
0
		public void UpdatePerformedReduceType(int view, string reduceKey, ReduceType reduceType)
		{
            var key = CreateMappedResultKey(view,reduceKey);
			var version = tableStorage.ReduceKeyTypes.ReadVersion(Snapshot, key, writeBatch.Value);

			AddReduceKeyType(key, view, reduceKey, reduceType, version);
		}
Ejemplo n.º 23
0
		private void AddReduceKeyType(string key, int view, string reduceKey, ReduceType status, ushort? expectedVersion)
		{
			var reduceKeyTypesByView = tableStorage.ReduceKeyTypes.GetIndex(Tables.ReduceKeyTypes.Indices.ByView);

			tableStorage.ReduceKeyTypes.Add(
						writeBatch.Value,
						key,
						new RavenJObject
						{
							{ "view", view },
							{ "reduceKey", reduceKey },
							{ "reduceType", (int)status }
						}, expectedVersion);

			reduceKeyTypesByView.MultiAdd(writeBatch.Value, CreateKey(view), key);
		}
Ejemplo n.º 24
0
		public void UpdatePerformedReduceType(int view, string reduceKey, ReduceType reduceType)
		{
            var reduceKeyHash = HashKey(reduceKey);
			var key = CreateKey(view, reduceKey, reduceKeyHash);
			var version = tableStorage.ReduceKeyTypes.ReadVersion(Snapshot, key);

			AddReduceKeyType(key, view, reduceKey, reduceType, version);
		}
		public void UpdatePerformedReduceType(string indexName, string reduceKey, ReduceType reduceType)
		{
			var readResult = storage.ReduceKeys.Read(new RavenJObject { { "view", indexName }, { "reduceKey", reduceKey } });

			if (readResult == null)
				throw new ArgumentException(string.Format("There is no reduce key '{0}' for index '{1}'", reduceKey, indexName));

			var key = (RavenJObject)readResult.Key.CloneToken();
			key["reduceType"] = (int)reduceType;
			storage.ReduceKeys.UpdateKey(key);
		}
Ejemplo n.º 26
0
		public ReduceTypePerKey(string reduceKey, ReduceType type)
		{
			ReduceKey = reduceKey;
			OperationTypeToPerform = type;
		}