Package org.fusesource.hawtdb.internal.util

Examples of org.fusesource.hawtdb.internal.util.Ranges


            os.close();
        } catch (IOException e) {
            throw new IndexException(e);
        }

        Ranges pages = eos.getPages();
        pages.remove(page);
        if (pages.isEmpty()) {
            return Collections.emptyList();
        }

        return pages.values();
    }
View Full Code Here


     */
    public void close() throws IOException {
        if (pageFile != null) {
            pageFile.flush();
            if( !isReadOnly() && pageFile.storeFreePages ) {
                Ranges ranges = pageFile.allocator().getFreeRanges().copy();
                int freePageExtent = pageFile.alloc();
                DataOutputStream os = new DataOutputStream(new ExtentOutputStream(pageFile, freePageExtent, (short)1, (short)200));
                ranges.writeExternal(os);
                os.close();
                writePageFileHeader(freePageExtent);
            }
            pageFile.flush();
            pageFile = null;
View Full Code Here

public class RangesTest {

    @Test
    public void test() {

        Ranges ranges = new Ranges();
       
        // Example of a simple range merges..
        ranges.add(0, 5);
        ranges.add(15, 5);
        ranges.add(5,10);
        assertEquals(ranges(range(0,20)), ranges.toArrayList());

        // Remove which splits an existing range into 2.
        ranges.remove(5,10);
        assertEquals(ranges(range(0,5),range(15,20)), ranges.toArrayList());
       
        // overlapping add...
        ranges.add(4,12);
        assertEquals(ranges(range(0,20)), ranges.toArrayList());

        // Removes are idempotent
        ranges.remove(5,10);
        assertEquals(ranges(range(0,5),range(15,20)), ranges.toArrayList());
        ranges.remove(5,10);
        assertEquals(ranges(range(0,5),range(15,20)), ranges.toArrayList());

        // Adds are idempotent
        ranges.add(5,10);
        assertEquals(ranges(range(0,20)), ranges.toArrayList());
        ranges.add(5,10);
        assertEquals(ranges(range(0,20)), ranges.toArrayList());
    }
View Full Code Here

TOP

Related Classes of org.fusesource.hawtdb.internal.util.Ranges

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.