public InputStream getInputStream(long start, long len) { if (fsos != null && !fsos.bytesWritten()) { if (start > Integer.MAX_VALUE) { throw new AssertionError("Invalid start " + start); //$NON-NLS-1$ } int s = (int)start; int intLen = fsos.getCount() - s; if (len >= 0) { intLen = (int)Math.min(len, len); } return new ByteArrayInputStream(fsos.getBuffer(), s, intLen); } return lobBuffer.createInputStream(start, len); }
public InputStream getInputStream(long start, long len) { if (fsos != null && !fsos.bytesWritten()) { if (start > Integer.MAX_VALUE) { throw new AssertionError("Invalid start " + start); //$NON-NLS-1$ } int s = (int)start; int intLen = fsos.getCount() - s; if (len >= 0) { intLen = (int)Math.min(len, len); } return new ByteArrayInputStream(fsos.getBuffer(), s, intLen); } return lobBuffer.createInputStream(start, len); }
public InputStream getInputStream(long start, long len) { if (fsos != null && !fsos.bytesWritten()) { if (start > Integer.MAX_VALUE) { throw new AssertionError("Invalid start " + start); //$NON-NLS-1$ } int s = (int)start; int intLen = fsos.getCount() - s; if (len >= 0) { intLen = (int)Math.min(len, len); } return new ByteArrayInputStream(fsos.getBuffer(), s, intLen); } return lobBuffer.createInputStream(start, len); }
/** * @see org.teiid.query.function.aggregate.AggregateFunction#getResult(CommandContext) */ public Object getResult(CommandContext commandContext) throws TeiidProcessingException{ if (this.result == null) { this.result = buildResult(commandContext); } 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); } } }
/** * @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) { this.result = buildResult(commandContext); } try { FileStoreOutputStream fs = this.result.getOuputStream(); fs.close(); if (fs.bytesWritten()) { return new BlobType(new BlobImpl(result)); } return new BlobType(new SerialBlob(Arrays.copyOf(fs.getBuffer(), fs.getCount()))); } 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) { this.result = buildResult(commandContext); } try { FileStoreOutputStream fs = this.result.getOuputStream(); fs.close(); if (fs.bytesWritten()) { return new BlobType(new BlobImpl(result)); } return new BlobType(new SerialBlob(Arrays.copyOf(fs.getBuffer(), fs.getCount()))); } 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) { this.result = buildResult(commandContext); } try { FileStoreOutputStream fs = this.result.getOuputStream(); fs.close(); if (fs.bytesWritten()) { return new BlobType(new BlobImpl(result)); } return new BlobType(new SerialBlob(Arrays.copyOf(fs.getBuffer(), fs.getCount()))); } catch (IOException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30422, e); } catch (SQLException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30423, e); } } }
public byte[] getMemoryBytes() { if (fsos != null && !fsos.bytesWritten() && fsos.getBuffer().length == fsos.getCount()) { return fsos.getBuffer(); } throw new IllegalStateException("In persistent mode or not closed for writing"); //$NON-NLS-1$ }
@Override public long getLength() { if (fsos != null && !fsos.bytesWritten()) { return fsos.getCount(); } return lobBuffer.getLength(); }
@Override public long getLength() { if (fsos != null && !fsos.bytesWritten()) { return fsos.getCount(); } return lobBuffer.getLength(); }
@Override public long getLength() { if (fsos != null && !fsos.bytesWritten()) { return fsos.getCount(); } return lobBuffer.getLength(); }
public byte[] getMemoryBytes() { if (fsos != null && !fsos.bytesWritten() && fsos.getBuffer().length == fsos.getCount()) { return fsos.getBuffer(); } throw new IllegalStateException("In persistent mode or not closed for writing"); //$NON-NLS-1$ }
@Test public void testFlush() throws Exception { FileStorageManager sm = getStorageManager(null, null); FileStore store = sm.createFileStore("0"); FileStoreOutputStream fsos = store.createOutputStream(2); fsos.write(new byte[3]); fsos.write(1); fsos.flush(); assertEquals(0, fsos.getCount()); }
public byte[] getMemoryBytes() { if (fsos != null && !fsos.bytesWritten() && fsos.getBuffer().length == fsos.getCount()) { return fsos.getBuffer(); } throw new IllegalStateException("In persistent mode or not closed for writing"); //$NON-NLS-1$ }
@Test public void testGrowth() throws Exception { FileStorageManager sm = getStorageManager(null, null); FileStore store = sm.createFileStore("0"); FileStoreOutputStream fsos = store.createOutputStream(1<<15); assertTrue(fsos.getBuffer().length < 1<<15); fsos.write(1); fsos.write(new byte[1<<14]); fsos.flush(); assertEquals(1 + (1<<14), fsos.getCount()); assertEquals(1<<15, fsos.getBuffer().length); }