ndnSIM : content store - c++

which method to add data in content store in forwarding strategy ndnSIM ?
i have tried to use cs::Cs::insert(data); after beforeSatisfiedInterest unfortunately I have no result

You can't actually manually add data on the default NDNsim. The content store is setup to only accept data that satisfies an interest in the "Pending Interest Table".
For manually entering data to a CS, you'd need to make changes to NDNsim with something like this discussed on the mailing list.

Related

Update list of data in a custom way

I have a scenario and want to know the best possible way to handle it.
I have a user who has n number of addresses.
addressList (id) for example (which I get at frontend) -
addresses=[1,2,3,4]
Once I fetch all the addresses to the frontend, the user can delete one or n number of addresses.
Note - The delete is only removing the address object from the list
(at frontend) and not permanently delete it from the database.
so here, addressList now can be -
addresses=[1,4]
Also, the users add n number of new addresses
the new addressList may be -
addresses=[1,4, {newAddressDetail}, {newAddressDetail}]
Now this updated data (addresses) is sent over to the backend for the update process.
Would like to know how to handle this scenario best at the backend?
Things are -
delete all the previously saved addresses which are not received currently.
Not to alter the previously saved addresses which are received currently.
create new addresses which are not in the database.
It is not advised to delete an address from the database when the user removes it from the frontend. The address is not editable at the frontend and the data which I have shown here is only for the explanation purpose and are not correct technically.
Can provide more details if required.
I think your best bet is to use sets in python.
So in your backend something like:
new = set(addresses_from_frontend)
old = set(user.addresses.all())
Address.objects.bulk_create([Address(**item) for item in old - new])
Address.objects.filter(id__in=[a.id for a in new - old]).delete()
Its not gonna look exactly like this, you are probably gonna have to use the address ids to get the addresses before deleting them and so forth. But the main point is that sets are an efficient way of doing this bulk_create() and delete() using a filter can also help you get your db queries down.

Update multiple field values matching a condition in InfluxDB

In an InfluxDB measurement, how can the field values of points matching a query be updated? Is this still not easily doable as of v1.6?
As the example in that GitHub ticket suggested, what's the cleanest way of achieving something like this?
UPDATE access_log SET username='something' WHERE mac='xxx'
Anything better than driving it all from the client by updating individual points?
Q: How can the field values of points matching a query be updated? Is this still not easily doable as of v1.4?
A: From the best of my knowledge, there isn't an easy way to accomplish update in version 1.4 yet.
Field value of a point can only be updated by overriding. That is, to overwrite its value you'll need to know the details of your points. These details include its timestamp and series information, which is the measurement it reside and its corresponding tags.
Note: This "update" strategy can only be used for changing the field value but not tag value. To update a tag value you'll need to first DELETE the point data first and rewrite the entire point data with the updated tag and value.
Q: Anything better than driving it all from the client by updating individual points?
A: Influxdb supports multi-point write. So if you can build a filter to pre-select a small dataset of points, modify their field values and then override them in bulk.
Update is possible and would take the format:
INSERT measurement,tag_name=tag_value_no_quotes value_key_1=value_value_1,value_key_2=value_value_2 time
for example where I want to update the line with tag my_box at time 1526988768877018669 on the box measurement:
INSERT box,box_name=my_box item_1='apple',item_2='melon' 1526988768877018669

How to update the properties of CMFCPropertyGridCtrl?

I'm developing an application that binds a data model and a user interface together through MFC and I'm trying to use the CMFCPropertyGridCtrl to display and edit the data that's extracted from the data model.Then after I finish editing the properities shown on the CMFCPropertyGridCtrl, I need to move the new updated data back to the data model. When doing this, I need to check if the data in the CMFCPropertyGridCtrl is really updated before the data transfer is executed. I achieve it through checking the return value of IsModified method. But after I move data back to data model, the CMFCPropertyGridCtrl doesn't update its properties itself. So the IsModified method will never work since it just compares the current value to the initial value, not the updated value. How can I solve this problem?
CMFCPropertyGridCtrl::OnPropertyChanged is designed to track a change in a property and to reflect the Change to your system. This virtual function is called by CMFCPropertyGridProperty::OnUpdateValue.
Because m_bModified is discussed here to here some words about it, because it causes sometimes confusion:
m_bModified is cleared by the function CMFCPropertyGridProperty::ResetOriginalValue! In this case m_varValueOrig is set back to the property. The original value may changed by SetOriginalValue.
So the only good position to check and track changes is CMFCPropertyGridCtrl::OnPropertyChanged. If a property is changed, IsModified is true. But this only compared to the original value...
If you're updating value and want to see your modifications in bold text, then it makes sense to use CMFCPropertyGridProperty::SetValue and CMFCPropertyGridProperty::SetOriginalValue in initialization phase.
But next time you want to get your value to be updated use CMFCPropertyGridProperty::SetValue and then call manually to CMFCPropertyGridCtrl::OnPropertyChanged( pointer to your property )
That function will call protected SetModifiedFlag() function, which in a turn will update protected m_bIsModified to have correct value.

List updating when shouldnt?

I am using a static class in my application. It basically uses an access database, and copies itself to various lists.
When the user modifies some data, the data is updates in the list, using LINQ, if there is no entry in the list for the modification then it will add a new item to the list.
This all works fine.
However on the 1st data interrogation, I create the original list, basically all records in the users table, so I have a list lstDATABASERECORDS.
What I do after populating this list I do lstDATABASERECORDSCOMPARISON=lstDATABASERECORDS
this enables me to quickly check whether to use an update or append query.
However when I add to lstDATABASERECORDS a record is added in lstDATABASERECORDSCOMPARISON too.
Can anyone advise?
You are assigning two variables to refer to the same instance of a list. Instead, you may want to try generating a clone of your list to keep for deltas (ICloneable is unfortunately not that useful without additional work to define cloneable semantics for your objects), or use objects that implement IEditableObject and probably INotifyPropertyChanged for change tracking (there's a few options there, including rolling your own).
There's nothing built in to the framework (until EF) that replicates the old ADO recordset capability to auto-magically generate update queries that only attempt to modify changed columns.

Lightswitch choice list

When we configure a field as a choice list and set up some initial values, where are they stored? I understand we could configure them as a dynamic list by using a separate table. I am trying to understand what happens with the static list.
Thanks.
Choice list data gets stored in the lsml file, which is why it's only a reasonable option for very static data.
To add/delete values, the developer has to make the change & redeploy the entire applictaion.
Does that help with what you were wanting to knmow?