Package xbird.storage.index

Examples of xbird.storage.index.SortedStaticHash$HashPageHeader


    public void xtestExtHash_Large3001Buckets() throws IOException, DbException {
        File tmpFile = File.createTempFile("exthash", ".tmp");
        tmpFile.deleteOnExit();
        int buckets = Primes.findLeastPrimeNumber(3000);
        SortedStaticHash hash = new SortedStaticHash(tmpFile, buckets);
        hash.create(false);

        List<byte[]> list = new ArrayList<byte[]>(REPEAT);
        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            String d = Double.toString(random.nextLong());
            byte[] b = StringUtils.getBytes(d);
            Key k = new Key(b);
            Value v = new Value(b);
            Assert.assertNull(hash.addValue(k, v));
            list.add(b);
        }
        System.err.println(sw1);

        hash.flush(true, true);

        StopWatch sw2 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), hash.findValue(new Key(b)));
        }
        System.err.println(sw2);
        hash.drop();
    }
View Full Code Here


    public void xtestExtHash_Large3001Buckets_2KPage() throws IOException, DbException {
        File tmpFile = File.createTempFile("exthash", ".tmp");
        tmpFile.deleteOnExit();
        int buckets = Primes.findLeastPrimeNumber(3000);
        SortedStaticHash hash = new SortedStaticHash(tmpFile, 1024 * 2, buckets);
        hash.create(false);

        List<byte[]> list = new ArrayList<byte[]>(REPEAT);
        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets_2kPage] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            String d = Double.toString(random.nextLong());
            byte[] b = StringUtils.getBytes(d);
            Key k = new Key(b);
            Value v = new Value(b);
            Assert.assertNull(hash.addValue(k, v));
            list.add(b);
        }
        System.err.println(sw1);

        hash.flush(true, true);

        StopWatch sw2 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets_2kPage] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), hash.findValue(new Key(b)));
        }
        System.err.println(sw2);
        hash.drop();
    }
View Full Code Here

    public void xtestExtHash_Default1021Buckets() throws IOException, DbException {
        File tmpFile = File.createTempFile("exthash", ".tmp");
        tmpFile.deleteOnExit();
        int buckets = Primes.findLeastPrimeNumber(REPEAT / 100);
        SortedStaticHash hash = new SortedStaticHash(tmpFile, buckets);
        hash.create(false);

        List<byte[]> list = new ArrayList<byte[]>(REPEAT);
        Random random = new Random(54552542345L);
        StopWatch sw1 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Construction of " + REPEAT);
        for(int i = 0; i < REPEAT; i++) {
            String d = Double.toString(random.nextLong());
            byte[] b = StringUtils.getBytes(d);
            Key k = new Key(b);
            Value v = new Value(b);
            Assert.assertNull(hash.addValue(k, v));
            list.add(b);
        }
        System.err.println(sw1);

        hash.flush(true, true);

        StopWatch sw2 = new StopWatch("[SortedStaticHash_with_" + buckets
                + "_buckets] Index Search of " + (REPEAT / 2));
        for(int i = REPEAT - 1; i >= 0; i -= 2) {
            byte[] b = list.get(i);
            Assert.assertEquals("#" + i, new Value(b), hash.findValue(new Key(b)));
        }
        System.err.println(sw2);
        hash.drop();
    }
View Full Code Here

TOP

Related Classes of xbird.storage.index.SortedStaticHash$HashPageHeader

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.