distinct-values

Java stream that is distinct by more than one property

自古美人都是妖i 提交于 2019-12-24 03:14:10
问题 I have following objects in the stream: class Foo{ String a; String b; int c; } I would like to filter a stream based on following criteria: eg. Having entries in stream: foo1 and foo2 : foo1 and foo2 have same values for a and b , but they differ in c property. I would like to get rid of entries that have c higher in such case. 回答1: Semantically equivalent to Eugene’s answer, but a bit simpler: List<Foo> foos = Stream.of(new Foo("a", "b", 1), new Foo("a", "b", 2), new Foo("a", "b", 3), new

Linq join on parameterized distinct key

梦想与她 提交于 2019-12-24 01:07:12
问题 I'm trying to LINQ two tables based on a dynamic key. User can change key via a combo box. Key may be money, string, double, int, etc. Currently I'm getting the data just fine, but without filtering out the doubles. I can filter the double in VB, but it's slooooow. I'd like to do it in the LINQ query right out of the gate. Here's the data: First Table: ------------------------------------------------------------- | AppleIndex | AppleCost | AppleColor | AppleDescription | ---------------------

Elasticsearch: how to get the top unique values of a field sorted by matching score?

纵饮孤独 提交于 2019-12-23 19:46:49
问题 I have a collection of addresses. Let's simplify and say the only fields are postcode , city , street , streetnumber and name . I'd like to be able to suggest a list of streets when the user enters a postcode, a city and some query for the street. For example, if the user, in a HTML form, enters: postcode: 75010 city: Paris street: rue des I'd like to get a list of streets like 'rue des petites écuries' 'rue des messageries' ... 'rue du faubourg poissonnière' ... that I could suggest to the

selecting a distinct combination of 2 columns in SQL

喜欢而已 提交于 2019-12-22 13:59:03
问题 When i run a select after a number of joins on my table I have an output of 2 columns and I want to select a distinct combination of col1 and col2 for the rowset returned. the query that i run will be smthing like this: select a.Col1,b.Col2 from a inner join b on b.Col4=a.Col3 now the output will be somewhat like this Col1 Col2 1 z 2 z 2 x 2 y 3 x 3 x 3 y 4 a 4 b 5 b 5 b 6 c 6 c 6 d now I want the output should be something like follows 1 z 2 y 3 x 4 a 5 b 6 d its ok if I pick the second

Trying to sum distinct values SQL

江枫思渺然 提交于 2019-12-22 04:51:03
问题 I'm having trouble coming up with a value for a cell in SSRS, which should be a sum of distinct values. I have a SSRS report that looks similar to the below screenshot: I'm having trouble getting the value in red ($11.25). I basically need to sum the Ship Cost, based on distinct Tracking #s. So there are two distinct tracking #s, one with a Ship Cost of $5.25 and the other $6.00, so the total displayed in red should be $11.25. But I cannot achieve this in SSRS and can't figure it out in the

get Distinct Values with Sorted Data

a 夏天 提交于 2019-12-20 12:35:53
问题 I need a Query to get distinct keys with sorted on basis of score in Mongodb 1.6.5 I have records Like {key ="SAGAR" score =16 note ="test1" } {key ="VARPE" score =17 note ="test1" } {key ="SAGAR" score =16 note ="test2" } {key ="VARPE" score =17 note ="test2" } I need a query which sorts all records on score and returns me distinct key..... 回答1: There is distinct command in mongodb: you can use distinct like this: db.test.distinct({"key":true,"score":true,"note":true}); the same in

FormControl.detectchanges - why use distinctUntilChanged?

徘徊边缘 提交于 2019-12-19 17:45:16
问题 Reading How to use RxJs distinctUntilChanged? and this, it seems that distinctUntilChanged alters the output stream to only provide distinct contiguous values . I take that to mean that if the same value arrives in immediate succession, you are essentially filtering the stream and only getting one occurrence of that repeated value. So if I write this: this.myFormControl.valueChanges .debounceTime(1000) .distinctUntilChanged() .subscribe(newValue => { console.log('debounced: ', newValue); });

Python plotting error bars with different values above and below the point

爱⌒轻易说出口 提交于 2019-12-18 22:36:52
问题 Warning: I'm very new to using python. I'm trying to graph data using error bars but my data has different values for the error above and below the bar, i.e. 2+.75,2-.32. import numpy as np import matplotlib.pyplot as plt # example data x = (1,2,3,4) y = (1,2,3,4) # example variable error bar values yerr = 0.2 plt.figure() plt.errorbar(x, y, yerr,"r^") plt.show() But I want the error bar above the point to be a specific value like .17 and below the point to be a specific point like .3 Does

Python plotting error bars with different values above and below the point

柔情痞子 提交于 2019-12-18 22:36:07
问题 Warning: I'm very new to using python. I'm trying to graph data using error bars but my data has different values for the error above and below the bar, i.e. 2+.75,2-.32. import numpy as np import matplotlib.pyplot as plt # example data x = (1,2,3,4) y = (1,2,3,4) # example variable error bar values yerr = 0.2 plt.figure() plt.errorbar(x, y, yerr,"r^") plt.show() But I want the error bar above the point to be a specific value like .17 and below the point to be a specific point like .3 Does

How to count distinct values in a list in linear time?

心已入冬 提交于 2019-12-18 07:51:59
问题 I can think of sorting them and then going over each element one by one but this is nlogn. Is there a linear method to count distinct elements in a list? 回答1: Update: - distinct vs. unique If you are looking for "unique" values (As in if you see an element "JASON" more than once, than it is no longer unique and should not be counted) You can do that in linear time by using a HashMap ;) (The generalized / language-agnostic idea is Hash table) Each entry of a HashMap / Hash table is <KEY, VALUE