Sphinx sql_query_killlist on a distributed remote index - sphinx

The sphinx documentation says that sql_query_killlist can be used with a distributed remote index:
Note that in the distributed index setup, K-lists are local to every node in the cluster. They are not get transmitted over the network when sending queries. (Because that might be too much of an impact when the K-list is huge.) You will need to setup a separate per-server K-lists in that case.
I can get sql_query_killlist working with a distributed "local" index that looks like this:
index mydistributedindex
{
type = distributed
local = main_index
local = delta_index
}
The sql_query_killlist sits on the source of the delta_index and it works.
I tried to change mydistributedindex above setting these all as "remote agents" pointing to localhost. The querys still work, but the sql_query_killlist no longer works:
index mydistributedindex
{
type = distributed
agent = localhost:9312:main_index
agent = localhost:9312:delta_index
}
If i want mydistributedindex to span accross multiple remote agents, I cannot find an example where sql_query_killlist will work in line with the documentation quoted above?

As shown here by barryhunter this will work:
index mydistributedindex
{
type = distributed
agent = localhost:9312:server1index
}
index server1index
{
type = distributed
local = main_index
local = delta_index
}

Related

Is there a way to train a PPOTrainer on one environment, then finish training it on a slightly modified environment?

I'm attempting to first train a PPOTrainer for 250 iterations on a simple environment, and then finish training it on a modified environment. (The only difference between the environments would be a change in one of the environment configuration parameters).
So far I have tried implementing the following:
ray.init()
config = ppo.DEFAULT_CONFIG.copy()
config["env_config"] = defaultconfig
trainer = ppo.PPOTrainer(config=config, env=qsd.QSDEnv)
trainer.config['env_config']['meas_quant']=1
for i in range(250):
result = trainer.train()
#attempt to change the parameter 'meas_quant' from 1 to 2
trainer.config['env_config']['meas_quant'] = 2
trainer.workers.local_worker().env.meas_quant = 2
for i in range(250):
result = trainer.train()
However, the second training still uses the initial environment configuration. Any help in figuring out how to fix this would be greatly appreciated!
I'd suggest one of two approaches
Create a new Trainer instance and restore from the first
ray.init()
env_config["meas_quant"] = 1 # Assuming env_config is set
config = {"env_config": env_config}
trainer = ppo.PPOTrainer(config=config, env=qsd.QSDEnv)
for i in range(250):
result = trainer.train()
checkpoint = trainer.save_to_object()
env_config['meas_quant'] = 2
config["env_config"] = env_config
trainer2 = ppo.PPOTrainer(config=config, env=qsd.QSDEnv)
trainer2.restore_from_object(checkpoint)
# Do whathever is needed ...
Alter the environment directly for each worker
May require modifying the environment to set the parameter you're looking to change.
# After the first training loop
trainer.workers.foreach_worker(
lambda w: w.foreach_env(lambda e: e.meas_quant = 2)
)
# Do your stuff ...
As an aside, I would avoid using DEFAULT_CONFIG.copy since it only creates a shallow copy of the dictionary, so changes to nested configuration dicts could alter the original default configuration. Plus, RLlib's Trainer already deepmerges wathever config dict you pass to it with the default configuration.

AnyLogic - is there a way to convert a Node from network.nodes() to Rectangular Node?

I am looking to dynamically add each Rectangular Node from my network to a particular collection, on simulation startup. I'm doing this because I will have 1000+ nodes and adding them manually is undesirable.
Each of these nodes is named using a convention and start with either "lane" or "grid".
If it is "lane" then it adds to one collection, and "grid" to the other.
Currently I am using the code:
for (Node n : network.nodes()) {
String layoutIdentifier = n.getName().split("_")[0];
if (layoutIdentifier.equals("lane")) {
laneNodes.add(n);
traceln(n);
//Lane newLane = add_lanes(n);
} else if (layoutIdentifier.equals("grid")) {
gridNodes.add(n);
}
}
This is working fine and adds them to the collections as Nodes, but I was really wanting to add them to collections of Rectangular Nodes (which is what they are) as I need to use this type in my Agents.
I tried this code (changing Node to RectangularNode):
for (RectangularNode n : network.nodes()) {
String layoutIdentifier = n.getName().split("_")[0];
if (layoutIdentifier.equals("lane")) {
laneNodes.add(n);
traceln(n);
//Lane newLane = add_lanes(n);
} else if (layoutIdentifier.equals("grid")) {
gridNodes.add(n);
}
}
but get the error
Type mismatch: cannot convert from element type Node to RectangularNode. Location: pbl_congestion_simulation/Main - Agent Type
Is there a way to convert the Node to RectangularNode? Or a better way to run through all the nodes in the network and add them as Rectangular nodes to collections of the same?
I can see that the Nodes are referenced as com.anylogic.engine.markup.RectangularNode#293cc7d0 so was hoping that RectangularNode portion could be accessed.
many thanks.
Your first code is fine, you can have a collection with elements of type RectangularNode and the only thing you need to change on that code is:
laneNodes.add((RectangularNode)n);
gridNodes.add((RectangularNode)n);
You can transform a node into a rectangular node, but not the other way around, that's why your second code doesn't work.
If you have other nodes on the network, that are not rectangular nodes, then you can add something like this:
if(n.getClass().equals(RectangularNode.class))
laneNodes.add((RectangularNode)n);

find_one() finds duplicates that are not there

I am trying to copy a remote mongodb atlas server to a local one. I do this by a python script which also checks if the record is already there. I see that eventhough the local database is empty my script find duplicates, which are not in the remote mongodb atlas (at least i cannot find them). I am not so experienced with mongodb and pymongo but I connot see what I am doing wrong. Sometimes Find_one() finds exactly the same record as before (all the fields are the same even the _id) ?
I removed the collection completely from my local server and tried again, but still the same result.
UserscollectionRemote = dbRemote['users']
UserscollectionNew = dbNew['users']
LogcollectionRemote = dbRemote['events']
LogcollectionNew = dbNew['events']
UsersOrg = UserscollectionRemote.find()
for document in UsersOrg: # loop over all users
print(document)
if UserscollectionNew.find_one({'owner_id': document["owner_id"]}) is None: # check if already there
UserscollectionNew.insert_one(document)
UserlogsOrg = LogcollectionRemote.find({'owner_id': document["owner_id"]}) # get all logs from this user
for doc in UserlogsOrg:
try:
if LogcollectionNew.find_one({'date': doc["date"]}) is None: # there was no entry yet with this date
LogcollectionNew.insert_one(doc)
else:
print("duplicate");
print (doc);
except:
print("an error occured finding the document");
print(doc);
You have the second for loop inside the first; that could be trouble.
On a separate note, you should investigate mongodump and mongorestore for copying collections; unless you need to be doing it in code, these tools are better suited for your use case.

How to make Windows' Bonjour resolve foo.bar.local subdomains created by Avahi

Why can't Windows' Bonjour (the Apple one) automatically resolve foo.bar.local, when Ubuntu and macOS can?
foo.local instead is resolved without issues by every OS.
Here's my avahi-daemon.conf:
[server]
host-name=foo
domain-name=bar.local
...
This discussion mentions that Windows' Bonjour implementation does not support aliases, is this the culprit?
How does this tool differ from my solution?
EDIT: I don't want to set an alias. foo.bar.local is different from bar.local.
I just want to have different hostnames under the same "domain".
For example, foo.bar.local is 192.168.0.8 while foo1.bar.local is 192.168.0.9.
I won't have foo.local, bar.local and foo.bar.local all in the same network. I will use foo.bar.local, with only foo varying (*.bar.local)
From my current findings, this seems to be intentional. Excerpt from the source code (mDNSResponder-878.30.4, function NSPLookupServiceBegin in mdnsNSP.c):
// <rdar://problem/4050633>
// Don't resolve multi-label name
// <rdar://problem/5914160> Eliminate use of GetNextLabel in mdnsNSP
// Add checks for GetNextLabel returning NULL, individual labels being greater than
// 64 bytes, and the number of labels being greater than MAX_LABELS
replyDomain = translated;
while (replyDomain && *replyDomain && labels < MAX_LABELS)
{
label[labels++] = replyDomain;
replyDomain = GetNextLabel(replyDomain, text);
}
require_action( labels == 2, exit, err = WSASERVICE_NOT_FOUND );
It returns an error if the name has more than two labels, as in the case of foo.bar.local.
In my tests, I just removed the last line. With the new build, it resolved names with multiple labels successfully. I did not yet encounter any side-effects so far.
Has anybody an idea about the intention behind not resolving multi-label names?

Unexpected results when star enabled

I have an index that looks like this:
index user_core
{
source = user_core_0
path = ...
charset-type = utf-8
min_infix_length = 3
enable_star = 1
}
We escape and wrap all of our searches in asterisks. Every so often, we'll come across a
very strange case in which something such as the following happens:
Search: mocuddles
Results: All users with nicknames containing "yellowstone".
This behavior seems unpredictable, but will happen every time on terms it does effect.
I've been told that there's no real way to debug Sphinx indexes. Is this true? Is there
any sort of "explain query" functionality?
I've confirmed at this point that these are instances of CRC32 hash collisions. Bummer.