All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.jena.tdb.index.bplustree.BPlusTreeRewriterUtils Maven / Gradle / Ivy

Go to download

TDB is a storage subsystem for Jena and ARQ, it is a native triple store providing persistent storage of triples/quads.

There is a newer version: 4.10.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.jena.tdb.index.bplustree;

import java.util.Iterator ;
import java.util.List ;

import org.apache.jena.atlas.iterator.Iter ;
import org.apache.jena.atlas.lib.Pair ;
import org.apache.jena.tdb.base.record.Record ;
import org.apache.jena.tdb.base.recordbuffer.RecordBufferPage ;
import org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr ;

class BPlusTreeRewriterUtils
{

    static String divider = "----------------------------------------" ;
    static String nextDivider = null ;

    static Iterator> summarizeDataBlocks(Iterator> iter, RecordBufferPageMgr recordPageMgr)
    {
        divider() ;
        List> x = Iter.toList(iter) ;
        for (Pair pair : x )
        {
            RecordBufferPage rbp = recordPageMgr.getRead(pair.car()) ;
            System.out.printf("%s -- RecordBufferPage[id=%d,link=%d] (%d) -> [%s]\n", pair, rbp.getId(), rbp.getLink(), rbp.getCount(), rbp.getRecordBuffer().getHigh() ) ;
            recordPageMgr.release(rbp) ;
        }
        return x.iterator() ;
    }

    static Iterator> summarizeIndexBlocks(Iterator> iter2, BPTreeNodeMgr bptNodeMgr)
    {
        divider() ;
        List> x = Iter.toList(iter2) ;
        for (Pair pair : x )
        {
            BPTreeNode bpNode = bptNodeMgr.getRead(pair.car(), BPlusTreeParams.RootParent) ;
            
            String hr = "null" ;
            if ( ! bpNode.getRecordBuffer().isEmpty() ) 
                hr = bpNode.getRecordBuffer().getHigh().toString() ;
            
            System.out.printf("%s -- BPTreeNode: %d (%d) -> [%s]\n", pair, bpNode.getId(), bpNode.getCount(), hr) ;
            bptNodeMgr.release(bpNode) ;
        }
        return x.iterator() ;
    }

    private static Iterator> printDataBlocks(Iterator> iter, RecordBufferPageMgr recordPageMgr)
    {
        divider() ;
        List> x = Iter.toList(iter) ;
        System.out.printf(">>Packed data blocks\n") ;
        for (Pair pair : x )
        {
            System.out.printf("  %s\n",pair) ;
            RecordBufferPage rbp = recordPageMgr.getRead(pair.car()) ;
            //System.out.printf("RecordBufferPage[id=%d,link=%d] %d\n", rbp.getId(), rbp.getLink(), rbp.getCount() ) ;
            System.out.println(rbp) ;
            recordPageMgr.release(rbp) ;
        }
        System.out.printf("<> printIndexBlocks(Iterator> iter2, BPTreeNodeMgr bptNodeMgr)
    {
        divider() ;
        List> x = Iter.toList(iter2) ;
        System.out.printf(">>Packed index blocks\n") ;
        for (Pair pair : x )
        {
            System.out.printf("  %s\n",pair) ;
            BPTreeNode bpNode = bptNodeMgr.getRead(pair.car(), BPlusTreeParams.RootParent) ;
            bpNode.setIsLeaf(true) ;
            System.out.printf("BPTreeNode: %d\n", bpNode.getId()) ;
            System.out.println(bpNode) ;
            bptNodeMgr.release(bpNode) ;
        }
        System.out.printf("<




© 2015 - 2024 Weber Informatics LLC | Privacy Policy