method finds unit_of_work record and returns it to the caller
483336
def get_by_params(self, process_name, timeperiod, start_id, end_id):
        
        query = {unit_of_work.PROCESS_NAME: process_name,
                 unit_of_work.TIMEPERIOD: timeperiod,
                 unit_of_work.START_ID: start_id,
                 unit_of_work.END_ID: end_id}
        collection = self.ds.connection(COLLECTION_UNIT_OF_WORK)

        document = collection.find_one(query)
        if document is None:
            raise LookupError('UOW satisfying query {0} was not found'.format(query))
        return UnitOfWork.from_json(document)
1162411
private String persistWorkUnit(final Path workUnitFileDir, final WorkUnit workUnit, ParallelRunner stateSerDeRunner)
      throws IOException {
    final StateStore stateStore;
    String workUnitFileName = workUnit.getId();

    if (workUnit instanceof MultiWorkUnit) {
      workUnitFileName += MULTI_WORK_UNIT_FILE_EXTENSION;
      stateStore = stateStores.getMwuStateStore();
    } else {
      workUnitFileName += WORK_UNIT_FILE_EXTENSION;
      stateStore = stateStores.getWuStateStore();
    }

    Path workUnitFile = new Path(workUnitFileDir, workUnitFileName);
    final String fileName = workUnitFile.getName();
    final String storeName = workUnitFile.getParent().getName();
    stateSerDeRunner.submitCallable(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        stateStore.put(storeName, fileName, workUnit);
        return null;
      }
    }, "Serialize state to store " + storeName + " file " + fileName);

    return workUnitFile.toString();
  }
1002215
def getUnitCost(self, CorpNum):
        

        result = self._httpget('/CloseDown/UnitCost', CorpNum)

        return float(result.unitCost)
1030733
def record(self):
        """"""
        if self.recordmetadata:
            return Record(self.recordmetadata.json, model=self.recordmetadata)
        else:
            return None
1125341
function determineIfIncluded(conn, earlier_unit, arrLaterUnits, handleResult){
	if (!earlier_unit)
		throw Error("no earlier_unit");
	if (storage.isGenesisUnit(earlier_unit))
		return handleResult(true);
	storage.readPropsOfUnits(conn, earlier_unit, arrLaterUnits, function(objEarlierUnitProps, arrLaterUnitProps){
		if (objEarlierUnitProps.is_free === 1)
			return handleResult(false);
		
		var max_later_limci = Math.max.apply(
			null, arrLaterUnitProps.map(function(objLaterUnitProps){ return objLaterUnitProps.latest_included_mc_index; }));
		//console.log("max limci "+max_later_limci+", earlier mci "+objEarlierUnitProps.main_chain_index);
		if (objEarlierUnitProps.main_chain_index !== null && max_later_limci >= objEarlierUnitProps.main_chain_index)
			return handleResult(true);
		
		var max_later_level = Math.max.apply(
			null, arrLaterUnitProps.map(function(objLaterUnitProps){ return objLaterUnitProps.level; }));
		if (max_later_level < objEarlierUnitProps.level)
			return handleResult(false);
		
		function goUp(arrStartUnits){
			//console.log('determine', earlier_unit, arrLaterUnits, arrStartUnits);
			conn.query(
				"SELECT unit, level, latest_included_mc_index, main_chain_index, is_on_main_chain \n\
				FROM parenthoods JOIN units ON parent_unit=unit \n\
				WHERE child_unit IN(?)",
				[arrStartUnits],
				function(rows){
					var arrNewStartUnits = [];
					for (var i=0; i<rows.length; i++){
						var objUnitProps = rows[i];
						if (objUnitProps.unit === earlier_unit)
							return handleResult(true);
						if (objUnitProps.is_on_main_chain === 0 && objUnitProps.level > objEarlierUnitProps.level)
							arrNewStartUnits.push(objUnitProps.unit);
					}
					(arrNewStartUnits.length > 0) ? goUp(_.uniq(arrNewStartUnits)) : handleResult(false);
				}
			);
		}
		
		goUp(arrLaterUnits);
	
	});
}
719365
def _guess_record(self, rtype, name=None, content=None):
        """"""
        records = self._list_records_internal(
            identifier=None, rtype=rtype, name=name, content=content)
        if len(records) == 1:
            return records[0]
        if len(records) > 1:
            raise Exception(
                'Identifier was not provided and several existing '
                'records match the request for {0}/{1}'.format(rtype, name))
        raise Exception(
            'Identifier was not provided and no existing records match '
            'the request for {0}/{1}'.format(rtype, name))
204257
def get(self, deviceId, measurementId):
        
        record = self.measurements.get(deviceId)
        if record is not None:
            return record.get(measurementId)
        return None
1267168
public int getRecordCount(Rec record)
    {
        int iRecordCount = 1;
        if ((this.getNodeType() == MessageRecordDesc.NON_UNIQUE_NODE)
            && (!this.isSingleDetail(record)))
                iRecordCount = Integer.MAX_VALUE;   // Until EOF
        return iRecordCount;
    }
214777
def _get_and_start_work(self):
        ""
        worker_id = nice_identifier()
        work_unit = self.task_master.get_work(worker_id, available_gb=self.available_gb())
        if work_unit is None:
            return None, None
        async_result = self.pool.apply_async(
            run_worker,
            (HeadlessWorker, self.task_master.registry.config,
             worker_id,
             work_unit.work_spec_name,
             work_unit.key),
            callback=self._finish_callback)
        return async_result, work_unit
1148054
def run_query(self, query):
        
        cursor = self.ds.filter(COLLECTION_UNIT_OF_WORK, query)
        return [UnitOfWork.from_json(document) for document in cursor]
749923
def get_one(self, key):
        
        query = {'_id': ObjectId(key)}
        collection = self.ds.connection(COLLECTION_UNIT_OF_WORK)

        document = collection.find_one(query)
        if document is None:
            msg = 'UOW with ID={0} was not found'.format(key)
            self.logger.warning(msg)
            raise LookupError(msg)
        return UnitOfWork.from_json(document)
661680
def record(self, i=0):
        """"""
        f = self.__getFileObj(self.dbf)
        if not self.numRecords:
            self.__dbfHeader()
        i = self.__restrictIndex(i)
        recSize = self.__recordFmt()[1]
        f.seek(0)
        f.seek(self.__dbfHeaderLength() + (i * recSize))
        return self.__record()
223772
public final DocWorkUnit findWorkUnitForClass(final Class<?> c) {
        for (final DocWorkUnit workUnit : this.workUnits)
            if (workUnit.getClazz().equals(c))
                return workUnit;
        return null;
    }
294078
def handle_units(changeset):
    """"""
    units, records = {}, {}
    for service_name, service in sorted(changeset.bundle['services'].items()):
        for i in range(service.get('num_units', 0)):
            record_id = 'addUnit-{}'.format(changeset.next_action())
            unit_name = '{}/{}'.format(service_name, i)
            records[record_id] = {
                'id': record_id,
                'method': 'addUnit',
                'args': [
                    '${}'.format(changeset.services_added[service_name]),
                    None,
                ],
                'requires': [changeset.services_added[service_name]],
            }
            units[unit_name] = {
                'record': record_id,
                'service': service_name,
                'unit': i,
            }
    _handle_units_placement(changeset, units, records)
691987
def get_unit_name(self):
        
        if not self.unit:
            return None
        name = sorted(self.unit.names, key=len)[-1]
        return '%ss' % name
228251
def bulk_record_workunits(self, engine_workunits):
    """"""
    for workunit in engine_workunits:
      duration = workunit['end_timestamp'] - workunit['start_timestamp']

      span = zipkin_span(
        service_name="pants",
        span_name=workunit['name'],
        duration=duration,
        span_storage=self.span_storage,
      )
      span.zipkin_attrs = ZipkinAttrs(
        trace_id=self.trace_id,
        span_id=workunit['span_id'],
        # TODO change it when we properly pass parent_id to the v2 engine Nodes
        # TODO Pass parent_id with ExecutionRequest when v2 engine is called by a workunit
        # TODO pass parent_id when v2 engine Node is called by another v2 engine Node
        parent_span_id=workunit.get("parent_id", self.parent_id),
        flags='0', # flags: stores flags header. Currently unused
        is_sampled=True,
      )
      span.start()
      span.start_timestamp = workunit['start_timestamp']
      span.stop()
857571
def get_record(identifier, opts = {})
      opts[:identifier] = identifier
      opts = @opts.merge(opts)
      @record_class.build(mint_id(identifier),
                          record_xml(client.get_record(opts).record))
    end