Package com.linkedin.helix.josql

Examples of com.linkedin.helix.josql.ZNRecordQueryProcessor$ZNRecordTupleReader


  {
    HelixManager manager = ((TestHelper.StartCMResult) (_startCMResultMap.values().toArray()[0]))._manager;

    DataAccessorBasedTupleReader tupleReader = new DataAccessorBasedTupleReader(manager.getHelixDataAccessor(), manager.getClusterName());

    ZNRecordQueryProcessor queryProcessor = new ZNRecordQueryProcessor();

    String partition = TEST_DB + "_4";

    String sql = "select T2.instance, T1.listIndex, T2.id from " +
    "explodeList(IDEALSTATES," + partition + ") as T1 join " +
     "LIVEINSTANCES as T2 using (T1.listVal, T2.id)";
    List<ZNRecord> result = queryProcessor.execute(sql, tupleReader);
    System.out.println(result);
    Assert.assertEquals(result.size(), 3);
  }
View Full Code Here


      Builder kb = accessor.keyBuilder();
      accessor.setProperty(kb.healthReport(instance, "scnTable"), new HealthStat(scnRecord));
    }

    ZNRecordQueryProcessor processor = new ZNRecordQueryProcessor();
    DataAccessorBasedTupleReader tupleReader = new DataAccessorBasedTupleReader(accessor, manager.getClusterName());

    String scnTableQuery = "SELECT T1.instance as instance, T1.mapField as partition, T1.gen as gen, T1.seq as seq " +
            "FROM explodeMap(`INSTANCES/*/HEALTHREPORT/scnTable`) AS T1" +
            " JOIN LIVEINSTANCES as T2 using (T1.instance, T2.id)";
    List<ZNRecord> scnTable = processor.execute(scnTableQuery, tupleReader);
    tupleReader.setTempTable("scnTable", scnTable);

    String rankQuery = "SELECT instance, partition, gen, seq, T1.listIndex AS instanceRank " +
            " FROM scnTable JOIN explodeList(`IDEALSTATES/" + TEST_DB + "`) AS T1 " +
                    "USING (scnTable.instance, T1.listVal) WHERE scnTable.partition=T1.listField";
    List<ZNRecord> rankTable = processor.execute(rankQuery, tupleReader);
    System.out.println(rankTable.size());
    tupleReader.setTempTable("rankTable", rankTable);

    String masterSelectionQuery = "SELECT instance, partition, instanceRank, gen, (T.maxSeq-seq) AS seqDiff, seq FROM rankTable JOIN " +
            " (SELECT partition, max(to_number(seq)) AS maxSeq FROM rankTable GROUP BY partition) AS T USING(rankTable.partition, T.partition) " +
            " WHERE to_number(seqDiff) < 10 " +
            " ORDER BY partition, to_number(gen) desc, to_number(instanceRank), to_number(seqDiff)";

    List<ZNRecord> masterSelectionTable = processor.execute(masterSelectionQuery, tupleReader);
    System.out.println(masterSelectionTable.size());
    for(ZNRecord record : masterSelectionTable)
    {
      System.out.println(record);
    }
View Full Code Here

TOP

Related Classes of com.linkedin.helix.josql.ZNRecordQueryProcessor$ZNRecordTupleReader

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.