翻譯

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
Linux仁發展(第3編輯)的圖像
XSLT 2.0和XPath 2.0程序参考(對程序員的程序員的)圖像
先進編程在UNIX環境,再版(阿狄森-維斯利專家計算的系列)的圖像
機器人無線应用開发的圖像

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的實際充分基於內容的查尋可能不有一段時間了發生。

評論是閉合的。