Re: need help reading blob column from oracle

2014-01-30 Thread Niels van Klaveren
(jdbc/query db [select blob_contents from ce_blob where event_id in (?,?,?) [10024279,10024280,10024281]] :row-fn (fn [r] (some- r :blob_contents .getBinaryStream

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-30 Thread Michael Gardner
On Jan 30, 2014, at 01:36 , Steffen steffen.die...@gmail.com wrote: If you would like to use a specific codec other than :byte or :ubyte but also restrict the number of bytes read this would only work if you expected to have some kind of optional padding after your objects, like:

When should I use non-blocking ! / threads and blocking !! / goroutines with clojure core.async

2014-01-30 Thread Sean Pietz
I'm writing a an ETL process to read event level data from a product database, transform / aggregate it and write to to an analytics data warehouse. I'm using clojure's core.async library to separate these process into concurrently executing components. Here's what the main part of my code

Re: [ANN] clj-refactor.el 0.10.0

2014-01-30 Thread Aaron France
Wow! This looks really cool. +1 On Thu, Jan 30, 2014 at 05:13:36AM -0800, Magnar Sveen wrote: clj-refactor.el Since the last update, there's been lots of activity for clj-refactor.elhttps://github.com/magnars/clj-refactor.el . Alex Baranosky https://github.com/AlexBaranosky and Lars

Improving the bean function with caching

2014-01-30 Thread pron
The bean function is a very useful Java interop feature that provides a read-only view of a Java Bean as a Clojure map. As it stands, the function performs introspection on the bean's class whenever the function is called: (defn bean Takes a Java object and returns a read-only implementation

David Nolen's sudoku solver not compatible with Peter Norvig's generator?

2014-01-30 Thread Jim - FooBar();
Hi all, I think we are all familiar with the wonderful core.logic implementation of a sudoku solver by David Nolen. Now, I am trying to combine his solver with the `random-puzzle` generator shown here ( http://jkkramer.com/sudoku.html). I have made the necessary changes (to deal with seqs

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-30 Thread Steffen Dienst
Am Donnerstag, 30. Januar 2014 14:05:07 UTC+1 schrieb Michael Gardner: On Jan 30, 2014, at 01:36 , Steffen steffen...@gmail.com javascript: wrote: If you would like to use a specific codec other than :byte or :ubyte but also restrict the number of bytes read this would only work if you

Re: Improving the bean function with caching

2014-01-30 Thread Jozef Wagner
Hi, Not every bean is immutable, so you cannot cache its values by default. If reading from the bean is expensive for you, either create a normal hash-map with into {} and select-keys, or use memoize. user= (def b (bean (java.util.Date.))) #'user/b user= (def hm (into {} (select-keys b [:year

Re: Improving the bean function with caching

2014-01-30 Thread pron
I'm not caching the values, only the mapping from keywords to methods (the caching is per class, not per bean). It's just saving the introspection/reflection on each call. The values themselves are always obtained directly from the bean. On Thursday, January 30, 2014 4:12:31 PM UTC+2, Jozef

Re: Improving the bean function with caching

2014-01-30 Thread Jozef Wagner
Sorry, I've misread your post. If you want this feature to be added to Clojure, please submit a ticket at http://dev.clojure.org/jira/browse/CLJ JW On Thu, Jan 30, 2014 at 3:16 PM, pron ron.press...@gmail.com wrote: I'm not caching the values, only the mapping from keywords to methods (the

Re: Improving the bean function with caching

2014-01-30 Thread Ambrose Bonnaire-Sergeant
Is there any way to invalidate this cache? Thanks, Ambrose On Thu, Jan 30, 2014 at 9:35 PM, pron ron.press...@gmail.com wrote: The bean function is a very useful Java interop feature that provides a read-only view of a Java Bean as a Clojure map. As it stands, the function performs

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-30 Thread Michael Gardner
On Jan 30, 2014, at 08:10 , Steffen Dienst steffen.die...@gmail.com wrote: That's exactly what padding is designed to do: Let's say you know there is a run of bytes with a known length (from a header field maybe) and you want to parse an unbounded number of objects within this area. You

Re: Improving the bean function with caching

2014-01-30 Thread Jozef Wagner
Well there is a remove method in ClassValue, http://docs.oracle.com/javase/7/docs/api/java/lang/ClassValue.html#remove(java.lang.Class)and it seems that the cache is implemented in a way that it does not hold class objects, thus it does not prevent class from GCing (the cached value is stored in

Re: Improving the bean function with caching

2014-01-30 Thread pron
Sorry, you're right. No WeakReferences on the class keys, rather a map is stored in a field of Class (similarly to ThreadLocal). BTW, this ClassValue was written by John Rose as part of JSR 292, and a very interesting implementation vis-a-vis concurrency On Thursday, January 30, 2014 4:59:40

Re: Request for help optimising a Clojure program

2014-01-30 Thread Andy Fingerhut
Thanks to the work and thought of Mark Engelberg, Alex Miller, Rich Hickey, myself, and likely several others who I should be naming here but am forgetting, the latest (not yet released) Clojure master version has an improved hash function that gives a much better variety of hash values, and thus

Re: Improving the bean function with caching

2014-01-30 Thread pron
Here's the Javadochttp://docs.oracle.com/javase/7/docs/api/java/lang/ClassValue.html . You can invalidate individual entries with the remove method. A class object itself - or at least those parts visible at runtime through reflection - can never change. Reloading a class with the same name

Re: need help reading blob column from oracle

2014-01-30 Thread bww00amd...@yahoo.com
Niels, Cant thank you enough. Regards Bryan On Sunday, January 26, 2014 10:21:18 PM UTC-6, bww00...@yahoo.com wrote: ANyone have some examples reading a blob column from an oracle db. We have a database with a blob column. A entity can be split acroos multiple rows. If there are multiple

Re: When should I use non-blocking ! / threads and blocking !! / goroutines with clojure core.async

2014-01-30 Thread Caspar Hasenclever
I think your case is exactly where not to use go blocks. Stuff in go blocks is executed on a limited size thread pool so with enough blocking I/O in there you could in theory slow down async processing. The win in using ! and ! in go blocks is that they don't block async threads _while they are

(async/go (async/chan)) gc ?

2014-01-30 Thread t x
Hi, Consider this block of code: (async/go (async/chan)) This creates a go-thread and a go-chan. The go-thread is linked from the list of blocked go-threads. The go-chan is linked from the go-thread. Thus, did we just create a go-thread and a go-chan which is NOT gc-ed at all?

Re: (async/go (async/chan)) gc ?

2014-01-30 Thread Timothy Baldridge
The key thing to remember in all questions of core.async GC is that there is no global blocked gos queue. Instead, the blocked gos are attached directly to the channel. When the channel is GC'd all attached gos are GC'd as well. So in this case, it's actually even simpler.the go never blocks.

Re: When should I use non-blocking ! / threads and blocking !! / goroutines with clojure core.async

2014-01-30 Thread Jozef Wagner
go blocks, together with !, !, alt!, etc... do not create any new threads and are not run in separate thread. There is no thread pool for go blocks. Code inside go blocks is transformed into state machine, and the state machine 'object' is parked in the corresponding channel. When the

Re: (async/go (async/chan)) gc ?

2014-01-30 Thread t x
The key thing to remember in all questions of core.async GC is that there is no global blocked gos queue. Instead, the blocked gos are attached directly to the channel. When the channel is GC'd all attached gos are GC'd as well. This is the source of all my mis-understanding. Thanks for

Re: Request for help optimising a Clojure program

2014-01-30 Thread Alex Miller
Thanks for posting that here Andy - I've been mostly off the grid this week and haven't had time to do some of this followup. I would also like to say many thanks to Mark and Andy who have spent a lot of time elucidating the original issue and working on how to address it. Alex On Thursday,

Re: (async/go (async/chan)) gc ?

2014-01-30 Thread t x
Following up on this. Is the following correct: * async/thread creates Java threads -- these _are_ root gc objects * async/go creates go blocks, which in reality, is just a state machine. go-blocks are NOT root gc objects * go-blocks do _NOT_ have stackframes -- they're just a simple, flat

Re: When should I use non-blocking ! / threads and blocking !! / goroutines with clojure core.async

2014-01-30 Thread Jozef Wagner
Couple of points: - If this piece of code is a performance bottleneck, benchmark whether go 'threads' or real threads better suits your needs. - Handle edge cases, e.g. how your code behave when the channels close, mainly if you have (while true ...) combo. - async/thread uses growing thread

Re: (async/go (async/chan)) gc ?

2014-01-30 Thread Jozef Wagner
Seems OK. Note that code inside go blocks is transformed into state machine 'object' immediatelly, not waiting for hitting !, as go is a macro. On Thu, Jan 30, 2014 at 8:36 PM, t x txrev...@gmail.com wrote: Following up on this. Is the following correct: * async/thread creates Java threads

Re: David Nolen's sudoku solver not compatible with Peter Norvig's generator?

2014-01-30 Thread martin_clausen
Hi Jim Using this https://gist.github.com/swannodette/3217582 version of Davids solver and and the random puzzle generator you refer to the below works for me: (sudokufd (vec (map #(if (= % \.) 0 (Integer. (str %))) (random-puzzle I did adapt David's solver to work with core.logic 0.8.5,

Re: David Nolen's sudoku solver not compatible with Peter Norvig's generator?

2014-01-30 Thread Norman Richards
On Thu, Jan 30, 2014 at 8:01 AM, Jim - FooBar(); jimpil1...@gmail.comwrote: Now, I am trying to combine his solver with the `random-puzzle` generator shown here ( http://jkkramer.com/sudoku.html). [...] any clues? I'd like to be able to generate random-puzzles that can be passed to the

Re: (async/go (async/chan)) gc ?

2014-01-30 Thread t x
Great! Thanks for verifying. On Thu, Jan 30, 2014 at 11:46 AM, Jozef Wagner jozef.wag...@gmail.com wrote: Seems OK. Note that code inside go blocks is transformed into state machine 'object' immediatelly, not waiting for hitting !, as go is a macro. On Thu, Jan 30, 2014 at 8:36 PM, t x

deadlock when using clojure data structures at startup

2014-01-30 Thread Michael Blume
I work on a Java team, so our use of clojure is either a) calling into clojure from java or b) directly using the clojure data structures. Recently we had an app fail because, as it was starting up, one thread was trying to require a clojure namespace, and another was trying to use a

Re: Request for help optimising a Clojure program

2014-01-30 Thread Cedric Greevey
+1 On Thu, Jan 30, 2014 at 11:13 AM, Andy Fingerhut andy.finger...@gmail.comwrote: Thanks to the work and thought of Mark Engelberg, Alex Miller, Rich Hickey, myself, and likely several others who I should be naming here but am forgetting, the latest (not yet released) Clojure master version

Re: When should I use non-blocking ! / threads and blocking !! / goroutines with clojure core.async

2014-01-30 Thread Mauricio Aldazosa
On Thu, Jan 30, 2014 at 12:48 PM, Jozef Wagner jozef.wag...@gmail.comwrote: go blocks, together with !, !, alt!, etc... do not create any new threads and are not run in separate thread. There is no thread pool for go blocks. I thought that go blocks do run in a thread pool of size 42 + (2 *

Re: When should I use non-blocking ! / threads and blocking !! / goroutines with clojure core.async

2014-01-30 Thread Timothy Baldridge
To quote Jozef it can happen all in one thread. This is somewhat true, there are some rare situations where this can happen, but it is fairly rare. Many times putting a value into a channel will mean that the callback on the other end of the channel needs to be dispatched. In that case Mauricio

soft question: should remote channels appear like local channels

2014-01-30 Thread t x
Hi, With apologies for a soft question: This question is NOT: I'm in a situation where client = cljs, server = clj, and I want to figure out how to setup a core.async channel, using pr-str and edn/read-string, where I can seamlessly push data back and forth between client and server. This

Re: deadlock when using clojure data structures at startup

2014-01-30 Thread Stephen C. Gilardi
On Jan 30, 2014, at 8:22 PM, Michael Blume blume.m...@gmail.com wrote: Recently we had an app fail because, as it was starting up, one thread was trying to require a clojure namespace, and another was trying to use a PersistentHashSet. Somehow these two threads wound up in deadlock. I've

Re: soft question: should remote channels appear like local channels

2014-01-30 Thread sean
My question would be “Why not?” If you have a client using core.async and a server using core.async and you have a library that feeds data from certain channels back and forth over websockets, then you have channels everywhere. So I’m not sure why you think your “con” is actually a thing?