示例#1
0
  /**
   * Prints all leaf pages
   *
   * @param currentPageId
   * @param keyType
   * @throws IOException
   * @throws ConstructPageException
   * @throws IteratorException
   * @throws InvalidFrameNumberException
   * @throws HashEntryNotFoundException
   * @throws PageUnpinnedException
   * @throws ReplacerException
   */
  private static void _printAllLeafPages(PageID currentPageId, int keyType)
      throws IOException, ConstructPageException, IteratorException, InvalidFrameNumberException,
          HashEntryNotFoundException, PageUnpinnedException, ReplacerException {

    BTSortedPage sortedPage = new BTSortedPage(currentPageId, keyType);

    if (sortedPage.getType() == NodeType.INDEX) {
      BTIndexPage indexPage = new BTIndexPage((Page) sortedPage, keyType);

      _printAllLeafPages(indexPage.getPrevPage(), keyType);

      TID genid = new TID();
      for (KeyDataEntry entry = indexPage.getFirst(genid);
          entry != null;
          entry = indexPage.getNext(genid)) {
        _printAllLeafPages(((IndexData) entry.data).getData(), keyType);
      }
    }

    if (sortedPage.getType() == NodeType.LEAF) {
      printPage(currentPageId, keyType);
    }

    SystemDefs.JavabaseBM.unpinPage(currentPageId, true /*dirty*/);
  }
示例#2
0
  /**
   * Prints tree
   *
   * @param currentPageId
   * @param prefix
   * @param i
   * @param keyType
   * @throws IOException
   * @throws ConstructPageException
   * @throws IteratorException
   * @throws HashEntryNotFoundException
   * @throws InvalidFrameNumberException
   * @throws PageUnpinnedException
   * @throws ReplacerException
   */
  private static void _printTree(PageID currentPageId, String prefix, int i, int keyType)
      throws IOException, ConstructPageException, IteratorException, HashEntryNotFoundException,
          InvalidFrameNumberException, PageUnpinnedException, ReplacerException {

    BTSortedPage sortedPage = new BTSortedPage(currentPageId, keyType);
    prefix = prefix + "       ";
    i++;
    if (sortedPage.getType() == NodeType.INDEX) {
      BTIndexPage indexPage = new BTIndexPage((Page) sortedPage, keyType);

      System.out.println(i + prefix + indexPage.getPrevPage());
      _printTree(indexPage.getPrevPage(), prefix, i, keyType);

      TID genid = new TID();
      for (KeyDataEntry entry = indexPage.getFirst(genid);
          entry != null;
          entry = indexPage.getNext(genid)) {
        System.out.println(i + prefix + (IndexData) entry.data);
        _printTree(((IndexData) entry.data).getData(), prefix, i, keyType);
      }
    }
    SystemDefs.JavabaseBM.unpinPage(currentPageId, true /*dirty*/);
  }