What's the meaning of Redis `hdr`? - redis

In Redis, the Simple Dynamic String (SDS) can be implemented with sdshdr8、sdshdr16、sdshdr32, etc. So what's the meaning of "hdr"? High Dynamic Range ?

Related

Can I write around 10MB of value against a single key in azure redis cache

Can I write around 10MB of value (JSON Data as a string) against a key (string - xyz) in Azure redis cache
Size- Standard 1 GB
Version - 4.0.14
I am able to insert 3MB of value , but while inserting 7MB of value it gives network error.
I am using StackExchange.Redis.2.1.58 client from .net console app.
From Redis website:
Strings are the most basic kind of Redis value. Redis Strings are
binary safe, this means that a Redis string can contain any kind of
data, for instance a JPEG image or a serialized Ruby object.
A String value can be at max 512 Megabytes in length.
You could put 'syncTimeout' parameter in ConnectionString like this "RedisConfiguration": {"ConnectionString": "mycache.redis.cache.windows.net:6380,password=$$$$$$$$$$$$$$$$$$=,ssl=True,abortConnect=False,syncTimeout=150000"," DatabaseNumber ": 1}. This parameter sets the "Time (ms) to allow synchronous operations", as can be seen at https://stackexchange.github.io/StackExchange.Redis/Configuration.html. I had this problem when I stored items that took more than 5 seconds to be processed, since this is the default value. You can try increasing this value using the parameter inserted in the connection string. I hope I can help you with this, regards.

Spring Data Redis using '+inf' to specify unlimited bounds of ZSetOperations.rangeByScore

Using the Redis CLI you can query a sorted set by range with an unlimited upper bound:
zrangebyscore my_key 0 +inf
Represented by the +inf as well as an unlimited lower bound: -inf. This retrieves the range from 0 to the last member.
Spring Data Redis provides an interface to this Redis command through this method signature:
Set<V> rangeByScore(K key, double min, double max, long offset, long count);
and
Set<V> rangeByScore(K key, double min, double max);
These only allow you to supply a double as the bounds.
How do you specify +inf or -inf to the bounds of ZRANGEBYSCORE using Spring Data Redis ?
The only mention of it is in the changelog so it's supported in some way but I can't find any mention of it elsewhere.
Maybe you could use Double.NEGATIVE_INFINITY and Double.POSITIVE_INFINITY to represent -inf and +inf, I've tested on my machine, which works well(with spring-boot-starter-data-redis version=2.2.4.RELEASE)
(They are both double values)
In more recent versions you can specify the range with Bound.unbounded().
Flux<V> rangeByScore(K key, Range<Double> range, Limit limit)
For example:
Range.of(Bound.inclusive(start), Bound.unbounded())
See Range class for other factory methods like leftUnbounded / rightUnbounded.
I used this with a redis version below 6.2. With 6.2+ the zrange semantics changed.

What is the difference between var map=HashMap<Int,String>() and var map=HashMap<Int,String>(n)?

Consider n is any integer with any particular value in the range of Int data type. so What is the difference between var map=HashMap<Int,String>() and var map=HashMap<Int,String>(n) ?
The HashMap(n) overload accepts the initial capacity, which is used to initialize the HashMap with the provided capacity instead of the default one (which is rather small to reduce memory usage, 16 in JDK 8).
Use it when you know how many items you are going to put into the map, at least approximately, because it allows you to avoid overhead of re-allocating the map and re-hashing the keys as you put entries into it

Erlang binary protocol serialization

I'm currently using Erlang for a big project but i have a question regarding a proper proceeding.
I receive bytes over a tcp socket. The bytes are according to a fixed protocol, the sender is a pyton client. The python client uses class inheritance to create bytes from the objects.
Now i would like to (in Erlang) take the bytes and convert these to their equivelant messages, they all have a common message header.
How can i do this as generic as possible in Erlang?
Kind Regards,
Me
Pattern matching/binary header consumption using Erlang's binary syntax. But you will need to know either exactly what bytes or bits your are expecting to receive, or the field sizes in bytes or bits.
For example, let's say that you are expecting a string of bytes that will either begin with the equivalent of the ASCII strings "PUSH" or "PULL", followed by some other data you will place somewhere. You can create a function head that matches those, and captures the rest to pass on to a function that does "push()" or "pull()" based on the byte header:
operation_type(<<"PUSH", Rest/binary>>) -> push(Rest);
operation_type(<<"PULL", Rest/binary>>) -> pull(Rest).
The bytes after the first four will now be in Rest, leaving you free to interpret whatever subsequent headers or data remain in turn. You could also match on the whole binary:
operation_type(Bin = <<"PUSH", _/binary>>) -> push(Bin);
operation_type(Bin = <<"PULL", _/binary>>) -> pull(Bin).
In this case the "_" variable works like it always does -- you're just checking for the lead, essentially peeking the buffer and passing the whole thing on based on the initial contents.
You could also skip around in it. Say you knew you were going to receive a binary with 4 bytes of fluff at the front, 6 bytes of type data, and then the rest you want to pass on:
filter_thingy(<<_:4/binary, Type:6/binary, Rest/binary>>) ->
% Do stuff with Rest based on Type...
It becomes very natural to split binaries in function headers (whether the data equates to character strings or not), letting the "Rest" fall through to appropriate functions as you go along. If you are receiving Python pickle data or something similar, you would want to write the parsing routine in a recursive way, so that the conclusion of each data type returns you to the top to determine the next type, with an accumulated tree that represents the data read so far.
I only covered 8-bit bytes above, but there is also a pure bitstring syntax, which lets you go as far into the weeds with bits and bytes as you need with the same ease of syntax. Matching is a real lifesaver here.
Hopefully this informed more than confused. Binary syntax in Erlang makes this the most pleasant binary parsing environment in a general programming language I've yet encountered.
http://www.erlang.org/doc/programming_examples/bit_syntax.html

Do Arrays take up space even without values in them in .net?

I have a program in VB.net that uses a 3D array:
Private gridList(10, 900, 900) As GridElement
Now, I just used a Memory Profiler on it (because my application is having some major leak issues or something) and apparently, this array (containing at the moment of testing 0-30 elements at one time) is using 94% of the memory currently in use by my application. Even when it is empty it takes up huge amounts of memory.
My only assumption is that even empty arrays take up space! This puts a major blow into my plans!
My Question:
Is there any alternative to this that allows me to still have the same abilities to map
i.g. I've been using it like this:
Dim cGE as GridElement = gridList(3, 5, 7)
but doesn't hog up so much memory for things that aren't using memory?
Thanks!
Do Arrays take up space even without values in them in .net?
No. But your array has values in it. And hence takes up space.
To avoid keeping a lot of elements in memory when you only access a few of all the possible elements, you need to use a so-called sparse array. In .NET, this is easiest implemented via a Dictionary, where the key in your case would be a three-element structure*, and the value would be a GridElement.
* If you’re using an up-to-date version of .NET, then you can model this via a Tuple(Of Integer, Integer, Integer)