Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Stephen Berger
    @GettingNifty
    plm75
    @plm75
    Hello, I'm planning on learning RxJava soon and have a little experience with RxSwift and RxJS. I was wondering if RxJava had the equivalent of the following library https://github.com/RxSwiftCommunity/Action , either as a separate library or as a language feature ? Thanks
    Stephen Berger
    @GettingNifty
    Oh I hate swift
    Stephen Berger
    @GettingNifty
    Well I'm not too good at web programming though.
    Yannick Lecaillez
    @ylecaillez

    Hi guys !
    I'm working on a custom groupBy() and reading the RxJava's one i wonder if there is a bug or something i don't get: it seems that groupBy() is request()ing twice its upstream for each receive item when each of these item is creating a new group:

    public void testGroup() {
            final AtomicLong requested = new AtomicLong();
            Flowable.range(1, 2048)
                    .doOnRequest(requested::addAndGet)
                    .groupBy(e -> e)
                    .subscribe(g -> g.subscribe(TestSubscriber.create()));
    
            System.out.println("Requested: " + requested);
    }

    Displays:
    Requested: 4224

    Ideally i would have expected 128 + 2048 so that requested of the source remains at 128.
    Am i missing something ?
    (I'm using RxJava 2.1.0)
    Stephen Berger
    @GettingNifty
    What's adsAndGet
    Yannick Lecaillez
    @ylecaillez
    its AtomicLong.addAndGet(requested)
    Stephen Berger
    @GettingNifty
    So is it retrieving and adding it toitself somehow .. I'm a newb
    Or your e reference
    Calling itself? How does that work
    Yannick Lecaillez
    @ylecaillez
    The problem i can see is if 2048 is not 2048 but something way bigger, at some point the requested value from the source will be huge.
    And if the source is at some point able to produce such number of items going into one group, we might hit an OOME ?
    @GettingNifty This is lamba. Basically its more or less the equivalent of:
    .doOnRequest(new LongConsumer() {
        void accept(long t) {
            requested.addAndGet(t);
        }
    })
    Stephen Berger
    @GettingNifty
    Maybe the one is the second array
    Try 0
    Yannick Lecaillez
    @ylecaillez
    Ok, i'm able to produce an OOME with groupBy() :-(
    Stephen Berger
    @GettingNifty
    I'm confused
    Stephen Berger
    @GettingNifty
    I think you need to schedule it or exit somehow
    var source = Observable.Interval(TimeSpan.FromSeconds(0.1)).Take(10);
    ''var group = source.GroupBy(i => i % 3);
    group.SelectMany(
    grp =>
    grp.Max()
    .Select(value => new { grp.Key, value }))
    .Dump("group");''
    ::hh::
    How do u format
    Yannick Lecaillez
    @ylecaillez

    This is how i'm able to produce an OOME:

    ```java

    Flowable.range(2, 200_000_000)
                    .groupBy(e -> {
                        // First 100 000 000 in different group
                        if (e < 100_000_000) {
                            return e;
                        }
                        // Last 100 000 000 in the same group
                        return 1;
                    })
                    .subscribe(g -> {
                        if (g.getKey() == 1) {
                            g.subscribe(TestSubscriber.create(0));
                        } else {
                            g.subscribe(new DefaultSubscriber<Integer>() {
                                @Override
                                public void onNext(Integer t) {
                                    if (t.intValue() % 100_000 == 0) {
                                        System.out.println("Received: " + t);
                                    }
                                    Schedulers.computation().scheduleDirect(this::cancel);
                                }
    
                                @Override
                                public void onError(Throwable t) {
                                }
    
                                @Override
                                public void onComplete() {
                                }
                            });
                        }
                    });
    You have to be patient but when 100.000.000 is reached, the following 100.000.000 will be queued internally by groupBy() because of the double request() bug (?)
    Hope that helps.
    Stephen Berger
    @GettingNifty
    Can u email me that last piece of code
    I need it for a scenegraph implementation
    @ylecaillez
    Stephen Berger
    @GettingNifty
    I'm trying to move the body parts and it uses keys I need it for reference
    Stephen Berger
    @GettingNifty
    ''' var taco= new Taco();'''
    '''
    '''
    '''code'''
    Ohhh
    var code
    Dorus
    @Dorus
    Try:
    ```Java
    code
    ```
    Stephen Berger
    @GettingNifty
    java code
    I'm on mobile how do I line break
    Dorus
    @Dorus
    ctrl+\ or the button on the right on desktop. Not sure about mobile
    Stephen Berger
    @GettingNifty
    java \ code
    Hmm idk
    Dorus
    @Dorus
    I think it's not possible. You could write your text somewhere else and copy-paste it?
    That might work
    Stephen Berger
    @GettingNifty
    Ahh
    Code
    Hey
    Dorus
    @Dorus
    :+1:
    Stephen Berger
    @GettingNifty
    help
    No boots
    \help
    Gitterbot helps kinda spammy but fun