public static void writeBatch(ObjectOutput out, String[] types, List<? extends List<?>> batch) throws IOException { writeBatch(out, types, batch, CURRENT_VERSION); }
public static void writeBatch(ObjectOutput out, String[] types, List<? extends List<?>> batch) throws IOException { writeBatch(out, types, batch, CURRENT_VERSION); }
public void writeValuesTo(ObjectOutputStream oos) throws TeiidComponentException, IOException { SPage page = header[0]; oos.writeLong(this.rowCount.get()); while (true) { List<List<?>> batch = page.getValues(); BatchSerializer.writeBatch(oos, leafManager.getTypes(), batch); if (page.next == null) { break; } page = page.next; } }
public void writeValuesTo(ObjectOutputStream oos) throws TeiidComponentException, IOException { SPage page = header[0]; oos.writeLong(this.rowCount.get()); while (true) { List<List<?>> batch = page.getValues(); BatchSerializer.writeBatch(oos, leafManager.getTypes(), batch); if (page.next == null) { break; } page = page.next; } }
public void writeValuesTo(ObjectOutputStream oos) throws TeiidComponentException, IOException { SPage page = header[0]; oos.writeLong(this.rowCount.get()); while (true) { List<List<?>> batch = page.getValues(); BatchSerializer.writeBatch(oos, leafManager.getTypes(), batch); if (page.next == null) { break; } page = page.next; } }
@Override public void serialize(List<? extends List<?>> obj, ObjectOutput oos) throws IOException { ResizingArrayList<?> list = null; if (obj instanceof ResizingArrayList<?>) { list = (ResizingArrayList<?>)obj; } try { //it's expected that the containing structure has updated the lob manager BatchSerializer.writeBatch(oos, types, obj); } catch (RuntimeException e) { if (ExceptionUtil.getExceptionOfType(e, ClassCastException.class) != null) { throw e; } //there is a chance of a concurrent persist while modifying //in which case we want to swallow this exception if (list == null) { throw e; } LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, e, "Possible Concurrent Modification", id); //$NON-NLS-1$ } }
@Override public void serialize(List<? extends List<?>> obj, ObjectOutput oos) throws IOException { ResizingArrayList<?> list = null; if (obj instanceof ResizingArrayList<?>) { list = (ResizingArrayList<?>)obj; } try { //it's expected that the containing structure has updated the lob manager BatchSerializer.writeBatch(oos, types, obj); } catch (RuntimeException e) { if (ExceptionUtil.getExceptionOfType(e, ClassCastException.class) != null) { throw e; } //there is a chance of a concurrent persist while modifying //in which case we want to swallow this exception if (list == null) { throw e; } LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, e, "Possible Concurrent Modification", id); //$NON-NLS-1$ } }
@Override public void serialize(List<? extends List<?>> obj, ObjectOutput oos) throws IOException { ResizingArrayList<?> list = null; if (obj instanceof ResizingArrayList<?>) { list = (ResizingArrayList<?>)obj; } try { //it's expected that the containing structure has updated the lob manager BatchSerializer.writeBatch(oos, types, obj); } catch (RuntimeException e) { if (ExceptionUtil.getExceptionOfType(e, ClassCastException.class) != null) { throw e; } //there is a chance of a concurrent persist while modifying //in which case we want to swallow this exception if (list == null) { throw e; } LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, e, "Possible Concurrent Modification", id); //$NON-NLS-1$ } }
private static List<List<Object>> helpTestSerialization(String[] types, List<?>[] batch, byte version) throws IOException, ClassNotFoundException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(byteStream); List<List<?>> batchList = Arrays.asList(batch); BatchSerializer.writeBatch(out, types, batchList, version); out.flush(); byte[] bytes = byteStream.toByteArray(); ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytes); ObjectInputStream in = new ObjectInputStream(bytesIn); List<List<Object>> newBatch = BatchSerializer.readBatch(in, types); out.close(); in.close(); assertTrue(batchList.equals(newBatch)); return newBatch; }
BatchSerializer.writeBatch(out, dataTypes, null, clientSerializationVersion); } else { BatchSerializer.writeBatch(out, dataTypes, results, clientSerializationVersion);
BatchSerializer.writeBatch(out, dataTypes, null, clientSerializationVersion); } else { BatchSerializer.writeBatch(out, dataTypes, results, clientSerializationVersion);
private void getTupleBufferState(ObjectOutputStream out, TupleBuffer buffer) throws TeiidComponentException, IOException { out.writeLong(buffer.getRowCount()); out.writeInt(buffer.getBatchSize()); out.writeObject(buffer.getTypes()); for (int row = 1; row <= buffer.getRowCount(); row+=buffer.getBatchSize()) { TupleBatch b = buffer.getBatch(row); BatchSerializer.writeBatch(out, buffer.getTypes(), b.getTuples()); } }
private void getTupleBufferState(ObjectOutputStream out, TupleBuffer buffer) throws TeiidComponentException, IOException { out.writeLong(buffer.getRowCount()); out.writeInt(buffer.getBatchSize()); out.writeObject(buffer.getTypes()); for (int row = 1; row <= buffer.getRowCount(); row+=buffer.getBatchSize()) { TupleBatch b = buffer.getBatch(row); BatchSerializer.writeBatch(out, buffer.getTypes(), b.getTuples()); } }
private void getTupleBufferState(ObjectOutputStream out, TupleBuffer buffer) throws TeiidComponentException, IOException { out.writeLong(buffer.getRowCount()); out.writeInt(buffer.getBatchSize()); out.writeObject(buffer.getTypes()); for (int row = 1; row <= buffer.getRowCount(); row+=buffer.getBatchSize()) { TupleBatch b = buffer.getBatch(row); BatchSerializer.writeBatch(out, buffer.getTypes(), b.getTuples()); } }
/** * Serialize the result data * @return the size of the data bytes * @throws IOException */ public int serialize(boolean keepSerialization) throws IOException { if (serializationBuffer == null) { serializationBuffer = new MultiArrayOutputStream(1 << 13); CompactObjectOutputStream oos = new CompactObjectOutputStream(serializationBuffer); BatchSerializer.writeBatch(oos, dataTypes, results, clientSerializationVersion); oos.close(); } int result = serializationBuffer.getCount(); if (!keepSerialization) { serializationBuffer = null; } return result; }
/** * Serialize the result data * @return the size of the data bytes * @throws IOException */ public int serialize(boolean keepSerialization) throws IOException { if (serializationBuffer == null) { serializationBuffer = new MultiArrayOutputStream(1 << 13); CompactObjectOutputStream oos = new CompactObjectOutputStream(serializationBuffer); BatchSerializer.writeBatch(oos, dataTypes, results, clientSerializationVersion); oos.close(); } int result = serializationBuffer.getCount(); if (!keepSerialization) { serializationBuffer = null; } return result; }
@SuppressWarnings("unchecked") @Test public void testArrayValueSerialization() throws Exception { ArrayImpl a1 = new ArrayImpl((Object[])new Integer[] {1, null, 3}); ArrayImpl a2 = new ArrayImpl((Object[])null); String[] types = TupleBuffer.getTypeNames(Arrays.asList(new Array(Integer.class, null))); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); BatchSerializer.writeBatch(oos, types, Arrays.asList(Arrays.asList(a1), Arrays.asList(a2))); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); List<List<Object>> batch = BatchSerializer.readBatch(ois, types); assertEquals(a1, batch.get(0).get(0)); try { ((java.sql.Array)batch.get(1).get(0)).getArray(); fail(); } catch (SQLException e) { } }