<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CodecSearchTree.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">MTAS</a> > <a href="index.source.html" class="el_package">mtas.codec.util</a> > <span class="el_source">CodecSearchTree.java</span></div><h1>CodecSearchTree.java</h1><pre class="source lang-java linenums">package mtas.codec.util; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import mtas.codec.tree.IntervalTree; import mtas.codec.tree.IntervalTreeNode; import mtas.codec.tree.MtasTree; import org.apache.lucene.store.IndexInput; /** * The Class CodecSearchTree. */ <span class="nc" id="L16">public class CodecSearchTree {</span> /** * Advance 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. */ public static ArrayList<MtasTreeHit<?>> advanceMtasTree(int position, IndexInput in, long ref, long objectRefApproxOffset) throws IOException { <span class="fc" id="L30"> ArrayList<MtasTreeHit<?>> list = new ArrayList<MtasTreeHit<?>>();</span> <span class="fc" id="L31"> ArrayList<MtasTreeItem> checkList = new ArrayList<MtasTreeItem>();</span> <span class="fc" id="L32"> AtomicBoolean isSinglePoint = new AtomicBoolean(false);</span> <span class="fc" id="L33"> AtomicBoolean isStoreAdditonalId = new AtomicBoolean(false);</span> <span class="fc" id="L34"> AtomicLong nodeRefApproxOffset = new AtomicLong(-1);</span> <span class="fc" id="L35"> checkList.add(getMtasTreeItem(ref, isSinglePoint, isStoreAdditonalId,</span> nodeRefApproxOffset, in, objectRefApproxOffset)); <span class="fc" id="L37"> ArrayList<Long> history = new ArrayList<Long>();</span> do { <span class="fc" id="L39"> MtasTreeItem checkItem = checkList.remove(checkList.size() - 1);</span> <span class="fc" id="L40"> advanceMtasTree(checkItem, position, in, isSinglePoint,</span> isStoreAdditonalId, objectRefApproxOffset, list, nodeRefApproxOffset, checkList); <span class="fc" id="L43"> history.add(checkItem.ref);</span> <span class="pc bpc" id="L44" title="1 of 2 branches missed."> if (history.size() > 1000) {</span> <span class="nc" id="L45"> throw new IOException(</span> "ADVANCE " + position + " " + checkList + "\n" + history); } <span class="fc bfc" id="L48" title="All 2 branches covered."> } while (checkList.size() > 0);</span> <span class="fc" id="L49"> return list;</span> } /** * Advance mtas tree. * * @param treeItem the tree item * @param position the position * @param in the in * @param isSinglePoint the is single point * @param isStoreAdditionalId the is store additional id * @param objectRefApproxOffset the object ref approx offset * @param list the list * @param nodeRefApproxOffset the node ref approx offset * @param checkList the check list * @throws IOException Signals that an I/O exception has occurred. */ private static void advanceMtasTree(MtasTreeItem treeItem, int position, IndexInput in, AtomicBoolean isSinglePoint, AtomicBoolean isStoreAdditionalId, long objectRefApproxOffset, ArrayList<MtasTreeHit<?>> list, AtomicLong nodeRefApproxOffset, ArrayList<MtasTreeItem> checkList) throws IOException { <span class="fc bfc" id="L71" title="All 2 branches covered."> if (position <= treeItem.max) {</span> // check current node <span class="fc bfc" id="L73" title="All 2 branches covered."> if (position <= treeItem.left) {</span> <span class="fc bfc" id="L74" title="All 2 branches covered."> if (list.size() > 0) {</span> <span class="pc bpc" id="L75" title="1 of 2 branches missed."> if (list.get(0).startPosition > treeItem.left) {</span> <span class="fc" id="L76"> list.clear();</span> } } <span class="fc bfc" id="L79" title="All 2 branches covered."> for (int i = 0; i < treeItem.objectRefs.length; i++) {</span> <span class="pc bpc" id="L80" title="2 of 4 branches missed."> list.add(new MtasTreeHit<>(treeItem.left, treeItem.right,</span> treeItem.objectRefs[i], treeItem.additionalIds == null ? 0 : treeItem.additionalIds[i], treeItem.additionalRefs == null ? 0 : treeItem.additionalRefs[i])); } // check leftChild <span class="fc bfc" id="L87" title="All 2 branches covered."> if (!treeItem.leftChild.equals(treeItem.ref)) {</span> <span class="fc" id="L88"> MtasTreeItem treeItemLeft = getMtasTreeItem(treeItem.leftChild,</span> isSinglePoint, isStoreAdditionalId, nodeRefApproxOffset, in, objectRefApproxOffset); <span class="fc bfc" id="L91" title="All 2 branches covered."> if (position <= treeItemLeft.max) {</span> <span class="fc" id="L92"> checkList.add(treeItemLeft);</span> } <span class="fc" id="L94"> }</span> } else { // check right <span class="pc bpc" id="L97" title="1 of 2 branches missed."> if (position <= treeItem.max) {</span> <span class="pc bpc" id="L98" title="1 of 2 branches missed."> if (!treeItem.rightChild.equals(treeItem.ref)) {</span> <span class="fc" id="L99"> MtasTreeItem treeItemRight = getMtasTreeItem(treeItem.rightChild,</span> isSinglePoint, isStoreAdditionalId, nodeRefApproxOffset, in, objectRefApproxOffset); <span class="pc bpc" id="L102" title="1 of 2 branches missed."> if (position <= treeItemRight.max) {</span> <span class="fc" id="L103"> checkList.add(treeItemRight);</span> } } } } } <span class="fc" id="L109"> }</span> /** * 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. */ public static ArrayList<MtasTreeHit<?>> searchMtasTree(int position, IndexInput in, long ref, long objectRefApproxOffset) throws IOException { <span class="fc" id="L123"> return searchMtasTree(position, position, in, ref, objectRefApproxOffset);</span> } /** * Search mtas tree. * * @param startPosition the start position * @param endPosition the end 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. */ public static ArrayList<MtasTreeHit<?>> searchMtasTree(int startPosition, int endPosition, IndexInput in, long ref, long objectRefApproxOffset) throws IOException { <span class="fc" id="L140"> int boundary = 1000 + 10 * (endPosition - startPosition);</span> <span class="fc" id="L141"> ArrayList<MtasTreeHit<?>> list = new ArrayList<MtasTreeHit<?>>();</span> <span class="fc" id="L142"> ArrayList<MtasTreeItem> checkList = new ArrayList<MtasTreeItem>();</span> <span class="fc" id="L143"> AtomicBoolean isSinglePoint = new AtomicBoolean(false);</span> <span class="fc" id="L144"> AtomicBoolean isStoreAdditionalId = new AtomicBoolean(false);</span> <span class="fc" id="L145"> AtomicLong nodeRefApproxOffset = new AtomicLong(-1);</span> <span class="fc" id="L146"> checkList.add(getMtasTreeItem(ref, isSinglePoint, isStoreAdditionalId,</span> nodeRefApproxOffset, in, objectRefApproxOffset)); <span class="fc" id="L148"> ArrayList<Long> history = new ArrayList<Long>();</span> do { <span class="fc" id="L150"> MtasTreeItem checkItem = checkList.remove(checkList.size() - 1);</span> <span class="fc" id="L151"> searchMtasTree(checkItem, startPosition, endPosition, in, isSinglePoint,</span> isStoreAdditionalId, objectRefApproxOffset, list, nodeRefApproxOffset, checkList); <span class="fc" id="L154"> history.add(checkItem.ref);</span> <span class="pc bpc" id="L155" title="1 of 2 branches missed."> if (history.size() > boundary) {</span> <span class="nc" id="L156"> throw new IOException("Too many items collected from tree");</span> } <span class="fc bfc" id="L158" title="All 2 branches covered."> } while (checkList.size() > 0);</span> <span class="fc" id="L159"> return list;</span> } /** * Search mtas tree. * * @param treeItem the tree item * @param startPosition the start position * @param endPosition the end position * @param in the in * @param isSinglePoint the is single point * @param isStoreAdditionalId the is store additional id * @param objectRefApproxOffset the object ref approx offset * @param list the list * @param nodeRefApproxOffset the node ref approx offset * @param checkList the check list * @throws IOException Signals that an I/O exception has occurred. */ private static void searchMtasTree(MtasTreeItem treeItem, int startPosition, int endPosition, IndexInput in, AtomicBoolean isSinglePoint, AtomicBoolean isStoreAdditionalId, long objectRefApproxOffset, ArrayList<MtasTreeHit<?>> list, AtomicLong nodeRefApproxOffset, ArrayList<MtasTreeItem> checkList) throws IOException { <span class="pc bpc" id="L182" title="1 of 2 branches missed."> if (startPosition <= treeItem.max) {</span> // match current node <span class="fc bfc" id="L184" title="All 4 branches covered."> if ((endPosition >= treeItem.left) && (startPosition <= treeItem.right)) {</span> <span class="fc bfc" id="L185" title="All 2 branches covered."> for (int i = 0; i < treeItem.objectRefs.length; i++) {</span> <span class="pc bpc" id="L186" title="2 of 4 branches missed."> list.add(new MtasTreeHit<>(treeItem.left, treeItem.right,</span> treeItem.objectRefs[i], treeItem.additionalIds == null ? 0 : treeItem.additionalIds[i], treeItem.additionalRefs == null ? 0 : treeItem.additionalRefs[i])); } } // check leftChild <span class="fc bfc" id="L194" title="All 2 branches covered."> if (!treeItem.leftChild.equals(treeItem.ref)) {</span> <span class="fc" id="L195"> MtasTreeItem treeItemLeft = getMtasTreeItem(treeItem.leftChild,</span> isSinglePoint, isStoreAdditionalId, nodeRefApproxOffset, in, objectRefApproxOffset); <span class="fc bfc" id="L198" title="All 2 branches covered."> if (treeItemLeft.max >= startPosition) {</span> <span class="fc" id="L199"> checkList.add(treeItemLeft);</span> } } // check rightChild <span class="fc bfc" id="L203" title="All 2 branches covered."> if (treeItem.left <= endPosition) {</span> <span class="fc bfc" id="L204" title="All 2 branches covered."> if (!treeItem.rightChild.equals(treeItem.ref)) {</span> <span class="fc" id="L205"> MtasTreeItem treeItemRight = getMtasTreeItem(treeItem.rightChild,</span> isSinglePoint, isStoreAdditionalId, nodeRefApproxOffset, in, objectRefApproxOffset); <span class="pc bpc" id="L208" title="3 of 4 branches missed."> if ((treeItemRight.left >= endPosition)</span> || (treeItemRight.max >= startPosition)) { <span class="fc" id="L210"> checkList.add(treeItemRight);</span> } } } } <span class="fc" id="L215"> }</span> /** * Gets the mtas tree item. * * @param ref the ref * @param isSinglePoint the is single point * @param isStoreAdditionalIdAndRef the is store additional id and ref * @param nodeRefApproxOffset the node ref approx offset * @param in the in * @param objectRefApproxOffset the object ref approx offset * @return the mtas tree item * @throws IOException Signals that an I/O exception has occurred. */ private static MtasTreeItem getMtasTreeItem(Long ref, AtomicBoolean isSinglePoint, AtomicBoolean isStoreAdditionalIdAndRef, AtomicLong nodeRefApproxOffset, IndexInput in, long objectRefApproxOffset) throws IOException { try { <span class="fc" id="L234"> Boolean isRoot = false;</span> <span class="fc bfc" id="L235" title="All 2 branches covered."> if (nodeRefApproxOffset.get() < 0) {</span> <span class="fc" id="L236"> isRoot = true;</span> } <span class="fc" id="L238"> in.seek(ref);</span> <span class="fc bfc" id="L239" title="All 2 branches covered."> if (isRoot) {</span> <span class="fc" id="L240"> nodeRefApproxOffset.set(in.readVLong());</span> <span class="fc" id="L241"> Byte flag = in.readByte();</span> <span class="fc bfc" id="L242" title="All 2 branches covered."> if ((flag</span> & MtasTree.SINGLE_POSITION_TREE) == MtasTree.SINGLE_POSITION_TREE) { <span class="fc" id="L244"> isSinglePoint.set(true);</span> } <span class="fc bfc" id="L246" title="All 2 branches covered."> if ((flag</span> & MtasTree.STORE_ADDITIONAL_ID) == MtasTree.STORE_ADDITIONAL_ID) { <span class="fc" id="L248"> isStoreAdditionalIdAndRef.set(true);</span> } } <span class="fc" id="L251"> int left = in.readVInt();</span> <span class="fc" id="L252"> int right = in.readVInt();</span> <span class="fc" id="L253"> int max = in.readVInt();</span> <span class="fc" id="L254"> Long leftChild = in.readVLong() + nodeRefApproxOffset.get();</span> <span class="fc" id="L255"> Long rightChild = in.readVLong() + nodeRefApproxOffset.get();</span> <span class="fc" id="L256"> int size = 1;</span> <span class="fc bfc" id="L257" title="All 2 branches covered."> if (!isSinglePoint.get()) {</span> <span class="fc" id="L258"> size = in.readVInt();</span> } // initialize <span class="fc" id="L261"> long[] objectRefs = new long[size];</span> <span class="fc" id="L262"> int[] objectAdditionalIds = null;</span> <span class="fc" id="L263"> long[] objectAdditionalRefs = null;</span> // get first <span class="fc" id="L265"> long objectRef = in.readVLong();</span> <span class="fc" id="L266"> long objectRefPrevious = objectRef + objectRefApproxOffset;</span> <span class="fc" id="L267"> objectRefs[0] = objectRefPrevious;</span> <span class="fc bfc" id="L268" title="All 2 branches covered."> if (isStoreAdditionalIdAndRef.get()) {</span> <span class="fc" id="L269"> objectAdditionalIds = new int[size];</span> <span class="fc" id="L270"> objectAdditionalRefs = new long[size];</span> <span class="fc" id="L271"> objectAdditionalIds[0] = in.readVInt();</span> <span class="fc" id="L272"> objectAdditionalRefs[0] = in.readVLong();</span> } // get others <span class="fc bfc" id="L275" title="All 2 branches covered."> for (int t = 1; t < size; t++) {</span> <span class="fc" id="L276"> objectRef = objectRefPrevious + in.readVLong();</span> <span class="fc" id="L277"> objectRefs[t] = objectRef;</span> <span class="fc" id="L278"> objectRefPrevious = objectRef;</span> <span class="pc bpc" id="L279" title="1 of 2 branches missed."> if (isStoreAdditionalIdAndRef.get()) {</span> <span class="fc" id="L280"> objectAdditionalIds[t] = in.readVInt();</span> <span class="fc" id="L281"> objectAdditionalRefs[t] = in.readVLong();</span> } } <span class="fc" id="L284"> return new MtasTreeItem(left, right, max, objectRefs, objectAdditionalIds,</span> objectAdditionalRefs, ref, leftChild, rightChild); <span class="nc" id="L286"> } catch (Exception e) {</span> <span class="nc" id="L287"> throw new IOException(e.getMessage());</span> } } /** * The Class MtasTreeItem. */ private static class MtasTreeItem { /** The max. */ public int left, right, max; /** The object refs. */ public long[] objectRefs; /** The additional ids. */ public int[] additionalIds; /** The additional refs. */ public long[] additionalRefs; /** The right child. */ public Long ref, leftChild, rightChild; /** * Instantiates a new mtas tree item. * * @param left the left * @param right the right * @param max the max * @param objectRefs the object refs * @param additionalIds the additional ids * @param additionalRefs the additional refs * @param ref the ref * @param leftChild the left child * @param rightChild the right child */ public MtasTreeItem(int left, int right, int max, long[] objectRefs, int[] additionalIds, long[] additionalRefs, Long ref, Long leftChild, <span class="fc" id="L326"> Long rightChild) {</span> <span class="fc" id="L327"> this.left = left;</span> <span class="fc" id="L328"> this.right = right;</span> <span class="fc" id="L329"> this.max = max;</span> <span class="fc" id="L330"> this.objectRefs = objectRefs;</span> <span class="fc" id="L331"> this.additionalIds = additionalIds;</span> <span class="fc" id="L332"> this.additionalRefs = additionalRefs;</span> <span class="fc" id="L333"> this.ref = ref;</span> <span class="fc" id="L334"> this.leftChild = leftChild;</span> <span class="fc" id="L335"> this.rightChild = rightChild;</span> <span class="fc" id="L336"> }</span> } /** * The Class MtasTreeHit. * * @param <T> the generic type */ public static class MtasTreeHit<T> { /** The start position. */ public int startPosition; /** The end position. */ public int endPosition; /** The ref. */ public long ref; /** The additional id. */ public int additionalId; /** The additional ref. */ public long additionalRef; /** The ref data. */ public T data, idData, refData; /** * Instantiates a new mtas tree hit. * * @param startPosition the start position * @param endPosition the end position * @param ref the ref * @param additionalId the additional id * @param additionalRef the additional ref */ public MtasTreeHit(int startPosition, int endPosition, long ref, <span class="fc" id="L374"> int additionalId, long additionalRef) {</span> <span class="fc" id="L375"> this.startPosition = startPosition;</span> <span class="fc" id="L376"> this.endPosition = endPosition;</span> <span class="fc" id="L377"> this.ref = ref;</span> <span class="fc" id="L378"> this.additionalId = additionalId;</span> <span class="fc" id="L379"> this.additionalRef = additionalRef;</span> <span class="fc" id="L380"> data = null;</span> <span class="fc" id="L381"> idData = null;</span> <span class="fc" id="L382"> refData = null;</span> <span class="fc" id="L383"> }</span> /** * Instantiates a new mtas tree hit. * * @param startPosition the start position * @param endPosition the end position * @param ref the ref * @param additionalId the additional id * @param additionalRef the additional ref * @param data the data */ public MtasTreeHit(int startPosition, int endPosition, long ref, int additionalId, long additionalRef, T data) { <span class="nc" id="L397"> this(startPosition, endPosition, ref, additionalId, additionalRef);</span> <span class="nc" id="L398"> this.data = data;</span> <span class="nc" id="L399"> this.idData = null;</span> <span class="nc" id="L400"> this.refData = null;</span> <span class="nc" id="L401"> }</span> /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { <span class="nc" id="L410"> return "hit[" + startPosition + "," + endPosition + "," + ref + ","</span> + additionalId + "," + additionalRef + "] - " + idData + " - " + refData; } } /** * Search mtas tree with interval tree. * * @param <T> the generic type * @param <N> the number type * @param additionalIds the additional ids * @param intervalTree the interval tree * @param in the in * @param ref the ref * @param objectRefApproxOffset the object ref approx offset * @throws IOException Signals that an I/O exception has occurred. */ public static <T, N extends IntervalTreeNode<T, N>> void searchMtasTreeWithIntervalTree( Collection<Integer> additionalIds, IntervalTree<T, N> intervalTree, IndexInput in, long ref, long objectRefApproxOffset) throws IOException { <span class="fc" id="L431"> ArrayList<IntervalItem<T, N>> checkList = new ArrayList<IntervalItem<T, N>>();</span> <span class="fc" id="L432"> AtomicBoolean isSinglePoint = new AtomicBoolean(false);</span> <span class="fc" id="L433"> AtomicBoolean isStoreAdditionalId = new AtomicBoolean(false);</span> <span class="fc" id="L434"> AtomicLong nodeRefApproxOffset = new AtomicLong(-1);</span> <span class="fc" id="L435"> checkList.add(new IntervalItem<T, N>(</span> <span class="fc" id="L436"> getMtasTreeItem(ref, isSinglePoint, isStoreAdditionalId,</span> nodeRefApproxOffset, in, objectRefApproxOffset), <span class="fc" id="L438"> intervalTree.getRoot()));</span> do { <span class="fc" id="L440"> IntervalItem<T, N> checkItem = checkList.remove(checkList.size() - 1);</span> <span class="fc" id="L441"> searchMtasTreeWithIntervalTree(additionalIds, checkItem, in,</span> isSinglePoint, isStoreAdditionalId, objectRefApproxOffset, nodeRefApproxOffset, checkList); <span class="fc bfc" id="L444" title="All 2 branches covered."> } while (checkList.size() > 0);</span> <span class="fc" id="L445"> }</span> /** * Search mtas tree with interval tree. * * @param <T> the generic type * @param <N> the number type * @param additionalIds the additional ids * @param checkItem the check item * @param in the in * @param isSinglePoint the is single point * @param isStoreAdditionalId the is store additional id * @param objectRefApproxOffset the object ref approx offset * @param nodeRefApproxOffset the node ref approx offset * @param checkList the check list * @throws IOException Signals that an I/O exception has occurred. */ private static <T, N extends IntervalTreeNode<T, N>> void searchMtasTreeWithIntervalTree( Collection<Integer> additionalIds, IntervalItem<T, N> checkItem, IndexInput in, AtomicBoolean isSinglePoint, AtomicBoolean isStoreAdditionalId, long objectRefApproxOffset, AtomicLong nodeRefApproxOffset, ArrayList<IntervalItem<T, N>> checkList) throws IOException { <span class="fc" id="L468"> MtasTreeItem treeItem = checkItem.mtasTreeItem;</span> <span class="fc" id="L469"> IntervalTreeNode<T, N> intervalTreeNode = checkItem.intervalTreeNode;</span> <span class="fc bfc" id="L470" title="All 2 branches covered."> if (intervalTreeNode.min <= treeItem.max) {</span> // advance intervalTree <span class="fc bfc" id="L472" title="All 2 branches covered."> while (intervalTreeNode.left > treeItem.max) {</span> <span class="pc bpc" id="L473" title="1 of 2 branches missed."> if (intervalTreeNode.rightChild == null) {</span> <span class="nc bnc" id="L474" title="All 2 branches missed."> if (intervalTreeNode.leftChild == null) {</span> <span class="nc" id="L475"> return;</span> } else { <span class="nc" id="L477"> intervalTreeNode = intervalTreeNode.leftChild;</span> } <span class="pc bpc" id="L479" title="1 of 2 branches missed."> } else if (intervalTreeNode.leftChild == null) {</span> <span class="nc" id="L480"> intervalTreeNode = intervalTreeNode.rightChild;</span> } else { <span class="pc bpc" id="L482" title="1 of 2 branches missed."> if (intervalTreeNode.rightChild.min > treeItem.max) {</span> <span class="fc" id="L483"> intervalTreeNode = intervalTreeNode.leftChild;</span> } else { break; } } } // find intervals matching current node <span class="fc" id="L490"> searchMtasTreeItemWithIntervalTree(additionalIds, treeItem,</span> intervalTreeNode); // check leftChild <span class="fc bfc" id="L493" title="All 2 branches covered."> if (!treeItem.leftChild.equals(treeItem.ref)) {</span> <span class="fc" id="L494"> MtasTreeItem treeItemLeft = getMtasTreeItem(treeItem.leftChild,</span> isSinglePoint, isStoreAdditionalId, nodeRefApproxOffset, in, objectRefApproxOffset); <span class="fc" id="L497"> checkList.add(new IntervalItem<T, N>(treeItemLeft, intervalTreeNode));</span> } // check rightChild <span class="fc bfc" id="L500" title="All 2 branches covered."> if (!treeItem.rightChild.equals(treeItem.ref)) {</span> <span class="fc" id="L501"> MtasTreeItem treeItemRight = getMtasTreeItem(treeItem.rightChild,</span> isSinglePoint, isStoreAdditionalId, nodeRefApproxOffset, in, objectRefApproxOffset); <span class="fc" id="L504"> checkList.add(new IntervalItem<T, N>(treeItemRight, intervalTreeNode));</span> } } <span class="fc" id="L507"> }</span> /** * Search mtas tree item with interval tree. * * @param <T> the generic type * @param <N> the number type * @param additionalIds the additional ids * @param treeItem the tree item * @param intervalTreeNode the interval tree node */ private static <T, N extends IntervalTreeNode<T, N>> void searchMtasTreeItemWithIntervalTree( Collection<Integer> additionalIds, MtasTreeItem treeItem, IntervalTreeNode<T, N> intervalTreeNode) { <span class="fc" id="L521"> ArrayList<IntervalTreeNode<T, N>> checkList = new ArrayList<IntervalTreeNode<T, N>>();</span> <span class="fc" id="L522"> checkList.add(intervalTreeNode);</span> do { <span class="fc" id="L524"> IntervalTreeNode<T, N> checkItem = checkList.remove(checkList.size() - 1);</span> <span class="fc" id="L525"> searchMtasTreeItemWithIntervalTree(additionalIds, checkItem,</span> treeItem.left, treeItem.right, treeItem.objectRefs, treeItem.additionalIds, treeItem.additionalRefs, checkList); <span class="fc bfc" id="L528" title="All 2 branches covered."> } while (checkList.size() > 0);</span> <span class="fc" id="L529"> }</span> /** * Search mtas tree item with interval tree. * * @param <T> the generic type * @param <N> the number type * @param requiredAdditionalIds the required additional ids * @param intervalTreeItem the interval tree item * @param startPosition the start position * @param endPosition the end position * @param refs the refs * @param additionalIds the additional ids * @param additionalRefs the additional refs * @param checkList the check list */ private static <T, N extends IntervalTreeNode<T, N>> void searchMtasTreeItemWithIntervalTree( Collection<Integer> requiredAdditionalIds, IntervalTreeNode<T, N> intervalTreeItem, int startPosition, int endPosition, long[] refs, int[] additionalIds, long[] additionalRefs, ArrayList<IntervalTreeNode<T, N>> checkList) { <span class="fc bfc" id="L550" title="All 2 branches covered."> if (startPosition <= intervalTreeItem.max) {</span> // match current node <span class="fc bfc" id="L552" title="All 4 branches covered."> if ((endPosition >= intervalTreeItem.left)</span> && (startPosition <= intervalTreeItem.right)) { // System.out.print("[" + startPosition + "-" + endPosition + "] "); <span class="pc bpc" id="L555" title="2 of 4 branches missed."> if (requiredAdditionalIds == null || additionalIds == null) {</span> <span class="nc bnc" id="L556" title="All 2 branches missed."> for (int i = 0; i < refs.length; i++) {</span> <span class="nc" id="L557"> MtasTreeHit<T> hit = new MtasTreeHit<T>(startPosition, endPosition,</span> refs[i], 0, 0); <span class="nc bnc" id="L559" title="All 2 branches missed."> for (ArrayList<MtasTreeHit<T>> list : intervalTreeItem.lists) {</span> <span class="nc" id="L560"> list.add(hit);</span> <span class="nc" id="L561"> }</span> } } else { <span class="fc bfc" id="L564" title="All 2 branches covered."> for (int i = 0; i < refs.length; i++) {</span> <span class="fc" id="L565"> MtasTreeHit<T> hit = new MtasTreeHit<T>(startPosition, endPosition,</span> refs[i], additionalIds[i], additionalRefs[i]); <span class="fc bfc" id="L567" title="All 2 branches covered."> for (ArrayList<MtasTreeHit<T>> list : intervalTreeItem.lists) {</span> <span class="fc bfc" id="L568" title="All 2 branches covered."> if (requiredAdditionalIds.contains(hit.additionalId)) {</span> <span class="fc" id="L569"> list.add(hit);</span> } <span class="fc" id="L571"> }</span> } } } // check leftChild <span class="fc bfc" id="L576" title="All 2 branches covered."> if (intervalTreeItem.leftChild != null) {</span> <span class="fc" id="L577"> IntervalTreeNode<T, N> treeItemLeft = intervalTreeItem.leftChild;</span> <span class="fc bfc" id="L578" title="All 2 branches covered."> if (treeItemLeft.max >= startPosition) {</span> <span class="fc" id="L579"> checkList.add(treeItemLeft);</span> } } // check rightChild <span class="fc bfc" id="L583" title="All 2 branches covered."> if (intervalTreeItem.left < endPosition) {</span> <span class="fc bfc" id="L584" title="All 2 branches covered."> if (intervalTreeItem.rightChild != null) {</span> <span class="fc" id="L585"> IntervalTreeNode<T, N> treeItemRight = intervalTreeItem.rightChild;</span> <span class="pc bpc" id="L586" title="1 of 4 branches missed."> if ((treeItemRight.left >= endPosition)</span> || (treeItemRight.max >= startPosition)) { <span class="fc" id="L588"> checkList.add(treeItemRight);</span> } } } } <span class="fc" id="L594"> }</span> /** * The Class IntervalItem. * * @param <T> the generic type * @param <N> the number type */ <span class="nc" id="L602"> private static class IntervalItem<T, N extends IntervalTreeNode<T, N>> {</span> /** The mtas tree item. */ public MtasTreeItem mtasTreeItem; /** The interval tree node. */ public IntervalTreeNode<T, N> intervalTreeNode; /** * Instantiates a new interval item. * * @param mtasTreeItem the mtas tree item * @param intervalTreeNode the interval tree node */ public IntervalItem(MtasTreeItem mtasTreeItem, <span class="fc" id="L617"> IntervalTreeNode<T, N> intervalTreeNode) {</span> <span class="fc" id="L618"> this.mtasTreeItem = mtasTreeItem;</span> <span class="fc" id="L619"> this.intervalTreeNode = intervalTreeNode;</span> <span class="fc" id="L620"> }</span> } } </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html>