Search in sources :

Example 1 with IcedInt

use of water.util.IcedInt in project h2o-3 by h2oai.

the class KeySnapshotTest method testGlobalKeySet.

@Test
public void testGlobalKeySet() {
    ArrayList<Key> madeKeys = new ArrayList<>();
    try {
        Futures fs = new Futures();
        for (int i = 0; i < 100; ++i) {
            Key k = Key.make("key" + i);
            madeKeys.add(k);
            DKV.put(k, new IcedInt(i), fs, true);
        }
        for (int i = 0; i < 100; ++i) {
            Key k = Key.make(H2O.SELF);
            madeKeys.add(k);
            DKV.put(k, new IcedInt(i), fs, true);
        }
        fs.blockForPending();
        Key[] keys = KeySnapshot.globalSnapshot().keys();
        assertEquals(100, keys.length);
    } finally {
        for (Key k : madeKeys) DKV.remove(k);
    }
}
Also used : IcedInt(water.util.IcedInt) ArrayList(java.util.ArrayList)

Example 2 with IcedInt

use of water.util.IcedInt in project h2o-3 by h2oai.

the class KeySnapshotTest method testFetchAll.

@Test
public void testFetchAll() {
    Key[] userKeys = new Key[200];
    Key[] systemKeys = new Key[200];
    Futures fs = new Futures();
    try {
        for (int i = 0; i < (userKeys.length >> 1); ++i) {
            DKV.put(userKeys[i] = Key.make("key" + i), new IcedInt(i), fs, false);
            systemKeys[i] = Key.make(H2O.SELF);
            DKV.put(systemKeys[i], new Value(systemKeys[i], new IcedInt(i)));
        }
        for (int i = (userKeys.length >> 1); i < userKeys.length; ++i) {
            DKV.put(userKeys[i] = Key.make("key" + i), new IcedDouble(i), fs, false);
            systemKeys[i] = Key.make(H2O.SELF);
            DKV.put(systemKeys[i], new Value(systemKeys[i], new IcedDouble(i)));
        }
        fs.blockForPending();
        KeySnapshot s = KeySnapshot.globalSnapshot();
        Map<String, Iced> all = s.fetchAll(Iced.class, true);
        assertTrue(all.isEmpty());
        all = s.fetchAll(Iced.class);
        assertEquals(userKeys.length, all.size());
        Map<String, IcedInt> ints = s.fetchAll(IcedInt.class);
        Map<String, IcedDouble> doubles = s.fetchAll(IcedDouble.class);
        assertEquals(userKeys.length >> 1, ints.size());
        assertEquals(userKeys.length >> 1, doubles.size());
    } finally {
        for (int i = 0; i < userKeys.length; ++i) {
            if (userKeys[i] != null)
                DKV.remove(userKeys[i]);
            if (systemKeys[i] != null)
                DKV.remove(systemKeys[i]);
        }
    }
}
Also used : IcedDouble(water.util.IcedDouble) IcedInt(water.util.IcedInt)

Example 3 with IcedInt

use of water.util.IcedInt in project h2o-3 by h2oai.

the class KeySnapshotTest method testLocalKeySet.

@Test
public void testLocalKeySet() {
    ArrayList<Key> madeKeys = new ArrayList<>();
    int homeKeys = 0;
    Futures fs = new Futures();
    try {
        for (int i = 0; i < 200; ++i) {
            Key k = Key.make("key" + i);
            madeKeys.add(k);
            DKV.put(k, new IcedInt(i), fs, true);
            if (k.home())
                ++homeKeys;
            k = Key.make(H2O.SELF);
            madeKeys.add(k);
            DKV.put(k, new IcedInt(i), fs, true);
        }
        fs.blockForPending();
        Key[] keys = KeySnapshot.localSnapshot().keys();
        assertEquals(homeKeys, keys.length);
        for (Key k : keys) assertTrue(k.home());
    } finally {
        for (Key k : madeKeys) DKV.remove(k);
    }
}
Also used : IcedInt(water.util.IcedInt) ArrayList(java.util.ArrayList)

Aggregations

IcedInt (water.util.IcedInt)3 ArrayList (java.util.ArrayList)2 IcedDouble (water.util.IcedDouble)1