Package clojure.lang

Examples of clojure.lang.ISeq


        public ClojureBSONSeq<Integer> create() {
            return new ClojureBSONSeq<Integer>();
        }

        public void itemsCanBeAddedIntoSequence() {
            ISeq seq = context.newInstance();
            ISeq value = context.addValue(seq, 1);
            ISeq value2 = context.addValue(value, 2);
            specify(value2.count(), does.equal(2));
            specify(value2.first(), does.equal(2));
            specify(value2.next().first(), does.equal(1));
        }
View Full Code Here


  }
 
  @Override
  protected long buildResponseComplexItemBuf(long r, Object item, long preChain) {
    if ((item instanceof ISeq) || (item instanceof Seqable) || (item instanceof Iterable)) {
      ISeq seq = RT.seq(item);
      long chain = preChain;
      long first = 0;
      while (seq != null) {
        Object o = seq.first();
        if (o != null) {
          long rc  = buildResponseItemBuf(r, o, chain);
          if (rc <= 0) {
            if (rc != -NGX_HTTP_NO_CONTENT) {
              return rc;
            }
          }else {
            chain = rc;
            if (first == 0) {
              first = chain;
            }
          }
          seq = seq.next();
        }
      }
      return preChain == 0 ? (first == 0 ? -NGX_HTTP_NO_CONTENT : first: chain;
    }
    return super.buildResponseComplexItemBuf(r, item, preChain);
View Full Code Here

  }

  @Override
  public void push(long h, long pool, Object v) {
   
    ISeq seq = null;
    if (v instanceof String) {
      String val = (String) v;
      seq = ArraySeq.create(val);
    }else if (v instanceof ISeq) {
      seq = (ISeq) v;
    }
   
    int c = seq.count();
    if (c == 0) {
      return;
    }
   
   
    for (int i = 0; i < c; i++) {
      String val = (String) seq.first();
      seq = seq.next();
      if (val != null) {
        long p = NginxClojureRT.ngx_list_push(h + NGX_HTTP_CLOJURE_HEADERSO_HEADERS_OFFSET);
        if (p == 0) {
          throw new RuntimeException("can not push ngx list for headers");
        }
View Full Code Here

    long haddr = h + offset;
    if (haddr == 0){
      throw new RuntimeException("invalid address for set header array value " + v);
    }
   
    ISeq seq = null;
    if (v instanceof String) {
      String val = (String) v;
      seq = ArraySeq.create(val);
    }else if (v instanceof ISeq) {
      seq = (ISeq) v;
    }else {
      seq = RT.seq(v);
    }
   
    int c = seq.count();
    if (c == 0) {
      return;
    }
   
    long lp = UNSAFE.getAddress(haddr + NGX_HTTP_CLOJURE_ARRAY_ELTS_OFFSET);
    if (lp == 0) {
      long code = NginxClojureRT.ngx_array_init(haddr, pool, c, NGX_HTTP_CLOJURE_TELT_SIZE);
      if (code != NGX_OK) {
        throw new RuntimeException("can not init ngx array for header, return code:" + code);
      }
    }
   
    lp = NginxClojureRT.ngx_array_push_n(haddr, c);
    if (lp == 0) {
      throw new RuntimeException("can not push ngx array for header");
    }
   
    for (int i = 0; i < c; i++) {
      String val = (String) seq.first();
      seq = seq.next();
      if (val != null) {
        long p = NginxClojureRT.ngx_list_push(h + NGX_HTTP_CLOJURE_HEADERSO_HEADERS_OFFSET);
        if (p == 0) {
          throw new RuntimeException("can not push ngx list for headers");
        }
View Full Code Here

          "Should only have one object in buffer combiner before extraction " + vals.size() + ":"
          + vals.toString());
    }
    Object val = vals.get(0);
    try {
      ISeq result_seq = RT.seq(extract_fn.invoke(val));
      while (result_seq != null) {
        Tuple t = Util.coerceToTuple(result_seq.first());
        Tuple emit = new Tuple(group);
        emit.addAll(t);
        output.add(emit);
        result_seq = result_seq.next();
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    for (int i = 0; i < context.size(); i++) {
      inputTuples
          .add(IteratorSeq.create(new RegularTupleSeqConverter(context.getArgumentsIterator(i))));
    }

    ISeq resultSeq = RT.seq(applyFunction(RT.seq(inputTuples)));
    while (resultSeq != null) {
      Object obj = resultSeq.first();
      context.emit(Util.coerceToTuple(obj));
      resultSeq = resultSeq.next();
    }
  }
View Full Code Here

  public ClojureMap(Fields outputFields, IFn fn) {
    super(outputFields, fn);
  }

  public void operate(FlowProcess fp, FunctionCall call) {
    ISeq fnArgs = Util.coerceFromTuple(call.getArguments().getTuple());
    Object res = applyFunction(fnArgs);
    call.getOutputCollector().add(Util.coerceToTuple(res));
  }
View Full Code Here

  public ClojureFilter(IFn fn) {
    super(fn);
  }

  public boolean isRemove(FlowProcess fp, FilterCall call) {
    ISeq fnArgs = Util.coerceFromTuple(call.getArguments().getTuple());
    return !Util.truthy(applyFunction(fnArgs));
  }
View Full Code Here

  public ClojureBuffer(Fields outputFields, IFn fn) {
    super(outputFields, fn);
  }

  public void operate(FlowProcess flow_process, BufferCall call) {
    ISeq resultSeq = RT.seq(invokeFunction(IteratorSeq
        .create(new TupleSeqConverter(call.getArgumentsIterator()))));
    TupleEntryCollector collector = call.getOutputCollector();
    while (resultSeq != null) {
      Object obj = resultSeq.first();
      collector.add(Util.coerceToTuple(obj));
      resultSeq = resultSeq.next();
    }
  }
View Full Code Here

  public void start(FlowProcess flow_process, AggregatorCall ag_call) {
    ag_call.setContext(invokeFunction());
  }

  public void aggregate(FlowProcess flow_process, AggregatorCall ag_call) {
    ISeq fn_args_seq = Util.coerceFromTuple(ag_call.getArguments().getTuple());
    ag_call.setContext(applyFunction(RT.cons(ag_call.getContext(), fn_args_seq)));
  }
View Full Code Here

TOP

Related Classes of clojure.lang.ISeq

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.