MPI derived datatypes - mpi

I want to create derived datatype consists of dynamic arrays, which lengths I don't know, how can I do this? It will be great, if smb post here a simple example. Thanks.

I posted an answer to a similar question here. In short:
You'll need a HIndexed datatype.
You'll have to use the MPI_Address() function to get the proper displacements.
You'll have to make sure that the typemap remains valid (i.e. the arrays don't change size or relative position to the other data members), and if it becomes invalid, redefeine and recommit the datatype.

Related

What is the use case of merge vs mergeFields

Can anyone actually explain, in layman's terms, what is a real-world use case for the set operation's options?
While I fully understand what set with merge does, as well as merge beeing a boolean and mergeFields being an array of fieldPaths, I cannot think of cases in which mergeFields might be of any use.
I also understand the fact that mergeFields basically acts like a mask for the object passed to the set operation, but I still cannot think of how is it so useful that it actually got implemented within the SDK.
Can someone shed some light?
After looking through the documentation, there seem to be two reasons why you might want to use one vs the other:
mergeFieldPaths/mergeFields trigger an error when passing in field values that don't currently exist on the document while merge will add in those fields if they don't exist. The error is good for safety purposes if you're concerned about typos/writing to incorrect field paths.
This one is just a guess, but the documentation indicates mergeFieldPaths/mergeFields ignores AND leaves fields untouched while merge ONLY leaves other fields untouched. It's possible there's some performance advantage to using mergeFieldPaths/mergeFields esp for documents with a ton of fields. The difference might be direct access vs still needing to look at unspecified fields to identify the matches in some way.
SetOptions Reference

PL/SQL Reflection Set Attribute Values

Here the link whose answer is the opposite to I want: Reflection in PLSQL?
I want to do the opposite operation to that Jon Heller wrote in the link above. I mean, I want to set attributes of an object dynamically not manually (because my user-defined type object has 130 attributes and in my opinion, filling out some many attributes manually is not best practice and not generic programming. Does anybody know how we can accomplish that?

Drupal 7: How can I create a key/value field(or field group, if that's even possible)?

Let's say I'm creating some app documentation. In creating a content type for functions, I have a text field for name, a box for a general description, and a couple other basic things. Now I need something for storing arguments to the function. Ideally, I'd like to input these as key-value pairs, or just two related fields, which can then be repeated as many times as needed for the given function. But I can't find any way to accomplish this.
The closest I've gotten is an abandonded field multigroup module that says to wait for CCK3, which hasn't even produced an alpha yet as far as I can tell and whose project page makes no obvious mention of this multi-group functionality. I also checked the CCK issue queue and don't think I saw it in there, either.
Is there a current viable way of doing this I'm not seeing? Viable includes "you're thinking of this the wrong way and do X instead." I've considered using a "Long text and summary" field, but that smells hackish and I don't know if I'd be setting myself up for side-effects. I'm new to Drupal.
There is the http://drupal.org/project/field_collection module but it's not yet ready. Right now you would need to implement your entity alas to do this :( not easy.
Not sure how well it would work, because it currently does a bit more (eg, forces to group pairs into categories and the keys need to be predefined) but you might want to have a look at http://drupal.org/project/properties.
You could create a these key-value fields on their own: create 2 regular fields that that can be added as often as needed.
So you have a x fields for the keys and x for the values. If this is only for you or other people it might work OK but usability wise, it's very ugly.
If you need to extract the fields from the function, to display it properly in a page template, you should propably use a different approach. Write the function with its arguemnts in a CCK field and in the template extract them as needed. The arguments are always (depending on language) in () and the different arguments are seperated by , so splitting them would by pretty easy.

Blackberry data binding?

I think I already know the answer, but does BB (5.0 or earlier) have any support data binding to fields?
For example, if I have a vector of items, could I bind that to a list (or some field) that will get auto-updated when new data is placed into the vector?
I'm thinking that is something I'd have to write with the ListFieldCallback or it's equivalent in other fields.
Thanks
You could implement this using a homemade observer. (http://en.wikipedia.org/wiki/Observer_pattern) You could use a custom vector which was aware of the observer if you wanted to. I've done this before and it works.
Unfortunatelly such funcionality is not available right out of the box.
As a starting point to ListField implementaion on BB, take a look at Simple ListField example by peter_strange.

How can I determine the position of an XML instance in an XMLList in ActionScript3?

What it says on the tin: I have an XMLList, and I want to find where in it a particular XML item falls. First index is good enough for my purposes.
Note that I have no problem writing a function to do this by hand... but I was hoping that the API has something buried somewhere that'll do it for me. I didn't see it, though.
Just loop through the xmllist until you find one that matches, then return the index in your loop (for loop with an index).
Without a code example it's a bit difficult to know what you're trying to do exactly, but maybe XML.childIndex() could the solution?

Resources