Examples of IntVector


Examples of org.apache.uima.internal.util.IntVector

        //new Sofas start at 2
        this.nextSofaNum = 2;
      } else {
        this.nextSofaNum = ((CASImpl)this.casBeingFilled).getBaseSofaCount() + 1;
      }
      this.deserializedFsAddrs = new IntVector();
      this.fsListNodesFromMultivaluedProperties = new IntVector();
      this.buffer = new StringBuffer();
      this.indexRepositories = new ArrayList<FSIndexRepository>();
      this.views = new ArrayList<CAS>();
      indexRepositories.add(this.casBeingFilled.getBaseIndexRepository());
      // There should always be another index for the Initial View
View Full Code Here

Examples of org.apache.uima.internal.util.IntVector

        if (attrName.equals(ID_ATTR_NAME)) {
          try {
            id = Integer.parseInt(attrValue);
            newFS = this.isNewFS(id);
            if (sofaTypeCode != typeCode && !newFS) {
              this.featsSeen = new IntVector(attrs.getLength());
            } else {
              this.featsSeen = null;
            }
          } catch (NumberFormatException e) {
            throw createException(XCASParsingException.ILLEGAL_ID, attrValue);
View Full Code Here

Examples of org.apache.uima.internal.util.IntVector

          // We need this so we can go back through later and reset the addresses of the
          // "head" features of these lists nodes (but not reset the tail features).
          // It also adds a mapping between the nodes and the encompassing FS in order
          // to properly serialize in delta xmi format.
          int listFS = casBeingFilled.getFeatureValue(addr, featCode);
          IntVector fslistnodes = new IntVector();
          if (listFS == 0) {
            listFS = listUtils.createFsList(featVals, fslistnodes);
            casBeingFilled.setFeatureValue(addr, featCode, listFS);
          } else {
          listUtils.updateFsList(listFS, featVals, fslistnodes);
          }
          //add to multivaluedproperties fs list.
          for (int i=0; i < fslistnodes.size();  i++) {
            fsListNodesFromMultivaluedProperties.add(fslistnodes.get(i));
          }
          //add to nonshared fs to encompassing FS map.
          if (!ts.ll_getFeatureForCode(featCode).isMultipleReferencesAllowed()) {
          for (int i=0; i < fslistnodes.size(); i++) {
            addNonsharedFSToEncompassingFSMapping(fslistnodes.get(i), addr);
          }
          }
          break;
        }
        default: {
View Full Code Here

Examples of org.apache.uima.internal.util.IntVector

    }

    // /////////////////////////////////////////////////////////////////////////
    // Create a reverse iterator for the set index and check that the result
    // is the same as for forward iteration.
    IntVector v = new IntVector();
    FSIndex<FeatureStructure> bagIndex = this.cas.getIndexRepository().getIndex(
        CASTestSetup.ANNOT_BAG_INDEX);
    FSIndex<FeatureStructure> setIndex = this.cas.getIndexRepository().getIndex(
        CASTestSetup.ANNOT_SET_INDEX);
    FSIndex<FeatureStructure> sortedIndex = this.cas.getIndexRepository().getIndex(
        CASTestSetup.ANNOT_SORT_INDEX);

    FSIterator<FeatureStructure> it = setIndex.iterator();
    AnnotationFS a, b = null;
    while (it.isValid()) {
      a = (AnnotationFS) it.get();
      if (b != null) {
        assertTrue(setIndex.compare(b, a) <= 0);
      }
      b = a;
      // System.out.println(
      // a.getType().getName() + " - " + a.getStart() + " - " +
      // a.getEnd());
      v.add(it.get().hashCode());
      it.moveToNext();
    }
    // System.out.println("Number of annotations: " + v.size());
    assertTrue(v.size() == ((10 * 3) + (10 * 3)));

    it = setIndex.iterator();
    it.moveToLast();
    int current = v.size() - 1;
    while (it.isValid() && (current >= 0)) {
      // System.out.println("Current: " + current);
      a = (AnnotationFS) it.get();
      // System.out.println(
      // a.getType().getName() + " - " + a.getStart() + " - " +
      // a.getEnd());
      assertTrue(it.get().hashCode() == v.get(current));
      it.moveToPrevious();
      --current;
    }
    assertTrue(current == -1);
    assertFalse(it.isValid());

    // /////////////////////////////////////////////////////////////////////////
    // Use an iterator to move forwards and backwards and make sure the
    // sequence
    // remains constant.
    it = setIndex.iterator();
    it.moveToFirst(); // This is redundant.
    current = 1;
    // System.out.println("Codes: " + v);
    while (current < (v.size() - 1)) {
      it.moveToNext();
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(current));
      it.moveToNext();
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(current + 1));
      it.moveToPrevious();
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(current));
      ++current;
    }

    // also test Java-style iteration
    Iterator<FeatureStructure> javaIt = setIndex.iterator();
    current = 0;
    while (javaIt.hasNext()) {
      assertEquals(javaIt.next().hashCode(), v.get(current++));
    }

    // test find()
    AnnotationFS annot = (AnnotationFS) setIndex.iterator().get();
    assertNotNull(setIndex.find(annot));
    assertNull(setIndex.find(this.cas.createAnnotation(this.annotationType, -1, -1)));

    // do same for JCas
    JCas jcas = null;
    try {
      jcas = this.cas.getJCas();
    } catch (CASException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
      assertTrue(false);
    }
    FSIndex jcasSetIndex = jcas.getJFSIndexRepository().getIndex(CASTestSetup.ANNOT_SET_INDEX);
    Annotation jcasAnnotation = (Annotation) jcasSetIndex.find(annot);
    assertNotNull(jcasAnnotation);
    assertNull(jcasSetIndex.find(this.cas.createAnnotation(this.annotationType, -1, -1)));

    // /////////////////////////////////////////////////////////////////////////
    // Test fast fail.

    it = bagIndex.iterator(); // use bag index, remove add last one
    // (preserves order for other tests).
    it.moveToLast();
    a = (AnnotationFS) it.get();
    it = setIndex.iterator(); // back to set iterator to do testing
    this.cas.getIndexRepository().removeFS(a);
    this.cas.getIndexRepository().addFS(a);

    boolean ok = false;
    try {
      it.next(); // should throw
    } catch (ConcurrentModificationException e) {
      ok = true;
    }
    assertTrue(ok);
    ok = false;
    try {
      it.next(); // should throw
    } catch (ConcurrentModificationException e) {
      ok = true;
    }
    assertTrue(ok);
    it.moveTo(a);
    ok = false;
    try {
      it.next(); // should not throw
      ok = true;
    } catch (ConcurrentModificationException e) {
      // checking this with the ok variable
    }
    assertTrue(ok);

    // Test find()
    Type wType = this.cas.getTypeSystem().getType("org.apache.uima.cas.test.types.Word");

    Feature wordFeat = wType.getFeatureByBaseName("word");

    for (int i = 0; i < 20; i++) {
      FeatureStructure fs = this.cas.createFS(wType);
      fs.setStringValue(wordFeat, "word" + i);
      this.cas.getIndexRepository().addFS(fs);
    }

    FSIndex<FeatureStructure> wordSetIndex = this.cas.getIndexRepository().getIndex(
        "Word Set Index");

    it = wordSetIndex.iterator();

    FeatureStructure fs = this.cas.createFS(wType);
    fs.setStringValue(wordFeat, "word1");

    // TEST moveTo() and get()
    it.moveTo(fs);

    assertSame(fs.getType(), it.get().getType());

    Type t1 = fs.getType();
    Type t2 = wordSetIndex.find(fs).getType();
    assertSame(t1, t2);

    // /////////////////////////////////////////////////////////////////////////
    // Test sorted index.

    // FSIndex sortedIndex = cas.getAnnotationIndex(); // using different
    // typeOrder
    // System.out.println("Number of annotations: " + sortedIndex.size());
    // for (it = sortedIndex.iterator(); it.hasNext(); it.next()) {
    // System.out.println(it.get());
    // }

    assertTrue(sortedIndex.size() == 100);
    v = new IntVector();
    it = sortedIndex.iterator();
    it.moveToFirst();
    b = null;
    while (it.isValid()) {
      a = (AnnotationFS) it.get();
      // System.out.println(a);
      assertTrue(a != null);
      if (b != null) {
        // System.out.println("b = " + b);
        assertTrue(sortedIndex.compare(b, a) <= 0);
      }
      b = a;
      v.add(a.hashCode());
      it.moveToNext();
    }
    assertTrue(sortedIndex.size() == v.size());

    // Test moveTo()
    List<AnnotationFS> list = new ArrayList<AnnotationFS>();
    FSIterator<AnnotationFS> it2 = this.cas.getAnnotationIndex().iterator();
    for (it2.moveToFirst(); it2.isValid(); it2.moveToNext()) {
      list.add(it2.get());
    }
    // AnnotationFS an;
    for (int i = 0; i < list.size(); i++) {
      // System.out.println("Iteration: " + i);
      it2.moveToFirst();
      it2.moveTo(list.get(i));
      assertTrue(((AnnotationFS) it2.get()).getBegin() == ((AnnotationFS) list.get(i)).getBegin());
      assertTrue(((AnnotationFS) it2.get()).getEnd() == ((AnnotationFS) list.get(i)).getEnd());
    }

    // Check that reverse iterator produces reverse sequence.
    // Note: this test is not valid. It is by no means guaranteed that reverse iteration of a
    // sorted index will produce the reverse result of forward iteration. I no two annotations
    // are equal wrt the sort order, this works of course. However, if some FSs are equal wrt
    // the sort order, those may be returned in any order.
    // it.moveToLast();
    // System.out.println(it.get());
    // for (int i = v.size() - 1; i >= 0; i--) {
    // assertTrue(it.isValid());
    // assertTrue(it.get().hashCode() == v.get(i));
    // it.moveToPrevious();
    // }

    // /////////////////////////////////////////////////////////////////////////
    // Use an iterator to move forwards and backwards and make sure the
    // sequence
    // remains constant.
    it = sortedIndex.iterator();
    it.moveToFirst(); // This is redundant.
    current = 1;
    // System.out.println("Codes: " + v);
    while (current < (v.size() - 1)) {
      it.moveToNext();
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(current));
      it.moveToNext();
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(current + 1));
      it.moveToPrevious();
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(current));
      ++current;
    }

    // also test Java-style iteration
    javaIt = sortedIndex.iterator();
    current = 0;
    while (javaIt.hasNext()) {
      assertEquals(javaIt.next().hashCode(), v.get(current++));
    }
    // /////////////////////////////////////////////////////////////////////////
    // Test fast fail.

    it = bagIndex.iterator(); // use bag index, remove add last one
    // (preserves order for other tests).
    it.moveToLast();
    a = (AnnotationFS) it.get();
    // for (it = sortedIndex.iterator(); it.hasNext(); it.next()) {
    // System.out.println(it.get());
    // }
    it = sortedIndex.iterator();
    it.next();
    it.next();
    this.cas.getIndexRepository().removeFS(a);
    this.cas.getIndexRepository().addFS(a);
    ok = false;
    try {
      it.get(); // should throw
    } catch (ConcurrentModificationException e) {
      ok = true;
    }
    assertTrue(ok);
    ok = false;
    try {
      it.next(); // should throw
    } catch (ConcurrentModificationException e) {
      ok = true;
    }
    assertTrue(ok);
    ok = false;
    try {
      it.moveToNext(); // should throw
    } catch (ConcurrentModificationException e) {
      ok = true;
    }
    assertTrue(ok);
    it.moveTo(a);
    ok = false;
    try {
      it.next(); // should not throw
      ok = true;
    } catch (ConcurrentModificationException e) {
      // checking with boolean "ok"
    }
    assertTrue(ok);

    sortedIndex = null;

    // /////////////////////////////////////////////////////////////////////////
    // Test bag index.
    // System.out.println("Number of annotations: " + sortedIndex.size());
    assertTrue(bagIndex.size() == 100);
    v = new IntVector();
    it = bagIndex.iterator();
    b = null;
    while (it.isValid()) {
      a = (AnnotationFS) it.get();
      assertTrue(a != null);
      if (b != null) {
        assertTrue(bagIndex.compare(b, a) <= 0);
      }
      b = a;
      v.add(a.hashCode());
      it.moveToNext();
    }
    assertTrue(bagIndex.size() == v.size());

    // Check that reverse iterator produces reverse sequence.
    it.moveToLast();
    for (int i = v.size() - 1; i >= 0; i--) {
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(i));
      it.moveToPrevious();
    }

    // /////////////////////////////////////////////////////////////////////////
    // Use an iterator to move forwards and backwards and make sure the
    // sequence
    // remains constant.
    it = bagIndex.iterator();
    it.moveToFirst(); // This is redundant.
    current = 1;
    // System.out.println("Codes: " + v);
    while (current < (v.size() - 1)) {
      it.moveToNext();
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(current));
      it.moveToNext();
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(current + 1));
      it.moveToPrevious();
      assertTrue(it.isValid());
      assertTrue(it.get().hashCode() == v.get(current));
      ++current;
    }

    // also test Java-style iteration
    javaIt = bagIndex.iterator();
    current = 0;
    while (javaIt.hasNext()) {
      assertEquals(javaIt.next().hashCode(), v.get(current++));
    }

    // Test iterator copy.
    FSIterator<AnnotationFS> source, copy;
    source = this.cas.getAnnotationIndex().iterator();
View Full Code Here

Examples of org.apache.uima.internal.util.IntVector

  // Public only for testing purposes.
  public FSIndexComparatorImpl(CASImpl cas) {
    super();
    this.keyVector = new Vector<Object>();
    this.compVector = new IntVector();
    this.keyTypeVector = new IntVector();
    this.type = null;
    this.ts = cas.getTypeSystem();
    this.cas = cas;
  }
View Full Code Here

Examples of org.apache.uima.internal.util.IntVector

      byteHeapObj   = cas.getByteHeap();

//      deserIn.readInt();    // reserved to record additional version info  // already read before calling
      final int nbrEntries = deserIn.readInt()// number of compressed streams
     
      IntVector idxAndLen = new IntVector(nbrEntries * 3);
     
      for (int i = 0; i < nbrEntries; i++) {
        idxAndLen.add(deserIn.readUnsignedByte())// slot ordinal number
        idxAndLen.add(deserIn.readInt());           // compressed size, bytes
        idxAndLen.add(deserIn.readInt());           // decompressed size, bytes (not currently used)
      }
     
      for (int i = 0; i < idxAndLen.size();) {
        setupReadStream(idxAndLen.get(i++), idxAndLen.get(i++), idxAndLen.get(i++));
      }

      arrayLength_dis = dataInputs[arrayLength_i];
      heapRef_dis = dataInputs[heapRef_i];
      int_dis = dataInputs[int_i];
View Full Code Here

Examples of org.apache.uima.internal.util.IntVector

      }

      if (CHANGE_FS_REFS_TO_SEQUENTIAL && (heapStart > 1)) {
        initFsStartIndexes(fsStartIndexes, heap, 1, heapStart, null);
      }
      fixupsNeeded = new IntVector(Math.max(16, heap.length / 10));

      /***************************
       * walk main heap
       ***************************/

 
View Full Code Here

Examples of org.apache.xml.utils.IntVector

  public static final int NULL=-1;

  public DTMStringPool()
    {
      m_intToString=new Vector();
      m_hashChain=new IntVector(512);
      removeAllElements();
     
      // -sb Add this to force empty strings to be index 0.
      stringToIndex("");
    }
View Full Code Here

Examples of org.apache.xml.utils.IntVector

    m_dataOrQName = new SuballocatedIntVector(m_initialblocksize);
   
    // m_useSourceLocationProperty=org.apache.xalan.processor.TransformerFactoryImpl.m_source_location;
    m_useSourceLocationProperty = m_source_location;
    m_sourceSystemId = (m_useSourceLocationProperty) ? new StringVector() : null;
   m_sourceLine = (m_useSourceLocationProperty) new IntVector() : null;
    m_sourceColumn = (m_useSourceLocationProperty) new IntVector() : null;
  }
View Full Code Here

Examples of org.apache.xml.utils.IntVector

     */
    public DTMAxisIterNodeList(DTM dtm, DTMAxisIterator dtmAxisIterator) {
        if (dtmAxisIterator == null) {
            m_last = 0;
        } else {
            m_cachedNodes = new IntVector();
            m_dtm = dtm;
        }
        m_iter = dtmAxisIterator;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.