PHP Class DataSift_Definition

Author: Stuart Dallas ([email protected])
Mostrar archivo Open project: datasift/datasift-php Class Usage Examples

Protected Properties

Property Type Description
$_created_at The hash creation time as a UNIX timestamp.
$_csdl The CSDL source code.
$_hash The stream hash.
$_total_dpu The total number of DPUs used.
$_user The DataSift User object.

Public Methods

Method Description
__construct ( DataSift_User $user, string $csdl = '', string $hash = false ) Constructor. A DataSift_User object is required, and you can optionally supply a default definition string.
compile ( ) : void Call the DataSift API to compile this defintion. On success it will store the returned hash.
createHistoric ( integer $start, integer $end, array $sources, string $name, float $sample = DataSift_Historic::DEFAULT_SAMPLE ) : DataSift_Historic Create a historic based on this CSDL.
get ( ) : string Returns the definition string.
getBuffered ( integer $count = false, integer $from_id = false ) : array Call the DataSift API to get buffered interactions.
getConsumer ( string $type, DataSift_IStreamConsumerEventHandler $eventHandler ) : DataSift_StreamConsumer Returns a DataSift_StreamConsumer-derived object for this definition, for the given type.
getCreatedAt ( ) : integer Returns the date when the stream was first created. If the created at date has not yet been obtained it validates the definition first.
getDPUBreakdown ( ) : array Call the DataSift API to get the DPU for this definition. Returns an array containing.
getHash ( ) : string Returns the hash for this definition. If the hash has not yet been obtained it compiles the definition first.
getTotalDPU ( ) : integer Returns the total DPU of the stream. If the DPU has not yet been obtained it validates the definition first.
set ( string $csdl ) : void Sets the definition string.
validate ( ) : void Call the DataSift API to validate this defintion. On success it will store the returned hash.

Protected Methods

Method Description
clearHash ( ) : void Reset the hash to false. The effect of this is to mark the definition as requiring compilation. Also resets other variables that depend on the CSDL.

Method Details

__construct() public method

Constructor. A DataSift_User object is required, and you can optionally supply a default definition string.
public __construct ( DataSift_User $user, string $csdl = '', string $hash = false )
$user DataSift_User The user object.
$csdl string An optional default definition string.
$hash string An optional hash for the passed definition.

clearHash() protected method

Reset the hash to false. The effect of this is to mark the definition as requiring compilation. Also resets other variables that depend on the CSDL.
protected clearHash ( ) : void
return void

compile() public method

Call the DataSift API to compile this defintion. On success it will store the returned hash.
public compile ( ) : void
return void

createHistoric() public method

Create a historic based on this CSDL.
public createHistoric ( integer $start, integer $end, array $sources, string $name, float $sample = DataSift_Historic::DEFAULT_SAMPLE ) : DataSift_Historic
$start integer The timestamp from which to start the query.
$end integer The timestamp at which to end the query.
$sources array An array of sources required.
$name string An optional name for this historic.
$sample float Sample size (10 or 100)
return DataSift_Historic

get() public method

Returns the definition string.
public get ( ) : string
return string The definition.

getBuffered() public method

Call the DataSift API to get buffered interactions.
public getBuffered ( integer $count = false, integer $from_id = false ) : array
$count integer Optional number of interactions to return (max 200).
$from_id integer Optional start ID.
return array

getConsumer() public method

Returns a DataSift_StreamConsumer-derived object for this definition, for the given type.
See also: DataSift_StreamConsumer
public getConsumer ( string $type, DataSift_IStreamConsumerEventHandler $eventHandler ) : DataSift_StreamConsumer
$type string The consumer type for which to construct a consumer.
$eventHandler DataSift_IStreamConsumerEventHandler An instance of DataSift_IStreamConsumerEventHandler
return DataSift_StreamConsumer The consumer object.

getCreatedAt() public method

Returns the date when the stream was first created. If the created at date has not yet been obtained it validates the definition first.
public getCreatedAt ( ) : integer
return integer The date as a unix timestamp.

getDPUBreakdown() public method

.. dpu => The breakdown of running the rule total => The total dpu of the rule
public getDPUBreakdown ( ) : array
return array

getHash() public method

Returns the hash for this definition. If the hash has not yet been obtained it compiles the definition first.
public getHash ( ) : string
return string The hash.

getTotalDPU() public method

Returns the total DPU of the stream. If the DPU has not yet been obtained it validates the definition first.
public getTotalDPU ( ) : integer
return integer The total DPU.

set() public method

Sets the definition string.
public set ( string $csdl ) : void
$csdl string The new definition string.
return void

validate() public method

Call the DataSift API to validate this defintion. On success it will store the returned hash.
public validate ( ) : void
return void

Property Details

$_created_at protected_oe property

The hash creation time as a UNIX timestamp.
protected $_created_at

$_csdl protected_oe property

The CSDL source code.
protected $_csdl

$_hash protected_oe property

The stream hash.
protected $_hash

$_total_dpu protected_oe property

The total number of DPUs used.
protected $_total_dpu

$_user protected_oe property

The DataSift User object.
protected $_user