RocketMQ supports filter by tag, where I dig into the source code of the Broker. It seems the broker do the following comparison:
subscriptionData.getCodeSet().contains(tagsCode.intValue()); in org.apache.rocketmq.broker.filter.ExpressionMessageFilter#isMatchedByConsumeQueue.
So i wonder if there is any chance two tags has the same hash code, and if that happens, some msg will not be filtered? I can't find any code comparing the actual tag String in Broker, am i missing something?
P.S.: my RocketMQ version is: 4.2.0-incubating-SNAPSHOT
The hashcode of an int is itself (source), so the hashcode of tagsCode.intValue() is itself. So as long as each code has a unique int value in the first place, there will be no hashcode collision.
Related
I've recently encountered all sorts of wrappers in Google's protobuf package. I'm struggling to imagine the use case. Can anyone shed the light: what problem were these intended to solve?
Here's one of the documentation links: https://developers.google.com/protocol-buffers/docs/reference/csharp/class/google/protobuf/well-known-types/string-value (it says nothing about what can this be used for).
One thing that will be different in behavior between this, and simple string type is that this field will be written less efficiently (a couple extra bytes, plus a redundant memory allocation). For other wrappers, the story is even worse, since the repeated variants of those fields will be written inefficiently (official Google's Protobuf serializer doesn't support packed encoding for non-numeric types).
Neither seems to be desirable. So, what's this all about?
There's a few reasons, mostly to do with where these are used - see struct.proto.
StringValue can be null, string often can't be in a language interfacing with protobufs. e.g. in Go strings are always set; the "zero value" for a string is "", the empty string, so it's impossible to distinguish between "this value is intentionally set to empty string" and "there was no value present". StringValue can be null and so solves this problem. It's especially important when they're used in a StructValue, which may represent arbitrary JSON: to do so it needs to distinguish between a JSON key which was set to empty string (StringValue with an empty string) or a JSON key which wasn't set at all (null StringValue).
Also if you look at struct.proto, you'll see that these aren't fully fledged message types in the proto - they're all generated from message Value, which has a oneof kind { number_value, string_value, bool_value... etc. By using a oneof struct.proto can represent a variety of different values in one field. Again this makes sense considering what struct.proto is designed to handle - arbitrary JSON - you don't know what type of value a given JSON key has ahead of time.
In addition to George's answer, you can't use a Protobuf primitive as the parameter or return value of a gRPC procedure.
I want to filter out the element of an RDD following a string value as in:
est_rdd = est_rdd.filter(lambda kv: kv[0] !=name_to_filter )
However, I see the filtered element is still in est_rdd. In that case I need to repartition for the next step to clear. But it is a time-consuming operation. How should I avoid repartitioning? Any help?
Spark has been tested carefully so I would discard the possibility of Spark not doing its job.
Check that the expected string name_to_filter matches exactly with the string in the key. Sometimes there are subtle differences that you ignore
I asked this question in the Storm user group and haven't gotten a response yet, so I decided to ask it here. I've found the code, and many references to how the the taskIndex is calculated but when I try using the following I don't get the same result as my Storm topology. I've also seen more than one posting where others report the same.
Here's the question:
Hello,
I’ve tried to use the information below to generate the hash, mod it, and in turn, calculate the correct consuming destination task index, but without success. I’ve scoured the Internet to find an example of a hand calculation of this nature and have turned up empty. I must be missing something in my hand calc, so I’m hoping someone on the list can help me out.
I have field grouped as follows:
.fieldsGrouping(EXAMPLE_BOLT, EXAMPLE_BOLT_STREAM, new Fields(TopologyConstants.EXAMPLE_FIELD_GROUPING_ID))
My EXAMPLE_BOLT emits as shown here:
collector.emit(TopologyConstants.EXAMPLE_BOLT_STREAM, new Values(EXAMPLE_FIELD_GROUPING_ID_VALUE, EXAMPLE_DATA_INSTANCE));
I perform the calculation as follows:
int numberOfConsumingTasks = x;
Integer EXAMPLE_FIELD_GROUPING_ID_VALUE = y;
ArrayList alist = new ArrayList();
alist.add(EXAMPLE_FIELD_GROUPING_ID_VALUE);
int hashCode = Arrays.deepHashCode(alist.toArray());
int targetTaskIndex = Math.abs(hashCode) % numberOfConsumingTasks;
The resulting targetTaskIndex value from this calculation does not match the value produced by Storm, when I use real values from my topology.
Can someone tell me what I’m doing wrong?
Thanks,
Aubrey
Freeswitch events contain two variables (Unique-ID and Channel-Call-UUID) that seem to always be set to the exact same value: the leg's unique identifier.
I don't see the purpose of this and while Unique-ID has a one-line documentation on FS's wiki ("uuid of this channel's call leg"), Channel-Call-UUID doesn't.
Even worse: I came accross two examples where their values were different:
[...]
Channel-Call-UUID: c9bbde8b-379b-45d4-b193-3f761a44f3e2
Unique-ID: 81273088-c31f-4469-85a6-c878e42210e5
[...]
[...]
Channel-Call-UUID: ada7f3de-2374-4144-9b1d-eade29df0779
Unique-ID: f3ebca6c-d9cd-4f89-ae12-748e6c479dda
[...]
I need to be able to clearly identify a leg in my code, so I'd like to know
which one is the most accurate and
what's the purpose of the other one
"Unique-ID" identifies the leg of the current channel (this value seems to always be identical to "Caller-Unique-ID", documented as "This channel's uuid").
"Channel-Call-UUID" is an ID that can be used to identify answered/bridged channels. It seems to be derived from the "Unique-ID" of the channel's creator.
The value of "Channel-Call-UUID" of the b-leg (the callee) differs from its "Unique-ID", but it is identical to the value of the "Other-Leg-Unique-ID" header.
The source code (src/switch_channel.c) supports my previous claims:
if ((v = switch_channel_get_variable(channel, "call_uuid"))) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Call-UUID", v);
} else {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Call-UUID", switch_core_session_get_uuid(channel->session));
}
I have a list of objects that are returned as a sequence, I would like to retrieve the keys of each object so as to be able to display the object correctly. At the moment I try data?first?keys which seems to get something like the queries that return the objects (Not sure how to explain that last sentence either but img below shows what I'm trying to explain).
The objects amount of objects returned are correct (7) but displaying the keys for each object is my aim. The macro that attempts this is here (from the apache ofbiz development book chapter 8).
Seems like it my sequence is a list of hashes and as explained by Daniel Dekany this post:
The original problem is that, someHash[key] expects a
string as key. Because, the hash type of FTL, by definition, maps
string keys to arbitrary values. It's not the same as Java's Map.
(Note that to further complicate the matters, in FTL
someSequenceOrString[index] expects an integer index. So, the [] thing
is used for that too.) Now someBeanWrappedMap(key) has technically
nothing to do with all the []-s, it's just a method call, so it
accepts all kind of keys. If you have a Map with non-string keys, you
must use that.
Thanks D Dekany if you're on stack, this ended my half day frustration with the ftl template.