bool MpiLauncher::waitForExit(pid_t pid, int *status, bool noWait) { int opts = 0; if (noWait) { opts = WNOHANG; } while(true) { pid_t rc = ::waitpid(pid,status,opts); if ((rc == -1) && (errno==EINTR)) { continue; } if (rc == 0 && noWait) { return false; } if ((rc <= 0) || (rc != pid)) { int err = errno; throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_SYSCALL_ERROR) << "wait" << rc << err << pid); } return true; } throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNREACHABLE_CODE); return false; }
void MpiLauncher::completeLaunch(pid_t pid, const std::string& pidFile, int status) { // rm args file boost::scoped_ptr<SharedMemoryIpc> shmIpc(mpi::newSharedMemoryIpc(_ipcName)); shmIpc->remove(); shmIpc.reset(); // rm pid file scidb::File::remove(pidFile.c_str(), false); // rm log file if (!logger->isTraceEnabled() && !_inError) { string logFileName = mpi::getLauncherLogFile(_installPath, _queryId, _launchId); scidb::File::remove(logFileName.c_str(), false); } if (WIFSIGNALED(status)) { LOG4CXX_ERROR(logger, "SciDB MPI launcher (pid="<<pid<<") terminated by signal = " << WTERMSIG(status) << (WCOREDUMP(status)? ", core dumped" : "")); throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_OPERATION_FAILED) << "MPI launcher process"; } else if (WIFEXITED(status)) { int rc = WEXITSTATUS(status); if (rc != 0) { LOG4CXX_ERROR(logger, "SciDB MPI launcher (pid="<<_pid<<") exited with status = " << rc); throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_OPERATION_FAILED) << "MPI launcher process"; } else { LOG4CXX_DEBUG(logger, "SciDB MPI launcher (pid="<<_pid<<") exited with status = " << rc); return; } } throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNREACHABLE_CODE); }
Value& ConstRLEChunkIterator::getItem() { if (end()) { throw SYSTEM_EXCEPTION(SCIDB_SE_EXECUTION, SCIDB_LE_NO_CURRENT_ELEMENT); } position_t pos = _bmIter.getPPos(); //uncommon case: _pIter is out of sync due to a setPosition call if (_pIter.end() || _pIter.getPPos() > pos) { if(!_pIter.setPosition(pos)) { throw SYSTEM_EXCEPTION(SCIDB_SE_EXECUTION, SCIDB_LE_OPERATION_FAILED) << "setPosition"; } } //more common case: _pIter is a few elements behind _bmIter while(_pIter.getPPos() < pos) { ++_pIter; } _pIter.getItem(_value); return _value; }
// XXX TODO: consider returning std::vector<scidb::SharedMemoryPtr> // XXX TODO: which would require supporting different types of memory (double, char etc.) std::vector<MPIPhysical::SMIptr_t> MPIPhysical::allocateMPISharedMemory(size_t numBufs, size_t elemSizes[], size_t numElems[], string dbgNames[]) { if(DBG) { std::cerr << "SHM ALLOCATIONS:@@@@@@@@@@@@@@@@@@@" << std::endl ; for(size_t ii=0; ii< numBufs; ii++) { std::cerr << "numElems["<<ii<<"] "<< dbgNames[ii] << " len = " << numElems[0] << std::endl; } } std::vector<SMIptr_t> shmIpc(numBufs); for(size_t ii=0; ii<numBufs; ii++) { std::stringstream suffix; suffix << "." << ii ; std::string ipcNameFull= _ipcName + suffix.str(); LOG4CXX_TRACE(logger, "IPC name = " << ipcNameFull); shmIpc[ii] = SMIptr_t(mpi::newSharedMemoryIpc(ipcNameFull)); // can I get 'em off ctx instead? _ctx->addSharedMemoryIpc(_launchId, shmIpc[ii]); try { shmIpc[ii]->create(SharedMemoryIpc::RDWR); shmIpc[ii]->truncate(elemSizes[ii] * numElems[ii]); } catch(SharedMemoryIpc::SystemErrorException& e) { std::stringstream ss; ss << "shared_memory_mmap " << e.what(); throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_OPERATION_FAILED) << ss.str()) ; } catch(SharedMemoryIpc::InvalidStateException& e) { throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR) << e.what()); } } return shmIpc; }
/// @todo XXX TODO tigor: make it timeout ? TBD int64_t MpiSlaveProxy::waitForStatus(std::shared_ptr<MpiOperatorContext>& ctx, bool raise) { if (!_connection) { throw (InvalidStateException(REL_FILE, __FUNCTION__, __LINE__) << "No connection to MPI slave"); } LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForStatus: launchId="<<_launchId); MpiOperatorContext::LaunchErrorChecker errChecker = boost::bind(&checkLauncher, _delayForTestingInSec, _1, _2); std::shared_ptr<scidb::ClientMessageDescription> msg = ctx->popMsg(_launchId, errChecker); assert(msg); LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForStatus: message from client: " <<" ctx = " << msg->getClientContext().get() <<", msg type = "<< msg->getMessageType() <<", queryID = "<<msg->getQueryId()); if (_connection != msg->getClientContext()) { if (!msg->getClientContext() && msg->getMessageType() == scidb::SYSTEM_NONE_MSG_ID) { throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR) << "MPI slave disconnected prematurely"); } throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR) << "MPI slave connection context mismatch"); } if (msg->getMessageType() != scidb::mtMpiSlaveResult) { throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR) << "MPI slave returned invalid status"); } std::shared_ptr<scidb_msg::MpiSlaveResult> result = std::dynamic_pointer_cast<scidb_msg::MpiSlaveResult>(msg->getRecord()); assert(result); if (!result->has_status()) { throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR) << "MPI slave returned no status"); } if (raise && result->status() != 0) { std::stringstream ss; ss << "MPI Slave Execution returned status " << result->status(); throw (SYSTEM_EXCEPTION(SCIDB_SE_OPERATOR, SCIDB_LE_OPERATION_FAILED) << ss.str()); } return result->status(); }
FILE* openMemoryStream(char const* ptr, size_t size) { FILE* f; f = tmpfile(); if (NULL == f) { throw SYSTEM_EXCEPTION(SCIDB_SE_EXECUTION, SCIDB_LE_OPERATION_FAILED) << "tmpfile"; } size_t rc = fwrite(ptr, 1, size, f); if (rc != size) { throw SYSTEM_EXCEPTION(SCIDB_SE_EXECUTION, SCIDB_LE_OPERATION_FAILED) << "fwrite"; } fseek(f, 0, SEEK_SET); return f; }
ScanRLEArray::ScanRLEArray(ArrayDesc const& arr, std::string path) : RLEArray(arr), _dirPath(path), _maxChunkNo(0), logger(log4cxx::Logger::getLogger("scidb.query.ops.ScanRQArray")) { filesystem::path full_path = filesystem::system_complete(filesystem::path(_dirPath)); if (!filesystem::exists(full_path)) { throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_CANT_OPEN_PATH) << _dirPath; } if (!filesystem::is_directory(full_path)) { throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_DIRECTORY_EXPECTED) << _dirPath; } _maxChunkNo = arr.getNumberOfChunks() / arr.getAttributes().size(); }
static trn_cell_analysis_redo *put_redo_trn_cell(trn_cell_analysis_redo *rcv_redo_list, transaction_id trid, LSN first_lsn) { trn_cell_analysis_redo *it = rcv_redo_list, *new_cell; if ((new_cell = (trn_cell_analysis_redo *)malloc(sizeof(trn_cell_analysis_redo))) == NULL) throw SYSTEM_EXCEPTION("Cannot allocate memory!"); new_cell->trid = trid; new_cell->first_lsn = first_lsn; new_cell->end_lsn = LFS_INVALID_LSN; new_cell->finish_status = TRN_NOT_FINISHED; new_cell->prev = NULL; new_cell->next = NULL; // empty list if (rcv_redo_list == NULL) { rcv_redo_list = new_cell; return new_cell; } // find last element while (it->next != NULL) it = it->next; new_cell->prev = it; it->next = new_cell; return new_cell; }
void MpiSlaveProxy::waitForExit(std::shared_ptr<MpiOperatorContext>& ctx) { if (!_connection) { throw (InvalidStateException(REL_FILE, __FUNCTION__, __LINE__) << "No connection to MPI slave"); } LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForExit: launchId="<<_launchId); MpiOperatorContext::LaunchErrorChecker errChecker = boost::bind(&checkTimeout, mpi::getTimeInSecs(), static_cast<double>(_MPI_SLAVE_RESPONSE_TIMEOUT), _1, _2); std::shared_ptr<scidb::ClientMessageDescription> msg = ctx->popMsg(_launchId, errChecker); assert(msg); LOG4CXX_DEBUG(logger, "MpiSlaveProxy::waitForExit: " <<" ctx = " << msg->getClientContext().get() <<", msg type = "<< msg->getMessageType() <<", queryID = "<<msg->getQueryId()); if (msg->getMessageType() != scidb::SYSTEM_NONE_MSG_ID) { throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNKNOWN_ERROR) << "MPI slave returned invalid status"); } assert(!msg->getClientContext()); _connection.reset(); }
inline void setOutputPosition( boost::shared_ptr<ArrayIterator>& stateArrayIterator, boost::shared_ptr<ChunkIterator>& stateChunkIterator, Coordinates const& outPos) { if (!stateChunkIterator || !stateChunkIterator->setPosition(outPos)) { //cout << "ok I couldn't set the pos" << endl; flush(cout); if (stateChunkIterator) { stateChunkIterator->flush(); stateChunkIterator.reset(); } //cout << "flushed the CiT" << endl; flush(cout); if (!stateArrayIterator->setPosition(outPos)) { //cout << "Even the AiT couldn't set .. do it" << endl; flush(cout); initializeOutput(stateArrayIterator, stateChunkIterator, outPos); //cout << "Done" << endl; flush(cout); } else { //cout << "The AiT was able .. Updating chunk .. or I dunno" << endl; flush(cout); boost::shared_ptr<Query> query(stateArrayIterator->getQuery()); Chunk& stateChunk = stateArrayIterator->updateChunk(); stateChunkIterator = stateChunk.getIterator(query, ChunkIterator::APPEND_CHUNK); //cout << "Done" << endl; flush(cout); } if (!stateChunkIterator->setPosition(outPos)) throw SYSTEM_EXCEPTION(SCIDB_SE_EXECUTION, SCIDB_LE_OPERATION_FAILED) << "setPosition"; } }
// Materialized Window Chunk Iterator MaterializedWindowChunkIterator::MaterializedWindowChunkIterator(WindowArrayIterator const& arrayIterator, WindowChunk const& chunk, int mode) : _array(arrayIterator.array), _chunk(chunk), _aggregate(_array._aggregates[_chunk._attrID]->clone()), _defaultValue(_chunk.getAttributeDesc().getDefaultValue()), _iterationMode(mode), _nextValue(TypeLibrary::getType(_chunk.getAttributeDesc().getType())), _stateMap(_chunk._stateMap), _inputMap(_chunk._inputMap), _currPos(0), _nDims(chunk._nDims), _coords(_nDims), _useOLDWindowAlgorithm( arrayIterator.useOLDWindowAlgorithm() ), _windowStartCoords(_nDims), _windowEndCoords(_nDims), _stripeStartCoords(_nDims), _stripeEndCoords(_nDims) { if ((_iterationMode & IGNORE_EMPTY_CELLS) == false) { //the client will ALWAYS use IGNORE_EMPTY_CELLS, right? Let's make sure they do. throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_CHUNK_WRONG_ITERATION_MODE); } reset(); }
/* Initialize the global DataStore state */ void DataStores::initDataStores(char const* basepath) { ScopedMutexLock sm(_dataStoreLock); if (_theDataStores == NULL) { _basePath = basepath; _basePath += "/"; _minAllocSize = Config::getInstance()->getOption<int>(CONFIG_STORAGE_MIN_ALLOC_SIZE_BYTES); /* Create the datastore directory if necessary */ if (!File::createDir(_basePath)) { throw SYSTEM_EXCEPTION(SCIDB_SE_STORAGE, SCIDB_LE_CANT_CREATE_DIRECTORY) << _basePath; } /* Start background flusher */ int syncMSeconds = Config::getInstance()->getOption<int> (CONFIG_SYNC_IO_INTERVAL); if (syncMSeconds > 0) { _dsflusher.start(syncMSeconds); } _theDataStores = new DataStoreMap(); /* Start error listener */ _listener.start(); } }
/* Construct a new DataStore object */ DataStore::DataStore(char const* filename, Guid guid, DataStores& parent) : _dsm(&parent), _dslock(), _guid(guid), _largestFreeChunk(0), _dirty(false), _fldirty(false) { /* Open the file */ string filenamestr = filename; _file = FileManager::getInstance()->openFileObj(filenamestr.c_str(), O_LARGEFILE | O_RDWR | O_CREAT); if (_file.get() == NULL) { throw SYSTEM_EXCEPTION(SCIDB_SE_STORAGE, SCIDB_LE_CANT_OPEN_FILE) << filenamestr << errno; } LOG4CXX_TRACE(logger, "datastore: new ds opened file " << filenamestr); /* Try to initialize the free lists from the free-list file. */ initializeFreelist(); }
/* Invalidate the free-list file on disk @pre caller has locked the DataStore */ void DataStore::invalidateFreelistFile() { if (!_fldirty) { File::FilePtr flfile; std::string filename; size_t nbuckets = 0; LOG4CXX_TRACE(logger, "datastore: invalidating freelist for " << _file->getPath()); filename = _file->getPath() + ".fl"; flfile = FileManager::getInstance()->openFileObj(filename, O_CREAT | O_TRUNC | O_RDWR); if (!flfile) { throw SYSTEM_EXCEPTION(SCIDB_SE_STORAGE, SCIDB_LE_CANT_OPEN_PATH) << filename; } /* This is one vulnerable spot... after truncate, but before we write the zero byte */ _dsm->getErrorListener().check(); flfile->writeAll((void*)&nbuckets, sizeof(size_t), 0); flfile->fsync(); _fldirty = true; _dsm->getFlusher().add(_guid); } }
/* Read a chunk from the DataStore */ void DataStore::readData(off_t off, void* buffer, size_t len) { DiskChunkHeader hdr; struct iovec iovs[2]; /* Set up the iovecs */ iovs[0].iov_base = (char*) &hdr; iovs[0].iov_len = sizeof(DiskChunkHeader); iovs[1].iov_base = (char*) buffer; iovs[1].iov_len = len; /* Issue the read */ _file->readAllv(iovs, 2, off); /* Check validity of header */ if (!hdr.isValid()) { throw SYSTEM_EXCEPTION(SCIDB_SE_STORAGE, SCIDB_LE_DATASTORE_CHUNK_CORRUPTED) << _file->getPath() << off; } }
/** * Generate a random value. * The function should be extended to cover all types and all special values such as NaN, and then be moved to a public header file. * @param[in] type the type of the value * @param[inout] value the value to be filled * @param[in] percentNull a number from 0 to 100, where 0 means never generate null, and 100 means always generate null * @return the value from the parameter */ Value& genRandomValue(TypeId const& type, Value& value, int percentNull, Value::reason nullReason) { assert(percentNull>=0 && percentNull<=100); if (percentNull>0 && rand()%100<percentNull) { value.setNull(nullReason); } else if (type==TID_INT64) { value.setInt64(rand()); } else if (type==TID_BOOL) { value.setBool(rand()%100<50); } else if (type==TID_STRING) { vector<char> str; const size_t maxLength = 300; const size_t minLength = 1; assert(minLength>0); size_t length = rand()%(maxLength-minLength) + minLength; str.resize(length + 1); for (size_t i=0; i<length; ++i) { int c; do { c = rand()%128; } while (! isalnum(c)); str[i] = (char)c; } str[length-1] = 0; value.setString(&str[0]); } else { throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNITTEST_FAILED) << "UnitTestChunkLimitPhysical" << "genRandomValue"; } return value; }
bool catalog_delete_name( enum catalog_named_objects obj_type, const char * name) { catalog_object_header * obj; catalog_name_record * n; catalog_journal_record * cr; obj = catalog_find_name(obj_type, name); if (obj == NULL) { throw SYSTEM_EXCEPTION("Catalog name being deleted doesn't exists"); } /* We really ADD the same name to cache (although it DOES already exist there) We don't care here who is going to set DELETED or RENAMED flag. */ n = catalog_cachetree_add_name(obj_type, name, obj); n->name_deleted = true; cr = new (cat_malloc_context(CATALOG_TEMPORARY_CONTEXT, sizeof(catalog_journal_record))) catalog_journal_record; cr->type = catalog_journal_record::del_name; cr->nor.object_type = obj_type; cr->nor.name_to_save = n; local_catalog->add_journal_record(cr); return true; }
void apply_after_insert_triggers(xptr new_var, xptr where_var, schema_node_cptr scm_node) { if (tr_globals::internal_auth_switch == BLOCK_AUTH_CHECK) return; //if insert while constructor if (IS_TMP_BLOCK(where_var)) return; if ((new_var==XNULL)||(where_var==XNULL)) throw SYSTEM_EXCEPTION("Bad parameters"); CHECKP(new_var); scm_node = getSchemaNode(new_var); //if the node is not element or attribute - return t_item node_type = getNodeType(new_var); if((node_type!=element)&&(node_type!=attribute)) return; // care about after-statement triggers find_triggers_for_node(scm_node, TRIGGER_INSERT_EVENT, TRIGGER_AFTER, TRIGGER_FOR_EACH_STATEMENT, &after_statement_triggers); t_triggers_set treated_triggers; trigger_cell_cptr trc = XNULL; while(true) { trc = find_trigger_for_node(scm_node, TRIGGER_INSERT_EVENT, TRIGGER_AFTER, TRIGGER_FOR_EACH_NODE, &treated_triggers); if(!trc.found()) return; trc->execute_trigger_action(new_var, XNULL, where_var); treated_triggers.insert(trc.ptr()); } }
/** * Build array chunk with indicated number of random values of the specified type, using indicated * iteration mode. * @param[in] query * @param[inout] array the array to receive data * @param[in] type the type of values to put into the chunk * @param[in] count the number of values to put into the chunk * @param[in] mode the iteration mode for the chunk iterator */ void buildRandomArrayChunk(std::shared_ptr<Query>& query, MemArray& array, TypeId type, int count, int mode) { Coordinates coord(1); coord[0] = 0; std::shared_ptr<ArrayIterator> arrayIter = array.getIterator(0); std::shared_ptr<ChunkIterator> chunkIter = ((MemChunk&)arrayIter->newChunk(coord)).getIterator(query, mode); if (!chunkIter->setPosition(coord)) { throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNITTEST_FAILED) << "UnitTestChunkLimit" << "Failed to set position in chunk"; } for (int j = 0; j < count; j++) { Value v; genRandomValue(type, v, 0, static_cast<Value::reason>(0)); chunkIter->writeItem(v); ++(*chunkIter); } chunkIter->flush(); }
ArrayDesc inferSchema(std::vector< ArrayDesc> schemas, std::shared_ptr< Query> query) { //As far as chunk sizes, they can be a pain! So we allow the user to specify an optional chunk size //as part of the sort op. assert(schemas.size() >= 1); ArrayDesc const& schema = schemas[0]; size_t chunkSize = 0; for (size_t i =0; i<_parameters.size(); i++) { if(_parameters[i]->getParamType()==PARAM_LOGICAL_EXPRESSION) { chunkSize = evaluate(((std::shared_ptr<OperatorParamLogicalExpression>&)_parameters[i])->getExpression(), query, TID_INT64).getInt64(); if(chunkSize <= 0) { throw SYSTEM_EXCEPTION(SCIDB_SE_INFER_SCHEMA, SCIDB_LE_CHUNK_SIZE_MUST_BE_POSITIVE); } break; } } // Use a SortArray object to build the schema. // Note: even though PhysicalSort::execute() uses an expanded schema, with chunk_pos and cell_pos, // these additional attributes are projected off before returning the final sort result. const bool preservePositions = false; SortArray sorter(schema, arena::getArena(), preservePositions, chunkSize); return sorter.getOutputArrayDesc(); }
void pping_client::shutdown() { if (!initialized) return; stop_keep_alive = true; if (UUnnamedSemaphoreUp(&sem, NULL) != 0) throw USER_ENV_EXCEPTION("Failed to up semaphore", false); if (uThreadJoin(client_thread_handle, NULL) != 0) throw USER_ENV_EXCEPTION("Error waiting for pping client thread to shutdown", false); if (uCloseThreadHandle(client_thread_handle, NULL) != 0) throw USER_EXCEPTION2(SE4063, "pping client_thread"); char c = PPING_DISCONNECT_MSG; if (usend(sock, &c, sizeof(char), NULL) != sizeof(char)) throw SYSTEM_EXCEPTION("pping server is down"); if (uclose_socket(sock, NULL) == U_SOCKET_ERROR) throw USER_ENV_EXCEPTION("Failed to close socket", false); if (UUnnamedSemaphoreRelease(&sem, NULL) != 0) throw USER_ENV_EXCEPTION("Failed to release semaphore", false); initialized = false; }
xptr apply_per_node_triggers(xptr new_var, xptr old_var, xptr where_var, schema_node_cptr scm_node, trigger_time time, trigger_event event) { switch (time){ case TRIGGER_BEFORE: switch (event){ case TRIGGER_INSERT_EVENT: if (!isTriggersOn) return new_var; return apply_before_insert_triggers(new_var, where_var); // return triggers_test(new_var, where_var, new_name, new_type); case TRIGGER_DELETE_EVENT: if (!isTriggersOn) return old_var; return apply_before_delete_triggers(old_var, where_var, scm_node); case TRIGGER_REPLACE_EVENT: if (!isTriggersOn) return new_var; return apply_before_replace_triggers(new_var, old_var, scm_node); default: throw SYSTEM_EXCEPTION("Bad trigger event"); } case TRIGGER_AFTER: switch (event){ case TRIGGER_INSERT_EVENT: if (!isTriggersOn) return XNULL; apply_after_insert_triggers(new_var, where_var, scm_node); return XNULL; case TRIGGER_DELETE_EVENT: if (!isTriggersOn) return XNULL; apply_after_delete_triggers(old_var, where_var, scm_node); return XNULL; case TRIGGER_REPLACE_EVENT: if (!isTriggersOn) return XNULL; apply_after_replace_triggers(new_var, old_var, where_var, scm_node); return XNULL; default: throw SYSTEM_EXCEPTION("Bad trigger event"); } default: throw SYSTEM_EXCEPTION("Bad trigger time"); } }
const std::string& PluginObjects::getObjectLibrary(const std::string& objectName) const { map< string, string>::const_iterator i = _objects.find(objectName); if (i != _objects.end()) return i->second; else throw SYSTEM_EXCEPTION(SCIDB_SE_PLUGIN_MGR, SCIDB_LE_OPERATOR_NOT_FOUND) << objectName; }
static void validateLauncherArg(const std::string& arg) { const char *notAllowed = " \n"; if (arg.find_first_of(notAllowed) != string::npos) { throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_INVALID_FUNCTION_ARGUMENT) << (string("MPI launcher argument with whitespace: ")+arg)); } }
// Window Chunk Iterator WindowChunkIterator::WindowChunkIterator(WindowArrayIterator const& arrayIterator, WindowChunk const& chunk, int mode) : _array(arrayIterator.array), _chunk(chunk), _firstPos(_chunk.getFirstPosition(false)), _lastPos(_chunk.getLastPosition(false)), _currPos(_firstPos.size()), _attrID(_chunk._attrID), _aggregate(_array._aggregates[_attrID]->clone()), _defaultValue(_chunk.getAttributeDesc().getDefaultValue()), _iterationMode(mode), _nextValue(TypeLibrary::getType(_chunk.getAttributeDesc().getType())) { if ((_iterationMode & IGNORE_EMPTY_CELLS) == false) { //the client will ALWAYS use IGNORE_EMPTY_CELLS, right? Let's make sure they do. throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_CHUNK_WRONG_ITERATION_MODE); } int iterMode = IGNORE_EMPTY_CELLS; if (_aggregate->ignoreNulls()) { iterMode |= IGNORE_NULL_VALUES; } if ( _aggregate->ignoreZeroes() && attributeDefaultIsSameAsTypeDefault() ) { iterMode |= IGNORE_DEFAULT_VALUES; } _inputIterator = arrayIterator.iterator->getChunk().getConstIterator(iterMode); if (_array.getArrayDesc().getEmptyBitmapAttribute()) { AttributeID eAttrId = _array._inputArray->getArrayDesc().getEmptyBitmapAttribute()->getId(); _emptyTagArrayIterator = _array._inputArray->getConstIterator(eAttrId); if (! _emptyTagArrayIterator->setPosition(_firstPos)) { throw SYSTEM_EXCEPTION(SCIDB_SE_EXECUTION, SCIDB_LE_OPERATION_FAILED) << "setPosition"; } _emptyTagIterator = _emptyTagArrayIterator->getChunk().getConstIterator(IGNORE_EMPTY_CELLS); } reset(); }
void ErrorsLibrary::registerErrors(const std::string &errorsNamespace, ErrorsMessages* msgMap) { ScopedMutexLock lock(_lock); int badErrorNumber = 0; if (_errorNamespaces.find(errorsNamespace) != _errorNamespaces.end()) throw SYSTEM_EXCEPTION(SCIDB_SE_ERRORS_MGR, SCIDB_LE_ERRNS_ALREADY_REGISTERED) << errorsNamespace; if ("scidb" != errorsNamespace) { // Check that non-SciDB error numbers are all > SCIDB_MAX_SYSTEM_ERROR. // (If there is more than one "foreign" error space, they still // might collide however. Bummer.) for (ErrorsMessages::const_iterator it = msgMap->begin(); it != msgMap->end(); ++it) { if (it->first <= SCIDB_MAX_SYSTEM_ERROR) { throw USER_EXCEPTION(SCIDB_SE_ERRORS_MGR, SCIDB_LE_INVALID_USER_ERROR_CODE) << errorsNamespace << it->first << SCIDB_MAX_SYSTEM_ERROR; } } } else { // Check that SciDB system error numbers are all <= SCIDB_MAX_SYSTEM_ERROR. for (ErrorsMessages::const_iterator it = msgMap->begin(); it != msgMap->end(); ++it) { if (it->first > SCIDB_MAX_SYSTEM_ERROR) { badErrorNumber = it->first; break; } } } _errorNamespaces[errorsNamespace] = msgMap; // Have to wait for SciDB errors to get registered (previous line) // before we throw one! Assuming SCIDB_LE_INVALID_SYSTEM_ERROR_CODE // is itself valid.... ;-D if (badErrorNumber) { throw SYSTEM_EXCEPTION(SCIDB_SE_ERRORS_MGR, SCIDB_LE_INVALID_SYSTEM_ERROR_CODE) << badErrorNumber << SCIDB_MAX_SYSTEM_ERROR; } }
/* inferSchema helps the query planner decide on the shape of * the output array. All operators must define this function. */ ArrayDesc inferSchema(vector< ArrayDesc> schemas, shared_ptr< Query> query) { ArrayDesc const& matrix = schemas[0]; if(matrix.getAttributes(true)[0].getType() != TID_STRING) throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_ILLEGAL_OPERATION) << "cu requires a single string-valued attribute"; Attributes outputAttributes(matrix.getAttributes()); Dimensions outputDimensions(matrix.getDimensions()); return ArrayDesc(matrix.getName(), outputAttributes, outputDimensions); }
/* Destructor (closes the file descriptor) */ File::~File() { int rc = close(); if (rc != 0) { throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_SYSCALL_ERROR) << "close" << rc << errno << _path); } }
/* Check if the file had been explicitly close and throw if so */ void File::checkClosedByUser() { if (_closed) { throw (SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_SYSCALL_ERROR) << "close called multiple times" << -1 << EBADFD << _path); } }
static double getTimingSec() { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) { assert(false); throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_CANT_GET_SYSTEM_TIME); } return (static_cast<double>(ts.tv_sec) + static_cast<double>(ts.tv_nsec) * 1e-9); }