org.nustaq.serialization.FSTObjectOutput Java Examples
The following examples show how to use
org.nustaq.serialization.FSTObjectOutput.
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: Parser.java From science-parse with Apache License 2.0 | 6 votes |
public static <T> void saveModel( final DataOutputStream dos, final CRFFeatureEncoder<String, T, String> fe, final Vector weights, final ParserLMFeatures plf, final GazetteerFeatures gf, final String dataVersion ) throws IOException { dos.writeUTF(dataVersion); fe.stateSpace.save(dos); fe.nodeFeatures.save(dos); fe.edgeFeatures.save(dos); IOUtils.saveDoubles(dos, weights.toDoubles()); logger.debug("Saving ParserLMFeatures"); try(final FSTObjectOutput out = new FSTObjectOutput(dos)) { out.writeObject(plf); if (plf != null) plf.logState(); logger.debug("Saving gazetteer features"); out.writeObject(gf); } }
Example #2
Source File: FstCodec.java From redisson with Apache License 2.0 | 6 votes |
@Override public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException { Map col = (Map) toWrite; out.writeInt(col.size()); FSTClazzInfo lastKClzI = null; FSTClazzInfo lastVClzI = null; Class lastKClz = null; Class lastVClz = null; for (Iterator iterator = col.entrySet().iterator(); iterator.hasNext();) { Map.Entry next = (Map.Entry) iterator.next(); Object key = next.getKey(); Object value = next.getValue(); if (key != null && value != null) { lastKClzI = out.writeObjectInternal(key, key.getClass() == lastKClz ? lastKClzI : null, null); lastVClzI = out.writeObjectInternal(value, value.getClass() == lastVClz ? lastVClzI : null, null); lastKClz = key.getClass(); lastVClz = value.getClass(); } else { out.writeObjectInternal(key, null, null); out.writeObjectInternal(value, null, null); } } }
Example #3
Source File: FstExample.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 6 votes |
public static void main(String[] args) throws Exception { FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration(); SomeMediumClass mediumClass = new SomeMediumClass(); byte barray[] = conf.asByteArray(mediumClass); System.out.println(barray.length); SomeMediumClass object = (SomeMediumClass)conf.asObject(barray); System.out.println(object); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); FSTObjectOutput output = new FSTObjectOutput(outputStream); output.writeObject(mediumClass); output.close(); FSTObjectInput input = new FSTObjectInput(new ByteArrayInputStream(outputStream.toByteArray())); object = (SomeMediumClass)input.readObject(SomeMediumClass.class); System.out.println(object); }
Example #4
Source File: FstSerializationRedisSerializer.java From jetlinks-community with Apache License 2.0 | 5 votes |
@Override @SneakyThrows public byte[] serialize(Object o) throws SerializationException { ByteArrayOutputStream arr = new ByteArrayOutputStream(1024); try (FSTObjectOutput output = configuration.get().getObjectOutput(arr)) { output.writeObject(o); } return arr.toByteArray(); }
Example #5
Source File: ExtractReferences.java From science-parse with Apache License 2.0 | 5 votes |
public static ExtractReferences createAndWriteGazCache( final InputStream is, final DataInputStream bibCRFModel, final OutputStream gazCacheFileOutputStream ) throws IOException { val result = new ExtractReferences(is, bibCRFModel); final FSTObjectOutput out = new FSTObjectOutput(gazCacheFileOutputStream); out.writeObject(result.cr); return result; }
Example #6
Source File: FSTPeerAddressSerializer.java From Hive2Hive with MIT License | 5 votes |
@Override public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTFieldInfo referencedBy, int streamPosition) throws IOException { byte[] value = ((PeerAddress) toWrite).toByteArray(); out.writeInt(value.length); out.write(value); }
Example #7
Source File: FstFactory.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
public FSTObjectOutput getObjectOutput(OutputStream outputStream) { return conf.getObjectOutput(outputStream); }
Example #8
Source File: FSTObjectWriter.java From joyrpc with Apache License 2.0 | 4 votes |
public FSTObjectWriter(FSTObjectOutput output) { super(output); }
Example #9
Source File: FstFactory.java From JobX with Apache License 2.0 | 4 votes |
public FSTObjectOutput getObjectOutput(OutputStream outputStream) { return conf.getObjectOutput(outputStream); }
Example #10
Source File: FstFactory.java From dubbox with Apache License 2.0 | 4 votes |
public FSTObjectOutput getObjectOutput(OutputStream outputStream) { return conf.getObjectOutput(outputStream); }
Example #11
Source File: Serializer.java From meghanada-server with GNU General Public License v3.0 | 4 votes |
public static void writeObject(OutputStream output, Object obj) throws IOException { FSTObjectOutput out = getFST().getObjectOutput(output); out.writeObject(obj); out.flush(); }
Example #12
Source File: FstFactory.java From dubbox with Apache License 2.0 | 4 votes |
public FSTObjectOutput getObjectOutput(OutputStream outputStream) { return conf.getObjectOutput(outputStream); }
Example #13
Source File: Parameters.java From htm.java with GNU Affero General Public License v3.0 | 4 votes |
public void writeForNetwork(FSTObjectOutput out) throws IOException { out.writeObject(this, Parameters.class); out.close(); }