@Override public List<? extends List<?>> deserialize(ObjectInput ois) throws IOException, ClassNotFoundException { List<? extends List<?>> batch = BatchSerializer.readBatch(ois, types); if (lobManager != null) { for (int i = batch.size() - 1; i >= 0; i--) { try { lobManager.updateReferences(batch.get(i), ReferenceMode.ATTACH); } catch (TeiidComponentException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30052, e); } } } return batch; }
@Override public List<? extends List<?>> deserialize(ObjectInput ois) throws IOException, ClassNotFoundException { List<? extends List<?>> batch = BatchSerializer.readBatch(ois, types); if (lobManager != null) { for (int i = batch.size() - 1; i >= 0; i--) { try { lobManager.updateReferences(batch.get(i), ReferenceMode.ATTACH); } catch (TeiidComponentException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30052, e); } } } return batch; }
@Override public List<? extends List<?>> deserialize(ObjectInput ois) throws IOException, ClassNotFoundException { List<? extends List<?>> batch = BatchSerializer.readBatch(ois, types); if (lobManager != null) { for (int i = batch.size() - 1; i >= 0; i--) { try { lobManager.updateReferences(batch.get(i), ReferenceMode.ATTACH); } catch (TeiidComponentException e) { throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30052, e); } } } return batch; }
public void processResults() throws TeiidSQLException { if (results == null && resultBytes != null) { try { CompactObjectInputStream ois = new CompactObjectInputStream(new ByteArrayInputStream(resultBytes), ResultsMessage.class.getClassLoader()); results = BatchSerializer.readBatch(ois, dataTypes); } catch (IOException e) { throw TeiidSQLException.create(e); } catch (ClassNotFoundException e) { throw TeiidSQLException.create(e); } finally { resultBytes = null; } } }
public void processResults() throws TeiidSQLException { if (results == null && resultBytes != null) { try { CompactObjectInputStream ois = new CompactObjectInputStream(new ByteArrayInputStream(resultBytes), ResultsMessage.class.getClassLoader()); results = BatchSerializer.readBatch(ois, dataTypes); } catch (IOException e) { throw TeiidSQLException.create(e); } catch (ClassNotFoundException e) { throw TeiidSQLException.create(e); } finally { resultBytes = null; } } }
public void readValuesFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException, TeiidComponentException { long size = ois.readLong(); int sizeHint = this.getExpectedHeight(size); batchInsert = true; while (this.getRowCount() < size) { List<List<Object>> batch = BatchSerializer.readBatch(ois, leafManager.getTypes()); for (List list : batch) { this.insert(list, InsertMode.ORDERED, sizeHint); } } batchInsert = false; }
public void readValuesFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException, TeiidComponentException { long size = ois.readLong(); int sizeHint = this.getExpectedHeight(size); batchInsert = true; while (this.getRowCount() < size) { List<List<Object>> batch = BatchSerializer.readBatch(ois, leafManager.getTypes()); for (List list : batch) { this.insert(list, InsertMode.ORDERED, sizeHint); } } batchInsert = false; }
public void readValuesFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException, TeiidComponentException { long size = ois.readLong(); int sizeHint = this.getExpectedHeight(size); batchInsert = true; while (this.getRowCount() < size) { List<List<Object>> batch = BatchSerializer.readBatch(ois, leafManager.getTypes()); for (List list : batch) { this.insert(list, InsertMode.ORDERED, sizeHint); } } batchInsert = false; }
results = BatchSerializer.readBatch(in, dataTypes);
results = BatchSerializer.readBatch(in, dataTypes);
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; }
private void setTupleBufferState(String state_id, ObjectInputStream in) throws IOException, ClassNotFoundException, TeiidComponentException { long rowCount = in.readLong(); int batchSize = in.readInt(); String[] types = (String[])in.readObject(); List<ElementSymbol> schema = new ArrayList<ElementSymbol>(types.length); for (int i = 0; i < types.length; i++) { ElementSymbol es = new ElementSymbol("x"); //$NON-NLS-1$ es.setType(DataTypeManager.getDataTypeClass(types[i])); schema.add(es); } TupleBuffer buffer = createTupleBuffer(schema, "cached", TupleSourceType.FINAL); //$NON-NLS-1$ buffer.setBatchSize(batchSize); buffer.setId(state_id); for (int row = 1; row <= rowCount; row+=batchSize) { List<List<Object>> batch = BatchSerializer.readBatch(in, types); for (int i = 0; i < batch.size(); i++) { buffer.addTuple(batch.get(i)); } } if (buffer.getRowCount() != rowCount) { buffer.remove(); throw new IOException(QueryPlugin.Util.getString("not_found_cache")); //$NON-NLS-1$ } buffer.close(); addTupleBuffer(buffer); }
private void setTupleBufferState(String state_id, ObjectInputStream in) throws IOException, ClassNotFoundException, TeiidComponentException { long rowCount = in.readLong(); int batchSize = in.readInt(); String[] types = (String[])in.readObject(); List<ElementSymbol> schema = new ArrayList<ElementSymbol>(types.length); for (int i = 0; i < types.length; i++) { ElementSymbol es = new ElementSymbol("x"); //$NON-NLS-1$ es.setType(DataTypeManager.getDataTypeClass(types[i])); schema.add(es); } TupleBuffer buffer = createTupleBuffer(schema, "cached", TupleSourceType.FINAL); //$NON-NLS-1$ buffer.setBatchSize(batchSize); buffer.setId(state_id); for (int row = 1; row <= rowCount; row+=batchSize) { List<List<Object>> batch = BatchSerializer.readBatch(in, types); for (int i = 0; i < batch.size(); i++) { buffer.addTuple(batch.get(i)); } } if (buffer.getRowCount() != rowCount) { buffer.remove(); throw new IOException(QueryPlugin.Util.getString("not_found_cache")); //$NON-NLS-1$ } buffer.close(); addTupleBuffer(buffer); }
private void setTupleBufferState(String state_id, ObjectInputStream in) throws IOException, ClassNotFoundException, TeiidComponentException { long rowCount = in.readLong(); int batchSize = in.readInt(); String[] types = (String[])in.readObject(); List<ElementSymbol> schema = new ArrayList<ElementSymbol>(types.length); for (int i = 0; i < types.length; i++) { ElementSymbol es = new ElementSymbol("x"); //$NON-NLS-1$ es.setType(DataTypeManager.getDataTypeClass(types[i])); schema.add(es); } TupleBuffer buffer = createTupleBuffer(schema, "cached", TupleSourceType.FINAL); //$NON-NLS-1$ buffer.setBatchSize(batchSize); buffer.setId(state_id); for (int row = 1; row <= rowCount; row+=batchSize) { List<List<Object>> batch = BatchSerializer.readBatch(in, types); for (int i = 0; i < batch.size(); i++) { buffer.addTuple(batch.get(i)); } } if (buffer.getRowCount() != rowCount) { buffer.remove(); throw new IOException(QueryPlugin.Util.getString("not_found_cache")); //$NON-NLS-1$ } buffer.close(); addTupleBuffer(buffer); }
@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) { } }