def _updateCss(self, database, table): """ Update CSS with information about loaded table and database. """ # create database in CSS if not there yet if not self.css.containsDb(database): self._log.info('Creating database CSS info') options = self.partOptions.cssDbOptions() striping = css.StripingParams(options['nStripes'], options['nSubStripes'], 0, options['overlap']) self.css.createDb(database, striping, options['storageClass'], 'RELEASED') # define options for table options = self.partOptions.cssTableOptions() schema = self._schemaForCSS(database, table) if options.get('match', False): matchParams = css.MatchTableParams(options['dirTable1'], options['dirColName1'], options['dirTable2'], options['dirColName2'], options['flagColName']) self._log.info('Creating table CSS info for match table') self.css.createMatchTable(database, table, schema, matchParams) else: if 'dirTable' in options: # partitioned table pParams = css.PartTableParams( options['dirDb'], options['dirTable'], options['dirColName'], options['latColName'], options['lonColName'], options['overlap'], True, options['subChunks']) sParams = css.ScanTableParams(options['lockInMem'], options['scanRating']) else: pParams = css.PartTableParams() sParams = css.ScanTableParams() self.css.createTable(database, table, schema, pParams, sParams) # save chunk mapping too self._log.info('Saving updated chunk map to CSS') self.chunkMap.save()
def _parseCreateTable(self, tokens): """ Subparser - handles all CREATE TABLE requests. Throws css.CssError, _ToolError. """ l = len(tokens) if l == 2: (dbTbName, configFile) = tokens dbName, tbName = CommandParser._parseDbTable(dbTbName) options = self._fetchOptionsFromConfigFile(configFile) options = self._processTbOptions(dbName, options) if options.get('match', False): matchParams = css.MatchTableParams(options['dirTable1'], options['dirColName1'], options['dirTable2'], options['dirColName2'], options['flagColName'], options['angSep']) self._css.createMatchTable(dbName, tbName, options['schema'], matchParams) else: if 'dirTable' in options: # partitioned table params = css.PartTableParams( options.get('dirDb', ""), options['dirTable'], options['dirColName'], options['latColName'], options['lonColName'], options.get('overlap', 0.0), True, bool(int(options['subChunks']))) sParams = css.ScanTableParams( bool(options.get('lockInMem', False)), int(options.get('scanRating', 0))) else: params = css.PartTableParams() sParams = css.ScanTableParams() self._css.createTable(dbName, tbName, options['schema'], params, sParams) else: raise _IllegalCommandError("Unexpected number of arguments.")
def _parseCreateTable(self, tokens): """ Subparser - handles all CREATE TABLE requests. Throws css.CssError, _ToolError. """ l = len(tokens) if l == 2: (dbTbName, configFile) = tokens if '.' not in dbTbName: raise _IllegalCommandError( "Invalid argument '{0}', should be <dbName>.<tbName>". format(dbTbName)) (dbName, tbName) = dbTbName.split('.') options = self._fetchOptionsFromConfigFile(configFile) options = self._processTbOptions(dbName, options) if options.get('match', False): matchParams = css.MatchTableParams(options['dirTable1'], options['dirColName1'], options['dirTable2'], options['dirColName2'], options['flagColName']) self._css.createMatchTable(dbName, tbName, options['schema'], matchParams) else: if 'dirTable' in options: # partitioned table params = css.PartTableParams( options.get('dirDb', ""), options['dirTable'], options['dirColName'], options['latColName'], options['lonColName'], options.get('overlap', 0.0), True, bool(int(options['subChunks']))) else: params = css.PartTableParams() self._css.createTable(dbName, tbName, options['schema'], params) else: raise _IllegalCommandError("Unexpected number of arguments.")