⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libgist.cc~

📁 Libgist is an implementation of the Generalized Search Tree, a template index structure that makes i
💻 CC~
📖 第 1 页 / 共 5 页
字号:
// Gist.cc -*- c++ -*--// Copyright (c) 1998, Regents of the University of California// $Id: Libgist.cc,v 1.7 2000/03/15 00:23:21 mashah Exp $/* * Gist.cc - native implementation of interface Gist.java * contains wrapper functions for the libgist interface, manages breakpoints */// VCPORT_B#ifdef WIN32#pragma warning(disable:4786) // Templates can cause names to get too long for							  // debug information. Disables this warning.#endif// VCPORT_E#include <assert.h>#include <ctype.h>#include <stdlib.h>#include <errno.h>#include <math.h>#include <malloc.h>#include "jni.h"#include "gist_query.h"#include "gist_cursor.h"#include "amdb_wkldprofile.h"#include "amdb_analysis.h"#include "amdb_wkldstats.h"#include "amdb_splitstats.h"#include "amdb_penaltystats.h"#include "amdb_treemap.h"#include "gist.h"#include <stdio.h>// VCPORT_B#ifdef WIN32#include <iostream>#include <strstream>#include <fstream>// STL #include <functional>#include <algorithm>#include <vector>#include <map>using namespace std;#else#include <iostream.h>#include <strstream.h>#include <fstream.h>// STL #include <function.h>#include <algo.h>#include <vector.h>#include <multimap.h>#endif#include "Libgist.h"#include "amdb_idxstruct.h"#include "amdb_ext.h"// include for extensions#include "gist_extensions.h"#define DUMPBUFLEN 64*1024#define MAXCMDLEN 1024// debugging supportstatic int Gist_dbgLevel = 0;#define DBGPRINT(x,y)	\{	\    if ((x) <= Gist_dbgLevel) {	\        (y);	\    }	\}extern "C" {// forward declarationsstatic void stringBufferAppend(JNIEnv* env, jobject buf, const char* str);static void copyCharArray(jchar* to, char* from);static void _highlightChildSubtrees( int parent, int levels, int& index, int color);/*  * General macros for detecting errors and Java exceptions and/or throwing them. *////////////////////////////////////////////////////////////////////////////////// HANDLEEXC - handle Java exception and return//// Description:///////////////////////////////////////////////////////////////////////////////#define HANDLEEXC(env)	\{	\    jthrowable exc = (env)->ExceptionOccurred();	\    if (exc) {	\        (env)->ExceptionDescribe();	\	return;	\    }	\}///////////////////////////////////////////////////////////////////////////////// HANDLEEXCR - handle Java exception and return value//// Description:///////////////////////////////////////////////////////////////////////////////#define HANDLEEXCR(env, retval)	\{	\    jthrowable exc = (env)->ExceptionOccurred();	\    if (exc) {	\        (env)->ExceptionDescribe();	\	return (retval);	\    }	\}///////////////////////////////////////////////////////////////////////////////// ERRORRETURNV - generate LibgistException and return value//// Description:///////////////////////////////////////////////////////////////////////////////#define ERRORRETURNV(str, retval) \{	\    jclass excCl = (env)->FindClass("LibgistException");	\    if (excCl == NULL) {	\	return (retval);	\    }	\    (env)->ThrowNew(excCl, (str));	\    return (retval);	\}///////////////////////////////////////////////////////////////////////////////// ERRORRETURN - generate LibgistException and return//// Description:///////////////////////////////////////////////////////////////////////////////#define ERRORRETURN(str) \{	\    jclass excCl = (env)->FindClass("LibgistException");	\    if (excCl == NULL) {	\	return;	\    }	\    (env)->ThrowNew(excCl, (str));	\    return;	\}///////////////////////////////////////////////////////////////////////////////// CHECKSTATUS - check execution status, generate LibgistException and return//// Description:///////////////////////////////////////////////////////////////////////////////#define CHECKSTATUS(status, env, str)	\{	\    if ((status) != RCOK) {	\	DBGPRINT(1, fprintf(stderr, "status: %d\n", status)); 	\        jclass excCl = (env)->FindClass("LibgistException");	\	if (excCl == NULL) {	\	    return;	\	}	\	(env)->ThrowNew(excCl, (str));	\	return;	\    }	\}///////////////////////////////////////////////////////////////////////////////// CHECKSTATUSR -//	check execution status, generate LibgistException and return value//// Description:///////////////////////////////////////////////////////////////////////////////#define CHECKSTATUSR(status, env, str, retval)	\{	\    if ((status) != RCOK) {	\	DBGPRINT(1, fprintf(stderr, "status: %d\n", status)); 	\        jclass excCl = (env)->FindClass("LibgistException");	\	if (excCl == NULL) {	\	    return (retval);	\	}	\	(env)->ThrowNew(excCl, (str));	\	return (retval);	\    }	\}// miscellaneous static variablesstatic gist *Gist_gist = new gist();static amdb_analysis* Gist_analysis;static amdb_idxstruct* Gist_indexStruct = NULL; // created when index created/openedstatic char* Gist_filename = NULL;static char* Gist_analysisname = NULL;static jobject Gist_handler;static amdb_treemap* _treeMap = NULL; // allocated and computed on demandstatic gist::DisplayPredInfo* Gist_predInfo = NULL;static int Gist_predInfoSize = 0;static int Gist_numPredInfo = 0;static int Gist_numPredInfoColors = 0;// cached class objects and method and field IDsstatic jclass Gist_handlerClass;static jmethodID Gist_handlerId;static jclass Gist_breakpointClass;//static jmethodID Gist_breakpointConstrId;static jfieldID Gist_bpEventId;static jfieldID Gist_bpIdId;static jfieldID Gist_bpNodeId;static jfieldID Gist_bpParam1Id;static jfieldID Gist_bpParam2Id;static jclass Gist_breakInfoClass;static jmethodID Gist_breakInfoConstrId;static jfieldID Gist_biEventId;static jfieldID Gist_biIdId;static jfieldID Gist_biNodeId;static jfieldID Gist_biTargetPenaltyId;static jfieldID Gist_biMinPenaltyId;static jfieldID Gist_biMinLeafId;static jobject Gist_infoObj = NULL; // single Java BreakInfo object, passed to handlerstatic jclass Gist_queryStatsClass;static jfieldID Gist_qsResultSetLimitId;static jfieldID Gist_qsQualId;static jfieldID Gist_qsResultSetSizeId;static jfieldID Gist_qsAvgUtilId;static jfieldID Gist_qsRetrievalVolId;static jfieldID Gist_qsTotalLeafIosId;static jfieldID Gist_qsTotalInternalIosId;static jfieldID Gist_qsMinIosId;static jfieldID Gist_qsOptimalIosId;static jfieldID Gist_qsOptimalOhId;static jfieldID Gist_qsOptLeafOhId;static jfieldID Gist_qsMinLeafOhId;static jfieldID Gist_qsRandomIosId;static jfieldID Gist_qsRandomStdDevId;static jfieldID Gist_qsOptRandomOhId;static jfieldID Gist_qsMinRandomOhId;static jfieldID Gist_qsOptClusterLossId;static jfieldID Gist_qsOptClusterOhId;static jfieldID Gist_qsMinClusterLossId;static jfieldID Gist_qsMinClusterOhId;static jfieldID Gist_qsLeafUtilLossId;static jfieldID Gist_qsUtilOhId;static jfieldID Gist_qsLeafExcCovLossId;static jfieldID Gist_qsExcCovOhId;static jfieldID Gist_qsInternalUtilLossId;static jfieldID Gist_qsInternalExcCovLossId;static jclass Gist_splitStatsClass;static jfieldID Gist_ssPreIosId;static jfieldID Gist_ssOptIosId;static jfieldID Gist_ssActualIosId;static jfieldID Gist_ssPreExcCovLossId;static jfieldID Gist_ssActualExcCovLossId;static jfieldID Gist_ssOptClusterDeltaId;static jfieldID Gist_ssActualClusterDeltaId;static jfieldID Gist_ssClusterLossId;static jfieldID Gist_ssClusterOhId;static jfieldID Gist_ssClusterSuccessId;static jfieldID Gist_ssExcCovDeltaId;static jfieldID Gist_ssExcCovLossId;static jfieldID Gist_ssExcCovOhId;static jfieldID Gist_ssExcCovSuccessId;static jclass Gist_penaltyStatsClass;static jfieldID Gist_psActualAddIosId;static jfieldID Gist_psOptAddIosId;static jfieldID Gist_psActualExcCovId;static jfieldID Gist_psExcCovDeltaId;static jfieldID Gist_psClusterLossId;static jfieldID Gist_psExcCovOhId;static jfieldID Gist_psExcCovSuccessId;static jfieldID Gist_psKeyId;static jclass Gist_analysisInfoClass;static jfieldID Gist_aiActualNameId;static jfieldID Gist_aiActualHasWkldStatsId;static jfieldID Gist_aiActualHasSplitStatsId;static jfieldID Gist_aiActualHasPenaltyStatsId;static jfieldID Gist_aiOptNameId;static jfieldID Gist_aiOptHasWkldStatsId;static jfieldID Gist_aiOptHasSplitStatsId;static jfieldID Gist_aiOptHasPenaltyStatsId;static jfieldID Gist_aiRandomRunsId;static jfieldID Gist_aiTargetUtilId;static jfieldID Gist_aiQueryFileId;static jfieldID Gist_aiNumQueriesId;static jfieldID Gist_aiNumRetrievedId;static jfieldID Gist_aiNumItemsId;static jclass Gist_libgistCommandClass;static jfieldID Gist_lcCmdTypeId;static jfieldID Gist_lcFetchLimitId;static jfieldID Gist_lcQualId; static jfieldID Gist_lcKeyId; static jfieldID Gist_lcDataId;static jfieldID Gist_lcIndexNameId;static jfieldID Gist_lcExtensionId;static jfieldID Gist_lcFillFactorId;static jfieldID Gist_lcLoadFileId;static jfieldID Gist_lcScriptFileId;static jfieldID Gist_lcAnalysisFileId;static jfieldID Gist_lcNumRandomRunsId;static jclass Gist_displayPredInfoClass;static jfieldID Gist_dpiNodeId;static jfieldID Gist_dpiSlotId;static jfieldID Gist_dpiLevelId;static jfieldID Gist_dpiColorId;static jclass Gist_jTextAreaClass;static jmethodID Gist_taAppendId;static jclass Gist_stringBufferClass;static jmethodID Gist_sbAppendId;static jclass Gist_fileClass;static jmethodID Gist_fInitId;/* * Breakpoints:  * Each event has two sets of breakpoints: one multiset, indexed on the node ID specified * for the breakpoints, and one list, if it is a general, non-node related breakpoint. */typedef vector<amdb_breakpoints::Breakpoint *> BpVect;typedef multimap<int, amdb_breakpoints::Breakpoint *, less<int> > BpMap;typedef pair<const int, amdb_breakpoints::Breakpoint *> BpPair;BpVect genBps[amdb_breakpoints::numEvents]; // bps without node attachmentBpMap nodeBps[amdb_breakpoints::numEvents]; // bps specific to a node// return value from Java breakpoint handlerenum WhatToDo {    nowContinue = 0,    nowStep, // run until we hit the next step unit    nowNext, // run until we hit the next entry point    nowCancel // cancel current function};static WhatToDo Gist_whatNow = nowContinue;static bool Gist_allDisabled = false; // all breakpoints disabledstatic JNIEnv* Gist_env; // 'passed' to breakHandlerstatic int Gist_bpCounter = 0; // ID generator/* * Breakpoint stuff */static voidprintBps(){    amdb_breakpoints::Breakpoint* bp;    int i;    for (i = 0; i < amdb_breakpoints::numEvents; i++) {        BpMap::iterator it;        for (it = nodeBps[i].begin(); it != nodeBps[i].end(); it++) {	    bp = (*it).second;	    printf("map %d: id: %d, event: %d, node: %d\n",	        i, bp->id, bp->event, bp->node);	}	BpVect::iterator vit;        for (vit = genBps[i].begin(); vit != genBps[i].end(); vit++) {	    bp = (*vit);	    printf("gen %d: id: %d, event: %d, node: %d\n",	        i, bp->id, bp->event, bp->node);	}    }}// Converts data in Java Breakpoint object to amdb_breakpoints::Breakpoint.static voidconvertBreakpoint(    amdb_breakpoints::Breakpoint* bp,    jobject info,    JNIEnv* env){    printf("convertBreakpoint\n");    bp->id = Gist_bpCounter;    bp->event = (amdb_breakpoints::BreakEvents) env->GetIntField(info, Gist_bpEventId);    bp->node = env->GetIntField(info, Gist_bpNodeId);    printf("bp: id=%d, event=%d, node=%d\n", bp->id, bp->event, bp->node);    jstring param1String = (jstring) env->GetObjectField(info, Gist_bpParam1Id);    const char* param1 = env->GetStringUTFChars(param1String, NULL);    jstring param2String = (jstring) env->GetObjectField(info, Gist_bpParam2Id);    const char* param2 = env->GetStringUTFChars(param2String, NULL);    // some break events have associated parameters, which are specified as a java.lang.String    if (bp->event == amdb_breakpoints::locateLeafEvent) {	if (strcmp(param1, "") == 0) {	    bp->param.penaltyParam.maxDeviation = -1; // meaning: ignore this	} else {	    bp->param.penaltyParam.maxDeviation = atoi(param1);	}	printf("locateLeaf: maxDev=%d\n", bp->param.penaltyParam.maxDeviation);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -