Package org.exist.storage.index

Examples of org.exist.storage.index.BFile$BFilePageHeader


            broker.sync(Sync.MAJOR_SYNC);
           
            Txn txn = mgr.beginTransaction();
            System.out.println("Transaction started ...");
           
            BFile collectionsDb = (BFile) ((NativeBroker)broker).getStorage(NativeBroker.COLLECTIONS_DBX_ID);
            BrokerPool.FORCE_CORRUPTION = true;
           
            for (int i = 1; i < 1001; i++) {
                String value = "test" + i;
                byte[] data = value.getBytes(UTF_8);
                collectionsDb.put(txn, new Value(data), new FixedByteArray(data, 0, data.length), true);
            }
           
            byte[] replacement = "new value".getBytes(UTF_8);
            for (int i = 1; i < 101; i++) {
                String value = "test" + i;
                byte[] data = value.getBytes(UTF_8);
                collectionsDb.put(txn, new Value(data), new FixedByteArray(replacement, 0, replacement.length), true);
            }
            mgr.commit(txn);
           
            Writer writer = new StringWriter();
            collectionsDb.dump(writer);
            System.out.println(writer.toString());
        } catch (Exception e) {           
            fail(e.getMessage());           
        } finally {
            pool.release(broker);
View Full Code Here


    public void testRead() {
        BrokerPool.FORCE_CORRUPTION = false;
        DBBroker broker = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            BFile collectionsDb = (BFile)((NativeBroker)broker).getStorage(NativeBroker.COLLECTIONS_DBX_ID);
            Writer writer = new StringWriter();
            collectionsDb.dump(writer);
            System.out.println(writer.toString());
           
            for (int i = 1; i < 1001; i++) {
                String key = "test" + i;
                byte[] data = key.getBytes(UTF_8);
                Value value = collectionsDb.get(new Value(data));
                if (value == null)
                    System.out.println("Key " + key + " not found.");
                else
                    System.out.println(new String(value.data(), value.start(), value.getLength(), UTF_8));
            }
View Full Code Here

            broker.sync(Sync.MAJOR_SYNC);
           
            Txn txn = mgr.beginTransaction();
            System.out.println("Transaction started ...");
           
            BFile collectionsDb = (BFile) ((NativeBroker)broker).getStorage(NativeBroker.COLLECTIONS_DBX_ID);
            BrokerPool.FORCE_CORRUPTION = true;
           
            Value key = new Value("test".getBytes());
           
            byte[] data = "_HELLO_YOU_".getBytes();
            collectionsDb.put(txn, key, new FixedByteArray(data, 0, data.length), true);
           
            for (int i = 1; i < 101; i++) {
                String value = "_HELLO_" + i;
                data = value.getBytes(UTF_8);
                collectionsDb.append(txn, key, new FixedByteArray(data, 0, data.length));
            }
           
            mgr.commit(txn);
           
            // start a new transaction that will not be committed and thus undone
            txn = mgr.beginTransaction();           
           
            for (int i = 1001; i < 2001; i++) {
                String value = "_HELLO_" + i;
                data = value.getBytes(UTF_8);
                collectionsDb.append(txn, key, new FixedByteArray(data, 0, data.length));
            }
      
            collectionsDb.remove(txn, key);
           
            mgr.getJournal().flushToLog(true);

        } catch (Exception e) {
            fail(e.getMessage());           
View Full Code Here

    public void testRead() {
        BrokerPool.FORCE_CORRUPTION = false;
        DBBroker broker = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            BFile collectionsDb = (BFile)((NativeBroker)broker).getStorage(NativeBroker.COLLECTIONS_DBX_ID);
           
            Value key = new Value("test".getBytes());
            Value val = collectionsDb.get(key);
            System.out.println(new String(val.data(), val.start(), val.getLength()));
        } catch (Exception e) {
            fail(e.getMessage());
        } finally {
            pool.release(broker);
View Full Code Here

    }

    @Override
    public void open() throws DatabaseConfigurationException {
        try {
            db = new BFile(pool, (byte) 0, false, dataFile, pool.getCacheManager(), 1.4, 0.01, 0.07);
        } catch (DBException e) {
            throw new DatabaseConfigurationException("Failed to create index file: " + dataFile.getAbsolutePath() + ": " +
                e.getMessage());
        }
        if (LOG.isDebugEnabled())
View Full Code Here

        final double cacheGrowth = NativeTextEngine.DEFAULT_WORD_CACHE_GROWTH;
        final double cacheKeyThresdhold = NativeTextEngine.DEFAULT_WORD_KEY_THRESHOLD;
        final double cacheValueThresHold = NativeTextEngine.DEFAULT_WORD_VALUE_THRESHOLD;
        LOG.debug("Creating '" + dataFile.getName() + "'...");
        try {
            db = new BFile(pool, (byte)0, false, dataFile, pool.getCacheManager(),
                cacheGrowth, cacheKeyThresdhold, cacheValueThresHold);
        } catch (final DBException e) {
            throw new DatabaseConfigurationException("Failed to create index file: " + dataFile.getAbsolutePath() + ": " +
                e.getMessage());
        }
View Full Code Here

        //use inheritance if necessary !
        //TODO : read from configuration (key ?)
        final double cacheGrowth = NativeValueIndex.DEFAULT_VALUE_CACHE_GROWTH;
        final double cacheKeyThresdhold = NativeValueIndex.DEFAULT_VALUE_KEY_THRESHOLD;
        final double cacheValueThresHold = NativeValueIndex.DEFAULT_VALUE_VALUE_THRESHOLD;
        BFile nativeFile = (BFile)config.getProperty(getConfigKeyForFile());
        if (nativeFile == null) {
            //use inheritance
            final File file = new File(dataDir + File.separatorChar + getFileName());
            LOG.debug("Creating '" + file.getName() + "'...");
            nativeFile = new BFile(broker.getBrokerPool(), id, false, file,
                broker.getBrokerPool().getCacheManager(), cacheGrowth,
                cacheKeyThresdhold, cacheValueThresHold);
            config.setProperty(getConfigKeyForFile(), nativeFile);
        }
        dbValues = nativeFile;
View Full Code Here

    private void genBufferStatus(BrokerPool instance) throws SAXException {
        final AttributesImpl atts = new AttributesImpl();
        this.contentHandler.startElement(NAMESPACE, "buffers", PREFIX + ":buffers", atts);
        final Configuration conf = instance.getConfiguration();
        BFile db;
        db = (BFile) conf.getProperty(CollectionStore.FILE_KEY_IN_CONFIG);
        genBufferDetails(db.getIndexBufferStats(), db.getDataBufferStats(), "Collections storage ("+ db.getFile().getName() + ")");
        final DOMFile dom = (DOMFile) conf.getProperty(DOMFile.CONFIG_KEY_FOR_FILE);
        genBufferDetails(dom.getIndexBufferStats(), dom.getDataBufferStats(), "Resource storage ("+ dom.getFile().getName() + ")");
        db = (BFile) conf.getProperty(NativeValueIndex.FILE_KEY_IN_CONFIG);
        if (db != null)
            {genBufferDetails(db.getIndexBufferStats(), db.getDataBufferStats(), "Values index ("+ db.getFile().getName() + ")");}
        db = (BFile) conf.getProperty(NativeTextEngine.FILE_KEY_IN_CONFIG);
        if (db != null)
            {genBufferDetails(db.getIndexBufferStats(), db.getDataBufferStats(), "Fulltext index ("+ db.getFile().getName() + ")");}   
        this.contentHandler.endElement(NAMESPACE, "buffers", PREFIX + ":buffers");
    }
View Full Code Here

     */
    public static void generateIndexStatistics(Configuration conf, Map<String, IndexStats> indexStats) {
        final DOMFile dom = (DOMFile) conf.getProperty(DOMFile.CONFIG_KEY_FOR_FILE);
        if(dom != null)
            {indexStats.put(DOMFile.FILE_NAME, new IndexStats(dom));}
        BFile db = (BFile) conf.getProperty(CollectionStore.FILE_KEY_IN_CONFIG);
        if(db != null)
            {indexStats.put(CollectionStore.FILE_NAME, new IndexStats(db));
        db = (BFile) conf.getProperty(NativeValueIndex.FILE_KEY_IN_CONFIG);
        if(db != null)
            {indexStats.put(NativeValueIndex.FILE_NAME, new IndexStats(db));}     
View Full Code Here

TOP

Related Classes of org.exist.storage.index.BFile$BFilePageHeader

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.