DrDub commented on code in PR #25: URL: https://github.com/apache/uima-uimacpp/pull/25#discussion_r1722939037
########## src/test/src/test_engine.cpp: ########## @@ -635,9 +636,9 @@ void mainTest(uima::util::ConsoleUI & rclConsole, testCallingSequence2(rclConsole, cpszConfigFilename); testCallingSequence3(rclConsole, cpszConfigFilename); } - testCasMultiplier(rclConsole); + testCasMultiplier(rclConsole); testAggregateCASMultiplier(rclConsole); Review Comment: Why ran it three times? ########## src/test/src/test_engine.cpp: ########## @@ -635,9 +636,9 @@ void mainTest(uima::util::ConsoleUI & rclConsole, testCallingSequence2(rclConsole, cpszConfigFilename); testCallingSequence3(rclConsole, cpszConfigFilename); } - testCasMultiplier(rclConsole); + testCasMultiplier(rclConsole); testAggregateCASMultiplier(rclConsole); + #if 0 - testAggregateCASMultiplier(rclConsole); testAggregateCASCombiner(rclConsole); Review Comment: So combiner still doesn't work, right? What'd you say it might be missing? ########## src/framework/uima/internal_engine_base.hpp: ########## @@ -64,6 +64,10 @@ namespace uima { /* Types / Classes */ /* ----------------------------------------------------------------------- */ namespace uima { + Review Comment: So there's no other exception already defined by the framework that we could use? The framework already declares other 80 exceptions: ``` uima-uimacpp/src$ find . -name \*.hpp -exec grep -H UIMA_EXC_CLASSDECLARE \{} \; ./cas/uima/featurestructure.hpp: UIMA_EXC_CLASSDECLARE(InvalidFSObjectException, CASException); ./cas/uima/featurestructure.hpp: UIMA_EXC_CLASSDECLARE(FeatureNotAppropriateException, CASException); ./cas/uima/featurestructure.hpp: UIMA_EXC_CLASSDECLARE(IncompatibleValueTypeException, CASException); ./cas/uima/featurestructure.hpp: UIMA_EXC_CLASSDECLARE(FSIsNotStringException, CASException); ./cas/uima/featurestructure.hpp: UIMA_EXC_CLASSDECLARE(WrongStringValueException, CASException); ./cas/uima/arrayfs.hpp: UIMA_EXC_CLASSDECLARE(FSIsNotArrayException, CASException); ./cas/uima/arrayfs.hpp: UIMA_EXC_CLASSDECLARE(FSArrayOutOfBoundsException, CASException); ./cas/uima/fsindexrepository.hpp: UIMA_EXC_CLASSDECLARE(InvalidIndexIDException, CASException); ./cas/uima/typesystem.hpp: UIMA_EXC_CLASSDECLARE(TypeSystemAlreadyCommittedException, CASException); ./cas/uima/typesystem.hpp: UIMA_EXC_CLASSDECLARE(InvalidFSFeatureObjectException, CASException); ./cas/uima/typesystem.hpp: UIMA_EXC_CLASSDECLARE(InvalidFSTypeObjectException, CASException); ./cas/uima/casexception.hpp: UIMA_EXC_CLASSDECLARE(CASException, Exception); ./cas/uima/casexception.hpp: UIMA_EXC_CLASSDECLARE(NotYetImplementedException, CASException); ./cas/uima/casexception.hpp: UIMA_EXC_CLASSDECLARE(SofaDataStreamException, CASException); ./cas/uima/cas.hpp: UIMA_EXC_CLASSDECLARE(CouldNotCreateFSOfFinalTypeException, CASException); ./cas/uima/cas.hpp: UIMA_EXC_CLASSDECLARE(DuplicateSofaNameException, CASException); ./cas/uima/cas.hpp: UIMA_EXC_CLASSDECLARE(InvalidBaseCasMethod, CASException); ./cas/uima/xmltypesystemreader.hpp: UIMA_EXC_CLASSDECLARE(XMLTypeSystemReaderException, uima::Exception); ./cas/uima/lowlevel_typesystem.hpp: UIMA_EXC_CLASSDECLARE(FeatureIntroductionFailedException, CASException); ./cas/uima/lowlevel_typesystem.hpp: UIMA_EXC_CLASSDECLARE(TypeCreationFailedException, CASException); ./cas/uima/fsindex.hpp: UIMA_EXC_CLASSDECLARE(InvalidIndexObjectException, CASException); ./cas/uima/fsindex.hpp: UIMA_EXC_CLASSDECLARE(WrongFSTypeForIndexException, CASException); ./cas/uima/listfs.hpp: UIMA_EXC_CLASSDECLARE(FSIsNotListException, CASException); ./cas/uima/listfs.hpp: UIMA_EXC_CLASSDECLARE(ListIsEmptyException, CASException); ./cas/uima/listfs.hpp: UIMA_EXC_CLASSDECLARE(ListIsCircularException, CASException); ./cas/uima/internal_casdeserializer.hpp: UIMA_EXC_CLASSDECLARE(DeserializationException, Exception); ./framework/uima/exceptions.hpp: UIMA_EXCEPTION_DESCRIPTION, UIMA_EXC_CLASSDECLARE, UIMA_EXC_CLASSIMPLEMENT, ./framework/uima/exceptions.hpp: <TT>UIMA_EXC_CLASSDECLARE</TT> in an .h/.hpp file there must be one use of ./framework/uima/exceptions.hpp:#define UIMA_EXC_CLASSDECLARE(child,parent) \ ./framework/uima/exceptions.hpp: <TT>UIMA_EXC_CLASSDECLARE</TT> (see above) in the corresponding .h/.hpp file ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(Uima_logic_error, Exception); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(Uima_runtime_error, Exception); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(Uima_domain_error, Uima_logic_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(Uima_invalid_argument, Uima_logic_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(Uima_length_error, Uima_logic_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(Uima_out_of_range, Uima_logic_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(Uima_range_error, Uima_runtime_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(Uima_overflow_error, Uima_runtime_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(Uima_underflow_error, Uima_runtime_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ConsoleAbortExc, Exception); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ExcDocBuffer, Uima_out_of_range); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ParseHandlerExc, Exception); ./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcAccessError, Uima_runtime_error); ./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcAssertionFailure, Exception); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ExcIllFormedInputError, Uima_runtime_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ExcInvalidParameter, Uima_invalid_argument); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ExcIndexOutOfRange, Uima_out_of_range); ./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcDeviceError, _runtime_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ExcInvalidRequest, Uima_runtime_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ExcResourceExhausted, Uima_runtime_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ExcOutOfMemory, ExcResourceExhausted); ./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcOutOfSystemResource, ResourceExhausted); ./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcOutOfWindowResource, ResourceExhausted); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ExcFileNotFoundError, Uima_runtime_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(ExcWinCException, Uima_runtime_error); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(CodePageConversionException, Exception); ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(AprFailureException, Exception); ./framework/uima/exceptions.hpp: To declare a new exception class, use the <TT>UIMA_EXC_CLASSDECLARE</TT> macro in an .h/.hpp ./framework/uima/exceptions.hpp: UIMA_EXC_CLASSDECLARE(AnnotatorException, InvalidRequest); ./framework/uima/casiterator.hpp: UIMA_EXC_CLASSDECLARE(CASIteratorException, uima::Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(UnknownTypeException, Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(UnknownFeatureException, Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(UnknownRangeTypeException, Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(IncompatibleRangeTypeException, Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(AllowedStringValuesIncompatibleException, Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(TypePriorityConflictException, Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(IncompatibleIndexDefinitionsException, Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(IncompatibleParentTypesException, Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(CASIncompatibilityException, Exception); ./framework/uima/engine.hpp: UIMA_EXC_CLASSDECLARE(UimaAnalysisComponentException, Exception); ./framework/uima/internal_jedii_engine.hpp: UIMA_EXC_CLASSDECLARE(JavaException, Exception); ./framework/uima/internal_capability_container.hpp: UIMA_EXC_CLASSDECLARE(CapabilityException, Exception); ./framework/uima/taespecifierbuilder.hpp: UIMA_EXC_CLASSDECLARE(InvalidXMLException, uima::Exception); ./framework/uima/caspool.hpp: UIMA_EXC_CLASSDECLARE(CASPoolException, uima::Exception); ./framework/uima/taespecifier.hpp: UIMA_EXC_CLASSDECLARE(ConfigParamLookupException, ConfigException); ./framework/uima/taemetadata.hpp: UIMA_EXC_CLASSDECLARE(DuplicateConfigElemException, uima::Exception); ./framework/uima/taemetadata.hpp: UIMA_EXC_CLASSDECLARE(ValidationException, uima::Exception); ./framework/uima/annotator.hpp: UIMA_EXC_CLASSDECLARE(ExcEnumerationOverflow, ExcIllFormedInputError); ./framework/uima/config_param.hpp: UIMA_EXC_CLASSDECLARE(ConfigException, Exception); ./framework/uima/config_param.hpp: UIMA_EXC_CLASSDECLARE(ConfigParamException, ConfigException); ``` ########## src/framework/uima/flow_controller.hpp: ########## @@ -0,0 +1,162 @@ +#ifndef UIMA_FLOW_CONTROLLER_HPP +#define UIMA_FLOW_CONTROLLER_HPP + +/** \file flow_controller.hpp . +----------------------------------------------------------------------------- + + + + + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + +----------------------------------------------------------------------------- + + Description: Review Comment: Please add a description, just grab the start of the description in the code below. Some of the framework files have entries describing when they were modified. I find that useful to gauge code maturity. Please add a section here after description, separated with '------------------------' that contains the current date and "Initial creation". Take a look at `src/framework/uima/annotator_mgr.hpp` for an example. ########## src/framework/flow.cpp: ########## @@ -0,0 +1,132 @@ +/** \file flow_controller.cpp . +----------------------------------------------------------------------------- + + + + + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + +----------------------------------------------------------------------------- +----------------------------------------------------------------------------- + + +-------------------------------------------------------------------------- */ + +#include "uima/flow.hpp" + +namespace uima { + Step::Step(const internal::SimpleStep &simpleStep): uStep(simpleStep), + type(StepType::SIMPLESTEP) { + } + + Step::Step(const internal::ParallelStep ¶llelStep): uStep(parallelStep), + type(StepType::PARALLELSTEP) { + } + + Step::Step(const internal::FinalStep &finalStep): uStep(finalStep), + type(StepType::FINALSTEP) { + } + + Step::Step(const Step& other) :type(other.type){ Review Comment: space before brace ########## src/framework/annotator_mgr.cpp: ########## @@ -152,12 +155,21 @@ namespace uima { assert(iv_vecEntries.empty()); AnnotatorContext & rANC = iv_pEngine->getAnnotatorContext(); - AnalysisEngineDescription const & crTAESpecifier = rANC.getTaeSpecifier(); // this method must be added - + const AnalysisEngineMetaData* pEngineMetadata = crTAESpecifier.getAnalysisEngineMetaData(); assert( ! crTAESpecifier.isPrimitive() ); - //BSIvector < icu::UnicodeString > const & crVecEngineNames = crTAESpecifier.getAnalysisEngineMetaData()->getFixedFlow()->getNodes(); - vector < icu::UnicodeString > const & crVecEngineNames = crTAESpecifier.getAnalysisEngineMetaData()->getFlowConstraints()->getNodes(); + + // FIXME: This shouldn't have been necessary since FlowContrainst::getFlowContraintsType Review Comment: which part is unnecessary? ########## src/framework/uima/annotator_mgr.hpp: ########## Review Comment: Add a line with date and a description of the changes in line 34, to document this functionality was upgraded with your work. ########## src/framework/uima/msgstrtab.h: ########## @@ -702,6 +702,8 @@ static const TCHAR * gs_aszMessageStringTable[] = { "Invalid call to next(). ", /* 331 - UIMA_MSG_ID_SIGNATURE_END: */ "[UIMA-LIBRARY]", + /* 332 - UIMA_MSG_ID_EXC_INVALID_CAS_RELEASE */ Review Comment: these numbers don't seem to be related to any messages in the Java version, so adding new ones looks fine. ########## src/framework/uima/flow.hpp: ########## @@ -0,0 +1,207 @@ +#ifndef UIMA_FLOW_HPP +#define UIMA_FLOW_HPP + +/** \file flow.hpp . +----------------------------------------------------------------------------- + + + + + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + +----------------------------------------------------------------------------- + + Description: Flow interface for the FlowController + +----------------------------------------------------------------------------- + + +-------------------------------------------------------------------------- */ +#include <memory> + +#include "uima/pragmas.hpp" +#include "uima/annotator.hpp" + +namespace uima { + namespace internal { + /** + * Indicates that a CAS should be routed to a single AnalysisEngine. + */ + class UIMA_LINK_IMPORTSPEC SimpleStep { + /* The key of the engine the CAS will be input to. + Not to be confused with the engine name, which is specified by the its descriptor*/ + icu::UnicodeString engineKey; + /* ResultSpecification *resultSpec; */ + public: + /* If SimpleStepWithResultSpec is required when CapabilityLanguageFlowController is implemented, + * this class could have an extra member ResultSpecification + SimpleStep(const icu::UnicodeString &name, ResultSpecification *resultSpec) : engineKey(name) { + } */ + + SimpleStep(const icu::UnicodeString &name) : engineKey(name) { + } + + const icu::UnicodeString &getEngineName() const { + return engineKey; + } + + /** Review Comment: why this code is commented out? Either add it or delete it. ########## src/test/data/descriptors/SimpleTextSegmenter.xml: ########## @@ -32,7 +32,7 @@ <name>Simple Text Segmenter</name> <description> Splits a text document into pieces. The point at which the text is split is determined by - SegmentDelimiter configuration parameter which defaults to new line ('\n'). + SegmentDelimiter configuration parameter which defaults to '.' Review Comment: I see what you mean. But the default _really_ is '\n'. This descriptor sets it to '.' instead. What about "new line ('\n'), here set to '.'"" instead? ########## src/framework/caspool.cpp: ########## @@ -77,6 +79,38 @@ namespace uima { } + CASPool::CASPool(AnnotatorContext *anContext, const AnalysisEngineDescription &taeSpec, Review Comment: there's a lot of code duplication between these two constructors. Any manner they can be mixed together? ########## src/framework/caspool.cpp: ########## @@ -77,6 +79,38 @@ namespace uima { } + CASPool::CASPool(AnnotatorContext *anContext, const AnalysisEngineDescription &taeSpec, + size_t numInstances) : iv_vecAllInstances(), + iv_vecFreeInstances(), + iv_numInstances(numInstances), + iv_pCasDef(nullptr), + iv_pOwner(anContext) { + iv_pCasDef = internal::CASDefinition::createCASDefinition(taeSpec); + if (iv_pCasDef == nullptr) { + UIMA_EXC_THROW_NEW(CASPoolException, + UIMA_ERR_CASPOOL_CREATE_CASDEFINITION, + UIMA_MSG_ID_EXC_CREATE_CASPOOL, + UIMA_MSG_ID_EXC_CREATE_CASPOOL, + ErrorInfo::unrecoverable); + } + + for (size_t i = 0; i < numInstances; i++) { + CAS *pCas = uima::internal::CASImpl::createCASImpl(*iv_pCasDef, false); + if (pCas == nullptr) { + UIMA_EXC_THROW_NEW(CASPoolException, + UIMA_ERR_CASPOOL_CREATE_CAS, + UIMA_MSG_ID_EXC_CREATE_CASPOOL, + UIMA_MSG_ID_EXC_CREATE_CASPOOL, + ErrorInfo::unrecoverable); + } + CAS *initialView = pCas->getInitialView(); Review Comment: this seems wrong. Why only the owner of the initialview? Shouldn't be the owner of the whole CAS? What about the other views? ########## src/framework/annotator_mgr.cpp: ########## @@ -86,12 +86,13 @@ namespace uima { /* Implementation */ /* ----------------------------------------------------------------------- */ - AnnotatorManager::AnnotatorManager(internal::AggregateEngine & rEngine) : - iv_pEngine(& rEngine), - iv_vecEntries(), - iv_bIsInitialized(false), - iv_uiNbrOfDocsProcessed(0) - /* ----------------------------------------------------------------------- */{ + AnnotatorManager::AnnotatorManager(internal::AggregateEngine & rEngine) : iv_pEngine(&rEngine), Review Comment: changing the white space here creates a diff that's difficult to appreciate. When working with legacy code don't do that, it is important to understand when the change got added rather than just making it look prettier. ########## src/cas/cas.cpp: ########## Review Comment: Looks good. Please remove the unnecessary whitespace changes. ########## src/framework/annotator_mgr.cpp: ########## @@ -403,39 +415,31 @@ namespace uima { #endif // treat dump-like annotators for this language specially - if (crCapContainer.hasEmptyOutputTypeOrFeatures( crLanguage )) { + if (crCapContainer.hasEmptyOutputTypeOrFeatures(crLanguage)) { return true; } - ResultSpecification::TyTypeOrFeatureSTLSet const & crTOFSet = rResultSpec.getTypeOrFeatureSTLSet(); + ResultSpecification::TyTypeOrFeatureSTLSet const &crTOFSet = rResultSpec.getTypeOrFeatureSTLSet(); bool bHasTOF = false; - ResultSpecification::TyTypeOrFeatureSTLSet::const_iterator cit; - for (cit = crTOFSet.begin(); cit != crTOFSet.end(); ++cit) { - TypeOrFeature const & crTOF = (*cit); - assert( (*cit).isValid() ); - assert( crTOF.isValid() ); - assert( rResultSpec.contains( crTOF ) ); - + for (const auto & crTOF : crTOFSet) { + assert(crTOF.isValid()); Review Comment: these two lines shouldn't in the diff ########## src/framework/annotator_mgr.cpp: ########## @@ -403,39 +415,31 @@ namespace uima { #endif // treat dump-like annotators for this language specially - if (crCapContainer.hasEmptyOutputTypeOrFeatures( crLanguage )) { + if (crCapContainer.hasEmptyOutputTypeOrFeatures(crLanguage)) { return true; } - ResultSpecification::TyTypeOrFeatureSTLSet const & crTOFSet = rResultSpec.getTypeOrFeatureSTLSet(); + ResultSpecification::TyTypeOrFeatureSTLSet const &crTOFSet = rResultSpec.getTypeOrFeatureSTLSet(); Review Comment: etc. Please leave only meaning changes in this diff. ########## src/framework/annotator_mgr.cpp: ########## @@ -379,10 +391,10 @@ namespace uima { bool AnnotatorManager::shouldEngineBeCalled(uima::internal::CapabilityContainer const & crCapContainer, - ResultSpecification const & rResultSpec, - Language const & crLanguage, - vector<TypeOrFeature> & rTOFSToBeRemoved) { - util::Trace clTrace(util::enTraceDetailHigh, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ANNOTATOR_MGR); + ResultSpecification const &rResultSpec, Review Comment: I don't see you have changed anything here aside from whitespace. Revert unnecessary changes. ########## src/framework/flow.cpp: ########## Review Comment: I can see the union type might be an unnecessary headache. But it looks nice. Do you have any test cases for it? ########## src/framework/annotator_mgr.cpp: ########## @@ -403,39 +415,31 @@ namespace uima { #endif // treat dump-like annotators for this language specially - if (crCapContainer.hasEmptyOutputTypeOrFeatures( crLanguage )) { + if (crCapContainer.hasEmptyOutputTypeOrFeatures(crLanguage)) { Review Comment: same here -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@uima.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org