Should I create multiple hiredis objects? - redis

I am using Hiredis in C++ project and it works well.
One thing I still haven't figured out is:
I need to use hiredis in multiple classes, should I create Redis object in all classes? Will it cause any problem?
Redis m_redis;

Related

Rankfile for MPICH

I'm interested in the issue related to the MPICH. I know that OpenMPI allows you to run programs using Rankfile. The Rankfile contains information about which node/socket/core the specific rank of the MPI process will be bound to.
Is there the same or similar possibility in MPICH? I mean, every MPI process has to be bound to the core, which I select myself and write in the file.
Thank you!

What is a good workflow for developing Julia modules with IPython/Jupyter?

I find myself frequently developing new Julia modules while at the same time using those modules for my work. So I'll have an IPython (Jupyter) notebook, with something like:
using DataFrames
using MyModule
Then I'll do something like:
x = myfunction(7, 3)
But I'll have to modify that function, and unfortunately by that point I can't simply do
using MyModule
again. I'm not really sure why; I thought that calling using simply declares available modules in order to make the global scope aware of them, and then when a name is actually needed, the runtime searches for the definition among the currently loaded modules (starting with Main).
So shouldn't using MyModule simply just refresh the definitions of the items in the already declared module? Why do I have to completely stop and restart the kernel in order to use my updated functions? (Is it because names are bound only once to functions that are declared using the function keyword?)
I've looked at Julia Workflow Tips, but I don't find the whole Tmp, tst.jl system very simple or elegant... at least for a notebook.
Any suggestions?
I think there's a lot of truth in this statement attributed to one of the Juno developers: Jupyter notebook is for working with data. Juno IDE is for working with code.
Jupyter is great for using modules in a notebook style that the output you're getting is reproducible. Juno and the REPL have less overhead that let you keep starting new sessions (faster testing, and fixes the problem you noted), have multiple tabs open to follow code around a complex module, and can use the debugger (in v0.5). They address different development issues for difference stages of use. I think you're pushing against the tide if you're using the wrong tool for the wrong job.

How Python interact with JVM inside Spark

I am writing Python code to develop some Spark applications. I am really curious how Python interact with running JVM and started reading the source code of Spark.
I can see that in the end, all the Spark transformations/actions ended up be calling certain jvm methods in the following way.
self._jvm.java.util.ArrayList(),
self._jvm.PythonAccumulatorParam(host, port))
self._jvm.org.apache.spark.util.Utils.getLocalDir(self._jsc.sc().conf())
self._jvm.org.apache.spark.util.Utils.createTempDir(local_dir, "pyspark") \
.getAbsolutePath()
...
As a Python programmer, I am really curious what is going on with this _jvm object. However, I have briefly read all the source code under pyspark and only found _jvm to be an attribute of Context class, beyond that, I know nothing about neither _jvm's attributes nor methods.
Can anyone help me understand how pyspark translate into JVM operations? should I read some scala code and see if _jvm is defined there?
It uses py4j. There is a special protocol to translate python calls into JVM calls. All of this you can find in Pyspark code, see java_gateway.py

objective c check if java installed

I am new to OS x programming , I am looking for the best way to check if Java is installed on Current machine.
The only thing that is coming to my mind is to run NSTask and read stdout ... but I am pretty sure that there is better way to do it. Thanks.
well I think you probably have lots of options, but the most reliable would be to write a java program that outputs in JSON or XML or whatever, all of the requirements that you need in your jvm (like version if some module can be loaded etc) then fire it up with NSTask... if you want to check in your own process you could just check for the existence of files... which wouldn't be AS reliable as it wouldn't gauranteed that the clients java actually works.. but it is going to be 90+% reliable.

how to fork JVM? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Java - C-Like Fork?
I wanted to know how is it possible to fork a child JVM from a JDK or even is it possible to do so?
Some frameworks like hadoop fork a child JVM for specific tasks thus Please throw some light on the subject.
Thanks!
Fork is commonly confused with spawn.
Spawn is fork + exec (which means start a process
which replaces the current one and inherits some of
its external resources, such as open sockets).
Spawn is available in Java (via System.exec and the like).
Fork is not in Java, because it would be extremely problematic.
Fork requires cloning of the address space.
The kernel support to do this efficiently is not available
in most non-Unix OSes; e.g. U/win and Cygwin have struggled
to emulate fork under Win32.
In a language such as Java, the garbage collector
& JIT compilers would tend to touch Vmem pages such
that the space would not long remain shared after fork.
Cloning has many side effects.
E.g., input or outputs buffers will be processed in all
of the forked children. SysV shared memory will be detached.
Most languages and many libraries simply refuse to
support forking. This includes the (POSIX) threading API ;
The child is not allowed to use threads until it execs
(i.e., becomes a spawn) !
Perl uses fork because its internals are extremely close to C/Unix,
and its multithreading is abysmal.
Unix shell uses fork by design, which is how it snapshots
all local variables and state. That's also why there is no
decent Unix shell for a non-Unix environment.
In general, I don't believe this is possible in the sense you mean. You can System.exec() to spin off a new process, and can call a new JVM that way. Note that you can certainly call fork() directly from native code, but in the words of a poster here, "Don't. Just don't."