From dc643512b7e2b4ffea173da8b87e81e548811ea9 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Mon, 10 Feb 2014 10:50:35 -0500 Subject: [PATCH] Commented out a bunch of debug logging statements that aren't needed right now. Updated some hibernate config files. Added some exceptions to the logback config to ignore debug statements from hibernate and EHCache as they aren't important in our debugging right now. Updated todo... sort of... --- pom.xml | 5 ++++ src/includes/logback.xml | 2 ++ src/main/resources/hibernate.cfg.xml | 25 +++++++++++++------ .../com/sothr/imagetools/hash/AHash.scala | 4 +-- .../com/sothr/imagetools/hash/DHash.scala | 4 +-- .../sothr/imagetools/hash/HashService.scala | 8 +++--- .../com/sothr/imagetools/hash/PHash.scala | 8 +++--- .../sothr/imagetools/image/ImageService.scala | 21 ++++++++-------- src/test/resources/hibernate.cfg.xml | 19 ++++++++++---- todo | 23 ++++++++--------- 10 files changed, 71 insertions(+), 48 deletions(-) diff --git a/pom.xml b/pom.xml index 0872d2f..03e72ac 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,11 @@ hibernate-ehcache ${lib.hibernate.version} + + org.hibernate + hibernate-c3p0 + ${lib.hibernate.version} + diff --git a/src/includes/logback.xml b/src/includes/logback.xml index 713ce5d..4d0b07f 100644 --- a/src/includes/logback.xml +++ b/src/includes/logback.xml @@ -1,5 +1,7 @@ + + diff --git a/src/main/resources/hibernate.cfg.xml b/src/main/resources/hibernate.cfg.xml index 41bd007..96f1af7 100644 --- a/src/main/resources/hibernate.cfg.xml +++ b/src/main/resources/hibernate.cfg.xml @@ -7,10 +7,12 @@ - org.h2.Driver - - org.hibernate.dialect.H2Dialect - false + org.h2.Driver + + org.hibernate.dialect.H2Dialect + false + + @@ -19,10 +21,19 @@ update - thread + thread - - + + org.hibernate.cache.ehcache.EhCacheRegionFactory + org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory + true + + 1 + 100 + 50 + 0 + 5 + 100 diff --git a/src/main/scala/com/sothr/imagetools/hash/AHash.scala b/src/main/scala/com/sothr/imagetools/hash/AHash.scala index cfec911..a2e7cd3 100644 --- a/src/main/scala/com/sothr/imagetools/hash/AHash.scala +++ b/src/main/scala/com/sothr/imagetools/hash/AHash.scala @@ -7,10 +7,10 @@ import grizzled.slf4j.Logging */ object AHash extends PerceptualHasher with Logging { def getHash(imageData: Array[Array[Int]]): Long = { - debug("Generating AHash") + //debug("Generating AHash") val width = imageData.length val height = imageData(0).length - debug(s"Image data size: ${width}x${height}") + //debug(s"Image data size: ${width}x${height}") //calculate average pixel var total = 0 diff --git a/src/main/scala/com/sothr/imagetools/hash/DHash.scala b/src/main/scala/com/sothr/imagetools/hash/DHash.scala index e1d1c77..74e8529 100644 --- a/src/main/scala/com/sothr/imagetools/hash/DHash.scala +++ b/src/main/scala/com/sothr/imagetools/hash/DHash.scala @@ -7,10 +7,10 @@ import grizzled.slf4j.Logging */ object DHash extends PerceptualHasher with Logging { def getHash(imageData: Array[Array[Int]]): Long = { - debug("Generating DHash") + //debug("Generating DHash") val width = imageData.length val height = imageData(0).length - debug(s"Image data size: ${width}x${height}") + //debug(s"Image data size: ${width}x${height}") //calculate dhash var hash = 0L diff --git a/src/main/scala/com/sothr/imagetools/hash/HashService.scala b/src/main/scala/com/sothr/imagetools/hash/HashService.scala index 880e372..acda243 100644 --- a/src/main/scala/com/sothr/imagetools/hash/HashService.scala +++ b/src/main/scala/com/sothr/imagetools/hash/HashService.scala @@ -23,7 +23,7 @@ object HashService extends Logging { } def getImageHashes(image:BufferedImage, imagePath:String):ImageHashDTO = { - debug("Creating hashes for an image") + //debug("Creating hashes for an image") var ahash:Long = 0L var dhash:Long = 0L @@ -50,7 +50,7 @@ object HashService extends Logging { } def getAhash(image:BufferedImage, alreadyGray:Boolean = false):Long = { - debug("Started generating an AHash") + //debug("Started generating an AHash") var grayImage:BufferedImage = null if (alreadyGray) { grayImage = image @@ -63,7 +63,7 @@ object HashService extends Logging { } def getDhash(image:BufferedImage, alreadyGray:Boolean = false):Long = { - debug("Started generating an DHash") + //debug("Started generating an DHash") var grayImage:BufferedImage = null if (alreadyGray) { grayImage = image @@ -76,7 +76,7 @@ object HashService extends Logging { } def getPhash(image:BufferedImage, alreadyGray:Boolean = false):Long = { - debug("Started generating an PHash") + //debug("Started generating an PHash") var grayImage:BufferedImage = null if (alreadyGray) { grayImage = image diff --git a/src/main/scala/com/sothr/imagetools/hash/PHash.scala b/src/main/scala/com/sothr/imagetools/hash/PHash.scala index 7e24cfd..8fe1242 100644 --- a/src/main/scala/com/sothr/imagetools/hash/PHash.scala +++ b/src/main/scala/com/sothr/imagetools/hash/PHash.scala @@ -11,7 +11,7 @@ object PHash extends PerceptualHasher with Logging { //convert the imageData into a FloatArray val width = imageData.length val height = imageData(0).length - debug(s"Starting with image of ${height}x${width} for PHash") + //debug(s"Starting with image of ${height}x${width} for PHash") val imageDataFloat:Array[Array[Float]] = Array.ofDim[Float](height, width) for (row <- 0 until height) { @@ -19,13 +19,13 @@ object PHash extends PerceptualHasher with Logging { imageDataFloat(row)(col) = imageData(row)(col).toFloat } } - debug("Copied image data to float array for transform") + //debug("Copied image data to float array for transform") //debug(s"\n${imageDataFloat.deep.mkString("\n")}") //perform transform on the data val dct:FloatDCT_2D = new FloatDCT_2D(height,width) dct.forward(imageDataFloat, true) - debug("Converted image data into DCT") + //debug("Converted image data into DCT") //debug(s"\n${imageDataFloat.deep.mkString("\n")}") //extract the DCT data @@ -40,7 +40,7 @@ object PHash extends PerceptualHasher with Logging { } } val mean = total / (dctDataHeight * dctDataWidth) - debug(s"Calculated mean as $mean from ${total}/${dctDataHeight * dctDataWidth}") + //debug(s"Calculated mean as $mean from ${total}/${dctDataHeight * dctDataWidth}") //calculate the hash var hash = 0L diff --git a/src/main/scala/com/sothr/imagetools/image/ImageService.scala b/src/main/scala/com/sothr/imagetools/image/ImageService.scala index de49a73..3b4735b 100644 --- a/src/main/scala/com/sothr/imagetools/image/ImageService.scala +++ b/src/main/scala/com/sothr/imagetools/image/ImageService.scala @@ -60,6 +60,7 @@ object ImageService extends Logging { debug(s"${file.getAbsolutePath} was already processed") return image } else { + debug(s"Processing image: ${file.getAbsolutePath}") val bufferedImage = ImageIO.read(file) val hashes = HashService.getImageHashes(bufferedImage, file.getAbsolutePath) var thumbnailPath = lookupThumbnailPath(hashes.md5) @@ -134,7 +135,7 @@ object ImageService extends Logging { * @return */ def convertToGray(image:BufferedImage):BufferedImage = { - debug("Converting an image to grayscale") + //debug("Converting an image to grayscale") val grayImage = new BufferedImage(image.getWidth, image.getHeight, BufferedImage.TYPE_BYTE_GRAY) //create a color conversion operation @@ -152,7 +153,7 @@ object ImageService extends Logging { } def resize(image:BufferedImage, size:Int, forced:Boolean=false):BufferedImage = { - debug(s"Resizing an image to size: ${size}x${size} forced: $forced") + //debug(s"Resizing an image to size: ${size}x${size} forced: $forced") if (forced) { Thumbnails.of(image).forceSize(size,size).asBufferedImage } else { @@ -174,15 +175,15 @@ object ImageService extends Logging { val height = image.getHeight val isSingleChannel = if(numPixels == (width * height)) true else false val hasAlphaChannel = image.getAlphaRaster != null - debug(s"Converting image to 2d. width:$width height:$height") + //debug(s"Converting image to 2d. width:$width height:$height") val result = Array.ofDim[Int](height,width) if (isSingleChannel) { - debug(s"Processing Single Channel Image") + //debug(s"Processing Single Channel Image") val pixelLength = 1 var row = 0 var col = 0 - debug(s"Processing pixels 0 until $numPixels by $pixelLength") + //debug(s"Processing pixels 0 until $numPixels by $pixelLength") for (pixel <- 0 until numPixels by pixelLength) { //debug(s"Processing pixel: $pixel/${numPixels - 1}") val argb:Int = pixels(pixel).toInt //singleChannel @@ -196,11 +197,11 @@ object ImageService extends Logging { } } else if (hasAlphaChannel) { - debug(s"Processing Four Channel Image") + //debug(s"Processing Four Channel Image") val pixelLength = 4 var row = 0 var col = 0 - debug(s"Processing pixels 0 until $numPixels by $pixelLength") + //debug(s"Processing pixels 0 until $numPixels by $pixelLength") for (pixel <- 0 until numPixels by pixelLength) { //debug(s"Processing pixel: $pixel/${numPixels - 1}") var argb:Int = 0 @@ -216,11 +217,11 @@ object ImageService extends Logging { } } } else { - debug(s"Processing Three Channel Image") + //debug(s"Processing Three Channel Image") val pixelLength = 3 var row = 0 var col = 0 - debug(s"Processing pixels 0 until $numPixels by $pixelLength") + //debug(s"Processing pixels 0 until $numPixels by $pixelLength") for (pixel <- 0 until numPixels by pixelLength) { //debug(s"Processing pixel: $pixel/${numPixels - 1}") var argb:Int = 0 @@ -236,8 +237,6 @@ object ImageService extends Logging { } } } - result } - } diff --git a/src/test/resources/hibernate.cfg.xml b/src/test/resources/hibernate.cfg.xml index 6bd87a5..829720d 100644 --- a/src/test/resources/hibernate.cfg.xml +++ b/src/test/resources/hibernate.cfg.xml @@ -7,9 +7,9 @@ - org.h2.Driver - org.hibernate.dialect.H2Dialect - true + org.h2.Driver + org.hibernate.dialect.H2Dialect + true @@ -20,8 +20,17 @@ thread - - + + org.hibernate.cache.ehcache.EhCacheRegionFactory + org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory + true + + 1 + 100 + 50 + 0 + 5 + 100 diff --git a/todo b/todo index c7718c2..e68f6af 100644 --- a/todo +++ b/todo @@ -1,16 +1,13 @@ Add functionality to both engines - -Move files to new locations - -Rename new files based on their MD5 -Add functionality to ImageService - -Cache thumbnails - -Generate thumbnails + -Move files to new locations + -Rename new files based on their MD5 - abandoned as bad idea Improve functionality of the PropertiesService - -Getters and Setters for sepcific values with proper cascading and type awareness - -Nicer debugging? + -Getters and Setters for sepcific values with proper cascading and type awareness + -Nicer debugging? Hibernate - H2 intergration - - setup hibernate - - setup h2 - - setup C3P0 connection pool - - transfer configuration files - - autoload configuration files? - - map DTO's \ No newline at end of file + - autoload configuration files? +Database - How to handle directories to reduce database storage? + - recursive database construction + -Factory to handle generating directory information + -Directory1 -> Directory2 -> Directory3 + -result = Directory/Directory2/Directory3 \ No newline at end of file