Package org.nustaq.serialization

Examples of org.nustaq.serialization.FSTObjectOutput.writeObject()


        public void testCustomSerializer() throws Exception {
                FSTConfiguration FST = FSTConfiguration.createDefaultConfiguration();
                //FST.setForceSerializable(true);
                FST.registerSerializer(Bug34.NonSerializableClass.class, new Serializer(), false);
                FSTObjectOutput out = FST.getObjectOutput();
                out.writeObject(new Bug34.NonSerializableClass());

                FSTObjectInput in = FST.getObjectInput(out.getCopyOfWrittenBuffer());
                assertEquals(NonSerializableClass.class, in.readObject().getClass());
        }
View Full Code Here


        try {
            throw new Exception("Test");
        } catch (Exception ex) {
            e = ex;
        }
        out.writeObject(e);
        out.flush();
        FSTObjectInput in = new FSTObjectInput(conf);
        in.resetForReuseUseArray(out.getBuffer(),out.getWritten());
        Object ex = in.readObject();
        System.out.println("success "+ex);
View Full Code Here

            ToWrite w = new ToWrite("bla");

            byte b[] = null;
            FSTObjectOutput out = new FSTObjectOutput(conf);
            out.writeObject(w);
            out.flush();
            b = out.getBuffer();

            FSTObjectInput in = new FSTObjectInput(conf);
            in.resetForReuseUseArray(b, b.length);
View Full Code Here

    @Test
    public void testFlush() throws IOException, ClassNotFoundException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream(1000*1000);
        FSTObjectOutput fout = new FSTObjectOutput(bout);
        Strings obj = new Strings();
        fout.writeObject(obj);
        fout.writeObject(new byte[1000*1000*10]);
        fout.writeObject(obj);
        fout.close();

        FSTObjectInput fin = new FSTObjectInput(new ByteArrayInputStream(bout.toByteArray()));
View Full Code Here

    public void testFlush() throws IOException, ClassNotFoundException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream(1000*1000);
        FSTObjectOutput fout = new FSTObjectOutput(bout);
        Strings obj = new Strings();
        fout.writeObject(obj);
        fout.writeObject(new byte[1000*1000*10]);
        fout.writeObject(obj);
        fout.close();

        FSTObjectInput fin = new FSTObjectInput(new ByteArrayInputStream(bout.toByteArray()));
        Strings res = (Strings) fin.readObject();
View Full Code Here

        ByteArrayOutputStream bout = new ByteArrayOutputStream(1000*1000);
        FSTObjectOutput fout = new FSTObjectOutput(bout);
        Strings obj = new Strings();
        fout.writeObject(obj);
        fout.writeObject(new byte[1000*1000*10]);
        fout.writeObject(obj);
        fout.close();

        FSTObjectInput fin = new FSTObjectInput(new ByteArrayInputStream(bout.toByteArray()));
        Strings res = (Strings) fin.readObject();
        fin.readObject();
View Full Code Here

        throws IOException, ClassNotFoundException {
        TestArray list = new TestArray();

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        FSTObjectOutput objOut = new FSTObjectOutput(os);
        objOut.writeObject(list);
        objOut.close();

        ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
        FSTObjectInput objIn = new FSTObjectInput(is);
//        objIn.setReadExternalReadAHead(16000);
View Full Code Here

        holder.o = new ToRead("foo");
        holder.o2 = holder.o;

        byte[] b = null;
        FSTObjectOutput out = new FSTObjectOutput(conf);
        out.writeObject(holder);
        out.flush();
        b = out.getBuffer();

        FSTObjectInput in = new FSTObjectInput(conf);
        in.resetForReuseUseArray(b,b.length);
View Full Code Here

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
   
    try {
      if(useFst) {
        FSTObjectOutput out = fstConf.get().getObjectOutput(baos);
        out.writeObject(object);
      } else {
                getByteBuffer(object).position(0);
                getByteBuffer(object).putInt(9999);
                getByteBuffer(object).position(0);
                System.out.println("original object "+ extractFirstBufferField(object));
View Full Code Here

    public void writeObject(Object toWrite) throws Exception {
        try {
            while ( !writeLock.compareAndSet(false,true) );
            FSTObjectOutput objectOutput = conf.getObjectOutput(); // could also do new with minor perf impact
            objectOutput.writeObject(toWrite);

            int written = objectOutput.getWritten();
            out.write((written >>> 0) & 0xFF);
            out.write((written >>> 8) & 0xFF);
            out.write((written >>> 16) & 0xFF);
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.