com.bigdata.rdf.internal.encoder
Class IVBindingSetEncoder

java.lang.Object
  extended by com.bigdata.rdf.internal.encoder.IVBindingSetEncoder
All Implemented Interfaces:
IBindingSetDecoder, IBindingSetEncoder
Direct Known Subclasses:
IVBindingSetEncoderWithIVCache

public class IVBindingSetEncoder
extends Object
implements IBindingSetEncoder, IBindingSetDecoder

A utility class for generating and processing compact representations of IBindingSets whose IConstants are bound to IVs. Individual IVs may be associated with a cached RDF Value.

Note: This implementation does NOT maintain the IVCache associations.

Version:
$Id: IVBindingSetEncoder.java 6032 2012-02-16 12:48:04Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected  boolean filter
          true iff this is in support of a DISTINCT filter.
protected  LinkedHashSet<IVariable<?>> ivCacheSchema
          The set of variables for which materialized IVs have been observed.
 
Constructor Summary
IVBindingSetEncoder(boolean filter)
           
 
Method Summary
 IBindingSet decodeSolution(byte[] val, int off, int len, boolean resolveCachedValues)
          Decode an IBindingSet.
 byte[] encodeSolution(IBindingSet bset)
          Encode the solution as an IV[], collecting updates for the internal IV to BigdataValue cache.
 byte[] encodeSolution(IBindingSet bset, boolean updateCache)
          Encode the solution as an IV[].
 void flush()
          Flush any updates.
 boolean isValueCache()
          Return true iff the IVCache associations are preserved by the encoder.
 void release()
          Release the state associated with the IVBindingSetEncoder.
 void resolveCachedValues(IBindingSet bset)
          Resolve any IVs in the solution for which there are cached BigdataValues to those values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filter

protected final boolean filter
true iff this is in support of a DISTINCT filter.

Note: we do not maintain the ivCacheSchema for a DISTINCT filter since the original solutions flow through the filter.


ivCacheSchema

protected final LinkedHashSet<IVariable<?>> ivCacheSchema
The set of variables for which materialized IVs have been observed.

Constructor Detail

IVBindingSetEncoder

public IVBindingSetEncoder(boolean filter)
Parameters:
filter - true iff this is in support of a DISTINCT filter.

Note: we do not maintain the ivCacheSchema for a DISTINCT filter since the original solutions flow through the filter.

Method Detail

isValueCache

public boolean isValueCache()
Return true iff the IVCache associations are preserved by the encoder.

This implementation does not maintain the IVCache associations.

Specified by:
isValueCache in interface IBindingSetDecoder
Specified by:
isValueCache in interface IBindingSetEncoder

encodeSolution

public byte[] encodeSolution(IBindingSet bset)
Description copied from interface: IBindingSetEncoder
Encode the solution as an IV[], collecting updates for the internal IV to BigdataValue cache.

Specified by:
encodeSolution in interface IBindingSetEncoder
Parameters:
bset - The solution to be encoded.
Returns:
The encoded solution.

encodeSolution

public byte[] encodeSolution(IBindingSet bset,
                             boolean updateCache)
Description copied from interface: IBindingSetEncoder
Encode the solution as an IV[].

Note: The IVCache associations may be buffered by this method. Use IBindingSetEncoder.flush() to vector any buffered associations.

Specified by:
encodeSolution in interface IBindingSetEncoder
Parameters:
bset - The solution to be encoded.
updateCache - When true, updates are accumulated for the IV to BigdataValue cache. You must still use IBindingSetEncoder.flush() to vector the accumulated updates.

If you are only generating the encoding in order to resolve a key in a hash index, then you would use false since you do not need to maintain the IVCache association for the given IBindingSet.

Returns:
The encoded solution.

flush

public void flush()
Description copied from interface: IBindingSetEncoder
Flush any updates. This allows for vectored operations when updating the IVCache associations.

Specified by:
flush in interface IBindingSetEncoder

decodeSolution

public IBindingSet decodeSolution(byte[] val,
                                  int off,
                                  int len,
                                  boolean resolveCachedValues)
Description copied from interface: IBindingSetDecoder
Decode an IBindingSet.

The resolution step can be deferred when the decoded IBindingSet does not require the resolved IVCache associations. For example, we do not need the IVCache association in order to decide if two IBindingSets can join. However, once we have a solution from a join, we may need to resolve the IVCache metadata for the joined solution.

Specified by:
decodeSolution in interface IBindingSetDecoder
Parameters:
val - The encoded IV[].
off - The starting offset.
len - The #of bytes of data to be decoded.
resolveCachedValues - When true, any decoded IVs will have their IVCache association resolved before the IBindingSet is returned to the caller. When false, the resolution step is not performed.
Returns:
The decoded IBindingSet.
See Also:
IBindingSetDecoder.resolveCachedValues(IBindingSet)

resolveCachedValues

public void resolveCachedValues(IBindingSet bset)
Resolve any IVs in the solution for which there are cached BigdataValues to those values. This method may be used to resolve IVCache associations for IBindingSets NOT produced by IBindingSetDecoder.decodeSolution(byte[], int, int, boolean). For example, when joining a decoded solution with another solution, the resolution step may be deferred until we know whether or not the join was successful.

Note: This implementation is a NOP as the IVCache association is NOT maintained by this class.

Specified by:
resolveCachedValues in interface IBindingSetDecoder
Parameters:
bset - A solution having IVs which need to be reunited with their cached BigdataValues.

release

public void release()
Description copied from interface: IBindingSetEncoder
Release the state associated with the IVBindingSetEncoder.

Specified by:
release in interface IBindingSetDecoder
Specified by:
release in interface IBindingSetEncoder


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.