📄 libgist.java
字号:
// Libgist.java// Copyright (c) 1998, Regents of the University of California// $Id: Libgist.java,v 1.3 1999/12/14 06:07:09 marcel Exp $import javax.swing.*;import java.lang.*;import java.awt.Graphics;import java.awt.Color;/* * Libgist.java - * Interface class to libgist, enhanced with a couple of extra functions to support amdb. * This class only works on one index at a time (has a single global gist_m object at * the C++ layer). */class Libgist {// array of extension info recordspublic static ExtensionInfo[] extInfo;private static ExtensionInfo[]getExtensionInfo(){ return libGetExtensionInfo();}static { System.loadLibrary("amdb"); libInit(); extInfo = getExtensionInfo();}public static voidcleanup(){ libCleanup();}static boolean closed = true; // no Libgist open at beginning// Per-node tree statistics, set by getNodeStats.// The size is increased dynamically, if necessary, to match the current size of// the tree. 'nodeStats' holds the node stats and 'display stats' holds the // particular value that treeView is supposed to display (extracted from 'nodeStats').public static float[] displayStats = new float[1];//public static NodeStats[] nodeStats = new NodeStats[1]; // currently not used!public static int nodeCnt = 0; // set to the node count by abovementioned functions/* * standard libgist interface functions */// all of these must raise some exception to indicate errorspublic static voidcreate(String fileName, int extId) throws LibgistException{ libCreate(fileName, extId); closed = false;}public static voidopen(String fileName) throws LibgistException{ libOpen(fileName); closed = false;}public static voidclose() throws LibgistException{ if (!closed) { libClose(); closed = true; }}public static voidflush() throws LibgistException{ libFlush();}public static voidsaveToFile(String filename) throws LibgistException{ // first save all changes, then copy file libSave(filename);}public static voidinsert(String key, String data) throws LibgistException{ libInsert(key, data);}public static voidremove(String query) throws LibgistException{ libRemove(query);}public static voidfetch(String query, int limit, ResultProcessor procResult) throws LibgistException{ libFetch(query, limit, procResult);}public static voidcheck() throws LibgistException{ libCheck();}// Dumps the content of the node in ASCII to the text area and// returns the length of the dump output.public static intdump(JTextArea area, int pgNo) throws LibgistException{ return libDump(area, pgNo);}///////////////////////////////////////////////////////////////////////////////// getPredInfo - load information about predicates in subtree//// Description://// Exceptions: LibgistException for errors in libgist calls//// Returns:// number of elements in predInfo that were set///////////////////////////////////////////////////////////////////////////////public static voidgetPredInfo( int root, // in: page # of root of subtree int levels) // in: # of levels to look at{ libGetPredInfo(root, levels);}///////////////////////////////////////////////////////////////////////////////// highlightSubtree - mark a subtree portion in the current predInfo array//// Description://// Exceptions: LibgistException for errors in libgist calls//// Returns:// number of elements in predInfo that were set///////////////////////////////////////////////////////////////////////////////public static voidhighlightSubtree( int root, // in: page # of root of subtree int levels, // in: # of levels to look at int color) // in: highlight color{ libHighlightSubtree(root, levels, color);}///////////////////////////////////////////////////////////////////////////////// highlightSplit - mark a set of right entries in the current predInfo array//// Description://// Exceptions: LibgistException for errors in libgist calls//// Returns:// number of elements in predInfo that were set///////////////////////////////////////////////////////////////////////////////public static voidhighlightSplit( int[] rightEntries, // in: slot #s of entries to go right int numRight, // in: # entries in 'rightEntries' int color) // in: highlight color{ libHighlightSplit(rightEntries, numRight, color);}///////////////////////////////////////////////////////////////////////////////// highlightPath - mark a path in the current predInfo array//// Description://// Exceptions: LibgistException for errors in libgist calls//// Returns:// number of elements in predInfo that were set///////////////////////////////////////////////////////////////////////////////public static voidhighlightPath( int topNode, // in: highest node in path int bottomNode, // in: lowest node in path int color) // in: highlight color{ libHighlightPath(topNode, bottomNode, color);}///////////////////////////////////////////////////////////////////////////////// displayPreds - display predicates in window//// Description:// - explicitly specifies the number of predicates identified in// predInfo to display, because predInfo might contain more elements// than necessary//// Exceptions: LibgistException///////////////////////////////////////////////////////////////////////////////public static voiddisplayPreds( Graphics g, // in: graphics context needed for drawing int width, // in: width of window int height, // in: height of window Color[] colors) // in: drawing colors throws LibgistException{ LibgistException exc = new LibgistException(); // exc.printStackTrace(); libDisplayPreds(g, width, height, colors);}// Determines which entries in the given node would go to the right sibling if// the node gets split ('splitItems' contains number of split-off items,// starting with 0 for the 'leftmost' item on the page). Returns the number of// items that are split off.public static intpickSplit(int pgno, int splitItems[]){ return libPickSplit(pgno, splitItems);}/* * tree info functions */// returns the number of pages in the indexpublic static intgetPageCount(){ return libGetPageCount();}// returns the page no of the root pagepublic static intgetRoot(){ return libGetRoot();}// returns the page no of the parent of the given pagepublic static intgetParent(int pgNo){ return libGetParent(pgNo);}// returns the page no of the parent of the given page// retuens (-1) if it isn't a node ...public static intgetLevel(int pgNo){ return libGetLevel(pgNo);}// returns the position in the parent node of the entry pointing to pgno // (or -1 if pgno = rootno)public static intgetParentPos(int pgNo) throws LibgistException{ return libGetParentPos(pgNo);}// Determines the page no's of the children of the given page// and returns them through 'children' (which is assumed to hold at// least gist_p::max_scnt integers). Returns the number of children.public static intgetChildren(int parent, int[] children) throws LibgistException{ return libGetChildren(parent, children);}// Returns the maximum number of a children any node can have.public static intmaxChildren(){ return libMaxChildren();}// Determines the page #s of the nodes on the path from pgNo to the root// including the pgNo and the root itself (path[0] holds pgNo). Returns the // number of nodes on the path.public static intgetPath(int pgNo, int[] path) throws LibgistException{ return libGetPath(pgNo, path);}// returns the nonce of the node with pgNo.public static intgetNonce(int pgNo) throws LibgistException{ return libGetNonce(pgNo);}/* * breakpoints etc. */// creates a new C++ breakpoint for the given info and returns its IDpublic static voidcreateBp(Breakpoint bp){ libCreateBp(bp);}// delete all breakpointspublic static voiddeleteBps(){ libDeleteBps();}// installs the Java break handler object public static voidsetBreakHandler(BreakHandler handler){ libSetBreakHandler(handler);}public static voiddisableBps(boolean disable){ libDisableAll(disable);}// immediately turns on single-stepping; the next time the C break handler is called,// it will pass control to the Java break handlerpublic static voidsingleStep(){ libSingleStep();}/* * Analysis *////////////////////////////////////////////////////////////////////////////////// createAnalysis -// run queries in script and create analysis with treemap and profile//// Description:////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// openAnalysis - read analysis from file//// Description://///////////////////////////////////////////////////////////////////////////////public static voidopenAnalysis(String name) throws LibgistException{ libOpenAnalysis(name);}///////////////////////////////////////////////////////////////////////////////// closeAnalysis - discard in-memory analysis//// Description://///////////////////////////////////////////////////////////////////////////////public static voidcloseAnalysis() throws LibgistException{ libCloseAnalysis();}///////////////////////////////////////////////////////////////////////////////// writeAnalysis - write analysis back to file//// Description://///////////////////////////////////////////////////////////////////////////////public static void
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -