Package net.yacy.kelondro.blob

Examples of net.yacy.kelondro.blob.MapDataMining$mapIterator


        if (!parentDir.exists()) {
      if(!parentDir.mkdirs())
        Log.logWarning("yacySeedDB", "could not create directories for "+ seedDBFile.getParent());
    }
        try {
            return new MapDataMining(seedDBFile, Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, sortFields, longaccFields, doubleaccFields, this);
        } catch (final Exception e) {
            // try again
            FileUtils.deletedelete(seedDBFile);
            try {
                return new MapDataMining(seedDBFile, Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, sortFields, longaccFields, doubleaccFields, this);
            } catch (IOException e1) {
                Log.logException(e1);
                System.exit(-1);
                return null;
            }
View Full Code Here


            final File yacyDBPath = new File(homePath, "DATA/INDEX/freeworld/NETWORK");

            final String[] dbFileNames = {"seed.new.db","seed.old.db","seed.pot.db"};
            for (final String dbFileName : dbFileNames) {
                final File dbFile = new File(yacyDBPath,dbFileName);
                final MapDataMining db = new MapDataMining(dbFile, Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, yacySeedDB.sortFields, yacySeedDB.longaccFields, yacySeedDB.doubleaccFields, null);

                MapDataMining.mapIterator it;
                it = db.maps(true, false);
                while (it.hasNext()) {
                    final Map<String, String> dna = it.next();
                    String peerHash = dna.get("key");
                    if (peerHash.length() < Word.commonHashLength) {
                        final String peerName = dna.get("Name");
                        final String peerIP = dna.get("IP");
                        final String peerPort = dna.get("Port");

                        while (peerHash.length() < Word.commonHashLength) { peerHash = peerHash + "_"; }
                        System.err.println("Invalid Peer-Hash found in '" + dbFileName + "': " + peerName + ":" +  peerHash + ", http://" + peerIP + ":" + peerPort);
                    }
                }
                db.close();
            }
        } catch (final Exception e) {
            Log.logException(e);
        }
    }
View Full Code Here

            final File yacyDBPath = new File(homePath, "DATA/INDEX/freeworld/NETWORK");

            final String[] dbFileNames = {"seed.new.db","seed.old.db","seed.pot.db"};
            for (final String dbFileName : dbFileNames) {
                final File dbFile = new File(yacyDBPath,dbFileName);
                final MapDataMining db = new MapDataMining(dbFile, Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, SeedDB.sortFields, SeedDB.longaccFields, SeedDB.doubleaccFields, null);

                MapDataMining.mapIterator it;
                it = db.maps(true, false);
                while (it.hasNext()) {
                    final Map<String, String> dna = it.next();
                    String peerHash = dna.get("key");
                    if (peerHash.length() < Word.commonHashLength) {
                        final String peerName = dna.get("Name");
                        final String peerIP = dna.get("IP");
                        final String peerPort = dna.get("Port");

                        while (peerHash.length() < Word.commonHashLength) { peerHash = peerHash + "_"; }
                        System.err.println("Invalid Peer-Hash found in '" + dbFileName + "': " + peerName + ":" +  peerHash + ", http://" + peerIP + ":" + peerPort);
                    }
                }
                db.close();
            }
        } catch (final Exception e) {
            Log.logException(e);
        }
    }
View Full Code Here

        if (!parentDir.exists()) {
      if(!parentDir.mkdirs())
        Log.logWarning("yacySeedDB", "could not create directories for "+ seedDBFile.getParent());
    }
        try {
            return new MapDataMining(seedDBFile, Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, sortFields, longaccFields, doubleaccFields, this);
        } catch (final Exception e) {
            // try again
            FileUtils.deletedelete(seedDBFile);
            try {
                return new MapDataMining(seedDBFile, Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, sortFields, longaccFields, doubleaccFields, this);
            } catch (final IOException e1) {
                Log.logException(e1);
                System.exit(-1);
                return null;
            }
View Full Code Here

    public void testMapIterator() {
        assertTrue(makeEmptyMapIterator() instanceof Unmodifiable);
    }

    public void testDecorateFactory() {
        MapIterator it = makeFullMapIterator();
        assertSame(it, UnmodifiableMapIterator.decorate(it));

        it = ((BidiMap) getMap()).mapIterator();
        assertTrue(it != UnmodifiableMapIterator.decorate(it));
View Full Code Here

        Object newValue1 = getOtherValues()[0];
        Object newValue2 = getOtherValues()[1];

        resetFull();
        BidiMap bidi = (BidiMap) map;
        MapIterator it = bidi.mapIterator();
        assertEquals(true, it.hasNext());
        Object key1 = it.next();

        if (isSetValueSupported() == false) {
            try {
                it.setValue(newValue1);
                fail();
            } catch (UnsupportedOperationException ex) {
            }
            return;
        }

        it.setValue(newValue1);
        confirmed.put(key1, newValue1);
        assertSame(key1, it.getKey());
        assertSame(newValue1, it.getValue());
        assertEquals(true, bidi.containsKey(key1));
        assertEquals(true, bidi.containsValue(newValue1));
        assertEquals(newValue1, bidi.get(key1));
        verify();

        it.setValue(newValue1)// same value - should be OK
        confirmed.put(key1, newValue1);
        assertSame(key1, it.getKey());
        assertSame(newValue1, it.getValue());
        assertEquals(true, bidi.containsKey(key1));
        assertEquals(true, bidi.containsValue(newValue1));
        assertEquals(newValue1, bidi.get(key1));
        verify();

        Object key2 = it.next();
        it.setValue(newValue2);
        confirmed.put(key2, newValue2);
        assertSame(key2, it.getKey());
        assertSame(newValue2, it.getValue());
        assertEquals(true, bidi.containsKey(key2));
        assertEquals(true, bidi.containsValue(newValue2));
        assertEquals(newValue2, bidi.get(key2));
        verify();
       
        // at this point
        // key1=newValue1, key2=newValue2
        try {
            it.setValue(newValue1)// should remove key1
            fail();
        } catch (IllegalArgumentException ex) {
            return// simplest way of dealing with tricky situation
        }
        confirmed.put(key2, newValue1);
        AbstractTestBidiMap.this.confirmed.remove(key1);
        assertEquals(newValue1, it.getValue());
        assertEquals(true, bidi.containsKey(it.getKey()));
        assertEquals(true, bidi.containsValue(newValue1));
        assertEquals(newValue1, bidi.get(it.getKey()));
        assertEquals(false, bidi.containsKey(key1));
        assertEquals(false, bidi.containsValue(newValue2));
        verify();
           
        // check for ConcurrentModification
        it.next()// if you fail here, maybe you should be throwing an IAE, see above
        if (isRemoveSupported()) {
            it.remove();
        }
    }
View Full Code Here

    public void testEmptyMapIterator() {
        if (supportsEmptyIterator() == false) {
            return;
        }

        MapIterator it = makeEmptyMapIterator();
        Map map = getMap();
        assertEquals(false, it.hasNext());
       
        // next() should throw a NoSuchElementException
        try {
            it.next();
            fail();
        } catch (NoSuchElementException ex) {
        }
       
        // getKey() should throw an IllegalStateException
        try {
            it.getKey();
            fail();
        } catch (IllegalStateException ex) {
        }
       
        // getValue() should throw an IllegalStateException
        try {
            it.getValue();
            fail();
        } catch (IllegalStateException ex) {
        }

        if (supportsSetValue() == false) {
            // setValue() should throw an UnsupportedOperationException/IllegalStateException
            try {
                it.setValue(addSetValues()[0]);
                fail();
            } catch (UnsupportedOperationException ex) {
            } catch (IllegalStateException ex) {
            }
        } else {
            // setValue() should throw an IllegalStateException
            try {
                it.setValue(addSetValues()[0]);
                fail();
            } catch (IllegalStateException ex) {
            }
        }
    }
View Full Code Here

    public void testFullMapIterator() {
        if (supportsFullIterator() == false) {
            return;
        }

        MapIterator it = makeFullMapIterator();
        Map map = getMap();
        assertEquals(true, it.hasNext());

        assertEquals(true, it.hasNext());
        Set set = new HashSet();
        while (it.hasNext()) {
            // getKey
            Object key = it.next();
            assertSame("it.next() should equals getKey()", key, it.getKey());
            assertTrue("Key must be in map", map.containsKey(key));
            assertTrue("Key must be unique", set.add(key));
           
            // getValue
            Object value = it.getValue();
            if (isGetStructuralModify() == false) {
                assertSame("Value must be mapped to key", map.get(key), value);
            }
            assertTrue("Value must be in map", map.containsValue(value));
View Full Code Here

            return;
        }

        Object newValue = addSetValues()[0];
        Object newValue2 = (addSetValues().length == 1 ? addSetValues()[0] : addSetValues()[1]);
        MapIterator it = makeFullMapIterator();
        Map map = getMap();
        Map confirmed = getConfirmedMap();
        assertEquals(true, it.hasNext());
        Object key = it.next();
        Object value = it.getValue();

        if (supportsSetValue() == false) {
            try {
                it.setValue(newValue);
                fail();
            } catch (UnsupportedOperationException ex) {
            }
            return;
        }
        Object old = it.setValue(newValue);
        confirmed.put(key, newValue);
        assertSame("Key must not change after setValue", key, it.getKey());
        assertSame("Value must be changed after setValue", newValue, it.getValue());
        assertSame("setValue must return old value", value, old);
        assertEquals("Map must contain key", true, map.containsKey(key));
        // test against confirmed, as map may contain value twice
        assertEquals("Map must not contain old value", confirmed.containsValue(old), map.containsValue(old));
        assertEquals("Map must contain new value", true, map.containsValue(newValue));
        verify();

        it.setValue(newValue)// same value - should be OK
        confirmed.put(key, newValue);
        assertSame("Key must not change after setValue", key, it.getKey());
        assertSame("Value must be changed after setValue", newValue, it.getValue());
        verify();

        it.setValue(newValue2)// new value
        confirmed.put(key, newValue2);
        assertSame("Key must not change after setValue", key, it.getKey());
        assertSame("Value must be changed after setValue", newValue2, it.getValue());
        verify();
    }
View Full Code Here

        verify();
    }

    //-----------------------------------------------------------------------
    public void testRemove() { // override
        MapIterator it = makeFullMapIterator();
        Map map = getMap();
        Map confirmed = getConfirmedMap();
        assertEquals(true, it.hasNext());
        Object key = it.next();

        if (supportsRemove() == false) {
            try {
                it.remove();
                fail();
            } catch (UnsupportedOperationException ex) {
            }
            return;
        }

        it.remove();
        confirmed.remove(key);
        assertEquals(false, map.containsKey(key));
        verify();

        try {
            it.remove()// second remove fails
        } catch (IllegalStateException ex) {
        }
        verify();
    }
View Full Code Here

TOP

Related Classes of net.yacy.kelondro.blob.MapDataMining$mapIterator

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.