public JSONBuilder(BufferManager bm) { fs = bm.createFileStore("json"); //$NON-NLS-1$ fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING); writer = fsisf.getWriter(); }
public JSONBuilder(BufferManager bm) { fs = bm.createFileStore("json"); //$NON-NLS-1$ fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING); writer = fsisf.getWriter(); }
public JSONBuilder(BufferManager bm) { fs = bm.createFileStore("json"); //$NON-NLS-1$ fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING); writer = fsisf.getWriter(); }
/** * @throws TeiidProcessingException * @throws TeiidComponentException * @see org.teiid.query.function.aggregate.AggregateFunction#addInputDirect(List, CommandContext, CommandContext) */ public void addInputDirect(Object input, List<?> tuple, CommandContext commandContext) throws TeiidComponentException, TeiidProcessingException { try { if (this.result == null) { this.result = buildResult(commandContext); } Array in = (Array)input; Writer w = result.getWriter(); writeList(w, (Object[])in.getArray()); w.flush(); } catch (SQLException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30421, e); } catch (IOException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30421, e); } }
/** * @throws TeiidProcessingException * @throws TeiidComponentException * @see org.teiid.query.function.aggregate.AggregateFunction#addInputDirect(List, CommandContext, CommandContext) */ public void addInputDirect(Object input, List<?> tuple, CommandContext commandContext) throws TeiidComponentException, TeiidProcessingException { try { if (this.result == null) { this.result = buildResult(commandContext); } Array in = (Array)input; Writer w = result.getWriter(); writeList(w, (Object[])in.getArray()); w.flush(); } catch (SQLException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30421, e); } catch (IOException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30421, e); } }
/** * @throws TeiidProcessingException * @throws TeiidComponentException * @see org.teiid.query.function.aggregate.AggregateFunction#addInputDirect(List, CommandContext, CommandContext) */ public void addInputDirect(Object input, List<?> tuple, CommandContext commandContext) throws TeiidComponentException, TeiidProcessingException { try { if (this.result == null) { this.result = buildResult(commandContext); } Array in = (Array)input; Writer w = result.getWriter(); writeList(w, (Object[])in.getArray()); w.flush(); } catch (SQLException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30421, e); } catch (IOException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30421, e); } }
public XmlConcat(BufferManager bm) throws TeiidProcessingException { fs = bm.createFileStore("xml"); //$NON-NLS-1$ fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING); writer = fsisf.getWriter(); ew = new ExtendedWriter(writer, fsisf); factory = getOutputFactory(); try { eventWriter = factory.createXMLEventWriter(writer); } catch (XMLStreamException e) { fs.remove(); throw new TeiidProcessingException(QueryPlugin.Event.TEIID30437, e); } }
public XmlConcat(BufferManager bm) throws TeiidProcessingException { fs = bm.createFileStore("xml"); //$NON-NLS-1$ fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING); writer = fsisf.getWriter(); ew = new ExtendedWriter(writer, fsisf); factory = getOutputFactory(); try { eventWriter = factory.createXMLEventWriter(writer); } catch (XMLStreamException e) { fs.remove(); throw new TeiidProcessingException(QueryPlugin.Event.TEIID30437, e); } }
public XmlConcat(BufferManager bm) throws TeiidProcessingException { fs = bm.createFileStore("xml"); //$NON-NLS-1$ fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING); writer = fsisf.getWriter(); ew = new ExtendedWriter(writer, fsisf); factory = getOutputFactory(); try { eventWriter = factory.createXMLEventWriter(writer); } catch (XMLStreamException e) { fs.remove(); throw new TeiidProcessingException(QueryPlugin.Event.TEIID30437, e); } }
public static ClobType concat(CommandContext context, ClobType str1, ClobType str2) throws IOException, SQLException { BufferManager bm = context.getBufferManager(); FileStore fs = bm.createFileStore("clob"); //$NON-NLS-1$ FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING); boolean remove = true; try (Reader characterStream = str1.getCharacterStream(); Reader characterStream2 = str2.getCharacterStream();){ Writer writer = fsisf.getWriter(); int chars = ObjectConverterUtil.write(writer, characterStream, -1, false); chars += ObjectConverterUtil.write(writer, characterStream2, -1, false); writer.close(); if (fsisf.getStorageMode() == StorageMode.MEMORY) { //detach if just in memory byte[] bytes = fsisf.getMemoryBytes(); return new ClobType(new ClobImpl(new String(bytes, Streamable.ENCODING))); } remove = false; context.addCreatedLob(fsisf); return new ClobType(new ClobImpl(fsisf, chars)); } finally { if (remove) { fs.remove(); } } }
public static ClobType concat(CommandContext context, ClobType str1, ClobType str2) throws IOException, SQLException { BufferManager bm = context.getBufferManager(); FileStore fs = bm.createFileStore("clob"); //$NON-NLS-1$ FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING); boolean remove = true; try (Reader characterStream = str1.getCharacterStream(); Reader characterStream2 = str2.getCharacterStream();){ Writer writer = fsisf.getWriter(); int chars = ObjectConverterUtil.write(writer, characterStream, -1, false); chars += ObjectConverterUtil.write(writer, characterStream2, -1, false); writer.close(); if (fsisf.getStorageMode() == StorageMode.MEMORY) { //detach if just in memory byte[] bytes = fsisf.getMemoryBytes(); return new ClobType(new ClobImpl(new String(bytes, Streamable.ENCODING))); } remove = false; context.addCreatedLob(fsisf); return new ClobType(new ClobImpl(fsisf, chars)); } finally { if (remove) { fs.remove(); } } }
public static ClobType concat(CommandContext context, ClobType str1, ClobType str2) throws IOException, SQLException { BufferManager bm = context.getBufferManager(); FileStore fs = bm.createFileStore("clob"); //$NON-NLS-1$ FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING); boolean remove = true; try (Reader characterStream = str1.getCharacterStream(); Reader characterStream2 = str2.getCharacterStream();){ Writer writer = fsisf.getWriter(); int chars = ObjectConverterUtil.write(writer, characterStream, -1, false); chars += ObjectConverterUtil.write(writer, characterStream2, -1, false); writer.close(); if (fsisf.getStorageMode() == StorageMode.MEMORY) { //detach if just in memory byte[] bytes = fsisf.getMemoryBytes(); return new ClobType(new ClobImpl(new String(bytes, Streamable.ENCODING))); } remove = false; context.addCreatedLob(fsisf); return new ClobType(new ClobImpl(fsisf, chars)); } finally { if (remove) { fs.remove(); } } }
/** * @see org.teiid.query.function.aggregate.AggregateFunction#getResult(CommandContext) */ public Object getResult(CommandContext commandContext) throws TeiidProcessingException{ if (this.result == null) { return null; } try { this.result.getWriter().close(); FileStoreOutputStream fs = this.result.getOuputStream(); fs.close(); if (binary) { if (fs.bytesWritten()) { return new BlobType(new BlobImpl(result)); } return new BlobType(new SerialBlob(Arrays.copyOf(fs.getBuffer(), fs.getCount()))); } if (fs.bytesWritten()) { return new ClobType(new ClobImpl(result, -1)); } return new ClobType(new ClobImpl(new String(Arrays.copyOf(fs.getBuffer(), fs.getCount()), Streamable.ENCODING))); } catch (IOException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30422, e); } catch (SQLException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30423, e); } } }
/** * @see org.teiid.query.function.aggregate.AggregateFunction#getResult(CommandContext) */ public Object getResult(CommandContext commandContext) throws TeiidProcessingException{ if (this.result == null) { return null; } try { this.result.getWriter().close(); FileStoreOutputStream fs = this.result.getOuputStream(); fs.close(); if (binary) { if (fs.bytesWritten()) { return new BlobType(new BlobImpl(result)); } return new BlobType(new SerialBlob(Arrays.copyOf(fs.getBuffer(), fs.getCount()))); } if (fs.bytesWritten()) { return new ClobType(new ClobImpl(result, -1)); } return new ClobType(new ClobImpl(new String(Arrays.copyOf(fs.getBuffer(), fs.getCount()), Streamable.ENCODING))); } catch (IOException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30422, e); } catch (SQLException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30423, e); } } }
private FileStoreInputStreamFactory buildResult(CommandContext context) throws TeiidProcessingException { try { FileStore fs = context.getBufferManager().createFileStore("textagg"); //$NON-NLS-1$ FileStoreInputStreamFactory fisf = new FileStoreInputStreamFactory(fs, textLine.getEncoding()==null?Streamable.ENCODING:textLine.getEncoding()); Writer w = fisf.getWriter(); if (textLine.isIncludeHeader()) { Object[] header = TextLine.evaluate(textLine.getExpressions(), new TextLine.ValueExtractor<DerivedColumn>() { public Object getValue(DerivedColumn t) { if (t.getAlias() == null && t.getExpression() instanceof ElementSymbol) { return ((ElementSymbol)t.getExpression()).getShortName(); } return t.getAlias(); } }, textLine); writeList(w, header); } w.flush(); return fisf; } catch (IOException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30420, e); } }
private FileStoreInputStreamFactory buildResult(CommandContext context) throws TeiidProcessingException { try { FileStore fs = context.getBufferManager().createFileStore("textagg"); //$NON-NLS-1$ FileStoreInputStreamFactory fisf = new FileStoreInputStreamFactory(fs, textLine.getEncoding()==null?Streamable.ENCODING:textLine.getEncoding()); Writer w = fisf.getWriter(); if (textLine.isIncludeHeader()) { Object[] header = TextLine.evaluate(textLine.getExpressions(), new TextLine.ValueExtractor<DerivedColumn>() { public Object getValue(DerivedColumn t) { if (t.getAlias() == null && t.getExpression() instanceof ElementSymbol) { return ((ElementSymbol)t.getExpression()).getShortName(); } return t.getAlias(); } }, textLine); writeList(w, header); } w.flush(); return fisf; } catch (IOException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30420, e); } }
private FileStoreInputStreamFactory buildResult(CommandContext context) throws TeiidProcessingException { try { FileStore fs = context.getBufferManager().createFileStore("textagg"); //$NON-NLS-1$ FileStoreInputStreamFactory fisf = new FileStoreInputStreamFactory(fs, textLine.getEncoding()==null?Streamable.ENCODING:textLine.getEncoding()); Writer w = fisf.getWriter(); if (textLine.isIncludeHeader()) { Object[] header = TextLine.evaluate(textLine.getExpressions(), new TextLine.ValueExtractor<DerivedColumn>() { public Object getValue(DerivedColumn t) { if (t.getAlias() == null && t.getExpression() instanceof ElementSymbol) { return ((ElementSymbol)t.getExpression()).getShortName(); } return t.getAlias(); } }, textLine); writeList(w, header); } w.flush(); return fisf; } catch (IOException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30420, e); } }
/** * This method saves the given XML object to the buffer manager's disk process * Documents less than the maxMemorySize will be held directly in memory */ public static SQLXMLImpl saveToBufferManager(BufferManager bufferMgr, XMLTranslator translator, CommandContext context) throws TeiidComponentException, TeiidProcessingException { boolean success = false; final FileStore lobBuffer = bufferMgr.createFileStore("xml"); //$NON-NLS-1$ final FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(lobBuffer, Streamable.ENCODING); try{ Writer writer = fsisf.getWriter(); final ExtendedWriter ew = new ExtendedWriter(writer, fsisf); translator.translate(ew); ew.close(); success = true; return createSQLXML(fsisf, ew, context); } catch(IOException e) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30444, e); } catch(TransformerException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30445, e); } finally { if (!success && lobBuffer != null) { lobBuffer.remove(); } } }
/** * This method saves the given XML object to the buffer manager's disk process * Documents less than the maxMemorySize will be held directly in memory */ public static SQLXMLImpl saveToBufferManager(BufferManager bufferMgr, XMLTranslator translator, CommandContext context) throws TeiidComponentException, TeiidProcessingException { boolean success = false; final FileStore lobBuffer = bufferMgr.createFileStore("xml"); //$NON-NLS-1$ final FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(lobBuffer, Streamable.ENCODING); try{ Writer writer = fsisf.getWriter(); final ExtendedWriter ew = new ExtendedWriter(writer, fsisf); translator.translate(ew); ew.close(); success = true; return createSQLXML(fsisf, ew, context); } catch(IOException e) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30444, e); } catch(TransformerException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30445, e); } finally { if (!success && lobBuffer != null) { lobBuffer.remove(); } } }
/** * This method saves the given XML object to the buffer manager's disk process * Documents less than the maxMemorySize will be held directly in memory */ public static SQLXMLImpl saveToBufferManager(BufferManager bufferMgr, XMLTranslator translator, CommandContext context) throws TeiidComponentException, TeiidProcessingException { boolean success = false; final FileStore lobBuffer = bufferMgr.createFileStore("xml"); //$NON-NLS-1$ final FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(lobBuffer, Streamable.ENCODING); try{ Writer writer = fsisf.getWriter(); final ExtendedWriter ew = new ExtendedWriter(writer, fsisf); translator.translate(ew); ew.close(); success = true; return createSQLXML(fsisf, ew, context); } catch(IOException e) { throw new TeiidComponentException(QueryPlugin.Event.TEIID30444, e); } catch(TransformerException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30445, e); } finally { if (!success && lobBuffer != null) { lobBuffer.remove(); } } }