com.alibaba.dubbo.common.serialize.support.java.CompactedObjectInputStream Java Examples
The following examples show how to use
com.alibaba.dubbo.common.serialize.support.java.CompactedObjectInputStream.
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: SerializationCompareTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testCompactedJavaOutputPerm() throws Exception { Bean bean = new Bean(); int len = 0; long now = System.currentTimeMillis(); for(int i=0;i<500;i++) { ByteArrayOutputStream os = new ByteArrayOutputStream(); CompactedObjectOutputStream out = new CompactedObjectOutputStream(os); out.writeObject(bean); os.close(); if( i == 0 ) len = os.toByteArray().length; ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); CompactedObjectInputStream in = new CompactedObjectInputStream(is); assertEquals(in.readObject().getClass(), Bean.class); } System.out.println("compacted java write and parse 500 times in " + (System.currentTimeMillis()-now)+"ms, size " + len); }
Example #2
Source File: SerializationCompareTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@Test public void testCompactedJavaOutputPerm() throws Exception { Bean bean = new Bean(); int len = 0; long now = System.currentTimeMillis(); for(int i=0;i<500;i++) { ByteArrayOutputStream os = new ByteArrayOutputStream(); CompactedObjectOutputStream out = new CompactedObjectOutputStream(os); out.writeObject(bean); os.close(); if( i == 0 ) len = os.toByteArray().length; ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); CompactedObjectInputStream in = new CompactedObjectInputStream(is); assertEquals(in.readObject().getClass(), Bean.class); } System.out.println("compacted java write and parse 500 times in " + (System.currentTimeMillis()-now)+"ms, size " + len); }
Example #3
Source File: Builder.java From dubbo3 with Apache License 2.0 | 6 votes |
@Override public Serializable parseFrom(GenericObjectInput in) throws IOException { byte b = in.read0(); if (b == OBJECT_NULL) return null; if (b != OBJECT_STREAM) throw new IOException("Input format error, expect OBJECT_NULL|OBJECT_STREAM, get " + b + "."); UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(in.read0(in.readUInt())); CompactedObjectInputStream ois = new CompactedObjectInputStream(bis); try { return (Serializable) ois.readObject(); } catch (ClassNotFoundException e) { throw new IOException(StringUtils.toString(e)); } }
Example #4
Source File: SerializationCompareTest.java From dubbo3 with Apache License 2.0 | 6 votes |
@Test public void testCompactedJavaOutputPerm() throws Exception { Bean bean = new Bean(); int len = 0; long now = System.currentTimeMillis(); for(int i=0;i<500;i++) { ByteArrayOutputStream os = new ByteArrayOutputStream(); CompactedObjectOutputStream out = new CompactedObjectOutputStream(os); out.writeObject(bean); os.close(); if( i == 0 ) len = os.toByteArray().length; ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); CompactedObjectInputStream in = new CompactedObjectInputStream(is); assertEquals(in.readObject().getClass(), Bean.class); } System.out.println("compacted java write and parse 500 times in " + (System.currentTimeMillis()-now)+"ms, size " + len); }
Example #5
Source File: SerializationCompareTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testCompactedJavaOutputPerm() throws Exception { Bean bean = new Bean(); int len = 0; long now = System.currentTimeMillis(); for(int i=0;i<500;i++) { ByteArrayOutputStream os = new ByteArrayOutputStream(); CompactedObjectOutputStream out = new CompactedObjectOutputStream(os); out.writeObject(bean); os.close(); if( i == 0 ) len = os.toByteArray().length; ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); CompactedObjectInputStream in = new CompactedObjectInputStream(is); assertEquals(in.readObject().getClass(), Bean.class); } System.out.println("compacted java write and parse 500 times in " + (System.currentTimeMillis()-now)+"ms, size " + len); }
Example #6
Source File: SerializationCompareTest.java From dubbox with Apache License 2.0 | 6 votes |
@Test public void testCompactedJavaOutputPerm() throws Exception { Bean bean = new Bean(); int len = 0; long now = System.currentTimeMillis(); for(int i=0;i<500;i++) { ByteArrayOutputStream os = new ByteArrayOutputStream(); CompactedObjectOutputStream out = new CompactedObjectOutputStream(os); out.writeObject(bean); os.close(); if( i == 0 ) len = os.toByteArray().length; ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); CompactedObjectInputStream in = new CompactedObjectInputStream(is); assertEquals(in.readObject().getClass(), Bean.class); } System.out.println("compacted java write and parse 500 times in " + (System.currentTimeMillis()-now)+"ms, size " + len); }
Example #7
Source File: Builder.java From dubbox with Apache License 2.0 | 5 votes |
@Override public Serializable parseFrom(GenericObjectInput in) throws IOException { byte b = in.read0(); if( b == OBJECT_NULL ) return null; if( b != OBJECT_STREAM ) throw new IOException("Input format error, expect OBJECT_NULL|OBJECT_STREAM, get " + b + "."); UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(in.read0(in.readUInt())); CompactedObjectInputStream ois = new CompactedObjectInputStream(bis); try{ return (Serializable)ois.readObject(); } catch(ClassNotFoundException e){ throw new IOException(StringUtils.toString(e)); } }
Example #8
Source File: Builder.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
@Override public Serializable parseFrom(GenericObjectInput in) throws IOException { byte b = in.read0(); if( b == OBJECT_NULL ) return null; if( b != OBJECT_STREAM ) throw new IOException("Input format error, expect OBJECT_NULL|OBJECT_STREAM, get " + b + "."); UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(in.read0(in.readUInt())); CompactedObjectInputStream ois = new CompactedObjectInputStream(bis); try{ return (Serializable)ois.readObject(); } catch(ClassNotFoundException e){ throw new IOException(StringUtils.toString(e)); } }
Example #9
Source File: Builder.java From dubbox with Apache License 2.0 | 5 votes |
@Override public Serializable parseFrom(GenericObjectInput in) throws IOException { byte b = in.read0(); if( b == OBJECT_NULL ) return null; if( b != OBJECT_STREAM ) throw new IOException("Input format error, expect OBJECT_NULL|OBJECT_STREAM, get " + b + "."); UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(in.read0(in.readUInt())); CompactedObjectInputStream ois = new CompactedObjectInputStream(bis); try{ return (Serializable)ois.readObject(); } catch(ClassNotFoundException e){ throw new IOException(StringUtils.toString(e)); } }
Example #10
Source File: Builder.java From dubbox with Apache License 2.0 | 5 votes |
@Override public Serializable parseFrom(GenericObjectInput in) throws IOException { byte b = in.read0(); if( b == OBJECT_NULL ) return null; if( b != OBJECT_STREAM ) throw new IOException("Input format error, expect OBJECT_NULL|OBJECT_STREAM, get " + b + "."); UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(in.read0(in.readUInt())); CompactedObjectInputStream ois = new CompactedObjectInputStream(bis); try{ return (Serializable)ois.readObject(); } catch(ClassNotFoundException e){ throw new IOException(StringUtils.toString(e)); } }