Search mtas tree.

@param position the position
@param in the in
@param ref the ref
@param objectRefApproxOffset the object ref approx offset
@return the array list
@throws IOException Signals that an I/O exception has occurred.
325169
public static ArrayList<MtasTreeHit<?>> searchMtasTree(int position,
      IndexInput in, long ref, long objectRefApproxOffset) throws IOException {
    return searchMtasTree(position, position, in, ref, objectRefApproxOffset);
  }
1110748
public static TypeAnnotationPosition
        methodRef(final List<TypePathEntry> location,
                  final JCLambda onLambda,
                  final int pos) {
        return new TypeAnnotationPosition(TargetType.METHOD_REFERENCE, pos,
                                          Integer.MIN_VALUE, onLambda,
                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
                                          location);
    }
437681
public static INode searchCache(List<INode> nodes, int offSet,
			IVdmElement element)
	{
		synchronized (seacher)
		{
			if (DEBUG_PRINT)
			{
				System.out.println("Search start");
			}
			seacher.init();
			seacher.offSet = offSet;
			seacher.currentElement = element;
			try
			{
				if (elementNodeCache.get(element) == null
						|| elementNodeCache.get(element).isEmpty())
				{
					// elementNodeCache.put(element, new HashMap<ILexLocation, INode>());
					// seacher.indexing = true;
					// for (INode node : nodes)
					// {
					// node.apply(seacher);
					// }
					return null;
				} else
				{
					for (Entry<ILexLocation, INode> entry : elementNodeCache.get(element).entrySet())
					{
						seacher.check(entry.getValue(), entry.getKey());
					}
				}

			} catch (AnalysisException e)
			{
				// We found what we are looking for
			}

			return seacher.bestHit != null ? seacher.bestHit
					: seacher.bestAlternativeHit;
		}

	}
513006
public static INode search(List<INode> nodes, int offSet,
			IVdmSourceUnit source)
	{
		synchronized (seacher)
		{
			if (DEBUG_PRINT)
			{
				System.out.println("Search start");
			}
			seacher.init();
			seacher.offSet = offSet;
			seacher.sourceFile = source.getSystemFile();
			try
			{
				for (INode node : nodes)
				{
					node.apply(seacher);
				}
			} catch (AnalysisException e)
			{
				// We found what we are looking for
			}

			return seacher.bestHit != null ? seacher.bestHit
					: seacher.bestAlternativeHit;
		}

	}
968860
@Override
    public void itemReferencesDroppedToZero()
    {
        super.itemReferencesDroppedToZero();
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "itemReferencesDroppedToZero");

        if (failedInitInRestore)
        {
            try
            {
                initialiseNonPersistent(true);
            } catch (SevereMessageStoreException e)
            {
                FFDCFilter.processException(
                                            e,
                                            "com.ibm.ws.sib.processor.impl.store.items.MessageItem.itemReferencesDroppedToZero",
                                            "1:1617:1.244.1.40",
                                            this);

                //There was a problem getting hold of the itemstream when trying to initilise
                //We wouldn't have registered any callbacks yet so we shouldn't carry on

                SibTr.exception(tc, e);

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "itemReferencesDroppedToZero", e);

                throw new SIErrorException(e);
            }
        }

        if (REFERENCES_DROPPED_TO_ZERO != null)
        {
            try
            {
                REFERENCES_DROPPED_TO_ZERO.messageEventOccurred(MessageEvents.REFERENCES_DROPPED_TO_ZERO, this, null);
            } catch (SIException e)
            {
                // Exceptions after a commit are bad !
                FFDCFilter.processException(
                                            e,
                                            "com.ibm.ws.sib.processor.impl.store.items.MessageItem.itemReferencesDroppedToZero",
                                            "1:1644:1.244.1.40",
                                            this);

                SibTr.exception(tc, e);

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "itemReferencesDroppedToZero", e);

                throw new SIErrorException(e);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "itemReferencesDroppedToZero");
    }
872131
public BytesRef getPayload() throws IOException {

    // initial bits - position
    if (mtasToken.checkPositionType(MtasPosition.POSITION_SINGLE)) {
      byteStream.writeBit(0);
      byteStream.writeBit(0);
    } else if (mtasToken.checkPositionType(MtasPosition.POSITION_RANGE)) {
      byteStream.writeBit(1);
      byteStream.writeBit(0);
    } else if (mtasToken.checkPositionType(MtasPosition.POSITION_SET)) {
      byteStream.writeBit(0);
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(1);
      byteStream.writeBit(1);
    }
    // initial bits - offset
    if ((encodingFlags & ENCODE_OFFSET) == ENCODE_OFFSET
        && mtasToken.checkOffset()) {
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(0);
    }
    // initial bits - realOffset
    if ((encodingFlags & ENCODE_REALOFFSET) == ENCODE_REALOFFSET
        && mtasToken.checkRealOffset()) {
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(0);
    }
    // initial bits - parentId
    if ((encodingFlags & ENCODE_PARENT) == ENCODE_PARENT
        && mtasToken.checkParentId()) {
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(0);
    }
    // initial bits - original payload
    if ((encodingFlags & ENCODE_PAYLOAD) == ENCODE_PAYLOAD
        && mtasToken.getPayload() != null) {
      byteStream.writeBit(1);
    } else {
      byteStream.writeBit(0);
    }
    if (mtasToken.getType().equals(MtasTokenString.TOKEN_TYPE)) {
      byteStream.writeBit(0);
    } else {
      // to add other token types later on
      byteStream.writeBit(1);
    }
    // add id (EliasGammaCoding)
    byteStream.writeEliasGammaCodingNonNegativeInteger(mtasToken.getId());
    // add position info (EliasGammaCoding)
    if (mtasToken.checkPositionType(MtasPosition.POSITION_SINGLE)) {
      // do nothing
    } else if (mtasToken.checkPositionType(MtasPosition.POSITION_RANGE)) {
      // write length
      byteStream.writeEliasGammaCodingPositiveInteger(
          1 + mtasToken.getPositionEnd() - mtasToken.getPositionStart());
    } else if (mtasToken.checkPositionType(MtasPosition.POSITION_SET)) {
      // write number of positions
      int[] positionList = mtasToken.getPositions();
      byteStream.writeEliasGammaCodingPositiveInteger(positionList.length);
      int previousPosition = positionList[0];
      for (int i = 1; i < positionList.length; i++) {
        byteStream.writeEliasGammaCodingPositiveInteger(
            positionList[i] - previousPosition);
        previousPosition = positionList[i];
      }
    } else {
      // do nothing
    }
    // add offset info (EliasGammaCoding)
    if ((encodingFlags & ENCODE_OFFSET) == ENCODE_OFFSET
        && mtasToken.checkOffset()) {
      byteStream
          .writeEliasGammaCodingNonNegativeInteger(mtasToken.getOffsetStart());
      byteStream.writeEliasGammaCodingPositiveInteger(
          1 + mtasToken.getOffsetEnd() - mtasToken.getOffsetStart());
    }
    // add realOffset info (EliasGammaCoding)
    if ((encodingFlags & ENCODE_REALOFFSET) == ENCODE_REALOFFSET
        && mtasToken.checkRealOffset()) {
      if ((encodingFlags & ENCODE_OFFSET) == ENCODE_OFFSET
          && mtasToken.checkOffset()) {
        byteStream.writeEliasGammaCodingInteger(
            mtasToken.getRealOffsetStart() - mtasToken.getOffsetStart());
        byteStream.writeEliasGammaCodingPositiveInteger(
            1 + mtasToken.getRealOffsetEnd() - mtasToken.getRealOffsetStart());
      } else {
        byteStream.writeEliasGammaCodingNonNegativeInteger(
            mtasToken.getRealOffsetStart());
        byteStream.writeEliasGammaCodingPositiveInteger(
            1 + mtasToken.getRealOffsetEnd() - mtasToken.getRealOffsetStart());
      }
    }
    // add parent info (EliasGammaCoding)
    if ((encodingFlags & ENCODE_PARENT) == ENCODE_PARENT
        && mtasToken.checkParentId()) {
      byteStream.writeEliasGammaCodingInteger(
          mtasToken.getParentId() - mtasToken.getId());
    }
    // add minimal number of zero-bits to get round number of bytes
    byteStream.createByte();
    // finally add original payload bytes
    if ((encodingFlags & ENCODE_PAYLOAD) == ENCODE_PAYLOAD
        && mtasToken.getPayload() != null) {
      BytesRef payload = mtasToken.getPayload();
      byteStream.write(Arrays.copyOfRange(payload.bytes, payload.offset,
          (payload.offset + payload.length)));
    }
    // construct new payload
    return new BytesRef(byteStream.toByteArray());
  }
901315
@Override
    public FilterChannel position(long newPosition) throws IOException
    {
        if (!isOpen())
        {
            throw new ClosedChannelException();
        }
        int skip = (int) (newPosition - position());
        if (skip < 0)
        {
            throw new UnsupportedOperationException("backwards position not supported");
        }
        if (skip > skipBuffer.capacity())
        {
            throw new UnsupportedOperationException(skip+" skip not supported maxSkipSize="+maxSkipSize);
        }
        if (skip > 0)
        {
            if (skipBuffer == null)
            {
                throw new UnsupportedOperationException("skip not supported maxSkipSize="+maxSkipSize);
            }
            skipBuffer.clear();
            skipBuffer.limit(skip);
            if (in != null)
            {
                read(skipBuffer);
            }
            else
            {
                write(skipBuffer);
            }
        }
        return this;
    }
62571
@Override
  protected int postOperationFix(int headIdx, Tree[] daughterTrees) {
    if (headIdx >= 2) {
      String prevLab = tlp.basicCategory(daughterTrees[headIdx - 1].value());
      if (prevLab.equals("CC") || prevLab.equals("CONJP")) {
        int newHeadIdx = headIdx - 2;
        Tree t = daughterTrees[newHeadIdx];
        while (newHeadIdx >= 0 && t.isPreTerminal() && tlp.isPunctuationTag(t.value())) {
          newHeadIdx--;
        }
        while (newHeadIdx >= 2 && tlp.isPunctuationTag(daughterTrees[newHeadIdx - 1].value())) {
          newHeadIdx = newHeadIdx - 2;
        }
        if (newHeadIdx >= 0) {
          headIdx = newHeadIdx;
        }
      }
    }
    return headIdx;
  }
740198
public static <T> T convertTo(String in, TypeReference<T> mapTo) throws IOException {
		try {
			return mapper.readValue(in, mapTo);
		} catch (Exception e) {
			log.error("Can not convert:{} to {}", in, mapTo, e);
			throw new OvhServiceException("local", "conversion Error to " + mapTo);
		}
	}
1050951
private int getTokenQueuePosFromMap(int i)
  {

    int pos = m_patternMap[i];

    return (pos >= TARGETEXTRA) ? (pos - TARGETEXTRA) : pos;
  }
645608
public static <T extends RefCounted<T>> Refs<T> tryRef(Iterable<T> reference)
    {
        HashMap<T, Ref<T>> refs = new HashMap<>();
        for (T rc : reference)
        {
            Ref<T> ref = rc.tryRef();
            if (ref == null)
            {
                release(refs.values());
                return null;
            }
            refs.put(rc, ref);
        }
        return new Refs<T>(refs);
    }
32249
private boolean moveToFollowingNode(final INodeReadTrx paramRtx, final ERevision paramRevision)
        throws TTIOException {
        boolean moved = false;
        while (!((ITreeStructData)paramRtx.getNode()).hasRightSibling()
            && ((ITreeStructData)paramRtx.getNode()).hasParent() && paramRtx.getNode().getDataKey() != mRootKey) {
            moved = paramRtx.moveTo(paramRtx.getNode().getParentKey());
            if (moved) {
                switch (paramRevision) {
                case NEW:
                    mDepth.decrementNewDepth();
                    break;
                case OLD:
                    mDepth.decrementOldDepth();
                    break;
                }
            }
        }

        if (paramRtx.getNode().getDataKey() == mRootKey) {
            paramRtx.moveTo(ROOT_NODE);
        }

        moved = paramRtx.moveTo(((ITreeStructData)paramRtx.getNode()).getRightSiblingKey());
        return moved;
    }
352327
@Override
    public ZoneOffset getStandardOffset(Instant instant) {
        long epochSec = instant.getEpochSecond();
        int index  = Arrays.binarySearch(standardTransitions, epochSec);
        if (index < 0) {
            // switch negative insert position to start of matched range
            index = -index - 2;
        }
        return standardOffsets[index + 1];
    }
1319938
@Override
	// @NotThreadSafe
	public byte get(long position) throws IOException {
		return mappedBuffers.get(getBufferNum(position)).get(getIndex(position));
	}
1052806
@SuppressWarnings("fallthrough")
    private boolean findSection(int offset, Position pos)
    {
        int i = offset, len = rawBytes.length;
        int last = offset;
        int next;
        boolean allBlank = true;

        pos.endOfFirstLine = -1;

        while (i < len) {
            byte b = rawBytes[i];
            switch(b) {
            case '\r':
                if (pos.endOfFirstLine == -1)
                    pos.endOfFirstLine = i-1;
                if ((i < len) &&  (rawBytes[i+1] == '\n'))
                    i++;
                /* fall through */
            case '\n':
                if (pos.endOfFirstLine == -1)
                    pos.endOfFirstLine = i-1;
                if (allBlank || (i == len-1)) {
                    if (i == len-1)
                        pos.endOfSection = i;
                    else
                        pos.endOfSection = last;
                    pos.startOfNext = i+1;
                    return true;
                }
                else {
                    // start of a new line
                    last = i;
                    allBlank = true;
                }
                break;
            default:
                allBlank = false;
                break;
            }
            i++;
        }
        return false;
    }
181442
private void preparePositions(ResponseBuilder rb, ComponentFields mtasFields)
      throws IOException {
    Set<String> ids = MtasSolrResultUtil
        .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_STATS_POSITIONS);
    if (!ids.isEmpty()) {
      int tmpCounter = 0;
      String[] fields = new String[ids.size()];
      String[] keys = new String[ids.size()];
      String[] minima = new String[ids.size()];
      String[] maxima = new String[ids.size()];
      String[] types = new String[ids.size()];
      for (String id : ids) {
        fields[tmpCounter] = rb.req.getParams().get(PARAM_MTAS_STATS_POSITIONS
            + "." + id + "." + NAME_MTAS_STATS_POSITIONS_FIELD, null);
        keys[tmpCounter] = rb.req.getParams()
            .get(PARAM_MTAS_STATS_POSITIONS + "." + id + "."
                + NAME_MTAS_STATS_POSITIONS_KEY, String.valueOf(tmpCounter))
            .trim();
        minima[tmpCounter] = rb.req.getParams().get(PARAM_MTAS_STATS_POSITIONS
            + "." + id + "." + NAME_MTAS_STATS_POSITIONS_MINIMUM, null);
        maxima[tmpCounter] = rb.req.getParams().get(PARAM_MTAS_STATS_POSITIONS
            + "." + id + "." + NAME_MTAS_STATS_POSITIONS_MAXIMUM, null);
        types[tmpCounter] = rb.req.getParams().get(PARAM_MTAS_STATS_POSITIONS
            + "." + id + "." + NAME_MTAS_STATS_POSITIONS_TYPE, null);
        tmpCounter++;
      }
      String uniqueKeyField = rb.req.getSchema().getUniqueKeyField().getName();
      mtasFields.doStats = true;
      mtasFields.doStatsPositions = true;
      rb.setNeedDocSet(true);
      for (String field : fields) {
        if (field == null || field.isEmpty()) {
          throw new IOException("no (valid) field in mtas stats positions");
        } else if (!mtasFields.list.containsKey(field)) {
          mtasFields.list.put(field, new ComponentField(uniqueKeyField));
        }
      }
      MtasSolrResultUtil.compareAndCheck(keys, fields,
          NAME_MTAS_STATS_POSITIONS_KEY, NAME_MTAS_STATS_POSITIONS_FIELD, true);
      MtasSolrResultUtil.compareAndCheck(minima, fields,
          NAME_MTAS_STATS_POSITIONS_MINIMUM, NAME_MTAS_STATS_POSITIONS_FIELD,
          false);
      MtasSolrResultUtil.compareAndCheck(maxima, fields,
          NAME_MTAS_STATS_POSITIONS_MAXIMUM, NAME_MTAS_STATS_POSITIONS_FIELD,
          false);
      MtasSolrResultUtil.compareAndCheck(types, fields,
          NAME_MTAS_STATS_POSITIONS_TYPE, NAME_MTAS_STATS_POSITIONS_FIELD,
          false);
      for (int i = 0; i < fields.length; i++) {
        String field = fields[i];
        String key = keys[i];
        String type = (types[i] == null) || (types[i].isEmpty()) ? null
            : types[i].trim();
        Double minimum = (minima[i] == null) || (minima[i].isEmpty()) ? null
            : Double.parseDouble(minima[i]);
        Double maximum = (maxima[i] == null) || (maxima[i].isEmpty()) ? null
            : Double.parseDouble(maxima[i]);
        try {
          mtasFields.list.get(field).statsPositionList
              .add(new ComponentPosition(key, minimum, maximum, type));
        } catch (ParseException e) {
          throw new IOException(e.getMessage());
        }
      }
    }
  }
816828
public int getNodeByPosition(int position)
  {
    if (position > 0) {
      final int pos = isReverse() ? getLast() - position + 1
                                   : position;
      int node;
      while ((node = next()) != DTMAxisIterator.END) {
        if (pos == getPosition()) {
          return node;
        }
      }
    }
    return END;
  }