~ubuntu-branches/ubuntu/natty/electric/natty

« back to all changes in this revision

Viewing changes to com/sun/electric/database/geometry/btree/MemoryPageStorage.java

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2010-01-09 16:26:04 UTC
  • mfrom: (1.1.4 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100109162604-1ypvmy8ijmlc6oq7
Tags: 8.10-1
* New upstream version.
* debian/control
  - Add libjava3d-java and quilt build dependencies.
  - Update standards version to 3.8.3.
  - Add libjava3d-java as recommends to binary package.
* debian/rules
  - Use quilt patch system instead of simple patchsys.
  - Add java3d related jar files to DEB_JARS.
* debian/patches/*
  - Update as per current upstream source. Convert to quilt.
* debian/ant.properties
  - Do not disable 3D plugin anymore.
  - Use new property to disable compilation of OS X related classes.
* debian/wrappers/electric
  - Add java3d related jar files to runtime classpath.
* debian/README.source
  - Change text to the appropriate one for quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- tab-width: 4 -*-
 
2
 *
 
3
 * Electric(tm) VLSI Design System
 
4
 *
 
5
 * File: MemoryPageStorage.java
 
6
 *
 
7
 * Copyright (c) 2009 Sun Microsystems and Static Free Software
 
8
 *
 
9
 * Electric(tm) is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU Lesser General Public License as published by
 
11
 * the Free Software Foundation; either version 3 of the License, or
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * Electric(tm) is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU Lesser General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU Lesser General Public License
 
20
 * along with Electric(tm); see the file COPYING.  If not, write to
 
21
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 
22
 * Boston, Mass 02111-1307, USA.
 
23
 */
 
24
package com.sun.electric.database.geometry.btree;
 
25
 
 
26
/** A PageStorage that uses plain old memory. */
 
27
public class MemoryPageStorage extends CachingPageStorage {
 
28
 
 
29
    private       CachedPageImpl[] pages;
 
30
    private       int              numpages;
 
31
 
 
32
    public MemoryPageStorage(int pagesize) {
 
33
        super(pagesize);
 
34
        this.numpages = 0;
 
35
        this.pages = new CachedPageImpl[1];
 
36
    }
 
37
 
 
38
    public int getNumPages() { return numpages; }
 
39
    public int createPage() {
 
40
        if (numpages >= pages.length) {
 
41
            CachedPageImpl[] newpages = new CachedPageImpl[pages.length*2];
 
42
            System.arraycopy(pages, 0, newpages, 0, pages.length);
 
43
            pages = newpages;
 
44
        }
 
45
        pages[numpages] = new CachedPageImpl(numpages);
 
46
        return numpages++;
 
47
    }
 
48
    /** no-op */
 
49
    public void fsync(int pageid) { }
 
50
    /** no-op */
 
51
    public void fsync() { }
 
52
    public void writePage(int pageid, byte[] buf, int ofs) {
 
53
        System.arraycopy(buf, ofs, pages[pageid].buf, 0, getPageSize());
 
54
    }
 
55
    public void readPage(int pageid, byte[] buf, int ofs) {
 
56
        System.arraycopy(pages[pageid].buf, 0, buf, ofs, getPageSize());
 
57
    }
 
58
    public synchronized void close() { pages = null; }
 
59
    public CachedPage getPage(int pageid, boolean readBytes) { return pages[pageid]; }
 
60
 
 
61
    private class CachedPageImpl extends CachedPage {
 
62
        private int pageid;
 
63
        private byte[] buf;
 
64
        private boolean dirty;
 
65
        public CachedPageImpl(int pageid) { this.pageid = pageid; this.buf = new byte[getPageSize()]; }
 
66
        public byte[] getBuf() { return buf; }
 
67
        public int    getPageId() { return pageid; }
 
68
        public void touch() { }
 
69
        public void setDirty() { this.dirty = true; }
 
70
        public void flush() { this.dirty = false; }
 
71
        public boolean isDirty() { return dirty; }
 
72
    }
 
73
}
 
 
b'\\ No newline at end of file'