public class PSOutputStream extends IPSOutputStream
Retrieved from an IObjectStore to enable output to the store.
The key idea here is that rather than a call like :
store.realloc(oldAddr, byteOutputStream)=> newAddress instead : store.allocStream(oldAddr)=>PSOutputStream and then : stream.save()=> newAddress
This will enable large data formats to be streamed to the data store, where the previous interface would have required that the entire resource was loaded into a memory structure first, before being written out in a single block to the store.
This new approach will also enable the removal of BLOB allocation strategy. Instead, "BLOBS" will be served by linked fixed allocation blocks, flushed out by the stream.
A big advantage of this is that BLOB reallocation is now a lot simpler, since BLOB storage is simply a potentially large number of 8K blocks.
This also opens up the possibility of a Stream oriented data type, that could be used to serve up a variety of data streams. By providing relevant interfaces with the client/server system, a server can then provide multiple streams to a high number of clients.
To this end, the output stream has a fixed buffer size, and they are recycled from a pool of output streams.
It is important that output streams are bound to the IStore they are requested for.
See ticket #641 that discusses creating and using a pool for PSOutputStream allocation.
Constructor and Description |
---|
PSOutputStream() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
long |
getAddr()
Called when writes to the stream are complete.
|
int |
getBytesWritten() |
OutputStream |
getFilterWrapper(boolean saveBeforeClose) |
static PSOutputStream |
getNew(IStore store,
int maxAlloc,
IAllocationContext context) |
void |
reset() |
long |
save()
on save() the current buffer is allocated and written to the
store, and the address of its location returned
If saving as Blob then addr must index to the BlobAllocator that then
points to the BlobHeader
|
void |
write(byte[] b,
int off,
int len)
write byte array to the buffer
we need to be able to efficiently handle large arrays beyond size
of the blobThreshold, so
|
void |
write(InputStream instr)
utility method that extracts data from the input stream
|
void |
write(int b)
write a single byte
this is the one place where the blob threshold is handled
and its done one byte at a time so should be easy enough,
We no longer store continuation addresses, instead we allocate
blob allocations via a blob header block.
|
void |
writeInt(int b)
write a single 4 byte integer
|
void |
writeLong(long b) |
flush, write
public static PSOutputStream getNew(IStore store, int maxAlloc, IAllocationContext context)
public void reset()
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void writeInt(int b) throws IOException
IOException
public void writeLong(long b) throws IOException
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void write(InputStream instr) throws IOException
instr
- and write to the store.
This method can be used to stream external files into
the store.IOException
public long save()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public int getBytesWritten()
public OutputStream getFilterWrapper(boolean saveBeforeClose)
public long getAddr()
IPSOutputStream
getAddr
in class IPSOutputStream
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.