コード例 #1
0
ファイル: ProjectIntoNode.java プロジェクト: skethire/teiid
 private void closeRequest() {
   if (this.buffer != null) {
     this.buffer.remove();
     this.buffer = null;
   }
   if (this.tupleSource != null) {
     tupleSource.closeSource();
     this.tupleSource = null;
   }
 }
コード例 #2
0
  public Object lookupCodeValue(
      CommandContext context,
      String codeTableName,
      String returnElementName,
      String keyElementName,
      Object keyValue)
      throws BlockedException, TeiidComponentException, TeiidProcessingException {
    // we are not using a resolved form of a lookup, so we canonicallize with upper case
    codeTableName = codeTableName.toUpperCase();
    keyElementName = keyElementName.toUpperCase();
    returnElementName = returnElementName.toUpperCase();
    String matTableName =
        CODE_PREFIX
            + codeTableName
            + ElementSymbol.SEPARATOR
            + keyElementName
            + ElementSymbol.SEPARATOR
            + returnElementName;

    TupleSource ts = context.getCodeLookup(matTableName, keyValue);
    if (ts == null) {
      QueryMetadataInterface metadata = context.getMetadata();

      TempMetadataID id =
          context
              .getGlobalTableStore()
              .getCodeTableMetadataId(
                  codeTableName, returnElementName, keyElementName, matTableName);

      ElementSymbol keyElement = new ElementSymbol(keyElementName, new GroupSymbol(matTableName));
      ElementSymbol returnElement =
          new ElementSymbol(returnElementName, new GroupSymbol(matTableName));
      keyElement.setType(
          DataTypeManager.getDataTypeClass(
              metadata.getElementType(
                  metadata.getElementID(
                      codeTableName + ElementSymbol.SEPARATOR + keyElementName))));
      returnElement.setType(
          DataTypeManager.getDataTypeClass(
              metadata.getElementType(
                  metadata.getElementID(
                      codeTableName + ElementSymbol.SEPARATOR + returnElementName))));

      Query query =
          RelationalPlanner.createMatViewQuery(
              id, matTableName, Arrays.asList(returnElement), true);
      query.setCriteria(
          new CompareCriteria(keyElement, CompareCriteria.EQ, new Constant(keyValue)));

      ts = registerQuery(context, context.getTempTableStore(), query);
    }
    try {
      List<?> row = ts.nextTuple();
      Object result = null;
      if (row != null) {
        result = row.get(0);
      }
      ts.closeSource();
      return result;
    } catch (BlockedException e) {
      context.putCodeLookup(matTableName, keyValue, ts);
      throw e;
    }
  }
コード例 #3
0
 @Override
 public void closeSource() {
   if (actual != null) {
     actual.closeSource();
   }
 }