under-the-hood | 📚 Go : Under The Hood | Go 语言原本
kandi X-RAY | under-the-hood Summary
kandi X-RAY | under-the-hood Summary
Go: Under The Hood | Go 语言原本 |
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of under-the-hood
under-the-hood Key Features
under-the-hood Examples and Code Snippets
// Add a request interceptor
axios.interceptors.request.use(function (config) {
// Do something before request is sent
return config;
}, function (error) {
// Do something with request error
return Promise.reject(error);
});
// A
def lstm_with_backend_selection(inputs, init_h, init_c, kernel,
recurrent_kernel, bias, mask, time_major,
go_backwards, sequence_lengths,
zero_output_for_
def gru_with_backend_selection(inputs, init_h, kernel, recurrent_kernel, bias,
mask, time_major, go_backwards, sequence_lengths,
zero_output_for_mask):
"""Call the GRU with optimized bac
def experimental_distribute_dataset(self, dataset, options=None):
# pylint: disable=line-too-long
"""Creates `tf.distribute.DistributedDataset` from `tf.data.Dataset`.
The returned `tf.distribute.DistributedDataset` can be iterated over
Community Discussions
Trending Discussions on under-the-hood
QUESTION
Currently we are on spring-data-elasticsearch 3.2.6 + elasticsearch 6.8. We are moving to new elasticsearch 7.x. Do I have to update spring-data-elasticsearch to 4.x? We only use ElasticsearchRepository in spring-data-elasticsearch. And we don't need to use any new feature in elasticsearch 7.x.
If we are moving to elasticsearch 8.x in the future, do I need update spring-data-elasticsearch ?
Update:
What Elasticsearch client does Spring-Data-Elasticsearch use under the hood?
All methods in the `ElasticsearchRepository` are deprecated. What should do I use?
I found some discussions in above threads. Here is my summary.
- Operations with Templates:
ElasticsearchTemplate implements ElasticSearchOperation. It uses TransportClient(which is deprecated in ES 7 and has been removed in ES8)
ElasticsearchRestTemplate implements ElasticSearchOperation. It uses high level client(which is deprecated in ES 7.16.0. It will be removed in future. @Deprecated(since = "7.16.0", forRemoval = true) )
ReactiveElasticsearchTemplate implements ReactiveElasticsearchOperations. It uses Reactive Client.
- Repository
ElasticsearchRepository uses TransportClient as default. All methods in the ElasticsearchRepository are deprecated now.
Reactive Elasticsearch repository builds on ReactiveElasticsearchOperations.
Due to underlying TransportClient or HigLevelRestClient has been deprecated, can I conclude that the correct way is to use Reactive Client(ReactiveElasticsearchTemplate or Reactive Elasticsearch repository) ?
...ANSWER
Answered 2022-Mar-24 at 16:54The new Elasticsearch would be 8.
Val already put the link to the compatibility matrix in his comment.
Version 3.2.6 is pretty outdated (March 25 2020) and out of support since October 2020.
The first thing you can try is to see if your application works with a 7 cluster - although I doubt that, I can't tell you exactly what had changed in the API, but there was quite some stuff.
What you should not do is putting newer Elasticsearch libraries on the classpath than the ones that Spring Data Elasticsearch was built with, this will in most cases make problems.
But I'd recommend to upgrade your application anyway and keep it regularly up to date.
As for future upgrade to version 8: It is possible to send a compatibility header in your requests (this can be done in Spring Data Elasticsearch 4) and the Elasticsearch cluster should respond in a format that is compatible with a client expecting version 7. I wrote should, because it does not conform to this in every case - I reported one case that is fixed now. But I wouldn't rely on that.
Again, please update your application and keep it up to date, not only because of Spring Data Elasticsearch, but also because these updates always include bug and/or security fixes.
QUESTION
I'm learning more about v8
internals as a hobby project. For this example, I'm trying to debug and understand how Javascript Map.prototype.set
actually works under-the-hood.
I'm using v8
tag 9.9.99
.
I first create a new Map
object in:
ANSWER
Answered 2022-Feb-19 at 15:14(V8 developer here.)
Many things in V8 have more than one implementation, for various reasons: in this case, there's the C++ way of adding an entry to an OrderedHashMap
(which you've found), and there's also a generated-code way of doing it. If you grep for MapPrototypeSet
, you'll find TF_BUILTIN(MapPrototypeSet, ...
in builtins-collections-gen.cc, which is the canonical implementation of Map.prototype.set
. Since that's a piece of code that runs at V8 build time to generate a "stub" which is then embedded into the binary, there's no direct way of setting a breakpoint into that stub. One way to do it is to insert a DebugBreak()
call into the stub-generating code, and recompile.
Not all builtins are implemented in the same way:
- some (like M.p.set) are generated "CSA builtins" in
src/builtins/*-gen.cc
- some are regular C++ in
src/builtins/*.cc
- some are written in Torque (
src/builtins/*.tq
) which is V8's own DSL that translates to CSA - some have fast paths directly in the compiler(s)
- some have their meat in "runtime functions" (
src/runtime/*.cc
)
Many have more than one implementation (typically a fully spec-compliant "slow" fallback, often but not always in C++, and then one or more fast paths that take shortcuts for common situations, often but not always in various forms of generated code). There are probably also a few special cases I'm forgetting right now; and as this post ages over the years, the enumeration above will become outdated (e.g. there used to be builtins in handwritten assembly, but we got rid of (almost all) of them; there used to be builtins generated by the old Crankshaft compiler, but we replaced that; there used to be builtins written in JavaScript, but we got rid of them; CSA was new at some point; Torque was new at some point; who knows what'll come next).
One consequence of all this is that questions like "how exactly does JavaScript's feature X work under the hood?" often don't have a concise answer.
Have fun with your investigation!
QUESTION
There is claim in this article that an array of ints in JavaScript is implemented by a C++ array of ints.
However; According to MDN unless you specifically use BigInts, in JavaScript all numbers are repressed as doubles.
If I do:
...ANSWER
Answered 2021-Dec-18 at 22:09(V8 developer here.)
"C++ array of ints" is a bit of a simplification, but the key idea described in that article is correct, and an array [0, 1, 2, 3]
will be stored as an array of "Smis".
What's a "Smi"? While every Number in JavaScript must behave like an IEEE754 double, V8 internally represents numbers as "small integer" (31 bits signed integer value + 1 bit tag) when it can, i.e. when the number has an integral value in the range -2**30
to 2**30-1
, to improve efficiency. Engines can generally do whatever they want under the hood, as long as things behave as if the implementation followed the spec to the letter. So when the spec (or MDN documentation) says "all Numbers are doubles", what it really means from the engine's (or an engine developer's) point of view is "all Numbers must behave as if they were doubles".
When an array contains only Smis, then the array itself keeps track of that fact, so that values loaded from such arrays know their type without having to check. This matters e.g. for a[i] + 1
, where the implementation of +
doesn't have to check whether a[i]
is a Smi when it's already known that a
is a Smi array.
When the first number that doesn't fit the Smi range is stored in the array, it'll be transitioned to an array of doubles (strictly speaking still not a "C++ array", rather a custom array on the garbage-collected heap, but it's similar to a C++ array, so that's a good way to explain it).
When the first non-Number is stored in an array, what happens depends on what state the array was in before: if it was a "Smi array", then it only needs to forget the fact that it contains only Smis. No rewriting is needed, as Smis are valid object pointers thanks to their tag bit. If the array was a "double array" before, then it does have to be rewritten, so that each element is a valid object pointer. All the doubles will be "boxed" as so-called "heap numbers" (objects on the managed heap that only wrap a double value) at this point.
In summary, I'd like to point out that in the vast majority of cases, there's no need to worry about any of these internal implementation tricks, or even be aware of them. I certainly understand your curiosity though! Also, array representations are one of the more common reasons why microbenchmarks that don't account for implementation details can easily be misleading by suggesting results that won't carry over to a larger app.
Addressing comments:
V8 does sometimes even use int16 or lower.
Nope, it does not. It may or may not start doing so in the future; though if anything does change, I'd guess that untagged int32 is more likely to be introduced than int16; also if anything does change about the implementation then of course the observable behavior would not change.
If you believe that your application would benefit from int16 storage, you can use an Int16Array
to enforce that, but be sure to measure whether that actually benefits you, because quite likely it won't, and may even decrease performance depending on what your app does with its arrays.
It may start to be a double when you make it a decimal
Slightly more accurately: there are several reasons why an array of Smis needs to be converted to an array of doubles, such as:
- storing a fractional value in it, e.g.
0.5
- storing a large value in it, e.g.
2**34
- storing
NaN
orInfinity
or-0
in it
QUESTION
How does the new Java 17 type pattern matching switch works under the hood ? As the feature is fairly new, this question doesn't talk about it.
Reminder: for this code to work under Java 17, you need to enable preview features
...ANSWER
Answered 2021-Dec-17 at 10:04What does this typeSwitch()
method do?
The invokeDynamic
instruction (upon first being hit) calls the SwitchBootstraps.typeSwitch()
method. This method then returns what method call should be executed (this is what invokedynamic
generally does).
The last argument of the SwitchBootstraps.typeSwitch()
method (the labels
parameter) is in this case the list of classes in the switch: Number.class
, Enum.class
, String.class
The SwitchBootstraps.typeSwitch()
bootstrap method checks the labels
parameter for correctness and then returns a ConstantCallSite
for the SwitchBootstraps.doTypeSwitch()
method that does the effective handling (i.e. the final execution of the invokeDynamic
instruction).
If you look at what SwitchBootstraps.doTypeSwitch()
does: it iterates over the list of classes and returns the first found match.
What's the purpose of the additional int
passed?
The additional parameter (startIndex
) is needed because of this case:
QUESTION
Consider the following code:
...ANSWER
Answered 2021-Nov-13 at 21:15You can use getEffectsMetadata
to verify dispatch is set to false
.
This method returns the config of an effect.
QUESTION
We've had great results using a K-NN search with a GiST index with gist_trgm_ops
. Pure magic. I've got other situations, with other datatypes like timestamp
where distance functions would be quite useful. If I didn't dream it, this is, or was, available through pg_catalog
. Looking around, I can't find a way to search on indexes by such properties. I think what I'm after, in this case, is AMPROP_DISTANCE_ORDERABLE
under-the-hood.
Just checked, and pg_am
did have a lot more attributes than it does now, prior to 9.6.
Is there another way to figure out what options various indexes have with a catalog search?
Catalogsjjanes' answer inspired me to look at the system information functions some more, and to spend a day in the pg_catalog tables. The catalogs for indexes and operators are complicated. The system information functions are a big help. This piece proved super useful for getting a handle on things:
https://postgrespro.com/blog/pgsql/4161264
I think the conclusion is "no, you can't readily figure out what data types and indexes support proximity searches." The relevant attribute is a property of a column in a specific index. However, it looks like nearest-neighbor searching requires a GiST index, and that there are readily-available index operator classes to add K-NN searching to a huge range of common types. Happy for corrections on these conclusions, or the details below.
Built-in Distance Supporthttps://www.postgresql.org/docs/current/gist-builtin-opclasses.html
From various bits of the docs, it sounds like there are distance (proximity, nearest neighbor, K-NN) operators for GiST indexes on a handful of built-in geometric types.
...ANSWER
Answered 2021-Nov-06 at 01:33timestamp type supports KNN with GiST indexes using the <-> operator created by the btree_gist extension.
You can check if a specific column of a specific index supports it, like this:
QUESTION
I am using an instance of the IHTMLDocument2
interface to parse some HTML as described in this post:
Load from IPersistMoniker takes long time to load unresolvable URL
The code is relatively simple:
...ANSWER
Answered 2021-Oct-21 at 17:45I used IHTMLDocument2.write
and it appears to work well.
QUESTION
As I learn new components in Kotlin, I came accross requireNotNull
and checkNotNull
but the only difference I've found is that requireNotNull
can throw an IllegalArgumentException
while checkNotNull
can throw an IllegalStateException
. Is this the only reason why there are two methods, or I'm missing some under-the-hood implementation detail?
ANSWER
Answered 2021-Jul-26 at 13:07If you're looking for differences in implementation, the best place to go would be the source code. In this case it seems like there are no differences aside from the different exception thrown, the source for both methods is otherwise identical.
checkNotNull
QUESTION
The {rlang}
documentation at help("nse-force")
gives the following:
The curly-curly operator {{ }} for function arguments is a bit special because it forces the function argument and immediately defuses it. The defused expression is substituted in place, ready to be evaluated in another context, such as the data frame.
I'm similarly confused about the 'bang-bang' operator !!
, about which the documentation is just as obtuse regarding what's going on under-the-hood.
My question isn't about how to use the operator as its usage is (I think) quite straightforward. Instead I'd like to know how such an operator is actually implemented in {rlang}
behind the scenes. According to one of the package authors, {{ foo }}
basically becomes !!rlang::enquo(foo)
. However I'm still at a loss to understand how non-standard operators like this are actually implemented, especially considering that this one seems to 'just work', regardless of whether it's being used by Actually it only works with functions underpinned by {rlang} - thanks @Konrad Rudolph for the correction.{rlang}
functions.
Looking at the source code all I can guess is that it's being done in C or C++. Can anyone give me some more information?
...ANSWER
Answered 2021-Oct-05 at 16:32However I'm still at a loss to understand how non-standard operators like this are actually implemented, especially considering that this one seems to 'just work', regardless of whether it's being used by {rlang} functions.
It doesn’t “just work” with arbitrary functions — on the contrary: functions do need to be aware of tidy evaluation. And as you probably guessed there’s no {{
operator. Instead, ‘rlang’ uses NSE to capture the unevaluated argument and then checks whether the parse tree of the expression contains two nested {
calls. It then takes the unevaluated expression and transforms it appropriately.
QUESTION
How would I get mutual friends using a GraphQL API?
I can find a lot of resources on how to do this in SQL or Cypher, but not GraphQL.
We could use Hasura in this example, or any GraphQL API.
Schema:
...ANSWER
Answered 2021-Sep-18 at 03:03Here is a sample query I believe would work...
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install under-the-hood
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page