示例#1
0
        public override IRow Process(IRow input, IUpdatableRow output)
        {
            var img = input.Get <byte[]>("image_data");

            // load image only once into memory per row
            using (StreamImage inImage = new StreamImage(img))
            {
                output.SetColumnIfRequested("equipment_make", () => inImage.getStreamImageProperty(ImageProperties.equipment_make));
                output.SetColumnIfRequested("equipment_model", () => inImage.getStreamImageProperty(ImageProperties.equipment_model));
                output.SetColumnIfRequested("description", () => inImage.getStreamImageProperty(ImageProperties.description));
                output.SetColumnIfRequested("copyright", () => inImage.getStreamImageProperty(ImageProperties.copyright));
                output.SetColumnIfRequested("thumbnail", () => inImage.scaleStreamImageTo(150, 150));
            }
            return(output.AsReadOnly());
        }
        public override IEnumerable <IRow> Extract(IUnstructuredReader input, IUpdatableRow output)
        {
            foreach (Stream current in input.Split())
            {
                using (StreamReader streamReader = new StreamReader(current, Encoding.UTF8))
                {
                    string[] array = streamReader.ReadToEnd().Split(new string[] { "\t" }, StringSplitOptions.None);

                    output.SetColumnIfRequested("UserId", () => Int32.Parse(array[0]));
                    output.SetColumnIfRequested("Start", () => DateTime.Parse(array[1]));
                    output.SetColumnIfRequested("Region", () => (array[2]));
                    output.SetColumnIfRequested("Query", () => (array[3]));
                    output.SetColumnIfRequested("Duration", () => Int32.Parse(array[4]));
                    output.SetColumnIfRequested("Urls", () => (array[5]));
                    output.SetColumnIfRequested("ClickedUrls", () => (array[6]));
                }
                yield return(output.AsReadOnly());
            }
        }
        public override IEnumerable <IRow> Extract(IUnstructuredReader input, IUpdatableRow output)
        {
            byte[] img = ImageOps.GetByteArrayforImage(input.BaseStream);

            // load image only once into memory per row
            using (StreamImage inImage = new StreamImage(img))
            {
                output.SetColumnIfRequested("image", () => img);
                output.SetColumnIfRequested("equipment_make", () => inImage.getStreamImageProperty(ImageProperties.equipment_make));
                output.SetColumnIfRequested("equipment_model", () => inImage.getStreamImageProperty(ImageProperties.equipment_model));
                output.SetColumnIfRequested("description", () => inImage.getStreamImageProperty(ImageProperties.description));
                output.SetColumnIfRequested("copyright", () => inImage.getStreamImageProperty(ImageProperties.copyright));
                output.SetColumnIfRequested("thumbnail", () => inImage.scaleStreamImageTo(this._scaleWidth, this._scaleHeight));
            }
            yield return(output.AsReadOnly());
        }