This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-17
Channels
- # announcements (2)
- # aws (7)
- # beginners (46)
- # cider (15)
- # clj-kondo (24)
- # cljs-dev (3)
- # clojure (46)
- # clojure-dev (34)
- # clojure-europe (7)
- # clojure-italy (7)
- # clojure-nl (10)
- # clojure-norway (15)
- # clojure-spec (5)
- # clojure-uk (42)
- # clojuredesign-podcast (1)
- # clojurescript (79)
- # clr (3)
- # core-async (1)
- # cursive (45)
- # data-science (1)
- # datomic (4)
- # fulcro (17)
- # funcool (14)
- # gorilla (2)
- # graphql (30)
- # jackdaw (5)
- # jobs-discuss (8)
- # joker (4)
- # lein-figwheel (1)
- # off-topic (48)
- # pedestal (26)
- # re-frame (36)
- # reagent (18)
- # reitit (6)
- # remote-jobs (4)
- # shadow-cljs (115)
- # tools-deps (62)
- # vim (12)
and do you mean something like (map (juxt f g) collection)
so it would yield ( ((f x1) (g x1)) ((f x2) (g x2)) ...)
?
sure does. i think i would just make a reduce wrapper that did the normal reduce and also built up the seq of stuff as well
(let [reduce-f +
reduce-init 0
f inc]
(reduce (fn [[acc coll] x]
[(reduce-f acc x) (conj coll (f x))])
[reduce-init ()]
(range 10)))
a reducer that does the normal reduction and also conj's like a mapping. you can make it more tailored or generic as you see fit
there's more elegant solutions out there. i'm playing around with it. perhaps defining map as a reduce and then just doing simultaneous reduces
When I give an xf
, that is a transducer, to a channel when constructing it, does it run when I put a value into channel (and thus is run on my thread), or when someone takes the value out of channel (and it's run on their thread)?
Also is it just me or is the clojure starting a lot faster on Java12 than Java 8
@roklenarcic seems it's applied when adding items to the channel buffer -> https://github.com/clojure/core.async/blob/a25ae2fb44f0bc2828377866443ed638beeed9c9/src/main/clojure/clojure/core/async/impl/channels.clj#L291
thanks
@roklenarcic @plexus the transducer can be run either by producer or consumer thread, depending on the channel state
they might have different chunking behavior with some inputs (but you shouldn't be using laziness if chunking would effect correctness)
I'm doing some license review prior to distributing a JAR. Our intent is that the JAR is closed-source (for now) but freely available, similar to REBL. Is there a good non-lawyer summary of how compatible LPGL libs might be with this kind of approach?
@rgm I'm not a lawyer, but Metabase is a) a clojure application b) uses AGPL https://github.com/metabase/metabase/blob/master/LICENSE.txt - might be helpful
you'd have to filter
if you want just doubles, then yes
you sure that doesn't throw with non-doubles?
I guess you'll get a conversion
it works! :)
Has anyone ever had problems importing java classes marked final? My namespace import
(ns com.my.ns
(:import (org.apache.lucene.search.suggest Input)))
The java class I'm importing
package org.apache.lucene.search.suggest;
import java.util.Set;
import org.apache.lucene.util.BytesRef;
/** corresponds to {@link InputIterator}'s entries */
public final class Input {
public final BytesRef term;
public final long v;
public final BytesRef payload;
public final boolean hasPayloads;
public final Set<BytesRef> contexts;
public final boolean hasContexts;
public Input(BytesRef term, long v, BytesRef payload) {
this(term, v, payload, true, null, false);
}
public Input(String term, long v, BytesRef payload) {
this(new BytesRef(term), v, payload);
}
public Input(BytesRef term, long v, Set<BytesRef> contexts) {
this(term, v, null, false, contexts, true);
}
public Input(String term, long v, Set<BytesRef> contexts) {
this(new BytesRef(term), v, null, false, contexts, true);
}
public Input(BytesRef term, long v) {
this(term, v, null, false, null, false);
}
public Input(String term, long v) {
this(new BytesRef(term), v, null, false, null, false);
}
public Input(String term, int v, BytesRef payload, Set<BytesRef> contexts) {
this(new BytesRef(term), v, payload, true, contexts, true);
}
public Input(BytesRef term, long v, BytesRef payload, Set<BytesRef> contexts) {
this(term, v, payload, true, contexts, true);
}
public Input(BytesRef term, long v, BytesRef payload, boolean hasPayloads, Set<BytesRef> contexts,
boolean hasContexts) {
this.term = term;
this.v = v;
this.payload = payload;
this.hasPayloads = hasPayloads;
this.contexts = contexts;
this.hasContexts = hasContexts;
}
public boolean hasContexts() {
return hasContexts;
}
public boolean hasPayloads() {
return hasPayloads;
}
}
The exception I'm getting:
(ns com.my.ns
(:import (org.apache.lucene.search.suggest Input)))
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
org.apache.lucene.search.suggest.Input
I am able to import all of these:
(ns my.com.ns
(:import (org.apache.lucene.search.suggest.analyzing AnalyzingInfixSuggester)
(org.apache.lucene.store NIOFSDirectory)
(org.apache.lucene.search.suggest InputIterator)
(org.apache.lucene.util BytesRef))
Including the InputIterator
from the same package as the Input
class, but Input
still fails. Ideas?you can check if the actual class file exists on the classpath with io/resource
ser=> ( "java/util/Set.class")
#object[java.net.URL 0x1fdfafd2 "jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre/lib/rt.jar!/java/util/Set.class"]
try that with "org/apache/lucene/search/suggest/Input.class"
you should check the version of the library you are using matches the version of the source you are looking at
for example these docs https://lucene.apache.org/core/4_10_2/suggest/org/apache/lucene/search/suggest/package-summary.html show InputIterator, but no Input
I'm using the latest lucene which, in the same package, it has the class InputIterator
(io/resource "org/apache/lucene/search/suggest/InputIterator.class")
#object[java.net.URL 0x7c4dd006 "jar:file:/Users/magemasher/.m2/repository/org/apache/lucene/lucene-suggest/8.2.0/lucene-suggest-8.2.0.jar!/org/apache/lucene/search/suggest/InputIterator.class"]
but when I search for Input
(io/resource "org/apache/lucene/search/suggest/Input.class")
nil
My deps edn contains
org.apache.lucene/lucene-core {:mvn/version "8.2.0"}
org.apache.lucene/lucene-suggest {:mvn/version "8.2.0"}
org.apache.lucene/lucene-analyzers-common {:mvn/version "8.2.0"}
org.apache.lucene/lucene-queries {:mvn/version "8.2.0"}
Which is why i'm so confused that the Input
class would be missing but the InputIterator
from the same package is present.
Figured it out, it's not on the class path or even in the jar because Input
is a test class. Sorry for the noise.
I don't know how to introspect version conflicts in deps.edn, I know you can sort this out with lein using lein deps :why ...
glad you sorted it out