Exemplo n.º 1
0
NABoolean ISPIterator::initializeISPCaches(SP_ROW_DATA  inputData, SP_EXTRACT_FUNCPTR  eFunc, SP_ERROR_STRUCT* error, 
                                  const NAArray<CmpContextInfo*> & ctxs, //input 
                                  NAString & contextName, 
                                  Int32 & index           //output, set initial index in arrary of CmpContextInfos
                                  ) 
{
//extract ISP input, find QueryCache belonging to specified context
//and use it for fetch later
  Lng32 maxSize = 16;
  char receivingField[maxSize+1];
  if (eFunc (0, inputData, (Lng32)maxSize, receivingField, FALSE) == SP_ERROR_EXTRACT_DATA)
  {
      error->error = arkcmpErrorISPFieldDef;
      return FALSE;
  }
   //choose context
   // 1. Search ctxInfos_ for all context with specified name('USER', 'META', 'USTATS'),
   //    'ALL' option will fetch all context in ctxInfos_, index is set to 0, qcache is always NULL, 
   // 2. For remote arkcmp, which has 0 context in ctxInfos_, index is always -1, 

  NAString qCntxt = receivingField;
  qCntxt.toLower();
  //the receivingField is of pattern xxx$trafodion.yyy, 
  //where xxx is the desired input string.
  Int32 dollarIdx = qCntxt.index("$");
  CMPASSERT(dollarIdx > 0);
  //find the specified context
  if(ctxs.entries() == 0){
    //for remote compiler
    if( (dollarIdx==3 && strncmp(qCntxt.data(), "all", dollarIdx)==0) 
     ||(dollarIdx==4 && strncmp(qCntxt.data(), "user", dollarIdx)==0) )
      index = -1;
  }
  else
  {
    if(dollarIdx==3 && strncmp(qCntxt.data(), "all", dollarIdx)==0)
    {
       contextName = "ALL";
       index = 0;
    }
    else if(dollarIdx==4 && strncmp(qCntxt.data(), "user", dollarIdx)==0)
    {
       contextName = "NONE";
       index = 0;
    }
    else if(dollarIdx==4 && strncmp(qCntxt.data(), "meta", dollarIdx)==0)
    {
       contextName = "META";
       index = 0;
    }
    else if(dollarIdx==6 && strncmp(qCntxt.data(), "ustats", dollarIdx)==0)
    {
       contextName = "USTATS";
       index = 0;
    }
  }           
  return TRUE;
}
Exemplo n.º 2
0
ExplainTuple *PhysicalFastExtract::addSpecificExplainInfo(ExplainTupleMaster *explainTuple, ComTdb *tdb,
    Generator *generator)
{

  NAString description = "Target_type: ";
  if (getTargetType() == FILE)
  {
    if (isHiveInsert())
      description += "hive table";
    else
      description += "file";
  }
  else if (getTargetType() == SOCKET)
    description += "socket";
  else
    description += "none";
  if (isHiveInsert())
  {

    NAString str = getTargetName();
    size_t colonIndex = str.index(":", 1,0,NAString::ignoreCase);
    while (colonIndex !=  NA_NPOS)
    {
      str = str.replace(colonIndex, 1, "_", 1);
      colonIndex = str.index(":", 1,0,NAString::ignoreCase);
    }

    description += " location: ";
    description += str;
  }


  if (isHiveInsert())
  {
    description += " table_name: ";
    description += getHiveTableName();
  }
  else
  {
    description += " target_name: ";
    description += getTargetName();
  }
  description += " delimiter: ";
  description += getDelimiter();

  if (isAppend())
    description += " append: yes";
  if ( !isHiveInsert() && includeHeader())
  {
    description += " header: ";
    description += getHeader();
  }
  if (getCompressionType() != NONE)
  {
    description += " compression_type: ";
    if (getCompressionType() == LZO)
      description += "LZO";
    else
      description += "error";
  }

  description += " null_string: ";
  description += getNullString();

  description += " record_separator: ";
  description += getRecordSeparator();


  explainTuple->setDescription(description);
  if (isHiveInsert())
    explainTuple->setTableName(getHiveTableName());

  return explainTuple;
}