コード例 #1
0
  private DocIndexMetaData docIndexMetaData() {
    DocIndexMetaData docIndexMetaData;
    String templateName = PartitionName.templateName(ident.schema(), ident.name());
    boolean createdFromTemplate = false;
    if (metaData.getTemplates().containsKey(templateName)) {
      docIndexMetaData = buildDocIndexMetaDataFromTemplate(ident.indexName(), templateName);
      createdFromTemplate = true;
      concreteIndices =
          metaData.concreteIndices(IndicesOptions.lenientExpandOpen(), ident.indexName());
    } else {
      try {
        concreteIndices =
            metaData.concreteIndices(IndicesOptions.strictExpandOpen(), ident.indexName());
        if (concreteIndices.length == 0) {
          // no matching index found
          throw new TableUnknownException(ident);
        }
        docIndexMetaData = buildDocIndexMetaData(concreteIndices[0]);
      } catch (IndexMissingException ex) {
        throw new TableUnknownException(ident.fqn(), ex);
      }
    }

    if ((!createdFromTemplate && concreteIndices.length == 1) || !checkAliasSchema) {
      return docIndexMetaData;
    }
    for (int i = 0; i < concreteIndices.length; i++) {
      try {
        docIndexMetaData =
            docIndexMetaData.merge(
                buildDocIndexMetaData(concreteIndices[i]),
                transportPutIndexTemplateAction,
                createdFromTemplate);
      } catch (IOException e) {
        throw new UnhandledServerException("Unable to merge/build new DocIndexMetaData", e);
      }
    }
    return docIndexMetaData;
  }
コード例 #2
0
  public DocTableInfo build() {
    DocIndexMetaData md = docIndexMetaData();

    List<PartitionName> partitions = new ArrayList<>();
    if (md.partitionedBy().size() > 0) {
      for (String index : concreteIndices) {
        if (PartitionName.isPartition(index)) {
          try {
            PartitionName partitionName = PartitionName.fromIndexOrTemplate(index);
            assert partitionName.tableIdent().equals(ident);
            partitions.add(partitionName);
          } catch (IllegalArgumentException e) {
            // ignore
            logger.warn(
                String.format(
                    Locale.ENGLISH,
                    "Cannot build partition %s of index %s",
                    index,
                    ident.indexName()));
          }
        }
      }
    }
    return new DocTableInfo(
        ident,
        md.columns(),
        md.partitionedByColumns(),
        md.generatedColumnReferences(),
        md.indices(),
        md.references(),
        md.analyzers(),
        md.primaryKey(),
        md.routingCol(),
        md.isAlias(),
        md.hasAutoGeneratedPrimaryKey(),
        concreteIndices,
        clusterService,
        md.numberOfShards(),
        md.numberOfReplicas(),
        md.tableParameters(),
        md.partitionedBy(),
        partitions,
        md.columnPolicy(),
        executorService);
  }