本文整理汇总了C++中NAString::data方法的典型用法代码示例。如果您正苦于以下问题:C++ NAString::data方法的具体用法?C++ NAString::data怎么用?C++ NAString::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NAString
的用法示例。
在下文中一共展示了NAString::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAuthDetails
// ----------------------------------------------------------------------------
// method: getAuthDetails
//
// Creates the CmpSeabaseDDLauth class containing auth details for the
// requested authName
//
// Input:
// authName - the database auth name to retrieve details for
// isExternal -
// true - the auth name is the external name (auth_ext_name)
// false - the auth name is the database name (auth_db_name)
//
// Output:
// A returned parameter:
// 0 - authorization details are available
// < 0 - an error was returned trying to get details
// 100 - authorization details were not found
// > 0 - (not 100) warning was returned
// ----------------------------------------------------------------------------
Int32 CmpSeabaseDDLauth::getAuthDetails(const char *pAuthName,
bool isExternal)
{
try
{
NAString sysCat = CmpSeabaseDDL::getSystemCatalogStatic();
char buf[1000];
NAString authNameCol = isExternal ? "auth_ext_name " : "auth_db_name ";
str_sprintf(buf, "select auth_id, auth_db_name, auth_ext_name, auth_type, auth_creator, auth_is_valid, auth_create_time, auth_redef_time from %s.\"%s\".%s where %s = '%s' ",
sysCat.data(), SEABASE_MD_SCHEMA, SEABASE_AUTHS, authNameCol.data(), pAuthName);
NAString cmd (buf);
if (selectExactRow(cmd))
return 0;
return 100;
}
catch (DDLException e)
{
return e.getSqlcode();
}
catch (...)
{
return -1;
}
}
示例2: authExists
// ----------------------------------------------------------------------------
// method: authExists
//
// Input: none
//
// Output:
// Returns true if authorization row exists in the metadata
// Returns false if authorization row does not exist in the metadata
//
// An exception is thrown if any unexpected errors occurred.
// ----------------------------------------------------------------------------
bool CmpSeabaseDDLauth::authExists (bool isExternal)
{
// Read the auths table based on the auth_db_name
NAString sysCat = CmpSeabaseDDL::getSystemCatalogStatic();
NAString colName = (isExternal) ? "auth_ext_name" : "auth_db_name";
NAString authName = (isExternal) ? getAuthExtName() : getAuthDbName();
char buf[1000];
str_sprintf(buf, "select count(*) from %s.\"%s\".%s where %s = '%s' ",
sysCat.data(), SEABASE_MD_SCHEMA, SEABASE_AUTHS, colName.data(),
authName.data());
Lng32 len = 0;
Int64 rowCount = 0;
ExeCliInterface cliInterface(STMTHEAP);
Lng32 cliRC = cliInterface.executeImmediate(buf, (char*)&rowCount, &len, NULL);
// If unexpected error occurred, return an exception
if (cliRC < 0)
{
cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
UserException excp (NULL, 0);
excp.throwException();
}
return (rowCount > 0) ? true : false;
}
示例3: hdfsExists
HDFS_Client_RetCode HdfsClient::hdfsExists( const NAString& uldPath, NABoolean & exist)
{
QRLogger::log(CAT_SQL_HDFS, LL_DEBUG, "HdfsClient::hdfsExists(%s) called.",
uldPath.data());
if (initJNIEnv() != JOI_OK)
return HDFS_CLIENT_ERROR_HDFS_EXISTS_PARAM;
if (getInstance() == NULL)
return HDFS_CLIENT_ERROR_HDFS_EXISTS_PARAM;
jstring js_UldPath = jenv_->NewStringUTF(uldPath.data());
if (js_UldPath == NULL) {
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_HDFS_EXISTS_PARAM;
}
tsRecentJMFromJNI = JavaMethods_[JM_HDFS_EXISTS].jm_full_name;
jboolean jresult = jenv_->CallStaticBooleanMethod(javaClass_, JavaMethods_[JM_HDFS_EXISTS].methodID, js_UldPath);
exist = jresult;
if (jenv_->ExceptionCheck())
{
getExceptionDetails();
logError(CAT_SQL_HDFS, __FILE__, __LINE__);
logError(CAT_SQL_HDFS, "HdfsClient::hdfsExists()", getLastError());
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_HDFS_EXISTS_EXCEPTION;
}
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_OK;
}
示例4: sprintf
short
IsolatedScalarUDF::generateShape(CollHeap * c, char * buf,
NAString * shapeStr)
{
Space *space = (Space *)c;
char mybuf[100];
sprintf (mybuf, "isolated_scalar_udf");
outputBuffer (space, buf, mybuf, shapeStr);
if (getRoutineDesc() &&
getRoutineDesc()->getNARoutine() &&
getRoutineDesc()->getNARoutine()->getRoutineName())
{
NAString fmtdStr;
ToQuotedString(fmtdStr, getRoutineDesc()->getNARoutine()->
getRoutineName()->getQualifiedNameObj().
getQualifiedNameAsAnsiString().data());
snprintf (mybuf, 100, "(scalar_udf %s", fmtdStr.data());
outputBuffer (space, buf, mybuf, shapeStr);
if (getRoutineDesc()->isUUDFRoutine() &&
getRoutineDesc()->getActionNARoutine() &&
getRoutineDesc()->getActionNARoutine()->getActionName())
{
ToQuotedString(fmtdStr, getRoutineDesc()->getActionNARoutine()->
getActionName()->data());
snprintf (mybuf, 100, ", udf_action %s", fmtdStr.data());
outputBuffer (space, buf, mybuf, shapeStr);
}
strcpy(mybuf, ")");
outputBuffer (space, buf, mybuf, shapeStr);
}
return 0;
}
示例5: hdfsCleanUnloadPath
HDFS_Client_RetCode HdfsClient::hdfsCleanUnloadPath( const NAString& uldPath)
{
QRLogger::log(CAT_SQL_HDFS, LL_DEBUG, "HdfsClient::hdfsCleanUnloadPath(%s) called.",
uldPath.data());
if (initJNIEnv() != JOI_OK)
return HDFS_CLIENT_ERROR_HDFS_CLEANUP_PARAM;
if (getInstance() == NULL)
return HDFS_CLIENT_ERROR_HDFS_CLEANUP_PARAM;
jstring js_UldPath = jenv_->NewStringUTF(uldPath.data());
if (js_UldPath == NULL) {
GetCliGlobals()->setJniErrorStr(getErrorText(HDFS_CLIENT_ERROR_HDFS_CLEANUP_PARAM));
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_HDFS_CLEANUP_PARAM;
}
tsRecentJMFromJNI = JavaMethods_[JM_HDFS_CLEAN_UNLOAD_PATH].jm_full_name;
jboolean jresult = jenv_->CallStaticBooleanMethod(javaClass_, JavaMethods_[JM_HDFS_CLEAN_UNLOAD_PATH].methodID, js_UldPath);
if (jenv_->ExceptionCheck())
{
getExceptionDetails();
logError(CAT_SQL_HDFS, __FILE__, __LINE__);
logError(CAT_SQL_HDFS, "HdfsClient::hdfsCleanUnloadPath()", getLastError());
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_HDFS_CLEANUP_EXCEPTION;
}
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_OK;
}
示例6: OutputFormat
NABoolean CmpInternalSP::OutputFormat(CmpSPOutputFormat& t)
{
NABoolean retStatus = TRUE;
CMPASSERT(state_ == COMPILE);
initSP_ERROR_STRUCT();
Lng32 num;
NAString outTableName = OutTableName();
if ( (*(procFuncs_.outNumFormatFunc_))( &num, compHandle_,
procFuncs_.spHandle_, &spError_[0])
== SP_SUCCESS )
{
if ( num == 0 )
{
// Create a dummy column if there is no output, since otherwise
// NATable generated later on will break later in binder.
SP_FIELDDESC_STRUCT fields;
strcpy(fields.COLUMN_DEF, "Dummy1 int");
if ( !(t.SetFormat(1, outTableName.data(), &fields, 0, 0) ) )
retStatus = FALSE;
}
else
{
SP_FIELDDESC_STRUCT* fields = allocSP_FIELDDESC_STRUCT(num);
SP_KEYDESC_STRUCT* keys = allocSP_KEYDESC_STRUCT(num);
Lng32 nKeys = 0;
initSP_ERROR_STRUCT();
if ( (*(procFuncs_.outFormatFunc_))
(fields, keys, &nKeys, compHandle_, procFuncs_.spHandle_, &spError_[0])
== SP_SUCCESS )
{
if (!(t.SetFormat(num, outTableName.data(), fields, nKeys, keys ) ) )
{
retStatus = FALSE;
}
}
else
{
appendDiags();
retStatus = FALSE;
}
// It is not supposed to jump out of this function before this
// delete[]
deleteSP_FIELDDESC_STRUCT(fields);
deleteSP_KEYDESC_STRUCT(keys);
}
}
else
{
appendDiags();
retStatus = FALSE;
}
if ( !retStatus )
*(cmpContext()->diags()) << DgSqlCode(arkcmpErrorISPFieldDef);
return retStatus;
}
示例7: connectHDFS
NABoolean HHDFSTableStats::connectHDFS(const NAString &host, Int32 port)
{
NABoolean result = TRUE;
// establish connection to HDFS . Conect to the connection cached in the context.
fs_ = ((GetCliGlobals()->currContext())->getHdfsServerConnection((char *)host.data(),port));
if (fs_ == NULL)
{
NAString errMsg("hdfsConnect to ");
errMsg += host;
errMsg += ":";
errMsg += port;
errMsg += " failed";
diags_.recordError(errMsg, "HHDFSTableStats::connectHDFS");
result = FALSE;
}
currHdfsHost_ = host;
currHdfsPort_ = port;
// }
return result;
}
示例8: extractKeyValuePairs
//
// data (begin or end) is in this format:
// <length><data> ... <length><data>
//
// a). length is 2-bytes long
// b). data is <length>-bytes long
// c). there are <n> such pairs, where <n> is determined by
// the total length of the source and the length of each pair.
//
static NABoolean extractKeyValuePairs(const NAString& source, NAString& result)
{
char buf[1024];
const char* data = source.data();
const char* end = data + source.length();
NABoolean hasData = ( data < end);
while ( data < end ) {
UInt16 len = 0;
memcpy((char*)&len, data, sizeof(len));
memcpy(buf, data+sizeof(len), len);
buf[len] = NULL;
result.append(buf);
data += sizeof(len) + len;
if ( data < end )
result.append(",");
}
return hasData;
}
示例9: hdfsCreateDirectory
HDFS_Client_RetCode HdfsClient::hdfsCreateDirectory(const NAString &dirName)
{
QRLogger::log(CAT_SQL_HBASE, LL_DEBUG, "Enter HDFSClient_JNI::createDirectory() called.");
if (initJNIEnv() != JOI_OK)
return HDFS_CLIENT_ERROR_CREATE_DIRECTORY_PARAM;
if (getInstance() == NULL)
return HDFS_CLIENT_ERROR_CREATE_DIRECTORY_PARAM;
jstring js_dirName = jenv_->NewStringUTF(dirName.data());
if (js_dirName == NULL) {
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_CREATE_DIRECTORY_PARAM;
}
tsRecentJMFromJNI = JavaMethods_[JM_HDFS_CREATE_DIRECTORY].jm_full_name;
jstring jresult =
(jstring)jenv_->CallStaticObjectMethod(javaClass_,
JavaMethods_[JM_HDFS_CREATE_DIRECTORY].methodID, js_dirName);
if (jenv_->ExceptionCheck())
{
getExceptionDetails(jenv_);
logError(CAT_SQL_HBASE, __FILE__, __LINE__);
logError(CAT_SQL_HBASE, "HDFSClient_JNI::hdfsCreateDirectory()", getLastError());
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_CREATE_DIRECTORY_EXCEPTION;
}
if (jresult == false)
{
logError(CAT_SQL_HDFS, "HdfsClient::hdfsCreateDirectory()", getLastError());
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_HDFS_DELETE_PATH_EXCEPTION;
}
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_OK;
}
示例10: logDiags
void QRLogger::logDiags(ComDiagsArea* diagsArea, std::string &cat)
{
const NAWchar* diagMsg;
NAString* diagStr;
Int32 i;
ComCondition* condition;
log4cxx::LoggerPtr myLogger = log4cxx::Logger::getLogger(cat);
if ( myLogger )
{
log4cxx::LevelPtr myLevel = myLogger->getLevel();
if ( myLevel )
{
// If configured Level is the same or less restrictive than WARN (30000)
// than report the warning
if ( myLevel != log4cxx::Level::getOff() && myLevel->toInt() <= LL_WARN )
{
for (i=1; i<=diagsArea->getNumber(DgSqlCode::WARNING_); i++)
{
condition = diagsArea->getWarningEntry(i);
diagMsg = condition->getMessageText();
diagStr = unicodeToChar(diagMsg, NAWstrlen(diagMsg),
CharInfo::ISO88591, NULL, TRUE);
log(cat, LL_WARN, condition->getSQLCODE(), "",
" warn condition %d: %s", i, diagStr->data());
delete diagStr;
}
}
}
}
}
示例11: deleteRow
// Delete a row from the AUTHS table based on the AUTH_ID
void CmpSeabaseDDLauth::deleteRow(const NAString &authName)
{
NAString systemCatalog = CmpSeabaseDDL::getSystemCatalogStatic();
char buf[1000];
ExeCliInterface cliInterface(STMTHEAP);
str_sprintf(buf, "delete from %s.\"%s\".%s where auth_db_name = '%s'",
systemCatalog.data(), SEABASE_MD_SCHEMA, SEABASE_AUTHS, authName.data());
Lng32 cliRC = cliInterface.executeImmediate(buf);
if (cliRC < 0)
{
cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
UserException excp (NULL, 0);
excp.throwException();
}
}
示例12: getCharsetsToUse
static NABoolean getCharsetsToUse(
Lng32 msgCharSet, Lng32 &inputCS, Lng32 &defaultCS)
{
if (msgCharSet == SQLCHARSETCODE_ISO_MAPPING)
{
// return the value isoMapping set for this system.
NAString cs;
CmpCommon::getDefault(ISO_MAPPING, cs);
inputCS = (Lng32)CharInfo::getCharSetEnum(cs.data());
defaultCS = (Lng32)SQLCHARSETCODE_ISO88591;
SetSqlParser_DEFAULT_CHARSET(CharInfo::ISO88591);
}
else
{
inputCS = msgCharSet;
defaultCS = (Lng32)SQLCHARSETCODE_UNKNOWN;
// no change to default charset, if ISO_MAPPING was not specified.
// Just set it to the same value as the original charset.
SetSqlParser_DEFAULT_CHARSET(SqlParser_ORIG_DEFAULT_CHARSET);
}
return FALSE;
}
示例13: dumpAnalysisToFile
void MvQueryRewriteHandler::dumpAnalysisToFile(QueryAnalysis* qa, RelExpr* expr)
{
// Dump the QueryAnalysis data to a file.
NAString analysisFileName = fileNamePrefix_ + ".analysis";
NAString str;
expr->unparse(str, OPTIMIZER_PHASE, MVINFO_FORMAT);
str += "\n";
str += qa->getText();
// Add in some stuff to look at join predicates for the JBBCs.
str += "Join Predicates\n";
str += "===============";
char buffer[20];
ARRAY(JBB*) jbbs = qa->getJBBs();
for (CollIndex jbbInx = 0; jbbInx < jbbs.entries(); jbbInx++)
{
JBB* jbb = jbbs[jbbInx];
str_itoa(jbbInx, buffer);
((str += "\nJBB #") += NAString(buffer)) += ":\n";
CANodeIdSet jbbcs = jbb->getJBBCs();
for (CANodeId jbbcId=jbbcs.init(); jbbcs.next(jbbcId); jbbcs.advance(jbbcId) )
{
str_itoa(jbbcId, buffer);
((str += "\nJBBC with CANodeId ") += NAString(buffer)) += ":\n";
ValueIdSet joinPreds = jbbcId.getNodeAnalysis()->getJBBC()->getJoinPreds();
str += valueIdSetGetText(joinPreds);
if (joinPreds.entries() > 0)
{
str.append("\n(value ids of predicates are ");
NABoolean first = true;
for (ValueId jpVid=joinPreds.init(); joinPreds.next(jpVid); joinPreds.advance(jpVid))
{
if (first)
first = FALSE;
else
str.append(", ");
str_itoa(jpVid, buffer);
str.append(buffer);
}
str.append(")\n");
}
}
str += '\n';
}
dumpToFile(analysisFileName.data(), str.data());
} // dumpAnalysisToFile()
示例14: hdfsMergeFiles
HDFS_Client_RetCode HdfsClient::hdfsMergeFiles( const NAString& srcPath,
const NAString& dstPath)
{
QRLogger::log(CAT_SQL_HDFS, LL_DEBUG, "HdfsClient::hdfsMergeFiles(%s, %s) called.",
srcPath.data(), dstPath.data());
if (initJNIEnv() != JOI_OK)
return HDFS_CLIENT_ERROR_HDFS_MERGE_FILES_PARAM;
if (getInstance() == NULL)
return HDFS_CLIENT_ERROR_HDFS_MERGE_FILES_PARAM;
jstring js_SrcPath = jenv_->NewStringUTF(srcPath.data());
if (js_SrcPath == NULL) {
GetCliGlobals()->setJniErrorStr(getErrorText(HDFS_CLIENT_ERROR_HDFS_MERGE_FILES_PARAM));
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_HDFS_MERGE_FILES_PARAM;
}
jstring js_DstPath= jenv_->NewStringUTF(dstPath.data());
if (js_DstPath == NULL) {
GetCliGlobals()->setJniErrorStr(getErrorText(HDFS_CLIENT_ERROR_HDFS_MERGE_FILES_PARAM));
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_HDFS_MERGE_FILES_PARAM;
}
tsRecentJMFromJNI = JavaMethods_[JM_HDFS_MERGE_FILES].jm_full_name;
jboolean jresult = jenv_->CallStaticBooleanMethod(javaClass_, JavaMethods_[JM_HDFS_MERGE_FILES].methodID, js_SrcPath, js_DstPath);
if (jenv_->ExceptionCheck())
{
getExceptionDetails();
logError(CAT_SQL_HDFS, __FILE__, __LINE__);
logError(CAT_SQL_HDFS, "HdfsClient::hdfsMergeFiles()", getLastError());
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_HDFS_MERGE_FILES_EXCEPTION;
}
if (jresult == false)
{
logError(CAT_SQL_HDFS, "HdfsClient::hdfsMergeFiles()", getLastError());
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_ERROR_HDFS_MERGE_FILES_EXCEPTION;
}
jenv_->PopLocalFrame(NULL);
return HDFS_CLIENT_OK;
}
示例15: describe
// -----------------------------------------------------------------------------
// Method: describe
//
// This method returns the showddl text for the requested user in string format
//
// Input:
// authName - name of user to describe
//
// Input/Output:
// authText - the REGISTER USER text
//
// returns result:
// true - successful
// false - failed (ComDiags area will be set up with appropriate error)
//-----------------------------------------------------------------------------
bool CmpSeabaseDDLuser::describe (const NAString &authName, NAString &authText)
{
Int32 retcode = 0;
try
{
retcode = getUserDetails(authName.data());
if (retcode == 100)
{
*CmpCommon::diags() << DgSqlCode(-CAT_USER_NOT_EXIST)
<< DgString0 (authName.data());
return false;
}
// throw an exception so the catch handler will put a value in ComDiags
// area in case no message exists
if (retcode < 0)
{
UserException excp (NULL, 0);
throw excp;
}
authText = "REGISTER USER ";
authText += getAuthExtName();
if (getAuthExtName() != getAuthDbName())
{
authText += " AS ";
authText += getAuthDbName();
}
authText += ";\n";
}
catch (...)
{
// At this time, an error should be in the diags area.
// If there is no error, set up an internal error
Int32 numErrors = CmpCommon::diags()->getNumber(DgSqlCode::ERROR_);
if (numErrors == 0)
*CmpCommon::diags() << DgSqlCode(-CAT_INTERNAL_EXCEPTION_ERROR)
<< DgInt0(__LINE__)
<< DgString0("describe");
return false;
}
return true;
}