For BATCHEXECDIRECT
347285
public static Result newBatchedExecuteRequest() {

        Type[] types  = new Type[]{ Type.SQL_VARCHAR };
        Result result = newResult(ResultConstants.BATCHEXECDIRECT);

        result.metaData = ResultMetaData.newSimpleResultMetaData(types);

        return result;
    }
1321281
def _spawnAsBatch(self, processProtocol, executable, args, env,
                      path, usePTY):
        """"""

        # NamedTemporaryFile differs in PY2 and PY3.
        # In PY2, it needs encoded str and its encoding cannot be specified.
        # In PY3, it needs str which is unicode and its encoding can be specified.
        if PY3:
            tf = NamedTemporaryFile(mode='w+', dir='.', suffix=".bat",
                                    delete=False, encoding=self.builder.unicode_encoding)
        else:
            tf = NamedTemporaryFile(mode='w+', dir='.', suffix=".bat",
                                    delete=False)

        # echo off hides this cheat from the log files.
        tf.write(u"@echo off\n")
        if isinstance(self.command, (string_types, bytes)):
            tf.write(bytes2NativeString(self.command, self.builder.unicode_encoding))
        else:
            tf.write(win32_batch_quote(self.command, self.builder.unicode_encoding))
        tf.close()

        argv = os.environ['COMSPEC'].split()  # allow %COMSPEC% to have args
        if '/c' not in argv:
            argv += ['/c']
        argv += [tf.name]

        def unlink_temp(result):
            os.unlink(tf.name)
            return result
        self.deferred.addBoth(unlink_temp)

        return reactor.spawnProcess(processProtocol, executable, argv, env,
                                    path, usePTY=usePTY)
135822
private List<Entity> findAllBatch(List<Object> batch) {
    String entityId = getEntityType().getId();
    EntityType entityType = getEntityType();
    List<Object> missingIds =
        batch
            .stream()
            .filter(id -> !l1Cache.get(entityId, id, entityType).isPresent())
            .collect(toList());

    Map<Object, Entity> missingEntities =
        delegate().findAll(missingIds.stream()).collect(toMap(Entity::getIdValue, e -> e));

    return batch
        .stream()
        .map(
            id ->
                l1Cache
                    .get(entityId, id, getEntityType())
                    .map(CacheHit::getValue)
                    .orElse(missingEntities.get(id)))
        .collect(toList());
  }
760788
function batch(ops, testCacheEnabled) {
  const cacheEnabled = testCacheEnabled || CACHE_ENABLED;

  return postgres.batch(ops)
    .then((res) => {
      if (cacheEnabled) {
        return redis.batch(ops).then(() => res);
      }

      return res;
    });
}
463568
public void batch(List<? extends Row> actions, @Nullable Object[] results)
      throws IOException, InterruptedException {
    if (results == null) {
      results = new Object[actions.size()];
    }
    batchCallback(actions, results, null);
  }
66012
def _do_batched_write_command(
        namespace, operation, command, docs, check_keys, opts, ctx):
    """"""
    if ctx.sock_info.compression_context:
        return _batched_write_command_compressed(
            namespace, operation, command, docs, check_keys, opts, ctx)
    return _batched_write_command(
        namespace, operation, command, docs, check_keys, opts, ctx)
369632
private static <T> void batchGroupBy(T[] array, int start, int end, MultimapPutProcedure<?, T> castProcedure)
    {
        for (int i = start; i < end; i++)
        {
            castProcedure.value(array[i]);
        }
    }
1171621
@Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {

        Batch batch = ctx.getBatchManager().getActiveBatch();
        if(batch == null) {
            throw new CommandFormatException("No active batch.");
        }
        batch.clear();
    }
330196
public static void createFileBatchesLocal(File inputDirectory, boolean recursive, File outputDirectory, int batchSize) throws IOException {
        createFileBatchesLocal(inputDirectory, null, recursive, outputDirectory, batchSize);
    }
656922
public void executeBatch(BatchOperation batchOperation) throws FMSException {

        IntuitMessage intuitMessage = prepareBatch(batchOperation);

        //execute interceptors
        executeInterceptors(intuitMessage);

        IntuitResponse intuitResponse = (IntuitResponse) intuitMessage.getResponseElements().getResponse();
        if (intuitResponse != null) {
            List<BatchItemResponse> batchItemResponses = intuitResponse.getBatchItemResponse();
            if (batchItemResponses != null && !batchItemResponses.isEmpty()) {
                int count = 0;
                Iterator<BatchItemResponse> itr = batchItemResponses.iterator();
                while (itr.hasNext()) {
                    BatchItemResponse batchItemResponse = itr.next();
                    String bId = batchItemResponse.getBId();
                    if (!StringUtils.hasText(bId)) {
                        bId = batchOperation.getBatchItemRequests().get(count).getBId();
                    }
                    if (batchItemResponse.getFault() != null) {
                        // segregate fault batch items
                        batchOperation.getFaultResult().put(bId, batchItemResponse.getFault());
                    } else if (batchItemResponse.getReport() != null) {
                        // segregate report batch items
                        batchOperation.getReportResult().put(bId, batchItemResponse.getReport());
                    } else if (batchItemResponse.getIntuitObject() != null) {
                        // segregate entity batch items
                        batchOperation.getEntityResult().put(bId, (IEntity) batchItemResponse.getIntuitObject().getValue());
                    } else if (batchItemResponse.getQueryResponse() != null) {
                        // segregate query batch items
                        QueryResult queryResult = getQueryResult(batchItemResponse.getQueryResponse());
                        batchOperation.getQueryResult().put(bId, queryResult);
                    } else if (batchItemResponse.getCDCResponse() != null) {
                        // segregate cdc query batch items
                        CDCQueryResult cdcQueryResult = getCDCQueryResult(batchItemResponse.getCDCResponse());
                        batchOperation.getCDCQueryResult().put(bId, cdcQueryResult);
                    } else {
                        LOG.warn("BatchItemResponse is not Fault, Entity, Query and Report.");
                    }
                    count++;
                }
            }
        }
    }
826534
@Override
    protected void doHandle(CommandContext ctx) throws CommandLineException {

        final BatchManager batchManager = ctx.getBatchManager();
        if(batchManager.isBatchActive()) {
            throw new CommandFormatException("try is not allowed while in batch mode.");
        }
        ctx.registerRedirection(new TryCatchFinallyControlFlow(ctx));
    }
1216521
@Override
    protected void doHandle(CommandContext ctx) throws CommandLineException {

        final BatchManager batchManager = ctx.getBatchManager();

        final boolean list = l.isPresent(ctx.getParsedCommandLine());
        final String path = file.getValue(ctx.getParsedCommandLine());
        final String name = this.name.getValue(ctx.getParsedCommandLine());

        if(list) {
            if(path != null || name != null) {
                throw new CommandFormatException("-l is exclusive, neither --file nor name can appear with -l.");
            }

            final Set<String> heldbackNames = batchManager.getHeldbackNames();
            if(!heldbackNames.isEmpty()) {
                List<String> names = new ArrayList<String>(heldbackNames.size());
                for (String heldbackName : heldbackNames) {
                    names.add(heldbackName == null ? "<unnamed>" : heldbackName);
                }
                Collections.sort(names);
                for (String heldbackName : names) {
                    ctx.printLine(heldbackName);
                }
            }
            return;
        }

        if(batchManager.isBatchActive()) {
            throw new CommandLineException("Can't start a new batch while in batch mode.");
        }

        if(path != null) {
            if(name != null) {
                throw new CommandFormatException("Either --file or name argument can be specified at a time.");
            }

            final File f = new File(path);
            if(!f.exists()) {
                throw new CommandLineException("File " + f.getAbsolutePath() + " does not exist.");
            }

            final File currentDir = ctx.getCurrentDir();
            final File baseDir = f.getParentFile();
            if(baseDir != null) {
                ctx.setCurrentDir(baseDir);
            }

            try (BufferedReader reader = new BufferedReader(new FileReader(f))) {
                String line = reader.readLine();
                batchManager.activateNewBatch();
                final Batch batch = batchManager.getActiveBatch();
                while (line != null) {
                    line = line.trim();
                    if (!line.isEmpty() && line.charAt(0) != '#') {
                        batch.add(ctx.toBatchedCommand(line));
                    }
                    line = reader.readLine();
                }
            } catch(IOException e) {
                batchManager.discardActiveBatch();
                throw new CommandLineException("Failed to read file " + f.getAbsolutePath(), e);
            } catch(CommandFormatException e) {
                batchManager.discardActiveBatch();
                throw new CommandLineException("Failed to create batch from " + f.getAbsolutePath(), e);
            } finally {
                if (baseDir != null) {
                    ctx.setCurrentDir(currentDir);
                }
            }
            return;
        }

        boolean activated;
        if(batchManager.isHeldback(name)) {
            activated = batchManager.activateHeldbackBatch(name);
            if (activated) {
                final String msg = name == null ? "Re-activated batch" : "Re-activated batch '" + name + "'";
                ctx.printLine(msg);
                List<BatchedCommand> batch = batchManager.getActiveBatch().getCommands();
                if (!batch.isEmpty()) {
                    for (int i = 0; i < batch.size(); ++i) {
                        BatchedCommand cmd = batch.get(i);
                        ctx.printLine("#" + (i + 1) + ' ' + cmd.getCommand());
                    }
                }
            }
        } else if(name != null) {
            throw new CommandLineException("'" + name + "' not found among the held back batches.");
        } else {
            activated = batchManager.activateNewBatch();
        }

        if(!activated) {
            // that's more like illegal state
            throw new CommandLineException("Failed to activate batch.");
        }
    }
683569
function stat(dir, files, cb) {
  var batch = new Batch();

  batch.concurrency(10);

  files.forEach(function(file){
    batch.push(function(done){
      fs.stat(join(dir, file), function(err, stat){
        if (err && err.code !== 'ENOENT') return done(err);

        // pass ENOENT as null stat, not error
        done(null, stat || null);
      });
    });
  });

  batch.end(cb);
}
808909
private void doWrite(final LogEntry logEntry) throws SQLException {
		if (checkConnection()) {
			if (batch) {
				batchCount += 1;
			}

			try {
				for (int i = 0; i < tokens.size(); ++i) {
					tokens.get(i).apply(logEntry, statement, i + 1);
				}
			} catch (SQLException ex) {
				resetConnection();
				throw ex;
			}

			try {
				if (batch) {
					statement.addBatch();
					if (batchCount >= MAX_BATCH_SIZE) {
						statement.executeBatch();
						batchCount = 0;
					}
				} else {
					statement.executeUpdate();
				}
			} catch (SQLException ex) {
				resetConnection();
				throw ex;
			}
		} else {
			lostCount += 1;
		}
	}
692681
async function mkdirp(dir, mode=0o777, recursive=false){
    
    // stats command executable ? dir/file exists
    const stats = await _statx(dir);

    // dir already exists ?
    if (stats){
        // check if its a directory
        if (!stats.isDirectory()){
            throw new Error('Requested directory <' + dir  + '> already exists and is not of type directory');
        }

        // check mode
        if (stats.mode !== mode){
            await _fs.chmod(dir, mode);
        }

    // create it recursivly
    }else if (recursive){
        // absolute or relative path ? make it absolute
        // split into components
        const dirComponents = _path.parse(_path.resolve(dir));

        // get root dir (posix + windows)
        const rootDir = dirComponents.root;

        // extract dir (without root)
        const dirRelativePath = _path.join(dirComponents.dir, dirComponents.base).substring(rootDir.length);

        // split into parts
        const subdirs = dirRelativePath.split(_path.sep);

        // minimum of 1 segement required - this function does not create directories within filesystem root
        if (subdirs.length < 2){
            throw new Error('Recursive mkdir does not create directories within filesystem root!');
        }

        // build initial directory
        let dyndir = _path.join(rootDir, subdirs.shift());

        // iterate over path
        while (subdirs.length > 0){

            // append part
            dyndir = _path.join(dyndir, subdirs.shift());

            // stats command executable ? dir/file exists
            const cstats = await _statx(dyndir);

            // dir already exists ?
            if (cstats){
                // check if its a directory
                if (!cstats.isDirectory()){
                    throw new Error('Requested path <' + dyndir  + '> already exists and not of type directory');
                }
            
            // create directory
            }else{
                await _fs.mkdir(dyndir, mode);
            }
        }

    // just create top level
    }else{
        await _fs.mkdir(dir, mode);
    }
}
370473
def do_batch(resource_root, elements):
  
  return call(resource_root.post, BATCH_PATH, ApiBatchResponseList,
      data=elements, api_version=6)
1374976
def _getBatchDirectory(self, projectRootDirectory):
        
        # Set output directory to main directory as default
        batchDirectory = projectRootDirectory

        # Get the replace folder card
        replaceFolderCard = self.getCard('REPLACE_FOLDER')

        if replaceFolderCard:
            replaceDir = replaceFolderCard.value.strip('"')
            batchDirectory = os.path.join(batchDirectory, replaceDir)

        # Create directory if it doesn't exist
        if not os.path.isdir(batchDirectory):
            os.mkdir(batchDirectory)
            log.info('Creating directory for batch output: {0}'.format(batchDirectory))

        return batchDirectory