翻译

Translate to EnglishÜbersetzen Sie zum Deutsch/GermanΜεταφράστε στα ελληνικά/GreekПереведите к русскому/RussianOversetter til Norsk/NorwegianÖversätta till Svensk/Swedishहिन्दी अनुवाद करने के लिए/Hindi
Tradueix al català/CatalanTulkot uz latviešu/LatvianPreložiť do slovenčiny/SlovakVertaal aan het Nederlands/Dutchترجمة الى العربية/ArabicTraduzca al Español/SpanishTraduisez au Français/French
Traduca ad Italiano/ItalianTraduza ao Português/Portuguese日本語に翻訳しなさい /Japanese한국어에게 번역하십시오/Korean中文翻译/Chinese Simplified中文翻译/Chinese TraditionalПереклад на українську/Ukrainian
先进编程在UNIX环境,再版(阿狄森-维斯利专家计算的系列)的图象
RHCE红色帽子的图象证明了工程师Linux研究指南(检查RH302) (证明新闻)
操作系统的概念的图象
XSLT 2.0和XPath 2.0程序参考(对程序员的程序员的)图象

XAM查询语言

并且提供供营商独立手段创造,检索,修改和删除XSets, SNIA XAM v1.0 规格根据SQL语言,为了选择和检索根据内容被定义的标准的XSets XUIDs的一个子集也定义了查询语言(XAM QL)。

套这查询语言的保留字是相当小的: 选择其中和或者没有存在束缚只读typeof长度日期真实错误以后包含之前。 故意地, XAM询问看起来象SQL精选的声明。 查询语言是厚脸皮的案件并且使用ASCII字符集。

这一次简单的XAM询问的例子:

select ".xset.xuid" where "com.example.name" = ’Tuckers Plantation'


XAM规格的版本1.0定义了查询语言支持的二个水平,即第1级和第2.级第1级定义了在物产的询问和在XSets的字段属性并且是必须的。 对应用程序是容易接近的通过XAM图书馆的所有XSet财产价值可以被询问。 第2级对在XStreams的支持询问扩大第1级并且是任意的。 询问的两个水平通过所有XAM提供者必须支持的一个唯一,被定义的工作类型访问。 因为供营商我知道没有实际上实现级2询问,这个岗位焦点剩下的人在第1级询问的。

XAM查询报表包括任意跟随的一个必须的精选的条目条目的地方。 对于XAM v1.0唯一的合法的精选的条目是精选的`.xset.xuid'.。 这指定应用请求XUID价值名单。 例如

select ".xset.xuid "


将退回在询问之时是可读的每XSet的名单。

条目被用于指定将被匹配的地方XSets的一个子集。 对于第1级询问它限于在XSet物产和逐字价值之间的比较和字段属性和逐字价值。

select ".xset.xuid" where ".xam.time.xuid" > date(’2009-02-01T00:00:00.0’)


将退回被创造或在2009年2月1日以后所有Xsets的名单。

调遣的下表展示和逐字类型可以合法被比较。

xam_intxam_doublexam_stringxam_datetimexam_xuid
int**
**
*
日期-时间*
XUID*

XAM图书馆确认串和串自由主义者是一致的UTF-8串。 非相容的UTF-8文字串引起一个XAM非致命询问句法错误。 问题例如唯一对多个纵的沟纹字符和非可印字符是非特指的并且是实施和应用受抚养者。 串比较区分大小写,并且比较操作符起作用一个字节由字节依据。 对于关系运算子关系是由字节价值定义的。 所有数据正常化是应用的责任。

支持的逸出序列下列。 其他逸出序列将引起一个非致命错误。

\ \斜线(\)
\ “双引号(")
\ ‘单引号(‘)
\ uxxxx一个Unicode字符以十六进制格式(xxxx)

必须引述文字串与单引号。 包含一个或更多单引号字符使用斜线的文字串必须逃脱每个单引号字符。 例如, ‘此的文字串是串literal将代表在询问
select ".xset.xuid" where "com.example.string-property" = ’This is a string literal’


要使用一个单引号在串,守卫它与斜线

select ".xset.xuid" where "com.example.claimed.ownership" = ’Tucker\’s’


必须引述字段名所有事例在XAM询问串的与双引号。 如果字段名包含双引号字符,必须逃脱使用斜线,每个双引号字符。 例如,字段名对于xam_boolean物产com.example。”在询问应该代表qstring”

select ".xam.xuid" where "com.example.\"qstring\"" = TRUE


如果字段名包含一个斜线字符,必须逃脱斜线与另一条斜线。 例如,在询问应该代表字段名对于xam_double物产com.example.file \比率

select ".xam.xuid" where "com.example.file\\ratio" = 100.1


查询语言接受日期-时间,并且使用选择器作用的XUID被重视的印刷错误分别约会()xuid ()日期()作用采取适当地被形成的日期-时间的价值,指定,因为与XAM日期-时间规格是一致的逐字串。

select ".xset.xuid" where ".xam.time.xuid" = date(’2009-06-01T00:00:00.0’)


xuid ()作用期待以base64编码文字串的形式,是的XUID。 在询问解析期间,不适当地被形成的文字串引起一个非致命错误。

字段属性访问使用存在typeof只读捆绑长度字段属性存取机构作用。 存在()一个名字字段属性(物产)的存在的功能考验在XSet。 它评估配齐,如果XSet包含它否则评估错误的名字字段。

select ".xset.xuid" where exists("com.example.name")


typeof ()作用退回一个名字字段的MIME类型在是串被重视的物产的XSet的。

select ".xset.xuid" where typeof("com.example.data") = ’text/plain’
select ".xset.xuid" where typeof("com.example.data") like ’text%’


可以使用这个作用,每当应用可能使用在串被重视的物产的领域参考。 注意在解析询问期间,与所有非串逐字价值的比较引起一个非致命错误。

只读()作用评估配齐在XSet的一个领域什么时候被标记如只读。

select ".xset.xuid" where readonly("com.example.flag")
select ".xset.xuid" where not readonly("com.example.name")


约束()作用评估配齐在XSet的一个领域什么时候被标记如束缚。

select ".xset.xuid" where binding("com.example.case_id")
select ".xset.xuid" where not binding("com.example.subject")


长度()作用退回长度,在字节,一个名字字段。

select ".xset.xuid" where length("com.example.data") > 1024


当使用在物产调遣这个作用回归长度如被定义为stypes。 注意不应该用于这个作用比较字符的数量在串的,当这比较取决于使用的字符内码。

现在转向逻辑操作符。 在之内的从句条目也许被结合和被修饰通过使用逻辑操作符,并且的地方或者没有。 这些操作员类似他们的SQL相对物。

操作员要求两个从句评估以前配齐包括在结果的XSet。 例如

select ".xset.xuid" where typeof("com.example.stream") = ’image/gif’ and length("com.example.stream") > 4096


只选择那些包含大小比4096个字节伟大的GIF图象的XSets。 如果任一个从句评估配齐,操作员评估配齐。 例如

select ".xset.xuid" where typeof("com.example.stream") = ’image/jpeg’ or typeof("com.example.stream") = ’image/gif’


只选择那些包含图象类型JPEG或GIF的一条名为小河XSets。 不是操作员否定一个布尔表示式。 例如

select ".xset.xuid" where not binding("com.example.property")


选择与无约束力的物产com.example.property的所有XSets。

在SQL某些操作员优先于询问的其他操作员。 XAM QL算符优先是如下:

优先次序操作员
1存在,只读, typeof,长度,捆绑, +, -
2= <>, >, >=, <>
3没有
4并且
5或者

同样优先次序的操作员在询问之内是被评估的左到右。 然而算符优先也许忽略使用括号如显示由以下例子。
select ".xset.xuid" where not "com.example.bool-prop" and  "com.example.int-prop" = 64
select ".xset.xuid" where not ("com.example.bool-prop" and "com.example.int-prop" = 64)


在第一个例子中,不是操作员只适用于com.example.bool支柱物产。 在第二个例子中,不是操作员适用于com.example.bool支柱和com.example.int支柱= 42

即然我们熟悉有些XAM QL句法,将被回答的下个问题是我们怎么告诉XAM存贮系统执行询问和退回结果到我们。 很好它结果询问被执行, XAM工作的一种特殊类型叫询问工作。 对询问工作的输入是您必须创造的XSet。 这XSet必须包含二个项目-总是被设置对`xam.job.query和XStream xam.job.query.com mand是UTF-8文本小河的领域org.snia.xam.job.com mand (MIME类型`文本或平原; charset=utf-8')包含实际询问表示串。

在工作的之前或之中,施行询问工作也许随意地做,但是这做没有需要。 能力做一个运行作业是任意和实施受抚养者。 应用可能确定是否做检查XSystem布尔物产支持工作.xsystem.job.com mit.supported。 在结束XSet意味之前询问工作的结果没有坚持地存放疏忽做询问工作。

询问工作通过祈求submitJob执行。 如果在询问工作XSet的二个需要的项目之一没有恰当地填写,标准工作错误领域.xam.job.error增加到询问工作XSet,并且它是价值被设置对任一org.snia.xam : :not_a_joborg.snia.xam : :unspecified_command和询问工作被放弃。 如下面试样应用所显示,询问工作的状态也许取决于审查.xam.job.status的价值。

当询问工作是成功的时,结果在询问工作XSet被存放以名为xam.job.query.results的新的XStream的形式。 这XStream有应用或vnd.snia.xam.query.xuid_list的一种MIME类型并且包含套的XUIDs XSets起因于询问的评估。 作为一个80-byte纪录一部分,每XUID在一个二进制格式被存放。 如果XUID比80个字节短,纪录是零被填塞对80个字节。

与结果XStream相关的一定数量的其他物产也被设定。 xam_int物产xam.job.query.results.count在结果XStream包含XUID纪录的当前计数。 这物产在询问处理期间,结果被输入结果XStream更新。 当询问工作执行,应用可能使用此提供状态信息给用户。 xam_string的物产xam.job.query.level表明匹配结果的询问水平。 它的价值是org.snia.xam.job.query.level.1org.snia.xam.job.query.level.2

记得是重要的询问工作在角色和允许之内经营被授予连接。 那意味对一种应用是可看见和容易接近的,至少从一个读的方面,根据角色在之下询问工作被执行的结果XStream只包括那些XSets。

询问工作也许设置在.xam.job.error的以下误差编码:

xam.job.query : :level_not_supportedXAM存贮系统无法支持在询问工作指定的询问水平。 一个非致命错误。
xam.job.query : :invalid_command_syntax一个非致命句法错误生成了,当解析询问串时
xam.job.query : :insufficient_permission当前验证的用户没有充足
允许执行询问工作
xam.job.query : :insufficient_resourcesXAM存贮系统没有完成的充足的资源询问工作

当询问工作无论什么原因时止步不前,和状态字段,即.xam.job.errorhealth.xam.job.status,设置标准工作健康合适价值,并且XAM存贮系统也许安置零或在结果XStream的更加另外的XUIDs。 因而应用应该总是看到在结果XStream的完全XUID价值。 一个止步不前的询问工作不支持恢复。

注意,不同于传统RDBMS,没有锁XAM存贮系统在询问工作时的施行。 因而询问结果不是XAM存贮系统的一张瞬间快照。 当询问工作被执行时, XAM存贮系统的内容也许或可能不改变。 一般规则是被存放了在询问工作开始前的所有XSet在结果XStream,如果它符合询问标准和存放了的任何XSet在结果XStream包括,在询问工作完成之后不将包括。 在询问工作施行时被存放的XSets也许或可能不是包括的。 同样标准适用于结果XStream。 它也许包括不再在XSets XAM存贮系统和XUIDs不再符合查寻标准由于在XSet上的一个变化XSets的XUIDs,在特殊性XSet被询问了之后。

这询问XAM存贮系统确定它是支持的水平XAM询问的一个简单的Java应用程序。

import org.snia.xam.XAMException;
import org.snia.xam.XAMLibrary;
import org.snia.xam.XSystem;
import org.snia.xam.toolkit.XAMXUID;
import org.snia.xam.util.XAMLibraryFactory;

public class CheckQuerySupport
{
    private static XAMLibrary xamLib;
    private static XSystem xSystem;

    public static void main(String[] args)
    {
        String xri = "snia-xam://centera_vim!XXX.XXXX.XXX.XXX?/home/fpm/xam/xamconnect.pea";

        long exitCode = 0;
        boolean isSupported = false;

        try
        {
            xamLib = XAMLibraryFactory.newXAMLibrary();
            System.out.println("Connecting to XSystem: " + xri + "\n");

            xSystem = xamLib.connect(xri);

            // support job commit?
            isSupported = xSystem.getBoolean(XSystem.XAM_XSYSTEM_JOB_COMMIT_SUPPORTED);
            System.out.println("Support job commit? " + (isSupported ? "Yes" : "No"));

            // support continuance of job?
            isSupported = xSystem.getBoolean(XSystem.XAM_XSYSTEM_JOB_QUERY_CONTINUANCE_SUPPORTED);
            System.out.println("Support job continuance? " + (isSupported ? "Yes" : "No"));

            // support level 1 query?
            isSupported = xSystem.getBoolean(XSystem.XAM_XSYSTEM_JOB_QUERY_LEVEL1_SUPPORTED);
            System.out.println("Support level 1 query? " + (isSupported ? "Yes" : "No"));

            // support level 2 query?
            isSupported = xSystem.getBoolean(XSystem.XAM_XSYSTEM_JOB_QUERY_LEVEL2_SUPPORTED);
            System.out.println("Support level 2 query? " + (isSupported ? "Yes" : "No"));

            xSystem.close();
            System.out.println("\nClosed connection to XSystem");

        } catch (XAMException xe) {
            exitCode = xe.getStatusCode();
            System.err.println("XAM Error occured: " + xe.getMessage());
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            exitCode = 1;
        }

        System.exit((int) exitCode);
    }
}


这从这种应用的产品,当连接到EMC Centera XAM存贮系统

Connecting to XSystem: snia-xam://centera_vim!XXX.XXX.XXX.XXX?/home/fpm/xam/xamconnect.pea

Support job commit? No
Support job continuance? No
Support level 1 query? Yes
Support level 2 query? No

Closed connection to XSystem


这实施三样品XSets和样品询问在XAM建筑学V1.0文件的被谈论第10.8部分的一个更长的Java应用程序。

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.snia.xam.XAMException;
import org.snia.xam.XAMLibrary;
import org.snia.xam.XSet;
import org.snia.xam.XStream;
import org.snia.xam.XSystem;
import org.snia.xam.XUID;
import org.snia.xam.toolkit.XAMXUID;
import org.snia.xam.util.XAMLibraryFactory;

public class QueryExample
{
    private static XAMLibrary xamLib;
    private static XSystem xSystem;

    private static void CreateXset(int parm1, String parm2, double parm3)
             throws XAMException
    {
        System.out.print("Create XSet 1 ....  ");

        XSet xSet = xSystem.createXSet(XSet.MODE_UNRESTRICTED);
        xSet.createProperty("com.example.rhc", false, true);
        xSet.createProperty("com,example.foo", false, parm1);
        xSet.createProperty("com.example.bar", false, parm2);
        xSet.createProperty("com.example.num", false, parm3);

        XUID xuID = xSet.commit();
        System.out.println("XUID: " + xuID.toString());

        xSet.close();
    }

   private static void CreateXset(int parm1, int parm2, int parm3)
             throws XAMException
    {
        System.out.print("Create XSet 2 ....  ");

        XSet xSet = xSystem.createXSet(XSet.MODE_UNRESTRICTED);
        xSet.createProperty("com.example.rhc", false, true);
        xSet.createProperty("com,example.foo", false, parm1);
        xSet.createProperty("com.example.bar", false, parm2);
        xSet.createProperty("com.example.num", false, parm3);

        XUID xuID = xSet.commit();
        System.out.println("XUID: " + xuID.toString());

        xSet.close();
    }

    private static void CreateXset(int parm1, int parm2)
             throws XAMException
    {
        System.out.print("Create XSet 3 ....  ");

        XSet xSet = xSystem.createXSet(XSet.MODE_UNRESTRICTED);
        xSet.createProperty("com.example.rhc", false, true);
        xSet.createProperty("com,example.foo", false, parm1);
        xSet.createProperty("com.example.num", false, parm2);

        XUID xuID = xSet.commit();
        System.out.println("XUID: " + xuID.toString());

        xSet.close();
    }

    private static void QueryXsystem(String queryString)
            throws XAMException
    {
        boolean finished = false;
        final int XAM_MAX_XUID = 80;
        int resultCount = 0;
        String status;

        System.out.println("Create query XSet. Query string: " + queryString);

        XSet query = xSystem.createXSet(XSet.MODE_UNRESTRICTED);
        query.createProperty(XSet.XAM_JOB_COMMAND, true, XSet.XAM_JOB_QUERY);

        byte[] buffer = queryString.getBytes();
        XStream queryStream = query.createXStream(XSet.XAM_JOB_QUERY_COMMAND, true, XAMLibrary.TEXT_PLAIN_MIME_TYPE);
        queryStream.write(buffer);
        queryStream.close();

        System.out.println("Submit query job ....");
        query.submitJob();

        System.out.println("Wait for query job to finish ....");

        while (!finished)
        {
            // check  status of query job
            status = query.getString(XSet.XAM_JOB_ERRORHEALTH);
            if (status.equals(XSet.XAM_JOB_ERRORHEALTH_ERROR))
            {
                System.out.println("ERROR: Errorhealth - " + query.getString(XSet.XAM_JOB_ERROR));
                query.haltJob();
                System.out.println("ERROR: Job halted");
                break;
            }

            status = query.getString(XSet.XAM_JOB_STATUS);
            resultCount = (int) query.getLong(XSet.XAM_JOB_QUERY_RESULTS_COUNT);

            // uncomment if you want continuous job status
            // System.out.println("Job Status: " + status + "  Result count: " + resultCount);

            // exit loop if job complete
            if (status.equals(XSet.XAM_JOB_STATUS_COMPLETE))
            {
                finished = true;
            }
       }

        System.out.println("Query job completed ....");
        System.out.println("Result set final count is: " + resultCount);

        if (resultCount > 0)
        {
             // open query job result stream
             XStream results = query.openXStream(XSet.XAM_JOB_QUERY_RESULTS, XStream.MODE_READ_ONLY);

             byte rawXUID[] = new byte[XAM_MAX_XUID];
             long bytesRead = 0;

             // output XUIDs in result set
             while( (bytesRead = results.read(rawXUID, XAM_MAX_XUID)) >= 0 )
             {
                 XAMXUID resultXUID = new XAMXUID(rawXUID);
                 System.out.println("XUID: " + resultXUID.toString());
             }

             results.close();
        }

        query.close();
    }

    public static void main(String[] args)
    {
        String xri = "snia-xam://centera_vim!XXX.XXX.XXX.XXX?/home/fpm/xam/xamconnect.pea";
        long exitCode = 0;

        try
        {
            xamLib = XAMLibraryFactory.newXAMLibrary();

            // uncomment next 2 lines if you want extensive XAM Library logging
            // xamLib.setProperty(XAMLibrary.XAM_LOG_VERBOSITY, 1);
            // xamLib.setProperty(XAMLibrary.XAM_LOG_LEVEL, 5);

            System.out.println("Connecting to XSystem " +  xri + "\n");

            xSystem = xamLib.connect(xri);
            xSystem.setProperty(".xsystem.log.verbosity", 1);
            xSystem.setProperty(".xsystem.log.level", 5);

            CreateXset(1, "string", 123.55);
            CreateXset(77, 42, 100);
            CreateXset(6, 200);

            xSystem.close();

            System.out.println("\nClose/reopen XSystem\n");

            xSystem = xamLib.connect(xri);

            // uncomment one or more of the following queries
            // QueryXsystem("select \".xset.xuid\"");
            QueryXsystem("select \".xset.xuid\" where (\"com.example.foo\" > 0) and (\"com.example.foo\" < 50)");
            // QueryXsystem("select \".xset.xuid\" where (\"com.example.bar\" > 0) and (\"com.example.bar\" < 100)");
            // QueryXsystem("select \".xset.xuid\" where exists (\"com.example.bar\")");
            // QueryXsystem("select \".xset.xuid\" where \"com.example.bar\" like '%ing%'");
            // QueryXsystem("select \".xset.xuid\" where \"com.example.num\" >= 124");
            // QueryXsystem("select \".xset.xuid\" where \"com.example.num\" >= 124.6 ");
            // QueryXsystem("select \".xset.xuid\" where (\"com.example.num\" >= 123) and typeof(\"com.example.num\") = 'application/vnd.snia.xam.int'");

            xSystem.close();
            System.out.println("\nClosed connection to XSystem");

        } catch (XAMException xe) {
            exitCode = xe.getStatusCode();
            System.err.println("XAM Error occured: " + xe.getMessage() + "("
                    + exitCode + ")");
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            exitCode = -1;
        }

        System.exit((int) exitCode);
    }
}


注意结果询问工作生产的XStream也许由应用消耗,在XAM存贮系统完成存放所有XUIDs在结果XStream之前,如果XStream.asyncRead使用而不是XStream.read

很好我认为我提供足够的信息和例子使您单独去与XAM查询语言的戏剧。 它您需要的帮助我肯定在 Google小组的 XAM开发商小组更比愉快将是帮助您。

在分割我指出,因为XAM存贮只当前要求系统提供者实施支持在美满的变数据的询问,我怀疑支持使用XAM的实际充分基于内容的查寻可能不有一段时间了发生。

评论是闭合的。