private ReadResult translate(Column current) {
   byte[] name = current.getName();
   byte[] value = current.getValue();
   Object time = meta.getIdColumnMeta().convertFromStorage2(name);
   Object val = colMeta.convertFromStorage2(value);
   // TODO:  parameterize timeColumn and valueColumn from options
   TSRelational tv = new TSRelational("time", "value");
   tv.put("time", time);
   tv.put(colMeta.getColumnName(), val);
   return new ReadResult(url, tv);
 }
Esempio n. 2
0
  public static void indexTable(
      SecureTable t, DboTableMeta tableMeta, Collection<SolrInputDocument> solrDocs)
      throws IOException, SAXException, ParserConfigurationException, SolrServerException {
    // Solr server instance
    SolrServer solrServer = Search.getSolrServer();
    // Add this new table to the meta index...
    createCoreIfNeeded("databusmeta", "databusmeta", solrServer);
    SolrInputDocument doc = new SolrInputDocument();

    // Add special fields to track the type of record an the primary
    // key.
    doc.addField("id", t.getTableName());
    doc.addField("type", "table");
    if (t.getCreator() != null) doc.addField("creator_texts", t.getCreator().getUsername());
    doc.addField("description_texts", t.getDescription());
    if (t.getSchema() != null) {
      doc.addField("database_texts", t.getSchema().getSchemaName());
      doc.addField("databaseDescription_texts", t.getSchema().getDescription());
    }
    if (t.isSearchable()) doc.addField("isSearchable_texts", "true");
    else doc.addField("isSearchable_texts", "false");

    Set<String> allTermsSet = new HashSet<String>();
    Set<String> columnsSet = new HashSet<String>();

    for (DboColumnMeta m : tableMeta.getAllColumns()) {
      SdiColumn sdicol = t.getNameToField().get(m.getColumnName());
      columnsSet.add(sdicol.getColumnName());
    }

    doc.addField("column_texts", columnsSet);

    allTermsSet.add((String) doc.getField("id").getValue());
    allTermsSet.add((String) doc.getField("type").getValue());
    allTermsSet.add((String) doc.getField("description_texts").getValue());

    allTermsSet.addAll(columnsSet);
    if (doc.getField("database_texts") != null) {
      allTermsSet.add((String) doc.getField("database_texts").getValue());
      allTermsSet.add((String) doc.getField("databaseDescription_texts").getValue());
    }
    doc.addField("allTerms_texts", allTermsSet);

    solrDocs.add(doc);
    // Create the core for data from this table to be indexed into when data is posted to this table
    if (t.isSearchable()) createCoreIfNeeded(t.getTableName(), t.getTableName(), solrServer);
  }