Fastest Iterating data structure

Forgetting about the semantics about list and set, purely from iteration point of view, which data structure class would give fastest iteration?

That question is meaningless.
The only way to get an answer is to test it for yourself. And then your answer will only apply to the particular version, JVM implementer, and OS an which you run your test. And the difference between the best and the worst will be completely negligible in all but the most bizarre corner cases.
So if you're asking just for curiosity's sake, your question has been completely answered, and you are now satisfied.
If you have an actual use case where this matters, you'll need to provide details about your use case and clarify exactly what you mean by "fastest iterating".
Also note that, even if List were to iterate 1000 times faster than Set (whatever that means), if you need what Set offers and List doesn't--no duplicates--then you'll want to use Set anyway. That is, your "forget about semantics" comment is a bogus requirement.

Similar Messages

  • Iterating a key-value data structure

    Hi All,
    Is there a key->value data structure whose iterator will return the elements in the order they were added. Something like a HashMap that returns the keys in the order they were entered - if not, any other thoughts on achieving this are appreciated.
    Thank you.

    There's no such thin in J2SE,What about LinkedHashMap? No, I'm not kidding -:)D'oh! Why didn't I ever see that? Probably because I never needed it ;-) thanks for the information.

  • Looking for an efficient data structur & search algorithm

    Hi all
    i have a list of digits (international phone network prefixes) with some hundreds to some thousends entries. An entry may be in the form
    ^00[1-9]{1}[0-9]{0,7}$
    I.e. this might be 001, 0041, 00317545, 00317548, 00317549 and so on. Regarding the last three examples, it might even be that there is an additonal 0031754.
    What i need a a data structur that allows to match these prefixes against a phonenumber.
    I.e. if i have the phonennumber 001123456789 it would match the prefix 001. If i had 00317549111 it would match 00317549.
    The easiest way would be to but all prefixes into an Vector or similar and loop over all entries, trying to match the phonenumber with startsWith(). But this wouldn't always result in a absolutely perfect match, since, i.e. for the phonenumber 00317549111 the check against the prefix 0031754 would return a match even if there was a more specific match with the prefix 00317549. But more than that, this simple algorithm is not very efficient.
    So i am looking for a more efficient way/pattern to do this. I thought about a kind of tree structure, starting with 00 in the top level, than provding [1-9] in the second level, and [0-9] from third level on. Then on every node it would either store if there is a matching prefix on that level, or if there is a prefix starting with that digits on a lower level or if there is no prefix on that level or any lower.
    I.e. when i have the phonenumber 00317549111 it would start at the top level with 00. That would be ok. On the next level it would check if there is a node for digit 3. If there is, it would go one level deeper and check if there is a node for digit 1. If yes, again it would go one level deeper to check if there is a node for digit 7. If that algorithm comes to a level where, for the request digit, it get's a prefix indicator rather than a node indicator, the algortihm would know, that a matching prefix was found and that there is no more specifig match on deeper levels.
    One thing i forgot to mention - the prefixes might be read once during startup/init and there it might take some time for building up the datastructur - i don't care about that. But, when running, then the maching process should be as efficient as possible, that's the most important point for me.
    What do you think about a pattern like this? Could this be efficient? Do you see other patterns, that might be easier to implement and that might be faster/need less memory?
    Thanks a lot for your help.
    Cheers, Frank

    I would really have gone for your first approach. With mperemsky5's approach you have the loop with (potential) n iterations (Let n be the length of the number) and in each iteration to compute the hash-code for the string which again takes time proportional to the strings length.
    The tree approach takes time equal to the length of the prefix and is imho not more complicated.
    Perhaps this way:
    public class DigitTree
      private class Node {
           private Object content;
           private Node[] children = new Node[10];
      private Node root = new Node();
      public DigitTree() {
      public void addPrefix(String prefix, Object value) {
           char[] numberChars = prefix.toCharArray();
           Node node = root;
           for (int i=0; i<numberChars.length; i++) {
                int number = numberChars[i] - '0';
                if (node.children[number] == null) node.children[number] = new Node();
                node = node.children[number];
           node.content = value;
      public Object match(String phonenumber) {
           char[] numberChars = prefix.toCharArray();
           Node node = root;
           for (int i=0; i<numberChars.length; i++) {
                int number = numberChars[i] - '0';
                if (node.children[number] == null) return code.content;
                node = node.children[number];
           return node.content;
    }The method addPrefix lets you add a prefix to the tree. The content-Object can hold a String or whatever to identify the prefix. If your data is not complete (i.e. if there are numbers for which no prefix exists) you might want to initialize the content-object of a node with a default value (e.g. "not found").
    The method match lets you look up a prefix for a given number and returns the Object associated with the prefix..
    The code was not tested.
    Greetings
    Thomas

  • Lock and wait free data structures...???

    Hi - I am developing an application that requires multi-threading. We are testing this on CentOS 5, 64 BIT, running on Intel Quad Core machines, with 8 GB RAM (3 of them). I am using a III party tool to create a datagrid, and have 2 more machines in the federation to monitor performance.
    Java collections/synchronized collections has restriction on multithreading. If thread1 performs puts or removes objects in collection (Tree, Map, List, Set), thread2 cannot iterate. Thread2 can iterate only if it acquires synchronized lock on collection – this implies thread1 has to wait till iteration is over. This introduces latency. If without acquiring lock thread2 does iteration, then “concurrent modification thread exception” arises.
    For real time application like financial markets (multiple thread based application) every microsecond/millisecond matters.
    For workaround at present we have customized sun code by masking “modCount and expectedCount”. This means check for concurrent modification is disabled. But not quite sure this is correct approach. Other option was multiple buffering.
    Other option is lock and waits free data structures – which I am interested.
    Any ideas on this???
    cheers - Murali

    It depends on what is acceptable to you.
    If you are only iterating and not removing any objects through the iterator, then there are two concerns;
    1. Iterator skips some elements.
    2. Iterator iterates to non-existent elements causing NPE.
    You can also copy the datastructure. Then iterate over the copy.
    You can also do "copy on write." This causes a copy only when the datastructure is modified and those iterators already created are not affected. This is the technique I use.
    Eliminating locks is not the objective. Locking is very quick. Its the contention that you want to eliminate. COW can do this nicely in my experience. Depends on your requirements.
    P.S. Try assigning duke dollars to the question and you will probably get more viewers.

  • Bit shifting tricks and speeding up data structure

    I'm pretty new to working directly with bits, but it is a lot of fun. I'm converting a javascript data structure to Flash.
    So I'm thinking that Math.floor(uint/32) is the same as uint >> 5, right?
    And that uint % 32 is the same as uint & 31 ? Evidently this works for modulos that are powers of 2, what a cool trick.
    Using both of those cut the time needed for storing and retrieving data about in half.
    But it is still takes about three times longer that just using the native Object. This is in reference to my previous post http://forums.adobe.com/message/5001353#5001353 but that didn't get very far.
    So if anybody has any suggestions on how else to speed this up it would be very helpful:
    package {
              public class BloomFilter {
                        private var _m:uint;
                        private var _k:int;
                        private var _locations:Vector.<uint>;
                        public var _buckets:Vector.<uint>;
                        public function BloomFilter(m:uint,k:int) {
                                  _m=m;
                                  _k=k;
                                  _locations=new Vector.<uint>  ;
                                  _buckets=new Vector.<uint>  ;
                                  var n:uint=Math.ceil(m/32);
                                  var i:int=-1;
                                  while (++i<n) {
                                            _buckets[i]=0;
                        private function hash(v:String) {
                                  var i:int=-1;
                                  var X:uint;
                                  var a,b:uint;
                                  a=fnv_1a(v);
                                  b=fnv_1a_b(a);
                                  X=a%_m;
                                  while (++i<_k) {
                                            _locations[i]=X<0? (X+_m) : X;
                                            X=(X+b)%_m;
                        public function add(v:String) {
                                  hash(v);
                                  var i:int=-1;
                                  while (++i<_k) {
                                            _buckets[_locations[i]>>5]|=1<<(_locations[i]&31);
                        public function test(v:String):Boolean {
                                  hash(v);
                                  var i:int=-1;
                                  var b:uint;
                                  while (++i<_k) {
                                            b=_locations[i];
                                             if ((_buckets[b>>5] & (1 << (b&31))) === 0) {
                                                      return false;
                                  return true;
                        // Fowler-Noll-Vo hash
                        private function fnv_1a(v:String):uint {
                                  var n:int=v.length;
                                  var a:uint=2166136261;
                                  var c,d:uint;
                                  var i:int=-1;
                                  while (++i<n) {
                                            c=v.charCodeAt(i);
                                            if (d=c&0xff000000) {
                                                      a^=d>>24;
                                                      a+=(a<<1) + (a<<4) + (a<<7) + (a<<8)+ (a<<24);
                                            if (d=c&0xff0000) {
                                                      a^=d>>16;
                                                      a+=(a<<1) + (a<<4) + (a<<7) + (a<<8)+ (a<<24);
                                            if (d=c&0xff00) {
                                                      a^=d>>8;
                                                      a+=(a<<1) + (a<<4) + (a<<7) + (a<<8)+ (a<<24);
                                            a^=c&0xff;
                                            a+=(a<<1) + (a<<4) + (a<<7) + (a<<8)+ (a<<24);
                                  a+=a<<13;
                                  a^=a>>7;
                                  a+=a<<3;
                                  a^=a>>17;
                                  a+=a<<5;
                                  return a&0xffffffff;
                        // One additional iteration of FNV
                        private function fnv_1a_b(a:uint):uint {
                                  a+=(a<<1) + (a<<4) + (a<<7) + (a<<8)+ (a<<24);
                                  a+=a<<13;
                                  a^=a>>7;
                                  a+=a<<3;
                                  a^=a>>17;
                                  a+=a<<5;
                                  return a&0xffffffff;

    the math shortcuts, as mentioned above, have a greater benefit.  (and thanks.  yes, that's from a book i wrote,
    Flash Game Development: In A Social, Mobile and 3D World
    Math Class Shortcuts
    These methods actually do provide a benefit and that benefit can be significant even without needing millions of operations to realize. They are listed in alphabetical order starting with Math.abs. (See support files/Chapter 07/math_class/Math.abs_v_conditional.fla, support files/Chapter 07/math_class/Math.floor_v_int.fla etc.)
    Math.abs
    Using
    x = (y<0) ? -y: y;
    instead of
    x = Math.abs(y)
    is about twice as fast. Unless you are using millions of Math.abs operations, you should not expect a noticeable benefit from using the inline code. In addition, the inline code is cumbersome.
    var xx:int;
    var n:int = 10000000;
    var n2:int = n/2;
    var i:int;
    var startTime:int = getTimer();
    //// Math.abs duration: 1016
    for(i=0;i<n;i++){
           xx = Math.abs(n2-i);
    trace("Math.abs duration:",getTimer()-startTime);
    // conditional duration: 445
    startTime = getTimer();
    for(i=0;i<n;i++){
            xx = (n2-i<0) ? i-n2 : n2-i;
    trace("conditional duration:",getTimer()-startTime);
    Math.ceil and Math.floor
    Using
    x = int(y);
    Instead of
    x = Math.floor(y); // y>=0
    x = Math.ceil(y); // y<=0
    Is about twice as fast. Unless you are using millions of Math.floor operations (with non-negative numbers), you should not expect a noticeable benefit.
    var i:int;
    var n:int = 10000000;
    var xx:int;
    var startTime:int = getTimer();
    // Math.floor duration: 1105
    for(i=0;i<n;i++){
           xx = Math.floor(i/n);
    trace("Math.floor duration:",getTimer()-startTime);
    // int duration: 479
    startTime = getTimer();
    for(i=0;i<n;i++){
           xx = int(i/n);
    trace("int duration:",getTimer()-startTime);
    Math.max
    Using
    x = (i>j) ? i : j;
    instead of
    x = Math.max(i,j);
    is about twice as fast.
    This shortcut is also cumbersome but has the greatest benefit (along with Math.min) of all those listed in this section. Notice the difference in time required to execute the code blocks and how few iterations are needed to demonstrate that difference.
    var xx:int;
    var n:int = 1000;
    var i:int;
    var j:int;
    var startTime:int;
    // Math.max duration: 109
    startTime = getTimer();
    for(i=n-1;i>=0;i--){
           for(j=n-1;j>-0;j--){
                  xx = Math.max(i,j);
    trace("Math.max duration:",getTimer()-startTime);
    // conditional duration 43
    startTime = getTimer();
    for(i=n-1;i>=0;i--){
           for(j=n-1;j>-0;j--){
                   xx = (i>j) ? i : j;
    trace("conditional duration",getTimer()-startTime);
    Math.min
    Using
    x = (i<j) ? i : j;
    instead of
    x = Math.min(i,j);
    is about twice as fast.
    This shortcut is also cumbersome but has the greatest benefit (along with Math.max) of all those listed in this section. Notice the difference in time required to execute the code blocks and how few iterations are needed to demonstrate that difference.
    var xx:int;
    var n:int = 1000;
    var i:int;
    var j:int;
    var startTime:int;
    // Duration Math.min 121
    startTime = getTimer();
    for(i=0;i<n;i++){
           for(j=0;j<n;j++){
                  xx = Math.min(i,j);
    trace("Duration Math.min",getTimer()-startTime);
    // Duration conditional 43
    startTime = getTimer();
    for(i=0;i<n;i++){
           for(j=0;j<n;j++){
                   xx = (i<j) ? i : j;
    trace("Duration conditional",getTimer()-startTime);
    Math.pow
    It is two to three times faster to explicitly multiply a number variable compared to using Math.pow. That benefit even extends a little beyond integer exponents because Math.sqrt(i) is about twice as fast as Math.pow(i,.5).
    var i:int;
    var n:int = 10000000;
    var xx:int;
    var startTime:int;
    // exp .5: 2020, exp 2: 1533, exp 3: 1617, exp 4: 1427, exp 5: 1381, exp 10: 1391
    startTime = getTimer();
    for(i=0;i<n;i++){
           xx = Math.pow(i,.5);
    trace("Duration Math.pow",getTimer()-startTime);
    // exp .5: 1064, exp 2: 427, exp 3: 778, exp 4: 557, exp 5: 501, exp 10: 586
    startTime = getTimer();
    for(i=0;i<n;i++){
           xx = Math.sqrt(i);
    trace("Duration iteration",getTimer()-startTime);

  • Which data structure to use in this scenario? queue, stack, list, ...

    Hi,
    I'm hesitant about what data structure to use (best efficient one) in the following scenario
    At a given moment I have an ordered set of data such as:
         (1,3,6,9,10)
    and a current value (by instance, 11)
    Then I need to access the LAST one (10) and
    If my value is greater I will add it to the list. In this example I will add 11 so the list will be (1,3,6,9,10,11)
    On the other hand, as a second step, I will iterate on the list as follows: I will get the first element, do something, then remove it, and go to next one until the list is empty. Therefore, basically I will access always the first element on the list.
    I don't really care about the elements in the middle.
    Which data structure do you suggest me to use?
    I was thinking on Queue (easy to access the head, and extract one by one in order), but I don't know how to get the tail element (10 in this case), as it is the one that tells me if I have to add another element...
    Thank you.

    >
    At a given moment I have an ordered set of data such as:
         (1,3,6,9,10)
    and a current value (by instance, 11)
    Then I need to access the LAST one (10) and
    If my value is greater I will add it to the list. In this example I will add 11 so the list will be (1,3,6,9,10,11)Any data structure will do, I would suggest a LinkedList.
    On the other hand, as a second step, I will iterate on the list as follows: I will get the first element, do something, then remove it, and go to next one until the list is empty. Therefore, basically I will access always the first element on the list.Use an iterator and the corresponding remove methods.
    Mel

  • Advice on Data Structures

    Hi, I've got a couple of years experience with Java but am quite confused on how to go about my latest project. I'm aiming to build some form of route planner.
    I'm looking for some sort of data structure that can represent two towns, and a link between them (probably an integer, which will be the distance).
    Then to include a user interface, where the user enters a start town and finish town, and a route is calculated for them.
    I've spent quite a bit of time looking around and am not quite sure on how to go about this, I'm thinking a Graph. Can anyone give me some advice/small code example on how to achieve this?
    Thanks

    I've had a go at setting this up with two classes, but if I try to run any methods on it, nothing seems to have been initialised as I keep getting NullPointerExceptions. What is causing this and how can I get around it?
    Thanks
    public class Main {
        private Place currentPlace;
        /** Creates a new instance of Main */
        public Main() {
           createPlaces();
        private void createPlaces()
             Place york, hull;
             york = new Place();
             hull = new Place();
            york.addEdge(50, hull);
            hull.addEdge(50, york);
            currentPlace = hull;
        private void printInfo()
            System.out.println(currentPlace.getExits());
    public class Place {
        public HashMap exits;
        /** Creates a new instance of Graph */
        public Place() {
            exits = new HashMap();
        public void addEdge (int distance, Place place)
       exits.put(distance,  place);
        public String getExits()
            return getExitString();
        public String getExitString()
            String returnString = "Exits from this room :";
            Set keys = exits.keySet();
            for(Iterator iter = keys.iterator(); iter.hasNext(); )
                returnString += " " + iter.next();
            return returnString;
    }

  • Data structure - tokenization

    Hi,
    I want to do the tokenization of several documents, saving the tokens (as strings) into a data structure. Obviously, I don't know the number of the tokens (it depends of the lenght of the documents). What is the data structure that you advice me?
    Thanx
    MP

    it seems you want the kinda of data structure that grows dynamically..however other factors can play a role too
    - want fast iteration --> use ArrayList
    - want synchronization --> use Vector
    - no duplicates --> use HashSet
    - want order --> use TreeSet
    - etc..many other i can't remember now..
    so it's really ur choice
    hope this helps

  • Table-like Data Structure

    I'm trying to develop an application where I require 2 or more store equivalent objects. Each object has an id (int) used as part of the hashCode() and equals() methods. I would like to store all objects in a data structure that would allow to store and easily retrieved the concepts based on either id. I have thought about using TreeMap or Hashtable but those only allow the retrieval of element using the key.

    In description logic, we can express statements, such as A := C, meaning that A and C are equivalent (i.e. the same object). I would like to keep track of these objects to reduce the number of iteration carried by the algorithm. If I store these elements in a java.util.Hashtable<K,V> then I'm only allowed to retrieve objects using the key (i.e. Hashtable.get(Object key)). However, I need to be able to retrieve elements either by keys or values depending on the task. For example, if I find C in another statement I would like to replace it by A and sometimes I need to use A to retrieve C.

  • Simple Transformation to deserialize an XML file into ABAP data structures?

    I'm attempting to write my first simple transformation to deserialize
    an XML file into ABAP data structures and I have a few questions.
    My simple transformation contains code like the following
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
                  xmlns:pp="http://www.sap.com/abapxml/types/defined" >
    <tt:type name="REPORT" line-type="?">
      <tt:node name="COMPANY_ID" type="C" length="10" />
      <tt:node name="JOB_ID" type="C" length="20" />
      <tt:node name="TYPE_CSV" type="C" length="1" />
      <tt:node name="TYPE_XLS" type="C" length="1" />
      <tt:node name="TYPE_PDF" type="C" length="1" />
      <tt:node name="IS_NEW" type="C" length="1" />
    </tt:type>
    <tt:root name="ROOT2" type="pp:REPORT" />
        <QueryResponse>
        <tt:loop ref="ROOT2" name="line">
          <QueryResponseRow>
            <CompanyID>
              <tt:value ref="$line.COMPANY_ID" />
            </CompanyID>
            <JobID>
              <tt:value ref="$line.JOB_ID" />
            </JobID>
            <ExportTypes>
              <tt:loop>
                <ExportType>
                   I don't know what to do here (see item 3, below)
                </ExportType>
              </tt:loop>
            </ExportTypes>
            <IsNew>
              <tt:value ref="$line.IS_NEW"
              map="val(' ') = xml('false'), val('X') = xml('true')" />
            </IsNew>
          </QueryResponseRow>
          </tt:loop>
        </QueryResponse>
        </tt:loop>
    1. In a DTD, an element can be designated as occurring zero or one
    time, zero or more times, or one or more times. How do I write the
    simple transformation to accommodate these possibilities?
    2. In trying to accommodate the "zero or more times" case, I am trying
    to use the <tt:loop> instruction. It occurs several layers deep in the
    XML hierarchy, but at the top level of the ABAP table. The internal
    table has a structure defined in the ABAP program, not in the data
    dictionary. In the simple transformation, I used <tt:type> and
    <tt:node> to define the structure of the internal table and then
    tried to use <tt:loop ref="ROOT2" name="line"> around the subtree that
    can occur zero or more times. But every variation I try seems to get
    different errors. Can anyone supply a working example of this?
    3. Among the fields in the internal table, I've defined three
    one-character fields named TYPE_CSV, TYPE_XLS, and TYPE_PDF. In the
    XML file, I expect zero to three elements of the form
    <ExportType exporttype='csv' />
    <ExportType exporttype='xls' />
    <ExportType exporttype='pdf' />
    I want to set field TYPE_CSV = 'X' if I find an ExportType element
    with its exporttype attribute set to 'csv'. I want to set field
    TYPE_XLS = 'X' if I find an ExportType element with its exporttype
    attribute set to 'xls'. I want to set field TYPE_PDF = 'X' if I find
    an ExportType element with its exporttype attribute set to 'pdf'. How
    can I do that?
    4. For an element that has a value like
    <ErrorCode>123</ErrorCode>
    in the simple transformation, the sequence
    <ErrorCode>  <tt:value ref="ROOT1.CODE" />  </ErrorCode>
    seems to work just fine.
    I have other situations where the XML reads
    <IsNew value='true' />
    I wanted to write
    <IsNew>
            <tt:value ref="$line.IS_NEW"
            map="val(' ') = xml('false'), val('X') = xml('true')" />
           </IsNew>
    but I'm afraid that the <tt:value> fails to deal with the fact that in
    the XML file the value is being passed as the value of an attribute
    (named "value"), rather than the value of the element itself. How do
    you handle this?

    Try this code below:
    data  l_xml_table2  type table of xml_line with header line.
    W_filename - This is a Path.
      if w_filename(02) = '
        open dataset w_filename for output in binary mode.
        if sy-subrc = 0.
          l_xml_table2[] = l_xml_table[].
          loop at l_xml_table2.
            transfer l_xml_table2 to w_filename.
          endloop.
        endif.
        close dataset w_filename.
      else.
        call method cl_gui_frontend_services=>gui_download
          exporting
            bin_filesize = l_xml_size
            filename     = w_filename
            filetype     = 'BIN'
          changing
            data_tab     = l_xml_table
          exceptions
            others       = 24.
        if sy-subrc <> 0.
          message id sy-msgid type sy-msgty number sy-msgno
                     with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.

  • OC4J: marshalling does not recreate the same data structure onthe client

    Hi guys,
    I am trying to use OC4J as an EJB container and have come across the following problem, which looks like a bug.
    I have a value object method that returns an instance of ArrayList with references to other value objects of the same class. The value objects have references to other value objects. When this structure is marshalled across the network, we expect it to be recreated as is but that does not happen and instead objects get duplicated.
    Suppose we have 2 value objects: ValueObject1 and ValueObject2. ValueObject1 references ValueObject2 via its private field and the ValueObject2 references ValueObject1. Both value objects are returned by our method in an ArrayList structure. Here is how it will look like (number after @ represents an address in memory):
    Object[0] = com.cramer.test.SomeVO@1
    Object[0].getValueObject[0] = com.cramer.test.SomeVO@2
    Object[1] = com.cramer.test.SomeVO@2
    Object[1].getValueObject[0] = com.cramer.test.SomeVO@1
    We would expect to see the same (except exact addresses) after marshalling. Here is what we get instead:
    Object[0] = com.cramer.test.SomeVO@1
    Object[0].getValueObject[0] = com.cramer.test.SomeVO@2
    Object[1] = com.cramer.test.SomeVO@3
    Object[1].getValueObject[0] = com.cramer.test.SomeVO@4
    It can be seen that objects get unnecessarily duplicated – the instance of the ValueObject1 referenced by the ValueObject2 is not the same now as the instance that is referenced by the ArrayList instance.
    This does not only break referential integrity, structure and consistency of the data but dramatically increases the amount of information sent across the network. The problem was discovered when we found that a relatively small but complicated structure that gets serialized into a 142kb file requires about 20Mb of network communication. All this extra info is duplicated object instances.
    I have created a small test case to demonstrate the problem and let you reproduce it.
    Here is RMITestBean.java:
    package com.cramer.test;
    import javax.ejb.EJBObject;
    import java.util.*;
    public interface RMITestBean extends EJBObject
    public ArrayList getSomeData(int testSize) throws java.rmi.RemoteException;
    public byte[] getSomeDataInBytes(int testSize) throws java.rmi.RemoteException;
    Here is RMITestBeanBean.java:
    package com.cramer.test;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.util.*;
    public class RMITestBeanBean implements SessionBean
    private SessionContext context;
    SomeVO someVO;
    public void ejbCreate()
    someVO = new SomeVO(0);
    public void ejbActivate()
    public void ejbPassivate()
    public void ejbRemove()
    public void setSessionContext(SessionContext ctx)
    this.context = ctx;
    public byte[] getSomeDataInBytes(int testSize)
    ArrayList someData = getSomeData(testSize);
    try {
    java.io.ByteArrayOutputStream byteOutputStream = new java.io.ByteArrayOutputStream();
    java.io.ObjectOutputStream objectOutputStream = new java.io.ObjectOutputStream(byteOutputStream);
    objectOutputStream.writeObject(someData);
    objectOutputStream.flush();
    System.out.println(" serialised output size: "+byteOutputStream.size());
    byte[] bytes = byteOutputStream.toByteArray();
    objectOutputStream.close();
    byteOutputStream.close();
    return bytes;
    } catch (Exception e) {
    System.out.println("Serialisation failed: "+e.getMessage());
    return null;
    public ArrayList getSomeData(int testSize)
    // Create array of objects
    ArrayList someData = new ArrayList();
    for (int i=0; i<testSize; i++)
    someData.add(new SomeVO(i));
    // Interlink all the objects
    for (int i=0; i<someData.size()-1; i++)
    for (int j=i+1; j<someData.size(); j++)
    ((SomeVO)someData.get(i)).addValueObject((SomeVO)someData.get(j));
    ((SomeVO)someData.get(j)).addValueObject((SomeVO)someData.get(i));
    // print out the data structure
    System.out.println("Data:");
    for (int i = 0; i<someData.size(); i++)
    SomeVO tmp = (SomeVO)someData.get(i);
    System.out.println("Object["+Integer.toString(i)+"] = "+tmp);
    System.out.println("Object["+Integer.toString(i)+"]'s some number = "+tmp.getSomeNumber());
    for (int j = 0; j<tmp.getValueObjectCount(); j++)
    SomeVO tmp2 = tmp.getValueObject(j);
    System.out.println(" getValueObject["+Integer.toString(j)+"] = "+tmp2);
    System.out.println(" getValueObject["+Integer.toString(j)+"]'s some number = "+tmp2.getSomeNumber());
    // Check the serialised size of the structure
    try {
    java.io.ByteArrayOutputStream byteOutputStream = new java.io.ByteArrayOutputStream();
    java.io.ObjectOutputStream objectOutputStream = new java.io.ObjectOutputStream(byteOutputStream);
    objectOutputStream.writeObject(someData);
    objectOutputStream.flush();
    System.out.println("Serialised output size: "+byteOutputStream.size());
    objectOutputStream.close();
    byteOutputStream.close();
    } catch (Exception e) {
    System.out.println("Serialisation failed: "+e.getMessage());
    return someData;
    Here is RMITestBeanHome:
    package com.cramer.test;
    import javax.ejb.EJBHome;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    public interface RMITestBeanHome extends EJBHome
    RMITestBean create() throws RemoteException, CreateException;
    Here is ejb-jar.xml:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
    <enterprise-beans>
    <session>
    <description>Session Bean ( Stateful )</description>
    <display-name>RMITestBean</display-name>
    <ejb-name>RMITestBean</ejb-name>
    <home>com.cramer.test.RMITestBeanHome</home>
    <remote>com.cramer.test.RMITestBean</remote>
    <ejb-class>com.cramer.test.RMITestBeanBean</ejb-class>
    <session-type>Stateful</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    And finally the application that tests the bean:
    package com.cramer.test;
    import java.util.*;
    import javax.rmi.*;
    import javax.naming.*;
    public class RMITestApplication
    final static boolean HARDCODE_SERIALISATION = false;
    final static int TEST_SIZE = 2;
    public static void main(String[] args)
    Hashtable props = new Hashtable();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    props.put(Context.PROVIDER_URL, "ormi://lil8m:23792/alexei");
    props.put(Context.SECURITY_PRINCIPAL, "admin");
    props.put(Context.SECURITY_CREDENTIALS, "admin");
    try {
    // Get the JNDI initial context
    InitialContext ctx = new InitialContext(props);
    NamingEnumeration list = ctx.list("comp/env/ejb");
    // Get a reference to the Home Object which we use to create the EJB Object
    Object objJNDI = ctx.lookup("comp/env/ejb/RMITestBean");
    // Now cast it to an InventoryHome object
    RMITestBeanHome testBeanHome = (RMITestBeanHome)PortableRemoteObject.narrow(objJNDI,RMITestBeanHome.class);
    // Create the Inventory remote interface
    RMITestBean testBean = testBeanHome.create();
    ArrayList someData = null;
    if (!HARDCODE_SERIALISATION)
    // ############################### Alternative 1 ##############################
    // ## This relies on marshalling serialisation ##
    someData = testBean.getSomeData(TEST_SIZE);
    // ############################ End of Alternative 1 ##########################
    } else
    // ############################### Alternative 2 ##############################
    // ## This gets a serialised byte stream and de-serialises it ##
    byte[] bytes = testBean.getSomeDataInBytes(TEST_SIZE);
    try {
    java.io.ByteArrayInputStream byteInputStream = new java.io.ByteArrayInputStream(bytes);
    java.io.ObjectInputStream objectInputStream = new java.io.ObjectInputStream(byteInputStream);
    someData = (ArrayList)objectInputStream.readObject();
    objectInputStream.close();
    byteInputStream.close();
    } catch (Exception e) {
    System.out.println("Serialisation failed: "+e.getMessage());
    // ############################ End of Alternative 2 ##########################
    // Print out the data structure
    System.out.println("Data:");
    for (int i = 0; i<someData.size(); i++)
    SomeVO tmp = (SomeVO)someData.get(i);
    System.out.println("Object["+Integer.toString(i)+"] = "+tmp);
    System.out.println("Object["+Integer.toString(i)+"]'s some number = "+tmp.getSomeNumber());
    for (int j = 0; j<tmp.getValueObjectCount(); j++)
    SomeVO tmp2 = tmp.getValueObject(j);
    System.out.println(" getValueObject["+Integer.toString(j)+"] = "+tmp2);
    System.out.println(" getValueObject["+Integer.toString(j)+"]'s some number = "+tmp2.getSomeNumber());
    // Print out the size of the serialised structure
    try {
    java.io.ByteArrayOutputStream byteOutputStream = new java.io.ByteArrayOutputStream();
    java.io.ObjectOutputStream objectOutputStream = new java.io.ObjectOutputStream(byteOutputStream);
    objectOutputStream.writeObject(someData);
    objectOutputStream.flush();
    System.out.println("Serialised output size: "+byteOutputStream.size());
    objectOutputStream.close();
    byteOutputStream.close();
    } catch (Exception e) {
    System.out.println("Serialisation failed: "+e.getMessage());
    catch(Exception ex){
    ex.printStackTrace(System.out);
    The parameters you might be interested in playing with are HARDCODE_SERIALISATION and TEST_SIZE defined at the beginning of RMITestApplication.java. The HARDCODE_SERIALISATION is a flag that specifies whether Java serialisation should be used to pass the data across or we should rely on OC4J marshalling. TEST_SIZE defines the size of the object graph and the ArrayList structure. The bigger this size is the more dramatic effect you get from data duplication.
    The test case outputs the structure both on the server and on the client and prints out the size of the serialised structure. That gives us sufficient comparison, as both structure and its size should be the same on the client and on the server.
    The test case also demonstrates that the problem is specific to OC4J. The standard Java serialisation does not suffer the same flaw. However using the standard serialisation the way I did in the test case code is generally unacceptable as it breaks the transparency benefit and complicates interfaces.
    To run the test case:
    1) Modify provider URL parameter value on line 15 of the RMITestApplication.java for your environment.
    2) Deploy the bean to the server.
    4) Run RMITestApplication on a client PC.
    5) Compare the outputs on the server and on the client.
    I hope someone can reproduce the problem and give their opinion, and possibly point to the solution if there is one at the moment.
    Cheers,
    Alexei

    Hi,
    Eugene, wrong end user recovery.  Alexey is referring to client desktop end user recovery which is entirely different.
    Alexy - As noted in the previous post:
    http://social.technet.microsoft.com/Forums/en-US/bc67c597-4379-4a8d-a5e0-cd4b26c85d91/dpm-2012-still-requires-put-end-users-into-local-admin-groups-for-the-purpose-of-end-user-data?forum=dataprotectionmanager
    Each recovery point has users permisions tied to it, so it's not possible to retroacively give the users permissions.  Implement the below and going forward all users can restore their own files.
    This is a hands off solution to allow all users that use a machine to be able to restore their own files.
     1) Make these two cmd files and save them in c:\temp
     2) Using windows scheduler – schedule addperms.cmd to run daily – any new users that log onto the machine will automatically be able to restore their own files.
    <addperms.cmd>
     Cmd.exe /v /c c:\temp\addreg.cmd
    <addreg.cmd>
     set users=
     echo Windows Registry Editor Version 5.00>c:\temp\perms.reg
     echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Data Protection Manager\Agent\ClientProtection]>>c:\temp\perms.reg
     FOR /F "Tokens=*" %%n IN ('dir c:\users\*. /b') do set users=!users!%Userdomain%\\%%n,
     echo "ClientOwners"=^"%users%%Userdomain%\\bogususer^">>c:\temp\perms.reg
     REG IMPORT c:\temp\perms.reg
     Del c:\temp\perms.reg
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT]
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • Error saving data structure CE11000 (please read log) message number KX 655

    while activating the data structure in the operating concern of CO PA sap gives the following errors.
    1.Error saving data structure CE11000 (please read log)
    Message no. KX655
    2.Error saving table CE01000
    Message no. KX593
    3.in Log Reference field CE31000-REC_WAERS for CE31000-VVQ10001 has incorrect type.
    Pls suggest

    Hey,
    Below tables are related to application logs
    BAL_AMODAL  :                   Application Log: INDX table for amodal communication
    BALC        :                   Application Log: Log or message context            
    BALDAT      :                   Application Log: Log data                          
    BALHANDLE   :                   Application Log: Lock object dummy table           
    BALHDR      :                   Application log: log header                        
    BALHDRP     :                   Application log: log parameter                     
    BAL_INDX    :                   Application Log: INDX tables                       
    BALM        :                   Application log: log message                       
    BALMP       :                   Application log: message parameter                 
    BALOBJ      :                   Application log: objects                           
    BALOBJT     :                   Application log: object texts                      
    BALSUB      :                   Application log: sub-objects                       
    BALSUBT     :                   Application log: Sub-object texts                  
    -Kiran
    *Please mark useful answers

  • Can I automate the creation of a cluster in LabView using the data structure created in an autogenerated .CSV, C header, or XML file?

    Can I automate the creation of a cluster in LabView using the data structure created in an auto generated .CSV, C header, or XML file?  I'm trying to take the data structure defined in one or more of those files listed and have LabView automatically create a cluster with identical structure and data types.  (Ideally, I would like to do this with a C header file only.)  Basically, I'm trying to avoid having to create the cluster by hand, as the number of cluster elements could be very large. I've looked into EasyXML and contacted the rep for the add-on.  Unfortunately, this capability has not been created yet.  Has anyone done something like this before? Thanks in advance for the help.  
    Message Edited by PhilipJoeP on 04-29-2009 04:54 PM
    Solved!
    Go to Solution.

    smercurio_fc wrote:
    Is this something you're trying to do at runtime? Clusters are fixed data structures so you can't change them programmatically. Or, are you just trying to create some typedef cluster controls so that you can use them for coding? What would your clusters basically look like? Perhaps another way of holding the information like an array of variants?
    You can try LabVIEW scripting, though be aware that this is not supported by NI. 
     Wow!  Thanks for the quick response!  We would use this cluster as a fixed data structure.  No need to change the structure during runtime.  The cluster would be a cluster of clusters with multiple levels.  There would be not pattern as to how deep these levels would go, or how many elements would be in each.   Here is the application.  I would like to be able to autocode a Simulink model file into a DLL.  The model DLL would accept a Simulink bus object of a certain data structure (bus of buses), pick out which elements of the bus is needed for the model calculation, and then pass the bus object.  I then will take the DLL file and use the DLL VI block to pass a cluster into the DLL block (with identical structure as the bus in Simulink).  To save time, I would like to auto generate the C header file using Simulink to define the bus structure and then have LabView read that header file and create the cluster automatically.   Right now I can do everything but the auto creation of the cluster.  I can manually build the cluster to match the Simulink model bus structure and it runs fine.  But this is only for an example model with a small structure.  Need to make the cluster creation automated so it can handle large structures with minimal brute force. Thanks!  

  • What is the best data structure for loading an enterprise Power BI site?

    Hi folks, I'd sure appreciate some help here!
    I'm a kinda old-fashioned gal and a bit of a traditionalist, building enterprise data warehouses out of Analysis Service hypercubes with a whole raft of MDX for analytics.  Those puppies would sit up and beg when you asked them to deliver up goodies
    to SSRS or PowerView.
    But Power BI is a whole new game for me.  
    Should I be exposing each dimension and fact table in the relational data warehouse as a single Odata feed?  
    Should I be running Data Management Gateway and exposing each table in my RDW individually?
    Should I be flattening my stars and snowflakes and creating a very wide First Normal Form dataset with everything relating to each fact? 
    I guess my real question, folks, is what's the optimum way of exposing data to the Power BI cloud?  
    And my subsidiary question is this:  am I right in saying that all the data management, validation, cleansing, and regular ETTL processes are still required
    before the data is suitable to expose to Power BI?  
    Or, to put it another way, is it not the case that you need to have a clean and properly structured data warehouse
    before the data is ready to be massaged and presented by Power BI? 
    I'd sure value your thoughts and opinions,
    Cheers, Donna
    Donna Kelly

    Dear All,
    My original question was: 
    what's the optimum way of exposing data to the Power BI cloud?
    Having spent the last month faffing about with Power BI – and reading about many people’s experiences using it – I think I can offer a few preliminary conclusions.
    Before I do that, though, let me summarise a few points:
    Melissa said “My initial thoughts:  I would expose each dim & fact as a separate OData feed” and went on to say “one of the hardest things . . . is
    the data modeling piece . . . I think we should try to expose the data in a way that'll help usability . . . which wouldn't be a wide, flat table ”.
    Greg said “data modeling is not a good thing to expose end users to . . . we've had better luck with is building out the data model, and teaching the users
    how to combine pre-built elements”
    I had commented “. . . end users and data modelling don't mix . . . self-service so
    far has been mostly a bust”.
    Here at Redwing, we give out a short White Paper on Business Intelligence Reporting.  It goes to clients and anyone else who wants one.  The heart
    of the Paper is the Reporting Pyramid, which states:  Business intelligence is all about the creation and delivery of actionable intelligence to the right audience at the right time
    For most of the audience, that means Corporate BI: pre-built reports delivered on a schedule.
    For most of the remaining audience, that means parameterised, drillable, and sliceable reporting available via the web, running the gamut from the dashboard to the details, available on
    demand.
    For the relatively few business analysts, that means the ability for business users to create their own semi-customised visual reports when required, to serve
    their audiences.
    For the very few high-power users, that means the ability to interrogate the data warehouse directly, extract the required data, and construct data mining models, spreadsheets and other
    intricate analyses as needed.
    On the subject of self-service, the Redwing view says:  Although many vendors want tot sell self-service reporting tools to the enterprise, the facts of the matter are these:
    v
    80%+ of all enterprise reporting requirement is satisfied by corporate BI . . . if it’s done right.
    v Very few staff members have the time, skills, or inclination to learn and employ self-service business intelligence in the course of their activities.
    I cannot just expose raw data and tell everyone to get on with it.  That way lies madness!
    I think that clean and well-structured data is a prerequisite for delivering business intelligence. 
    Assuming that data is properly integrated, historically accurate and non-volatile as well, then I've just described
    a data warehouse, which is the physical expression of the dimensional model.
    Therefore, exposing the presentation layer of the data warehouse is – in my opinion – the appropriate interface for self-service business intelligence.
    Of course, we can choose to expose perspectives as well, which is functionally identical to building and exposing subject data marts.
    That way, all calculations, KPIs, definitions, and even field names, and all consistent because they all come from the single source of the truth, and not from spreadmart hell.
    So my conclusion is that exposing the presentation layer of the properly modelled data warehouse is – in general - the way to expose data for self-service.
    That’s fine for the general case, but what about Power BI?  Well, it’s important to distinguish between new capabilities in Excel, and the ones in Office 365.
    I think that to all intents and purposes, we’re talking about exposing data through the Data Management Gateway and reading it via Power Query.
    The question boils down to what data structures should go down that pipe. 
    According to
    Create a Data Source and Enable OData Feed in Power BI Admin Center, the possibilities are tables and views.  I guess I could have repeating data in there, so it could be a flattened structure of the kind Melissa doesn’t like (and neither do I). 
    I could expose all the dims and all the facts . . . but that would mean essentially re-building the DW in the PowerPivot DM, and that would be just plain stoopid.  I mean, not a toy system, but a real one with scores of facts and maybe hundreds of dimensions?
    Fact is, I cannot for the life of me see what advantages DMG/PQ
    has over just telling corporate users to go directly to the Cube Perspective they want, that has already all the right calcs, KPIs, security, analytics, field names . . . and most importantly, is already modelled correctly!
    If I’m a real Power User, then I can use PQ on my desktop to pull mashup data from the world, along with all my on-prem data through my exposed Cube presentation layer, and PowerPivot the
    heck out of that to produce all the reporting I’d ever want.  It'd be a zillion times faster reading the data directly from the Cube instead of via the DMG, as well (I think Power BI performance sucks, actually).
    Of course, your enterprise might not
    have a DW, just a heterogeneous mass of dirty unstructured data.  If that’s the case,
    choosing Power BI data structures is the least of your problems!  :-)
    Cheers, Donna
    Donna Kelly

  • Lease Out Contract - Master Data Structural Relations

    Dear Gurus,
    I am new to FX RE and if my question is too simple, please excuse me!
    I am researching the possibilities for the master data structure of lease in contracts and have a serious confusion.
    The documentation says that objects can be assigned to a contract individually or many objects related to one contract. At the same tim it is said that rental units are assigned only to lease out contracts.
    How should i proceed if my company has got many lease in contracts for different object. Is it a must the contract to be assigned to an object or it can be managed just as a contract? I saw that from the RE Navigator you can create a contract, does that mean that in FX RE the contracts itself is considered as master data record?
    Any opinions will be highly appreciated.
    Many thanks in advance!

    Dear Kumar,
    Sorry if I ve been confusing. I will try to make it more clear.
    I am working for a Teleco and i am researching the possibility of implementing FX - RE internally. We will not need all the functionalities of the module, but only the ones that allow you to manage your lease in contracts. We`ve got lots of base stations contracts (as you can imagine) where our company is a tenant in a lease contract. 
    I did some research in relation to the master data structure and cant work out how should our master data be structured. The business requirements are  - handling the advance payments, accruals and postings, giving and receiving notices, adjustments of rent etc. Is it possible to create the contract within the system,  set all the conditions directly in it or do we need to have another master record other that the contract itself.
    My confusion comes from the fact that the standard solution of the lease outs suggests creating a rental unit first and then assigning the contract to it. But since we will be tenants we dont need to more detailed information on these objects, we just need the conditions in the contract that will let us handle all the activities that arise in connection to it.
    I hope that i put the question more clearly this time.
    Can you also tell me if it is possible to create a template and after entering the conditions about the particular contract to generate it from the system on a hard copy?
    Many thanks and sorry if i cant make myself more clear!

Maybe you are looking for

  • Line Item Not dispaying in Payment Advice standard report

    Hi Experts, I have cleared line items of a vendor by making payment through F-53 and subsequently generated the Print Form spoon request through FBZ5. But in the print, line items (cleared Items) doesn't display in Payment advice report. But for the

  • Users of Word for Mac:  Help on Two Issues!!

    I downloaded some fonts I wanted to use in my Word for Mac document. Download went fine and the fonts are happily nestled in the Fonts folder. However, when I open Word, they do not appear on the Font listing. Any thoughts as to how to get them over

  • API to create Purchase Order in Oracle applications?

    Hi All, Can you please tell me the API to create Purchase Order in Oracle Applications.

  • How to manually add music

    I want to add music manually from my mac. however when i try to set it up to do that, it wipes my itouch music out completely and have to do a complete re-sync for music from the Library. Isn't there some way to sync it and only add new music that i

  • Email subject+sender Unknown?

    Hello,  This started ocurring since the 15th. Tried to do online chat but after 20mins just said no one's available and try later. Subject and sender are blank/unknown. Body has all information in such as header and message, all messy. This was in th