Get Started

Durable Map
    /* initialize a memory allocator */
    m_act = new NonVolatileMemAllocator(
                1024 * 1024 * 1024L,

    /* prepare generic types in order as an array for durable map
       you can specify any durable type here 
       e.g. durable object, durable buffer/chunk, durable list/map/set */
    DurableType gtypes[] = {DurableType.STRING, DurableType.INTEGER};

    /* create a new durable map through durable map factory,
       the durable map store your objects on external memory-class storage
       with no need to do serialization at all */
    DurableHashMap<String, Integer> map = DurableHashMapFactory.create(
                m_act, null, gtypes, mInitialCapacity, false);

    /* fetch the handler of the durable map, 
       it is just a long type value.
       it is used for restore this durable map back later,
       you can put this handler anywhere you like
       e.g. durable key-value store, durable buffer */
    Long handler = map.getHandler();

    /* use this durable map as usual */
    Integer val = map.put("hello", 1);

    val = map.put("hello", 3);
    AssertJUnit.assertEquals(1, val.intValue());

    val = map.put("world", 2);

    val = map.remove("world");
    AssertJUnit.assertEquals(2, val.intValue());

    /* restore the same durable map from the stored handler 
       with no need to do de-serializatoin */
    DurableHashMap<String, Integer> restoredMap = DurableHashMapFactory.restore(
                m_act, null, gtypes, handler, false);

    val = restoredMap.get("hello");
    AssertJUnit.assertEquals(3, val.intValue());

    val = restoredMap.get("world");

    val = restoredMap.get("test");
Durable Sorting
    /* get sort service instance */
    GeneralComputingService gcsvr = Utils.getGeneralComputingService("sort");

    /* instantiate a value info object */
    ValueInfo vinfo = new ValueInfo();

    /* instantiate an object stack list */
    List<long[][]> objstack = new ArrayList<long[][]>();

    /* fill it up with durable object info in order */

    /* configure the field id info stack to specify which field value
       need to be sorted */
    long[][] fidinfostack = { {2L, 1L} };

    /* assign the handler of a durable list to vinfo.handler */
    vinfo.handler = this.head;

    /* set a translate table from handler's memory allocator */
    vinfo.transtable = m_act.getTranslateTable();

    /* specify the durable type of value */
    vinfo.dtype = DurableType.LONG;

    /* generate an array of frame from
       object info stack and field info stack */
    vinfo.frames = Utils.genNativeParamForm(objstack, fidinfostack);

    /* wrap a set of value info as an array */
    ValueInfo[] vinfos = {vinfo};

    /* perform the sorting operation,
       the durable list and its value are not marshaled or un-marshaled
       across native boundary */
    long[] ret = gcsvr.perform("1dlong_bubble", vinfos);

    /* return the handler of new head of sorted durable list */
    this.head = ret[0];