/*
Helper methods
513875
protected OrganizationalEntity[] convert(List<String> orgEntities, boolean isUser) {
        return orgEntities.stream().map(isUser ? mapToUser : mapToGroup).toArray(size -> new OrganizationalEntity[size]);
    }
52796
function  buildSqlFilter(filter, columns)  {
	if (filter.op === 'and')  {
		var  clones = [];
		filter.filters.forEach(function(f) {
			var  cf = buildSqlFilter(f, columns);
			if (cf)
				clones.push( cf );
		});
		
		var  len = clones.length;
		if (len < 1)
			return null;
		else
			return  len > 1  ?  {op: 'and', filters: clones} : clones[0];
	}
	else  if (filter.op === 'or')  {
		var  clones = [];
		filter.filters.forEach(function(f) {
			var  cf = buildSqlFilter(f, columns);
			if (cf)
				clones.push( cf );
		});

		return  clones.length === filter.filters.length  ?  {op: 'or', filters: clones} : null;
	}

	var  cf = null,
		 colName = filter.name;
	if (columns.indexOf(colName) >= 0)
		cf = filter; //cloneObj( filter );


	return  cf;
}
1144710
@Override
    public List<? extends SatConstraint> buildConstraint(BtrPlaceTree t, List<BtrpOperand> args) {
        if (checkConformance(t, args)) {
            @SuppressWarnings("unchecked")
            Collection<Collection<VM>> vs = (Collection<Collection<VM>>) params[0].transform(this, t, args.get(0));
            @SuppressWarnings("unchecked")
            Collection<Collection<Node>> ps = (Collection<Collection<Node>>) params[1].transform(this, t, args.get(1));
            return vs != null && ps != null ? Collections.singletonList(new SplitAmong(vs, ps, false)) : Collections.emptyList();
        }
        return Collections.emptyList();
    }
1212447
@Override
    public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException {
        ParsedCommandLine args = ctx.getParsedCommandLine();
        final String path = this.path.getValue(args, true);

        final File archive;
        archive = new File(path);
        if(!archive.exists()) {
            throw new OperationFormatException("Path " + archive.getAbsolutePath() + " doesn't exist.");
        }
        if(archive.isDirectory()) {
            throw new OperationFormatException(archive.getAbsolutePath() + " is a directory.");
        }
        File root;
        try {
            root = extractArchive(archive);
        } catch (IOException e) {
            throw new OperationFormatException("Unable to extract archive '" + archive.getAbsolutePath() + "' to temporary location");
        }

        ctx.setCurrentDir(root);
        String holdbackBatch = activateNewBatch(ctx);

        try {
            String script = this.script.getValue(args);
            if (script == null) {
                script = "deploy.scr";
            }

            File scriptFile = new File(ctx.getCurrentDir(),script);
            if (!scriptFile.exists()) {
                throw new CommandFormatException("ERROR: script " + script + "' not found.");
            }
            ctx.printLine("Processing script '" + script + "'.");

            try (BufferedReader reader = new BufferedReader(new FileReader(scriptFile))) {
                String line = reader.readLine();
                while (!ctx.isTerminated() && line != null) {
                    ctx.handle(line);
                    line = reader.readLine();
                }
            } catch (FileNotFoundException e) {
                throw new CommandFormatException("ERROR: script " + script + "' not found.");
            } catch (IOException e) {
                throw new CommandFormatException(e.getMessage());
            } catch (CommandLineException e) {
                throw new CommandFormatException(e.getMessage());
            }

            ModelNode composite = ctx.getBatchManager().getActiveBatch().toRequest();

            return composite;
        } finally {
            // reset current dir in context
            ctx.setCurrentDir(new File(""));
            discardBatch(ctx, holdbackBatch);
            recursiveDelete(root);
        }
    }
1006943
@Override
    public void init(NamedList args) {

        Object regex = args.remove(PARAM_REGEX);
        if (null == regex) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_REGEX);
        }
        try {
            m_regex = Pattern.compile(regex.toString());
        } catch (PatternSyntaxException e) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Invalid regex: " + regex, e);
        }

        Object replacement = args.remove(PARAM_REPLACEMENT);
        if (null == replacement) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_REPLACEMENT);
        }
        m_replacement = replacement.toString();

        Object source = args.remove(PARAM_SOURCE);
        if (null == source) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_SOURCE);
        }
        m_source = source.toString();

        Object target = args.remove(PARAM_TARGET);
        if (null == target) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_TARGET);
        }
        m_target = target.toString();

    }
325956
function toSQL(method) {
    method = method || this.method;
    var val = this[method]();
    var defaults = {
      method: method,
      options: assign({}, this.options),
      bindings: this.formatter.bindings
    };
    if (typeof val === 'string') {
      val = { sql: val };
    }

    if (method === 'select' && this.single.as) {
      defaults.as = this.single.as;
    }
    var out = assign(defaults, val);
    debug(out);
    return out;
  }
161292
private void setRequestArgsForReadAttr(final Request request, final String[] names,
            final DevSource src, final ClntIdent ident, final TypeCode return_type) {
        Any any;
        any = request.add_in_arg();
        DevVarStringArrayHelper.insert(any, names);

        // Add source if any
        if (src != null) {
            any = request.add_in_arg();
            DevSourceHelper.insert(any, src);
        }
        if (ident != null) {
            any = request.add_in_arg();
            ClntIdentHelper.insert(any, ident);
        }
        request.set_return_type(return_type);
        request.exceptions().add(DevFailedHelper.type());
    }
550741
@Override public void lcompute() {
    _ok = new int[_files.length][H2O.CLOUD.size()];
    for (int i = 0; i < _files.length; ++i) {
      File f = new File(_files[i]);
      if (f.exists() && (f.length()==_sizes[i]))
        _ok[i][H2O.SELF.index()] = 1;
    }
    tryComplete();
  }
375337
ForCtrl forCtrl() {
		ExprList exprList = exprList();
		if (peek().sym == Sym.SEMICOLON) {
			move();
			Expr cond = expr();
			match(Sym.SEMICOLON);
			ExprList update = exprList();
			return new ForCtrl(exprList, cond, update, location);
		}
		
		if (exprList.length() == 1) {
			Expr expr = exprList.getExprArray()[0];
			if (expr instanceof Id) {
				match(Sym.COLON);
				return new ForCtrl(((Id)expr), expr(), location);
			}
		}
		throw new ParseException("The expression of #for directive is error", location);
	}
900928
public static String[] getStringArray(String name){
        if(getConfiguration().containsKey(name)){
            return getConfiguration().getStringArray(name);
        }
        return null;
    }
51111
@Override
  public int[] columns(String[] names) {
    int[] idxs = new int[_strs.length];
    for (int i = 0; i < _strs.length; i++) {
      int idx = idxs[i] = water.util.ArrayUtils.find(names, _strs[i]);
      if (idx == -1) throw new IllegalArgumentException("Column " + _strs[i] + " not found");
    }
    return idxs;
  }
1073164
public static void main(String[] args) throws IOException, ClassNotFoundException {
    CoNLLDocumentReaderAndWriter f = new CoNLLDocumentReaderAndWriter();
    f.init(new SeqClassifierFlags());
    int numDocs = 0;
    int numTokens = 0;
    int numEntities = 0;
    String lastAnsBase = "";
    for (Iterator<List<CoreLabel>> it = f.getIterator(new FileReader(args[0])); it.hasNext(); ) {
      List<CoreLabel> doc = it.next();
      numDocs++;
      for (CoreLabel fl : doc) {
        // System.out.println("FL " + (++i) + " was " + fl);
        if (fl.word().equals(BOUNDARY)) {
          continue;
        }
        String ans = fl.get(AnswerAnnotation.class);
        String ansBase;
        String ansPrefix;
        String[] bits = ans.split("-");
        if (bits.length == 1) {
          ansBase = bits[0];
          ansPrefix = "";
        } else {
          ansBase = bits[1];
          ansPrefix = bits[0];
        }
        numTokens++;
        if (ansBase.equals("O")) {
        } else if (ansBase.equals(lastAnsBase)) {
          if (ansPrefix.equals("B")) {
            numEntities++;
          }
        } else {
          numEntities++;
        }
      }
    }
    System.out.println("File " + args[0] + " has " + numDocs + " documents, " +
            numTokens + " (non-blank line) tokens and " +
            numEntities + " entities.");
  }
218225
function() {
        this.io = µBlock.CompiledLineIO;
        this.blockId = undefined;
        this.block = undefined;
        this.stringifier = this.io.serialize;
        this.blocks = new Map();
        this.properties = new Map();
    }
995645
function(req) {
    var fields = {};

    // Fields
    if (_.isString(req.query.fields)) {
      _.forEach(req.query.fields.split(','), function(field) {
        fields[field] = 1;
      });
    }

    return fields;
  }
129851
@Override
    public List<MaxOnline> buildConstraint(BtrPlaceTree t, List<BtrpOperand> args) {
        if (checkConformance(t, args)) {
          @SuppressWarnings("unchecked")
          List<Node> ns = (List<Node>) params[0].transform(this, t, args.get(0));
            if (ns == null) {
                return Collections.emptyList();
            }
            Set<Node> s = new HashSet<>(ns);
            if (s.size() != ns.size()) {                //Prevent duplicates
                return Collections.emptyList();
            }

            BtrpNumber n = (BtrpNumber) args.get(1);
            if (!n.isInteger()) {
                t.ignoreError("Parameter '" + params[1].getName() + "' expects an integer");
                return Collections.emptyList();
            }
            int v = n.getIntValue();
            if (v < 0) {
                t.ignoreError("Parameter '" + params[1].getName() + "' expects a positive integer (" + v + " given)");
                return Collections.emptyList();
            }

            return Collections.singletonList(new MaxOnline(new HashSet<>(ns), v, true));
        }
        return Collections.emptyList();
    }
1280089
function (mode, code, tokens, flags, scope, parseMode) {
    var index = code.index,
        length = code.length;

    if ( /* <!-- */
        code.codePointAt(index) === 0x003c &&
        code.codePointAt(++index) === 0x0021 &&
        code.codePointAt(++index) === 0x002d &&
        code.codePointAt(++index) === 0x002d
    ) {
        index++;

        for (; index < length; index++) {
            if ( /* --> */
                code.codePointAt(index) === 0x002d &&
                code.codePointAt(index + 1) === 0x002d &&
                code.codePointAt(index + 2) === 0x003e
            ) {
                index += 3;
                code.index = index;

                return true;
            }
        }

        throw code.makeError(
            code.index, code.index + 4,
            'Unclosed Comment: Expected "-->" to fallow "<!--".'
        );
    }

    return null;
}
632154
@Override
  public PathImpl schemeWalk(String userPath,
                         Map<String,Object> attributes,
                         String filePath,
                         int offset)
  {
    int length = filePath.length();

    if (length <= offset || filePath.charAt(offset) != '(')
      return super.schemeWalk(userPath, attributes, filePath, offset);

    MergePath mergePath = createMergePath();
    mergePath.setUserPath(userPath);

    int head = ++offset;
    int tail = head;
    while (tail < length) {
      int ch = filePath.charAt(tail);

      if (ch == ')') {
        if (head + 1 != tail) {
          String subPath = filePath.substring(head, tail);

          if (subPath.startsWith("(") && subPath.endsWith(")"))
            subPath = subPath.substring(1, subPath.length() - 1);

          mergePath.addMergePath(VfsOld.lookup(subPath));
        }

        if (tail + 1 == length)
          return mergePath;
        else
          return mergePath.fsWalk(userPath, attributes, filePath.substring(tail + 1));
      }
      else if (ch == ';') {
        String subPath = filePath.substring(head, tail);

        if (subPath.startsWith("(") && subPath.endsWith(")"))
          subPath = subPath.substring(1, subPath.length() - 1);

        mergePath.addMergePath(VfsOld.lookup(subPath));

        head = ++tail;
      }
      else if (ch == '(') {
        int depth = 1;

        for (tail++; tail < length; tail++) {
          if (filePath.charAt(tail) == '(')
            depth++;
          else if (filePath.charAt(tail) == ')') {
            tail++;
            depth--;
            if (depth == 0)
              break;
          }
        }

        if (depth != 0)
          return new NotFoundPath(getSchemeMap(), filePath);
      }
      else
        tail++;
    }

    return new NotFoundPath(getSchemeMap(), filePath);
  }