コード例 #1
0
    public static void Main(string [] args)
    {
        int datatype;

        // create an HDF file named "example.h5" and use (i.e. open) it
        HDFql.Execute("CREATE FILE example.h5");
        HDFql.Execute("USE FILE example.h5");
        // create an attribute named "attrib" of type float
        HDFql.Execute("CREATE ATTRIBUTE attrib AS FLOAT");
        // get datatype of attribute "attrib" and populate HDFql default cursor with it
        HDFql.Execute("SHOW DATATYPE attrib");
        // move HDFql default cursor to first position
        HDFql.CursorFirst();
        // retrieve datatype from HDFql default cursor
        datatype = (int)HDFql.CursorGetInt();
        // print message according to datatype
        if (datatype == HDFql.TinyInt || datatype == HDFql.VarTinyInt)
        {
            System.Console.WriteLine("Datatype is a char");
        }
        else if (datatype == HDFql.UnsignedTinyInt || datatype == HDFql.UnsignedVarTinyInt)
        {
            System.Console.WriteLine("Datatype is an unsigned char");
        }
        else if (datatype == HDFql.SmallInt || datatype == HDFql.VarSmallInt)
        {
            System.Console.WriteLine("Datatype is a short");
        }
        else if (datatype == HDFql.UnsignedSmallInt || datatype == HDFql.UnsignedVarSmallInt)
        {
            System.Console.WriteLine("Datatype is an unsigned short");
        }
        else if (datatype == HDFql.Int || datatype == HDFql.VarInt)
        {
            System.Console.WriteLine("Datatype is an int");
        }
        else if (datatype == HDFql.UnsignedInt || datatype == HDFql.UnsignedVarInt)
        {
            System.Console.WriteLine("Datatype is an unsigned int");
        }
        else if (datatype == HDFql.BigInt || datatype == HDFql.VarBigInt)
        {
            System.Console.WriteLine("Datatype is a long long");
        }
        else if (datatype == HDFql.UnsignedBigInt || datatype == HDFql.UnsignedVarBigInt)
        {
            System.Console.WriteLine("Datatype is an unsigned long long");
        }
        else if (datatype == HDFql.Float || datatype == HDFql.VarFloat)
        {
            System.Console.WriteLine("Datatype is a float");
        }
        else if (datatype == HDFql.Double || datatype == HDFql.VarDouble)
        {
            System.Console.WriteLine("Datatype is a double");
        }
        else if (datatype == HDFql.Char || datatype == HDFql.VarChar)
        {
            System.Console.WriteLine("Datatype is a char");
        }
        else if (datatype == HDFql.Opaque)
        {
            System.Console.WriteLine("Datatype is an opaque");
        }
        else
        {
            System.Console.WriteLine("Unknown datatype");
        }
    }
コード例 #2
0
        /// <summary>
        /// Retrieves all of the image data from the .h5 file and
        /// initializes all of the data attributes.
        /// </summary>
        /// <param name="file">The .h5 file specified by the user</param>
        private void Initialize(string file)
        {
            // Get the relative path of the file since only relative paths work as of right now.
            // TODO: Make absolute paths work.
            string relativePath = GetRelativePath(file, System.IO.Directory.GetCurrentDirectory());

            fileName = file;

            // Open the .h5 file specified by the user
            HDFql.Execute("USE FILE " + relativePath);

            // Create myCursor "myCursor" and use it
            myCursor = new HDFqlCursor();
            HDFql.CursorUse(myCursor);

            string path = "";

            HDFql.Execute("SHOW DATASET LIKE {50e35494-f4dd-4122-96f8-4d47c927abe5}/resultarray/inputdata WHERE DATATYPE IS INT");
            if (HDFql.CursorNext() == HDFql.Success)
            {
                path = HDFql.CursorGetChar();
            }
            else
            {
                HDFql.Execute("SHOW DATASET LIKE inputdata WHERE DATATYPE IS INT");

                if (HDFql.CursorNext() == HDFql.Success)
                {
                    path = HDFql.CursorGetChar();
                }
                else
                {
                    HDFql.Execute("SHOW DATASET LIKE Cube/resultarray/inputdata WHERE DATATYPE IS INT");

                    if (HDFql.CursorNext() == HDFql.Success)
                    {
                        path = HDFql.CursorGetChar();
                    }
                }
            }

            // Populate cursor "myCursor" with size of dataset "example_dataset" and display it
            if (path == "{50e35494-f4dd-4122-96f8-4d47c927abe5}/resultarray/inputdata")
            {
                HDFql.Execute("USE GROUP {50e35494-f4dd-4122-96f8-4d47c927abe5}");
                HDFql.Execute("USE GROUP resultarray");
                HDFql.Execute("USE DATASET inputdata");
            }
            else if (path == "inputdata")
            {
                HDFql.Execute("USE DATASET inputdata");
            }
            else
            {
                HDFql.Execute("USE GROUP Cube");
                HDFql.Execute("USE GROUP resultarray");
                HDFql.Execute("USE DATASET inputdata");
            }

            HDFql.Execute("SHOW SIZE inputdata");
            HDFql.CursorFirst();
            Console.WriteLine("Dataset size: {0}", HDFql.CursorGetInt());

            HDFql.Execute("SHOW DIMENSION inputdata");
            HDFql.CursorFirst();
            Console.WriteLine("Dataset size: {0}", HDFql.CursorGetInt());

            // Console.WriteLine lambda count, should be 78
            HDFql.CursorFirst(null);
            lambdaCount = HDFql.CursorGetInt() != null ? (int)HDFql.CursorGetInt() : 0;
            Console.WriteLine("inputdata dimension 0 (Λ): " + lambdaCount);

            // Console.WriteLine the the x and y dimensions of the dataset
            HDFql.CursorAbsolute(null, 2);
            int xDimension = HDFql.CursorGetInt() != null ? (int)HDFql.CursorGetInt() : 0;

            Console.WriteLine("inputdata dimension 2 (X): " + xDimension);

            HDFql.CursorAbsolute(null, 3);
            int yDimension = HDFql.CursorGetInt() != null ? (int)HDFql.CursorGetInt() : 0;

            Console.WriteLine("inputdata dimension 3 (Y): " + yDimension);

            // Set the size of the data array to be lambdaCount * xDimension * yDimension
            data = new float[lambdaCount, xDimension, yDimension];

            // Register variable "data" for subsequent use (by HDFql)
            HDFql.VariableRegister(data);

            // Select (y.e. read) dataset into variable "data"
            HDFql.Execute("SELECT FROM inputdata INTO MEMORY " + HDFql.VariableGetNumber(data));

            // Unregister variable "data" as it is no longer used/needed (by HDFql)
            HDFql.VariableUnregister(data);

            // Set the length and width of the textures
            imageWidth  = yDimension;
            imageHeight = xDimension;

            FindMinAndMaxValue();
        }