/** * Deserialize the data in a CASCompleteSerializer into an * existing CAS * @param casCompSer the source for deserialization * @param casMgr the CAS to receive the data */ public static void deserializeCASComplete(CASCompleteSerializer casCompSer, CASMgr casMgr) { ((CASImpl) casMgr).reinit(casCompSer); }
TypeSystemImpl ts) throws CASRuntimeException { if (this != this.svd.baseCAS) { return this.svd.baseCAS.reinit(h, istream, casMgrSerializer, casLoadMode, f6, allowPreexistingFS, ts);
/** * Deserialize a CAS, in various binary formats, into an existing CAS * Note: this form supports deserializing the following binary representations: * - plain (uncompressed) * - compressed, no type filtering (form 4), Delta and not-delta * - compressed, no type filtering (form 6), not-delta only. * If this form encounters a non-conforming kind of input, it will throw a runtime exception. * @param cas the CAS to deserialize into. If the incoming representation is a Delta Cas, then the receiving CAS is not reset, but is added to. * @param istream the input stream * @return The form of the serialized CAS (from its header) */ public static SerialFormat deserializeCAS(CAS cas, InputStream istream) { return ((CASImpl) cas).reinit(istream); }
/** * Deserialize the data in a CASSerializer into an existing CAS, * return the currentview in that Cas. * @param casMgr the CAS Manager * @param casSer the serializer * @return the initialized CAS loaded with the deserialized data */ public static CAS createCAS(CASMgr casMgr, CASSerializer casSer) { ((CASImpl) casMgr).reinit(casSer); return ((CASImpl) casMgr).getCurrentView(); }
/** * Version used by uima-as to read delta cas from remote parallel steps * @param istream input stream * @param allowPreexistingFS what to do if item already exists below the mark * @throws IOException passthru */ public void deserialize(InputStream istream, AllowPreexistingFS allowPreexistingFS) throws IOException { Header h = readHeader(istream); if (isReadingDelta) { if (!reuseInfoProvided) { throw new UnsupportedOperationException("Deserializing Delta Cas, but original not serialized from"); } } else { throw new UnsupportedOperationException("Delta CAS required for this call"); } cas.reinit(h, deserIn, null, CasLoadMode.DEFAULT, this, allowPreexistingFS, null); }
/** * * @param istream - * @throws IOException - */ public void deserialize(InputStream istream) throws IOException { Header h = readHeader(istream); // side effect, sets deserIn if (isReadingDelta) { if (!reuseInfoProvided) { throw new UnsupportedOperationException("Deserializing Delta Cas, but original not serialized from"); } } else { cas.resetNoQuestions(); } cas.reinit(h, deserIn, null, CasLoadMode.DEFAULT, this, AllowPreexistingFS.allow, null); // deserializeAfterVersion(deserIn, isReadingDelta, AllowPreexistingFS.allow); }
/** * handle both ordinary binary and compressed6 binary * @param aSerializedCAS * @param cachedRequest * @return * @throws Exception */ protected CAS deserializeCAS(byte[] aSerializedCAS, ClientRequest cachedRequest) throws Exception { CAS cas = cachedRequest.getCAS(); ReuseInfo reuseInfo = cachedRequest.getCompress6ReuseInfo(); ByteArrayInputStream bais = new ByteArrayInputStream(aSerializedCAS); if (reuseInfo != null) { Serialization.deserializeCAS(cas, bais, null, reuseInfo); } else { ((CASImpl)cas).reinit(bais); } // uimaSerializer.deserializeCasFromBinary(aSerializedCAS, cas); return cas; }
return casImpl.reinit(h, casInputStream, readCasManager(tsiInputStream), casLoadMode, null, AllowPreexistingFS.allow, typeSystem); if (o instanceof CASSerializer) { casImpl.setupCasFromCasMgrSerializer(readCasManager(tsiInputStream)); casImpl.reinit((CASSerializer) o); // deserialize from object return SerialFormat.SERIALIZED; } else if (o instanceof CASCompleteSerializer) { casImpl.reinit((CASCompleteSerializer) o); return SerialFormat.SERIALIZED_TSI; } else {
public void reinit(CASCompleteSerializer casCompSer) { if (this != this.svd.baseCAS) { this.svd.baseCAS.reinit(casCompSer); return; } setupCasFromCasMgrSerializer(casCompSer.getCASMgrSerializer()); // deserialize heap CASSerializer casSer = casCompSer.getCASSerializer(); reinit(casSer.getHeapMetadata(), casSer.getHeapArray(), casSer.getStringTable(), casSer .getFSIndex(), casSer.getByteArray(), casSer.getShortArray(), casSer.getLongArray()); // we also need to throw away the JCAS. A new JCAS will be created on // the next // call to getJCas(). As with the CAS, we are counting on the fact that // this happens only in a service, where JCAS handles are not held on // to. this.jcas = null; // this.sofa2jcasMap.clear(); clearTrackingMarks(); }
/** * @see AnalysisEngineServiceStub#callProcess(CAS) */ public void callProcess(CAS aCAS) throws ResourceServiceException { try { AFrame requestFrame = new AFrame(); requestFrame.fset(Constants.VINCI_COMMAND, Constants.ANNOTATE); // serialize CAS (including type system) CASMgr cas = (CASMgr) aCAS; CASCompleteSerializer serializer = Serialization.serializeCASComplete(cas); requestFrame.fsetTrueBinary("BinaryCAS", SerializationUtils.serialize(serializer)); AFrame responseFrame = (AFrame) mVinciClient.sendAndReceive(requestFrame, mTimeout); // deserialize CAS from response frame byte[] responseCasBytes = responseFrame.fgetTrueBinary("BinaryCAS"); CASSerializer responseSerializer = (CASSerializer) SerializationUtils .deserialize(responseCasBytes); ((CASImpl) cas).reinit(responseSerializer); // also read annotation time and enter into AnalysisEngineManagementMBean int annotationTime = responseFrame.fgetInt(Constants.ANNOTATION_TIME); if (annotationTime > 0) { AnalysisEngineManagementImpl mbean = (AnalysisEngineManagementImpl) mOwner .getManagementInterface(); mbean.reportAnalysisTime(annotationTime); } } catch (Exception e) { throw new ResourceServiceException(e); } }
completeSerializer.setCasSerializer(Serialization.serializeCAS(casImpl)); casImpl.reinit(completeSerializer);
switch (serialFormat) { case BINARY: ((CASImpl)cas).reinit(istream); break; case COMPRESSED_FILTERED:
serializer.longHeapArray = aLongHeapArray; casImpl.reinit(serializer);