sort large data in redis [closed] - sorting

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
how to sort large data in redis?

What kind of data?
In Redis, it makes more sense to store the data in the order you want to retrieve it.
Depending on your use case you may want to look at lists or sorted sets.

You can use the ZADD and ZRANGE commands for this:
redis> zadd mySet 1 "Large data 1"
(integer) 1
redis> zadd mySet 3 "Large data 3"
(integer) 1
redis> zadd mySet 2 "Large data 2"
(integer) 1
redis> zrange mySet 0 -1
1) "Large data 1"
2) "Large data 2"
3) "Large data 3"

Related

Sum and conditional in oracle sql [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Hello I need help on this query
I Have folliwing datas
Part OderQty ShippedQty QOH
10510 10 5 10
10510 10 0 10
10510 10 0 10
10511 10 10 20
10511 20 0 20
I need to filter where the sum of OrderQty - sum of Shipped Qty is < QOH.
Example:
Part 10510
total sum Ordered: 30
total sum Shipped: 5
Balance: 25
QOH: 10
I need all part where the condition is like part 10510
the second part number is fine because I needed 30, shipped 10 and have 20 on hand, do you how to write this query for oracle,
Thanks
ld
select part
from your_table
group by part
having
sum(OrderQty) - sum(ShippedQty) < max(QOH)

Optimizing deleting million rows in a SQL databse [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Imagine a situation when you have a table with 2 million rows and you wanted to delete a million rows. These rows are not bunched together. I might want to delete row1, and then row5, and then may be row7. But I want to deletes rows that may have age < 23 What is the best way to go about deleting these rows?
You will want to delete them in batches. This previous question provides some interesting answers.

Getting minimum with a default [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
In my params hash, I receive a value for :limit. I need to assign this value to a variable limit, but not exceed 50, and if the value for :limit is not given, default to 50.
First, I did this:
limit = [params[:limit], 50].min
This will make it maximum of 50, but won't work: If nothing is given for :limit, then this will make limit 0.
Next, I did this:
limit = [params[:limit] || 50, 50].min
This works, but I am wondering if this is efficient or if there's a better way to do this.
try
limit = (params[:limit] && params[:limit] < 50) ? params[:limit] : 50
Your solution it's quite easy to read but rather inefficient because you're creating an array and invoking the min method every time and it is an overkill.
A maybe less readable and more verbose but more easy on the machine approach could be:
if params[:limit] && params[:limit] < 50
params[:limit]
else
50
end

How to get a percentage from a range [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a basic math question. I am trying to get a percentage from a range of numbers and the algorithm is troubling me.
Say I have a range of -5 to +5 and I want to know what percentage is in between given a value. I know that -5 would be equivalent to 0% and 5 would be 100%, with 0 being 50%.
I tried to add 5 to bring up the scale, but it just feels like a hack. I would like it to feel dynamic so that I can give it any range and successfully work.
Ex.
percent = (5 + value) * 100 / 10
How do I figure out what value should be the a general case?
range = top_value - bottom_value
percent = (value - bottom_value) / range

create 10000 files with size 4k by using bash? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to do this.
Create 10000 files, (filename can be just combination of time and random number).
File size should be 4k.
And I want to time this. say how many seconds it will take.
How can I do this on bash?
Thank you.
time for x in {1..10000}; do
dd if=/dev/zero ibs=4k count=1 of=$x.txt 2>/dev/null
done

Resources