Beispiel #1
0
    /**
     * Determine the schema of the output. inferSchema is called on the coordinator instance during query planning and
     * may be called several times as the planner gets its act together. It will always be called with the same inputs
     * for the same query. This function must behave deterministically, but the shape of the output may vary based on
     * inputs and parameters.
     * @param schemas all of the schemas of the input arrays (if the operator accepts any)
     * @param query the query context
     * @return the schema of the outpt, as described above.
     */
    ArrayDesc inferSchema(vector< ArrayDesc> schemas, shared_ptr< Query> query)
    {
        /*
         * Make one string attribute: id=0, name="instance_status" of type string, no flags, no default compression.
         * The ID of the attribute is simply a number from 0 to num_attributes-1 and must equal to its position
         * in the attributes vector.
         */
        AttributeDesc outputAttribute (0, "instance_status", TID_STRING, 0, 0);
        Attributes outputAttributes(1, outputAttribute);

        /* Add the empty tag attribute. Arrays with the empty tag are "emptyable" meaning that some cells may be empty.
         * It is a good practice to add this to every constructed array. In fact, in the future it may become the
         * default for all arrays.
         */
        outputAttributes = addEmptyTagAttribute(outputAttributes);

        /* The output dimension: from 0 to "*" with a chunk size of 1. The amount of data returned is so small that the
         * chunk size is not relevant.
         */
        DimensionDesc outputDimension("instance_no", 0, MAX_COORDINATE, 1, 0);
        Dimensions outputDimensions(1, outputDimension);

        /* The first argument is the name of the returned array. */
        return ArrayDesc("hello_instances", outputAttributes, outputDimensions);
    }
ThinConsole& ThinConsole::WriteToConsole(string_type const& outputString, console_location_type const& location, console_color_type const& foreground, console_color_type const& background) {
	assert(outputHandle != NULL && "Output Handle Not Initialized");
	std::vector<console_attribute_type> outputAttributes(outputString.size(), foregroundColorMap[foreground] | backgroundColorMap[background]);
	console_information_type charsWritten;
	ExceptionCheck(WriteConsoleOutputCharacter(outputHandle, std::wstring(outputString.begin(), outputString.end()).c_str(), outputString.size(), location, &charsWritten), __FUNCTION__, __LINE__);
	ExceptionCheck(WriteConsoleOutputAttribute(outputHandle, outputAttributes.data(), outputAttributes.size(), location, &charsWritten), __FUNCTION__, __LINE__);
	return *this;
}
Beispiel #3
0
/* inferSchema helps the query planner decide on the shape of
 * the output array. All operators must define this function.
 */
    ArrayDesc inferSchema(vector< ArrayDesc> schemas, shared_ptr< Query> query)
    {
        ArrayDesc const& matrix = schemas[0];
        if(matrix.getAttributes(true)[0].getType() != TID_STRING)
           throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_ILLEGAL_OPERATION) <<  "cu requires a single string-valued attribute";
        Attributes outputAttributes(matrix.getAttributes());
        Dimensions outputDimensions(matrix.getDimensions());
        return ArrayDesc(matrix.getName(), outputAttributes, outputDimensions);
    }
Beispiel #4
0
bool outputLight( const ScenePlug *scene, const ScenePlug::ScenePath &path, IECore::Renderer *renderer )
{
	IECore::ConstLightPtr constLight = runTimeCast<const IECore::Light>( scene->object( path ) );
	if( !constLight )
	{
		return false;
	}

	if( !visible( scene, path ) )
	{
		/// \todo Since both visible() and fullAttributes() perform similar work,
		/// we may want to combine them into one query if we see this function
		/// being a significant fraction of render time. Maybe something like
		/// `fullAttributes( returnNullIfInvisible = true )`? It probably also
		/// makes sense to migrate all the convenience functions from ScenePlug
		/// into SceneAlgo.
		return false;
	}

	ConstCompoundObjectPtr attributes = scene->fullAttributes( path );
	const M44f transform = scene->fullTransform( path );

	std::string lightHandle;
	ScenePlug::pathToString( path, lightHandle );

	LightPtr light = constLight->copy();
	light->setHandle( lightHandle );

	{
		AttributeBlock attributeBlock( renderer );

		renderer->setAttribute( "name", new StringData( lightHandle ) );
		outputAttributes( attributes.get(), renderer );

		renderer->concatTransform( transform );

		light->render( renderer );
	}

	renderer->illuminate( lightHandle, true );

	return true;
}