Creates a new srl predicate. It assigns an appropriate ID to it. The predicate is added to the document.
@param span span containing all the targets of the predicate
@return a new predicate
491186
public Predicate newPredicate(Span<Term> span) {
	String newId = idManager.getNextId(AnnotationType.PREDICATE);
	Predicate newPredicate = new Predicate(newId, span);
	annotationContainer.add(newPredicate, Layer.SRL, AnnotationType.PREDICATE);
	return newPredicate;
    }
1250518
def build_registered_span(self, span):
        
        data = Data(baggage=span.context.baggage)

        kind = 1 # entry
        if span.operation_name in self.exit_spans:
            kind = 2 # exit
        # log is a special case as it is not entry nor exit
        if span.operation_name == "log":
            kind = 3 # intermediate span

        logs = self.collect_logs(span)
        if len(logs) > 0:
            if data.custom is None:
                data.custom = CustomData()
            data.custom.logs = logs

        if span.operation_name in self.http_spans:
            data.http = HttpData(host=span.tags.pop("http.host", None),
                                 url=span.tags.pop(ext.HTTP_URL, None),
                                 params=span.tags.pop('http.params', None),
                                 method=span.tags.pop(ext.HTTP_METHOD, None),
                                 status=span.tags.pop(ext.HTTP_STATUS_CODE, None),
                                 path_tpl=span.tags.pop("http.path_tpl", None),
                                 error=span.tags.pop('http.error', None))

        if span.operation_name == "rabbitmq":
            data.rabbitmq = RabbitmqData(exchange=span.tags.pop('exchange', None),
                                         queue=span.tags.pop('queue', None),
                                         sort=span.tags.pop('sort', None),
                                         address=span.tags.pop('address', None),
                                         key=span.tags.pop('key', None))
            if data.rabbitmq.sort == 'consume':
                kind = 1 # entry

        if span.operation_name == "redis":
            data.redis = RedisData(connection=span.tags.pop('connection', None),
                                   driver=span.tags.pop('driver', None),
                                   command=span.tags.pop('command', None),
                                   error=span.tags.pop('redis.error', None),
                                   subCommands=span.tags.pop('subCommands', None))

        if span.operation_name == "rpc-client" or span.operation_name == "rpc-server":
            data.rpc = RPCData(flavor=span.tags.pop('rpc.flavor', None),
                               host=span.tags.pop('rpc.host', None),
                               port=span.tags.pop('rpc.port', None),
                               call=span.tags.pop('rpc.call', None),
                               call_type=span.tags.pop('rpc.call_type', None),
                               params=span.tags.pop('rpc.params', None),
                               baggage=span.tags.pop('rpc.baggage', None),
                               error=span.tags.pop('rpc.error', None))

        if span.operation_name == "sqlalchemy":
            data.sqlalchemy = SQLAlchemyData(sql=span.tags.pop('sqlalchemy.sql', None),
                                             eng=span.tags.pop('sqlalchemy.eng', None),
                                             url=span.tags.pop('sqlalchemy.url', None),
                                             err=span.tags.pop('sqlalchemy.err', None))

        if span.operation_name == "soap":
            data.soap = SoapData(action=span.tags.pop('soap.action', None))

        if span.operation_name == "mysql":
            data.mysql = MySQLData(host=span.tags.pop('host', None),
                                   db=span.tags.pop(ext.DATABASE_INSTANCE, None),
                                   user=span.tags.pop(ext.DATABASE_USER, None),
                                   stmt=span.tags.pop(ext.DATABASE_STATEMENT, None))
            if (data.custom is not None) and (data.custom.logs is not None) and len(data.custom.logs):
                tskey = list(data.custom.logs.keys())[0]
                data.mysql.error = data.custom.logs[tskey]['message']

        if span.operation_name == "log":
            data.log = {}
            # use last special key values
            # TODO - logic might need a tweak here
            for l in span.logs:
                if "message" in l.key_values:
                    data.log["message"] = l.key_values.pop("message", None)
                if "parameters" in l.key_values:
                    data.log["parameters"] = l.key_values.pop("parameters", None)

        entity_from = {'e': instana.singletons.agent.from_.pid,
                      'h': instana.singletons.agent.from_.agentUuid}

        json_span = JsonSpan(n=span.operation_name,
                             k=kind,
                             t=span.context.trace_id,
                             p=span.parent_id,
                             s=span.context.span_id,
                             ts=int(round(span.start_time * 1000)),
                             d=int(round(span.duration * 1000)),
                             f=entity_from,
                             data=data)

        if span.stack:
            json_span.stack = span.stack

        error = span.tags.pop("error", False)
        ec = span.tags.pop("ec", None)

        if error and ec:
            json_span.error = error
            json_span.ec = ec

        if len(span.tags) > 0:
            if data.custom is None:
                data.custom = CustomData()
            data.custom.tags = span.tags

        return json_span
1065384
protected static Span guess(Span span) {
    if (span == null) {
      return null;
    }
    long guessValue;
    if (span.getWidth() > 1) {
      guessValue = span.getBegin() + (span.getWidth() / 2);
    }
    else {
      guessValue = span.getBegin();
    }
    Span guess = new Span(guessValue, guessValue);
    return guess;
  }
610773
static <T extends IdentifiableAnnotation> Span<T> list2Span(List<T> list) {
	Span<T> span = new Span<T>();
	for (T elem : list) {
	    span.addTarget(elem);
	}
	return span;
    }
504333
private Node createNode(final Iterable<Range<C>> ranges) {
        Range<C> span = Iterables.getFirst(ranges, null);
        if (span == null) {
            return null;
        }
        for (Range<C> range : ranges) {
            checkNotNull(range, "ranges must not contain null ranges");
            span = range.span(span);
        }
        if (span.isEmpty()) {
            return null;
        }
        C center = Ranges.center(span);
        List<Range<C>> left = Lists.newArrayList();
        List<Range<C>> right = Lists.newArrayList();
        List<Range<C>> overlap = Lists.newArrayList();
        for (Range<C> range : ranges) {
            if (Ranges.isLessThan(range, center)) {
                left.add(range);
            }
            else if (Ranges.isGreaterThan(range, center)) {
                right.add(range);
            }
            else {
                overlap.add(range);
            }
        }
        return new Node(center, createNode(left), createNode(right), overlap);
    }
12931
@Override
  public MtasSpanWeight createWeight(IndexSearcher searcher,
      boolean needsScores, float boost) throws IOException {
    return new SpanAllWeight(searcher, null, boost);
  }
1120705
function makePartSpan(value, doc) {
  var text = value;
  if (value.nodeType == 3) text = value.nodeValue;
  else value = doc.createTextNode(text);

  var span = doc.createElement("SPAN");
  span.isPart = true;
  span.appendChild(value);
  span.currentText = text;
  return span;
}
918558
public SpannedExpression getLogicalFormForSpan(int spanStart, int spanEnd) {
    CcgParse spanningParse = getParseForSpan(spanStart, spanEnd);
    Expression2 lf = spanningParse.getPreUnaryLogicalForm();
    if (lf != null) {
      return new SpannedExpression(spanningParse.getHeadedSyntacticCategory(),
          spanningParse.getLogicalForm(), spanningParse.getSpanStart(), spanningParse.getSpanEnd());
    } else {
      return null;
    }
  }
1349098
@Override
  public SpanConsumer spanConsumer() {
    if (spanConsumer == null) {
      synchronized (this) {
        if (spanConsumer == null) {
          spanConsumer = new CassandraSpanConsumer(this, indexCacheSpec);
        }
      }
    }
    return spanConsumer;
  }
999972
public static Span prefix(Bytes rowPrefix) {
    Objects.requireNonNull(rowPrefix);
    Bytes fp = followingPrefix(rowPrefix);
    return new Span(rowPrefix, true, fp == null ? Bytes.EMPTY : fp, false);
  }
300942
def encompasses(self, span):
        
        if isinstance(span, list):
            return [sp for sp in span if self._encompasses(sp)]

        return self._encompasses(span)
1291826
@Override
  public MtasSpanWeight createWeight(IndexSearcher searcher,
      boolean needsScores, float boost) throws IOException {
    SpanWeight spanWeight = ((SpanQuery) searcher.rewrite(clause))
        .createWeight(searcher, needsScores, boost);
    return new SpanTermWeight(spanWeight, searcher, boost);
  }
765884
public function fromIncomingResponse(Span $originalSpan, ResponseInterface $response = null)
    {
        return new Span(
            $originalSpan->getIdentifier(),
            $originalSpan->getName(),
            $originalSpan->getTraceIdentifier(),
            [
                new Annotation(Annotation::CLIENT_RECEIVE, $this->clock->microseconds(), $this->endpointResolver->resolve()),
            ],
            [
                new BinaryAnnotation('http.status', $response !== null ? $response->getStatusCode() : 0, BinaryAnnotation::TYPE_INTEGER_16),
            ],
            $originalSpan->getParentIdentifier(),
            $originalSpan->getDebug()
        );
    }
1092201
public SpanManager insert(int offset, String str){
		sb.insert(offset, str);
		adjustLists( offset, str.length() );
		
		if( calculateSrcPositions ) for( int i=0; i<str.length(); i++ ) ib.add( offset, -1 );
		
		return this;
	}
	
	/**
	 * Replaces the content between s.getStart() (included) and s.getEnd() (excluded) with
	 * a String
	 */
	public SpanManager replace(Span s, String str){	return replace( s.getStart(), s.getEnd(), str); }
	
	/**
	 * Replaces the content between start (included) and end (excluded) with a String
	 */
	public SpanManager replace(int start, int end, String str){
		sb.replace(start, end, str);
		
		if( calculateSrcPositions ){
			for( int i=0; i<end-start; i++) ib.remove( start );
			for( int i=0; i<str.length(); i++) ib.add( start, -1 );
		}
		
		adjustLists(start, str.length()-(end-start) );
		return this;
	}
	
	public int indexOf(String str){ return this.indexOf(str, 0); }
	public int indexOf(String str, int fromIndex){ return sb.indexOf(str, fromIndex); }
	public int indexOf(String str, Span s){	return indexOf(str, s.getStart(), s.getEnd() ); }
	
	public int indexOf(String str, int fromIndex, int toIndex){
		int result = sb.indexOf(str, fromIndex);
		if( result >= toIndex ) return -1 ;
		return result;
	}
	
	public String substring(int start){
	    if (start < 0) {
	        start = 0;
	    }
	    return this.sb.substring(start);
	}
	
	public String substring(int start, int end){
	    if (start < 0) {
	        start = 0;
	    }
	    if (start > end) {
	        return "";
	    }
	
	    return sb.substring(start, end);
	}
	
	public String substring( Span s ) {
	    if (s.getStart() < s.getEnd()) {
	        return sb.substring( s.getStart(), s.getEnd() );
	    }
	    else {
	        return "";
	    }
	}
	
	/**
	 * <font color="#ff0000">This function is not implemented !!!</font>
	 */
	public CharSequence subSequence(int start, int end){
		//TODO Implementieren
		System.err.println("CharSequence subSequence(int start, int end)\nSorry, not Implemented");
		sb.charAt(-1); //causes an error
		return null;
	}
	
	public int length(){
		return sb.length();
	}
	
	public SpanManager setCharAt(int index, char c){
		sb.setCharAt( index, c );
		if( calculateSrcPositions ) ib.set( index, -1 );
		return this;
	}
	
	public char charAt(int index){
		return sb.charAt(index);
	}
	
	@Override
    public String toString(){
		return sb.toString();
	}
	
	/**
	 * Returnes some information about the content of the SpanManager an it�s manages
	 * Spans
	 */
	public String info(){
		StringBuilder result = new StringBuilder();
		
		result.append("\n-=SPANMANAGER=----------------------------------------------------------------\n");
				
		result.append("TEXT:");
		result.append( "\""+ sb.toString() + "\"");
		result.append("\n");		
			
		result.append("\nMANAGED SPAN LISTS:");
		if( managedLists.isEmpty() )
			result.append(" NONE\n");
		else{	
			result.append("\n");
			for( int k=0; k<managedLists.size(); k++ ){
				List<Span> sl = managedLists.get(k);
				result.append("{");
				if( sl.size() != 0 ){
					for( int i=1; i<sl.size()-1; i++ ) result.append(sl.get(i)+", ");
					result.append(sl.get( sl.size()-1));
				}
				result.append("}\n");
			}
		}
		
		result.append("------------------------------------------------------------------------------");
		
		return result.toString();
	}	
}
773012
public function withSpan(Span $span)
    {
        $spanData = $span->spanData();
        $startTime = $spanData->startTime()
            ? (float)($spanData->startTime()->format('U.u'))
            : microtime(true);
        $info = [
            'traceId' => $spanData->traceId(),
            'spanId' => $spanData->spanId(),
            'parentSpanId' => $spanData->parentSpanId(),
            'startTime' => $startTime,
            'attributes' => $spanData->attributes(),
            'stackTrace' => $spanData->stackTrace(),
            'kind' => $spanData->kind(),
            'sameProcessAsParentSpan' => $spanData->sameProcessAsParentSpan()
        ];
        opencensus_trace_begin($spanData->name(), $info);
        $this->hasSpans = true;
        $span->attach();
        foreach ($spanData->timeEvents() as $timeEvent) {
            $this->timeEventAdded($span, $timeEvent);
        }
        foreach ($spanData->links() as $link) {
            $this->linkAdded($span, $link);
        }
        return new Scope(function () {
            opencensus_trace_finish();
        });
    }
1096746
public static String deriveFault(Span span) {
        List<SpanHttpDeriverUtil.HttpCode> errorCodes =
                SpanHttpDeriverUtil.getClientOrServerErrors(SpanHttpDeriverUtil.getHttpStatusCodes(span.getBinaryAnnotations()));

        if (errorCodes.size() > 0) {
            return errorCodes.iterator().next().getDescription();
        }

        return null;
    }
1362979
public function span_containing(AbstractSpanQuery $little = null, AbstractSpanQuery $big = null): SpanContaining
    {
        return new SpanContaining($little, $big);
    }