T
- The type of the RDF primitive, should be one of Triple
, Quad
, or Tuple<Node>
public class PipedRDFIterator<T> extends Object implements Iterator<T>, Closeable
PipedRDFIterator
should be connected to a PipedRDFStream
implementation;
the piped iterator then provides whatever RDF primitives are written to the PipedRDFStream
.
Typically, data is read from a PipedRDFIterator
by one thread and data is written
to the corresponding PipedRDFStream
by some other thread. Attempting to use both
objects from a single thread is not recommended, as it may deadlock the thread.
The PipedRDFIterator
contains a buffer, decoupling read operations from write operations,
within limits.
Inspired by Java's PipedInputStream
and PipedOutputStream
PipedTriplesStream
,
PipedQuadsStream
,
PipedTuplesStream
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE
Constant for default buffer size
|
Constructor and Description |
---|
PipedRDFIterator()
Creates a new piped RDF iterator with the default buffer size of
DEFAULT_BUFFER_SIZE . |
PipedRDFIterator(int bufferSize)
Creates a new piped RDF iterator
|
PipedRDFIterator(int bufferSize,
boolean fair)
Creates a new piped RDF iterator
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
getBaseIri()
Gets the most recently seen Base IRI
|
PrefixMap |
getPrefixes()
Gets the prefix map which contains the prefixes seen so far in the stream
|
boolean |
hasNext() |
T |
next() |
void |
remove() |
public static final int DEFAULT_BUFFER_SIZE
public PipedRDFIterator()
DEFAULT_BUFFER_SIZE
.
Buffer size must be chosen carefully in order to avoid performance problems, if you set the buffer size too low you will experience a lot of blocked calls so it will take longer to consume the data from the iterator. For best performance the buffer size should be at least 10% of the expected input size though you may need to tune this depending on how fast your consumer thread is.
public PipedRDFIterator(int bufferSize)
Buffer size must be chosen carefully in order to avoid performance problems, if you set the buffer size too low you will experience a lot of blocked calls so it will take longer to consume the data from the iterator. For best performance the buffer size should be at least 10% of the expected input size though you may need to tune this depending on how fast your consumer thread is.
bufferSize
- Buffer sizepublic PipedRDFIterator(int bufferSize, boolean fair)
Buffer size must be chosen carefully in order to avoid performance problems, if you set the buffer size too low you will experience a lot of blocked calls so it will take longer to consume the data from the iterator. For best performance the buffer size should be at least 10% of the expected input size though you may need to tune this depending on how fast your consumer thread is.
The fair parameter controls whether the locking policy used for the buffer is fair. When enabled this reduces throughput but also reduces the chance of thread starvation.
bufferSize
- Buffer sizefair
- Whether the buffer should use a fair locking policyLicenced under the Apache License, Version 2.0