com.bigdata.rdf.spo
Class SPOIndexWriteProc

java.lang.Object
  extended by com.bigdata.btree.proc.AbstractIndexProcedure
      extended by com.bigdata.btree.proc.AbstractKeyArrayIndexProcedure
          extended by com.bigdata.rdf.spo.SPOIndexWriteProc
All Implemented Interfaces:
IIndexProcedure, IKeyArrayIndexProcedure, IParallelizableIndexProcedure, IMutableRelationIndexWriteProcedure, Externalizable, Serializable

public class SPOIndexWriteProc
extends AbstractKeyArrayIndexProcedure
implements IParallelizableIndexProcedure, IMutableRelationIndexWriteProcedure

Procedure for batch index on a single statement index (or index partition).

The key for each statement encodes the {s:p:o} of the statement in the order that is appropriate for the index (SPO, POS, OSP, etc). The key is written unchanged on the index.

The value for each statement is a byte that encodes the StatementEnum and also encodes whether or not the "override" flag is set using - see StatementEnum.MASK_OVERRIDE - followed by 8 bytes representing the statement identifier IFF statement identifiers are enabled AND the StatementEnum is StatementEnum.Explicit. The value requires interpretation to determine the byte[] that will be written as the value on the index - see the code for more details.

Note: This needs to be a custom batch operation using a conditional insert so that we do not write on the index when the data would not be changed and to handle the overflow flag and the optional statement identifier correctly.

Version:
$Id: SPOIndexWriteProc.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Nested Class Summary
static class SPOIndexWriteProc.IndexWriteProcConstructor
           
 
Nested classes/interfaces inherited from class com.bigdata.btree.proc.AbstractKeyArrayIndexProcedure
AbstractKeyArrayIndexProcedure.ResultBitBuffer, AbstractKeyArrayIndexProcedure.ResultBitBufferCounter, AbstractKeyArrayIndexProcedure.ResultBitBufferHandler, AbstractKeyArrayIndexProcedure.ResultBuffer, AbstractKeyArrayIndexProcedure.ResultBufferHandler
 
Field Summary
protected  boolean DEBUG
           
protected  boolean INFO
           
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
  SPOIndexWriteProc()
          De-serialization constructor.
protected SPOIndexWriteProc(IRabaCoder keySer, IRabaCoder valSer, int fromIndex, int toIndex, byte[][] keys, byte[][] vals)
           
 
Method Summary
 Object apply(IIndex ndx)
          Run the procedure.
protected  long decodeStatementIdentifier(StatementEnum type, byte[] val)
          Decodes and validate the statement identifier from the value.
 boolean isReadOnly()
          Return true iff the procedure asserts that it will not write on the index.
 
Methods inherited from class com.bigdata.btree.proc.AbstractKeyArrayIndexProcedure
getKey, getKeyCount, getKeys, getValue, getValues, readExternal, readMetadata, writeExternal, writeMetadata
 
Methods inherited from class com.bigdata.btree.proc.AbstractIndexProcedure
getKeyBuilder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final transient org.apache.log4j.Logger log

INFO

protected final transient boolean INFO

DEBUG

protected final transient boolean DEBUG
Constructor Detail

SPOIndexWriteProc

public SPOIndexWriteProc()
De-serialization constructor.


SPOIndexWriteProc

protected SPOIndexWriteProc(IRabaCoder keySer,
                            IRabaCoder valSer,
                            int fromIndex,
                            int toIndex,
                            byte[][] keys,
                            byte[][] vals)
Parameters:
fromIndex -
toIndex -
keys -
vals -
Method Detail

isReadOnly

public final boolean isReadOnly()
Description copied from interface: IIndexProcedure
Return true iff the procedure asserts that it will not write on the index. When true, the procedure may be run against a view of the index that is read-only or which allows concurrent processes to read on the same index object. When false the procedure will be run against a mutable view of the index (assuming that the procedure is executed in a context that has access to a mutable index view).

Specified by:
isReadOnly in interface IIndexProcedure

apply

public Object apply(IIndex ndx)
Description copied from interface: IIndexProcedure
Run the procedure.

Note: Unisolated procedures have "auto-commit" ACID properties for a local index only. In order for a distributed procedure to be ACID, the procedure MUST be executed within a fully isolated transaction.

Specified by:
apply in interface IIndexProcedure
Parameters:
ndx - The index.
Returns:
The #of statements actually written on the index as an Long.

decodeStatementIdentifier

protected long decodeStatementIdentifier(StatementEnum type,
                                         byte[] val)
Decodes and validate the statement identifier from the value.

Parameters:
type - The statement type.
val - The value.
Returns:
The statement identifier if the statement is StatementEnum.Explicit and statement identifiers are enabled and otherwise IRawTripleStore.NULL.
Throws:
RuntimeException - if validation fails.


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