Lng32 ExpLOBinterfaceInit(void *& exLobGlob, void * lobHeap,
                          void *currContext,NABoolean isHive,
                          char *hdfsServer, 
                          Int32 port)
{
  Ex_Lob_Error err;

  Int64 dummyParam = 0;
  Int64 cliError = -1; 
  Ex_Lob_Error status;
  Int32 dummyParam2 = 0;
  
 
  err = ExLobsOper((char*)"dummy",
		   NULL, 0,
		   NULL, 0, 
		   NULL, dummyParam2, 0, dummyParam, 
                   dummyParam, 0, dummyParam, status, cliError,
		   NULL, Lob_HDFS_File,
		   NULL, 0, 
		   0,NULL,
		   Lob_Init,
		   Lob_None,
                   1, // waited op
		   exLobGlob,
		   0,
		   NULL, 0,
		   0);
  if (exLobGlob)
    {
      ((ExLobGlobals *)exLobGlob)->setIsHive(isHive);
      NAHeap *heap = new ((NAHeap *)lobHeap) NAHeap("LOB Heap", (NAHeap *)lobHeap);
      if (isHive)
        ((ExLobGlobals *)exLobGlob)->startWorkerThreads();
      heap->setThreadSafe();
      ((ExLobGlobals *)exLobGlob)->setHeap(heap);
      
    }

  //set hdfsConnection from context global 
  ContextCli *localContext = (ContextCli *)currContext;
  if (localContext)
    {
      hdfsFS fs = localContext->getHdfsServerConnection(hdfsServer,port);
      if (fs == NULL)
        {
          return LOB_HDFS_CONNECT_ERROR;
        }
      else
        {
          ((ExLobGlobals *)exLobGlob)->setHdfsFs(fs);
        }
    }

  if (err != LOB_OPER_OK)
    return err;
  else
    return 0;
}
Пример #2
0
// read and return descriptor area (headers + entries)
Int32
readDescArea
(fstream              &mf,          // (IN) : binary module file
 module_header_struct &latestModHdr,// (IN) : its module header
 NAHeap               &heap,        // (IN) : allocate DESC area from here
 const char *         name,       // (IN) : module name (for error msg)
 ComDiagsArea         &diags,       // (IN) : deposit any error msg here
 char                *&descArea)    // (OUT): desc headers + entries
{
  // make sure we have reasonable arguments
  if (latestModHdr.descriptor_area_offset <= 0 ||
      latestModHdr.descriptor_area_length <= 0)
    return -1;

  // allocate space for DESC headers + entries
  descArea = (char*)
    heap.allocateMemory((size_t)latestModHdr.descriptor_area_length);
	  
  // read DESC headers + entries
  mf.seekg(latestModHdr.descriptor_area_offset, ios::beg);
  mf.read(descArea, (Int32)latestModHdr.descriptor_area_length);
  if (mf.fail()) {
    diags << DgSqlCode(-CLI_READ_ERROR) << DgString0(name);
    return -1;
  }
  return 1; // all OK
}
Пример #3
0
Lng32 MXCI_RW_allocateHeap (void* sqlciEnv, Lng32 len, char* &ptr)
{

  SqlciEnv * sqlci_env = (SqlciEnv *)sqlciEnv;
  
  NAHeap *h = sqlci_env->sqlciRWEnv()->rwHeap();
  void *p = NULL;

  if (h)
    p = h->allocateMemory(len, TRUE);
 
  if (p)
  {
    ptr = (char *)p;
    return SUCCESS;
  }
  else
    return ERR;
}
Lng32 ExpLOBinterfaceInit(void *& exLobGlob, void * lobHeap,NABoolean isHive, Int64  lobMaxSize)
{
  Ex_Lob_Error err;

  Int64 dummyParam = 0;
  Int64 cliError = -1; 
  Ex_Lob_Error status;
  Int32 dummyParam2 = 0;
  char dir[100];
  strcpy(dir, "/lobs");
  err = ExLobsOper(dir,
		   NULL, 0,
		   NULL, 0, 
		   NULL, dummyParam2, 0, dummyParam, 
                   dummyParam, 0, dummyParam, status, cliError,
		   dir, Lob_HDFS_File,
		   NULL, 0, 
		   0,NULL,
		   Lob_Init,
		   Lob_None,
                   1, // waited op
		   exLobGlob,
		   0,
		   exLobGlob, 0,
		   lobMaxSize);
  if (exLobGlob)
    {
      ((ExLobGlobals *)exLobGlob)->setIsHive(isHive);
      NAHeap *heap = new ((NAHeap *)lobHeap) NAHeap("LOB Heap", (NAHeap *)lobHeap);
      
      heap->setThreadSafe();
      ((ExLobGlobals *)exLobGlob)->setHeap(heap);
      
    }
    

  if (err != LOB_OPER_OK)
    return -1;
  else
    return 0;
}
Пример #5
0
NA_EIDPROC
void NABasicObject::operator delete[](void* p)
{
#if 0
  if (p)	// "delete NULL;" is legal in C++, obviously a no-op
    {
      //NGG      CollHeap* h = ((NABasicObject*)p)->h_;
      NAHeap* h = (NAHeap *) ((NABasicObject*)p)->h_;

      // ComDEBUG(h != invalidHeapPtr());
      if (h == invalidHeapPtr())
        {
	  #ifndef NDEBUG
	  #ifndef __EID
	    cerr << "**WARNING: " << __FILE__ << ": "
	         << "Ignoring attempt to delete pointer twice    "
	         << "(possible memory leak at " << p << "; need to run Purify)"
		 << endl;
	  #endif
	  #endif
	  return;
	}

      ((NABasicObject*)p)->h_ = invalidHeapPtr();
      if (h)
	h->deallocateMemory(p);
      else
	{
	  //	  HEAPLOG_DELETE_ENTRY(p, NA_HEAP_BASIC)
	  ::operator delete(p);
	}
    }
#endif
	  ::operator delete(p);

}
Пример #6
0
// read and return a binary module file's source area
SourceBuf readSourceArea
(fstream               &mf,          // (IN) : binary module file
 module_header_struct  &latestModHdr,// (IN) : its module header
 NAHeap                &heap,        // (IN) : allocate PLT area from here
 const char *          name,         // (IN) : module name (for error msg)
 ComDiagsArea          &diags)       // (IN) : deposit any error msg here
{
  SourceBuf srcArea = NULL;
  if (latestModHdr.source_area_length > 0) {
    // allocate space for source area
    srcArea = (SourceBuf)
      heap.allocateMemory((size_t)latestModHdr.source_area_length);

    // read source area
    mf.seekg(latestModHdr.source_area_offset, ios::beg);
    mf.read(srcArea, (Int32)latestModHdr.source_area_length);
    if (mf.fail()) {
      diags << DgSqlCode(-CLI_READ_ERROR) << DgString0(name);
      return NULL;
    }
  }
  return srcArea;
}
Пример #7
0
// read and return procedure location table area (header + entries)
Int32
readPLTArea
(fstream              &mf,          // (IN) : binary module file
 module_header_struct &latestModHdr,// (IN) : its module header
 NAHeap               &heap,        // (IN) : allocate PLT area from here
 const char *     name,       // (IN) : module name (for error msg)
 ComDiagsArea         &diags,       // (IN) : deposit any error msg here
 plt_header_struct   *&pltArea)     // (OUT): plt header + entries
{
  // make sure we have reasonable arguments
  if (latestModHdr.plt_area_offset  <= 0 ||
      latestModHdr.plt_area_length  <= 0 ||
      latestModHdr.plt_hdr_length   <= 0 ||
      latestModHdr.plt_entry_length <= 0)
    return -1;

  // allocate space for PLT header
  plt_header_struct pltHdrCls, *latestPLTHdr, *plt;
  plt = (plt_header_struct *)
    heap.allocateMemory(latestModHdr.plt_hdr_length);

  // read procedure location table header
  mf.seekg(latestModHdr.plt_area_offset, ios::beg);
  mf.read((char *)plt, latestModHdr.plt_hdr_length);
  if (mf.fail()) {
    diags << DgSqlCode(-CLI_READ_ERROR) << DgString0(name);
    return -1;
  }
      
  // give versioning a chance to massage/migrate it to this version
  latestPLTHdr = (plt_header_struct*)plt->driveUnpack(plt, &pltHdrCls,NULL);
  if (!latestPLTHdr) {
    // error: version is no longer supported
    diags << DgSqlCode(-CLI_MOD_PLT_HDR_VERSION_ERROR) 
          << DgString0(name);
    return -1;
  }

  pltArea = latestPLTHdr;
  Int32 num_procs = latestPLTHdr->num_procedures;
  
  if (num_procs >= 1) {
	// allocate space for PLT header + entries
    heap.deallocateMemory(plt);
    plt = (plt_header_struct *)
      heap.allocateMemory((size_t)latestModHdr.plt_area_length);
	  
    // read procedure location table header + entries
    mf.seekg(latestModHdr.plt_area_offset, ios::beg);
    mf.read((char *)plt, (Int32)latestModHdr.plt_area_length);
    if (mf.fail()) {
      diags << DgSqlCode(-CLI_READ_ERROR) << DgString0(name);
      return -1;
    }
	  
    // give versioning a chance to massage/migrate it to this version
    latestPLTHdr = (plt_header_struct*)plt->driveUnpack(plt, &pltHdrCls, NULL);
    if (!latestPLTHdr) {
      // error: version is no longer supported
      diags << DgSqlCode(-CLI_MOD_PLT_HDR_VERSION_ERROR) 
            << DgString0(name);
      return -1;
    }
    pltArea = latestPLTHdr;
  }

  // verify its validity
  Lng32 errCode = pltArea->RtduStructIsCorrupt();
  if (errCode) {
    // the module file is corrupted or has invalid data
    diags << DgSqlCode(errCode) << DgString0(name);
    heap.deallocateMemory(plt);
    return -1;
  }
  return num_procs;
}