Package net.openhft.collections

Examples of net.openhft.collections.SharedHashMapBuilder


public class GettingStartedTest {
    @Test
    @Ignore
    public void testTheCodeInGuide() throws IOException {
        String tmpdir = System.getProperty("java.io.tmpdir");
        Map<String, String> map = new SharedHashMapBuilder().file(new File(tmpdir + "/shared.map")).kClass(String.class).vClass(String.class).create();
        map.put("some.json", "missing");
        map.get("some.json");

        map.put("Hello", "World");
        String hi = map.get("Hello");
View Full Code Here


    @Test
    @Ignore
    public void bondExample() throws IOException, InterruptedException {


        SharedHashMap<String, BondVOInterface> shm = new SharedHashMapBuilder()
                .generatedValueType(true)
                .entrySize(512).file(new File(TMP + "/shm-myBondPortfolioSHM")).kClass(String.class).vClass(BondVOInterface.class).create();


        BondVOInterface bondVO = DataValueClasses.newDirectReference(BondVOInterface.class);
        shm.acquireUsing("369604103", bondVO);
        bondVO.setIssueDate(parseYYYYMMDD("20130915"));
        bondVO.setMaturityDate(parseYYYYMMDD("20140915"));
        bondVO.setCoupon(5.0 / 100); // 5.0%

        BondVOInterface.MarketPx mpx930 = bondVO.getMarketPxIntraDayHistoryAt(0);
        mpx930.setAskPx(109.2);
        mpx930.setBidPx(106.9);

        BondVOInterface.MarketPx mpx1030 = bondVO.getMarketPxIntraDayHistoryAt(1);
        mpx1030.setAskPx(109.7);
        mpx1030.setBidPx(107.6);


        SharedHashMap<String, BondVOInterface> shmB = new SharedHashMapBuilder()
                .generatedValueType(true)
                .entrySize(320).file(new File(TMP + "/shm-myBondPortfolioSHM")).kClass(String.class).vClass(BondVOInterface.class).create();

        // ZERO Copy but creates a new off heap reference each time
View Full Code Here

    static SharedHashMap<String, BondVOInterface> acquireSHM() throws IOException {
        // ensure thread ids are globally unique.
        AffinitySupport.setThreadId();

        String TMP = System.getProperty("java.io.tmpdir");
        return new SharedHashMapBuilder()
                .generatedValueType(true)
                .entries(16)
                .entrySize(64).file(new File(TMP + "/BondPortfolioSHM")).kClass(String.class).vClass(BondVOInterface.class).create();
    }
View Full Code Here

        return file;
    }

    static SharedHashMap<Integer, CharSequence> newShmIntString(int size) throws IOException {

        return new SharedHashMapBuilder()
                .entries(size).file(getPersistenceFile()).kClass(Integer.class).vClass(CharSequence.class).create();

    }
View Full Code Here

    }

    static SharedHashMap<ArrayList, CharSequence> newShmListBoolean(int size) throws IOException {

        return new SharedHashMapBuilder()
                .entries(size).file(getPersistenceFile()).kClass(ArrayList.class).vClass(CharSequence.class).create();

    }
View Full Code Here

    }


    static SharedHashMap<ArrayList, CharSequence> newShmListBoolean() throws IOException {

        return new SharedHashMapBuilder().file(getPersistenceFile()).kClass(ArrayList.class).vClass(CharSequence.class).create();

    }
View Full Code Here

    }

    static SharedHashMap<CharSequence, CharSequence> newShmStringString(int size) throws IOException {

        return new SharedHashMapBuilder()
                .entries(size).file(getPersistenceFile()).kClass(CharSequence.class).vClass(CharSequence.class).create();

    }
View Full Code Here

    }


    static SharedHashMap<Integer, CharSequence> newShmIntString() throws IOException {

        return new SharedHashMapBuilder().file(getPersistenceFile()).kClass(Integer.class).vClass(CharSequence.class).create();

    }
View Full Code Here

    }

    static SharedHashMap<BI, Boolean> newShmBiBoolean() throws IOException {

        return new SharedHashMapBuilder().file(getPersistenceFile()).kClass(BI.class).vClass(Boolean.class).create();

    }
View Full Code Here

    static Map newMap() {
        try {

//            return new net.openhft.chronicle.map.ConcurrentHashMap();
            return new SharedHashMapBuilder().file(getPersistenceFile()).kClass(Object.class).vClass(Object.class).create();

        } catch (Exception e) {
            throw new RuntimeException("Can't instantiate SHM : " + e);
        }
    }
View Full Code Here

TOP

Related Classes of net.openhft.collections.SharedHashMapBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.