Java Code Examples for org.apache.uima.cas.CAS#release()
The following examples show how to use
org.apache.uima.cas.CAS#release() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ASB_impl.java From uima-uimaj with Apache License 2.0 | 6 votes |
public void release() { // pop all frames off the casIteratorStack, calling Flow.abort() on flow objects and //CasIterator.release() on the CAS iterators while (!casIteratorStack.isEmpty()) { StackFrame frame = casIteratorStack.pop(); frame.originalCasFlow.aborted(); frame.casIterator.release(); } // release all active, internal CASes Iterator<CAS> iter = activeCASes.iterator(); while (iter.hasNext()) { CAS cas = iter.next(); // mFlowControllerContainer.dropCas(cas); if (cas != mInputCas) // don't release the input CAS, it's caller's responsibility { cas.release(); } } //clear the active CASes list, to guard against ever trying to //reuse these CASes or trying to release them a second time. activeCASes.clear(); }
Example 2
Source File: CasManager_implTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
public void testEnableReset() throws Exception { CasManager mgr = UIMAFramework.newDefaultResourceManager().getCasManager(); mgr.defineCasPool("test", 1, null); CAS cas = mgr.getCas("test"); ((CASImpl)cas).enableReset(false); // try { // cas.release(); // fail(); // } // catch (CASAdminException e) { // //expected // } cas.release(); // should work, release unlocks things. cas = mgr.getCas("test"); ((CASImpl)cas).enableReset(true); cas.release(); }
Example 3
Source File: TestCasMultiplier.java From uima-uimaj with Apache License 2.0 | 5 votes |
public boolean hasNext() throws AnalysisEngineProcessException { CAS outputCas = getEmptyCAS(); try { Assert.assertTrue(((TypeSystemImpl)mInputCAS.getTypeSystem()).getLargestTypeCode() == ((TypeSystemImpl)outputCas.getTypeSystem()).getLargestTypeCode()); Assert.assertTrue(mInputCAS.getTypeSystem() == outputCas.getTypeSystem()); } finally { outputCas.release(); } return false; }
Example 4
Source File: AnalysisEngineImplBase.java From uima-uimaj with Apache License 2.0 | 5 votes |
public ProcessTrace process(CAS aCAS) throws AnalysisEngineProcessException { CasIterator iter = processAndOutputNewCASes(aCAS); // step through all output CASes which lets the AE finish all processing while (iter.hasNext()) { CAS cas = iter.next(); cas.release(); } // https://issues.apache.org/jira/browse/UIMA-4151 return isProcessTraceEnabled() ? buildProcessTraceFromMBeanStats() : ProcessTrace_impl.disabledProcessTrace; // return buildProcessTraceFromMBeanStats(); }
Example 5
Source File: UimaContext_implTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testGetEmptyCas() throws Exception { try { CAS emptyCas = mContext5.getEmptyCas(CAS.class); //should be allowed to release this CAS emptyCas.release(); //and then get it again emptyCas = mContext5.getEmptyCas(CAS.class); emptyCas.release(); } catch (Exception e) { JUnitExtension.handleException(e); } }
Example 6
Source File: CasMultiplierExampleApplication.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Main program. * * @param args * Command-line arguments - see class description */ public static void main(String[] args) { try { // get Resource Specifier from XML file XMLInputSource in = new XMLInputSource(args[0]); ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in); // create AnalysisEngine AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier); // read input text file File textFile = new File(args[1]); String document = FileUtils.file2String(textFile, "UTF-8"); // create a new CAS and set the document text CAS initialCas = ae.newCAS(); initialCas.setDocumentText(document); // pass the CAS to the AnalysisEngine and get back // a CasIterator for stepping over the output CASes that are produced. CasIterator casIterator = ae.processAndOutputNewCASes(initialCas); while (casIterator.hasNext()) { CAS outCas = casIterator.next(); // dump the document text and annotations for this segment System.out.println("********* NEW SEGMENT *********"); System.out.println(outCas.getDocumentText()); PrintAnnotations.printAnnotations(outCas, System.out); // release the CAS (important) outCas.release(); } // If there's a CAS Consumer inside this aggregate and we want // it's collectionProcessComplete method to be called, we need to // call it ourselves. If run inside a CPE this would get called // automatically. ae.collectionProcessComplete(); } catch (Exception e) { e.printStackTrace(); } }