Package org.zorbaxquery.api

Examples of org.zorbaxquery.api.Item


    // execute query and get iterator
    Iterator iter = xquery.iterator();
    iter.open();

    // loop over all items
    Item item = new Item();
    Text keyData = new Text();
    keyData.set("zero");
    Text valueData = new Text();
    while (iter.next(item)) {
      String itemStr = item.serialize();
      itemStr = itemStr.substring(39,itemStr.length());
      if (itemStr.startsWith("<key>")) {
        keyData.set(itemStr);
      } else {
        valueData.set(itemStr);
        System.out.println("ZorbaReducer: Emmitting:" + keyData.toString() + "," + valueData.toString());
        // log.info("Emmitting:" + keyData.toString() + "," +
        // valueData.toString());
        try {
          // Context not null
          if (context != null) {
            context.write(keyData, valueData);
          }
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }

    // clean up
    iter.close();
    iter.destroy();
    iter.delete();
    item.delete();
   
    xquery.destroy();
    xquery.delete();
    zorba.shutdown();
    InMemoryStore.shutdown(store);
View Full Code Here


       
    System.err.println("ZorbaMapper: Received Key: " + key.toString() + " Received Value: " + value.toString());
    //log.info("Received Key: " + key.toString() + " Received Value: " + value.toString());
   
   
    Item i = xData.parseDocument(value.toString());
   
   
   
    // bind key
    xquery.setVariableAsDocument(XadoopUtil.XADOOP_KEY, "key.xml", "<key>"+key.toString()+"</key>");
   
     
    // bind value
    xquery.setVariableAsDocument(XadoopUtil.XADOOP_VALUE, "value.xml", "<frame>"+value.toString()+"</frame>");
    System.err.println("ZorbaMapper: binding value: " + value);
    //log.info("binding value: " + value.toString());

    // execute query and get iterator
    Iterator iter = xquery.iterator();
    iter.open();
   
    //loop over all items.
    Item item = new Item();
    Text keyData = new Text();
       
    keyData.set("zero");
    Text valueData = new Text();
    while (iter.next(item)) {
      String itemStr = item.serialize();
      itemStr = itemStr.substring(39,itemStr.length());
      if (itemStr.startsWith("<key>")) {
        keyData.set(itemStr);
      } else {
        valueData.set(itemStr);

        // TODO could be debug
        System.err.println("ZorbaMapper: Emmitting:" + keyData.toString() + "," + valueData.toString());
        //log.info("Emmitting:" + keyData.toString() + "," + valueData.toString());
        try {
          // Context not null
          if (context != null) {
            // this collects the key value pairs - hopefully
            context.write(keyData, valueData);
          }
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }

    // clean up
    iter.close();
    iter.destroy();
    iter.delete();
    item.delete();
   
    xquery.destroy();
    xquery.delete();
    zorba.shutdown();
    InMemoryStore.shutdown(store);
View Full Code Here

    Zorba zorba = Zorba.getInstance(store);
    XQuery xquery = zorba.compileQuery("declare variable $input external; for $x in $input//b return $x");
    xquery.setVariableAsDocument("input", "test.xml", "<a><b>Hallo</b><b>Lukas</b><b>1</b></a>");
    Iterator iter = xquery.iterator();
    iter.open();
    Item item = new Item();
    while(iter.next(item)){
      String test = item.getStringValue();
      System.out.println(test);
    }
    iter.close();
    iter.destroy();
    xquery.destroy();
View Full Code Here

    String query = "declare variable $test external;" + "$test//b";
    XQuery xquery = zorba.compileQuery(query);
    xquery.setVariableAsDocument("test", filename, value);
    Iterator iter = xquery.iterator();
    iter.open();
    Item item = new Item();
    while (iter.next(item)) {
      String itemStr = item.serialize();
      System.out.println(itemStr);
    }
    // clean up
    iter.close();
    iter.destroy();
View Full Code Here

TOP

Related Classes of org.zorbaxquery.api.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.