Tabnine Logo
IFunctionDescriptor
Code IndexAdd Tabnine to your IDE (free)

How to use
IFunctionDescriptor
in
org.apache.asterix.om.functions

Best Java code snippets using org.apache.asterix.om.functions.IFunctionDescriptor (Showing top 20 results out of 315)

origin: apache/asterixdb

  @Override
  public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context,
      CompilerProperties compilerProps) throws AlgebricksException {
    AbstractFunctionCallExpression funCallExpr = (AbstractFunctionCallExpression) expr;
    Object[] samplingParameters = funCallExpr.getOpaqueParameters();
    fd.setImmutableStates(samplingParameters[0]);
  }
};
origin: apache/asterixdb

protected IFunctionDescriptor createCastFunction(boolean strictCast) throws AlgebricksException {
  IFunctionDescriptor castFuncDesc = metadataProvider.getFunctionManager()
      .lookupFunction(strictCast ? BuiltinFunctions.CAST_TYPE : BuiltinFunctions.CAST_TYPE_LAX);
  castFuncDesc.setSourceLocation(sourceLoc);
  castFuncDesc.setImmutableStates(enforcedItemType, itemType);
  return castFuncDesc;
}
origin: apache/asterixdb

  @Override
  public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context,
      CompilerProperties compilerProps) throws AlgebricksException {
    AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
    IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
    ATypeTag typeTag = t.getTypeTag();
    switch (typeTag) {
      case OBJECT: {
        fd.setImmutableStates(t);
        break;
      }
      case ANY: {
        fd.setImmutableStates(RecordUtil.FULLY_OPEN_RECORD_TYPE);
        break;
      }
      default: {
        if (strict) {
          throw new NotImplementedException(fd.getIdentifier().getName() + " for data of type " + t);
        } else {
          fd.setImmutableStates(new Object[] { null });
        }
        break;
      }
    }
  }
}
origin: apache/asterixdb

@Override
public IAggregateEvaluatorFactory createAggregateFunctionFactory(AggregateFunctionCallExpression expr,
    IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)
    throws AlgebricksException {
  IScalarEvaluatorFactory[] args = codegenArguments(expr, env, inputSchemas, context);
  IFunctionDescriptor fd = resolveFunction(expr, env, context);
  switch (fd.getFunctionDescriptorTag()) {
    case SERIALAGGREGATE:
      return null;
    case AGGREGATE:
      return fd.createAggregateEvaluatorFactory(args);
    default:
      throw new IllegalStateException(
          "Invalid function descriptor " + fd.getFunctionDescriptorTag() + " expected "
              + FunctionDescriptorTag.SERIALAGGREGATE + " or " + FunctionDescriptorTag.AGGREGATE);
  }
}
origin: apache/asterixdb

@Override
public ISerializedAggregateEvaluatorFactory createSerializableAggregateFunctionFactory(
    AggregateFunctionCallExpression expr, IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas,
    JobGenContext context) throws AlgebricksException {
  IScalarEvaluatorFactory[] args = codegenArguments(expr, env, inputSchemas, context);
  IFunctionDescriptor fd = resolveFunction(expr, env, context);
  switch (fd.getFunctionDescriptorTag()) {
    case AGGREGATE: {
      if (BuiltinFunctions.isAggregateFunctionSerializable(fd.getIdentifier())) {
        AggregateFunctionCallExpression serialAggExpr = BuiltinFunctions
            .makeSerializableAggregateFunctionExpression(fd.getIdentifier(), expr.getArguments());
        IFunctionDescriptor afdd = resolveFunction(serialAggExpr, env, context);
        return afdd.createSerializableAggregateEvaluatorFactory(args);
      } else {
        throw new AlgebricksException(
            "Trying to create a serializable aggregate from a non-serializable aggregate function descriptor. (fi="
                + expr.getFunctionIdentifier() + ")");
      }
    }
    case SERIALAGGREGATE: {
      return fd.createSerializableAggregateEvaluatorFactory(args);
    }
    default:
      throw new IllegalStateException(
          "Invalid function descriptor " + fd.getFunctionDescriptorTag() + " expected "
              + FunctionDescriptorTag.SERIALAGGREGATE + " or " + FunctionDescriptorTag.AGGREGATE);
  }
}
origin: apache/asterixdb

        new ConstantEvalFactory(Arrays.copyOf(abvs.getByteArray(), abvs.getLength()));
    IFunctionDescriptor fDesc = functionManager.lookupFunction(BuiltinFunctions.FIELD_ACCESS_BY_INDEX);
    fDesc.setSourceLocation(sourceLoc);
    fDesc.setImmutableStates(recType);
    return fDesc.createEvaluatorFactory(
        new IScalarEvaluatorFactory[] { recordEvalFactory, fldIndexEvalFactory });
      new ConstantEvalFactory(Arrays.copyOf(abvs.getByteArray(), abvs.getLength()));
  IFunctionDescriptor fDesc = functionManager.lookupFunction(BuiltinFunctions.FIELD_ACCESS_BY_NAME);
  fDesc.setSourceLocation(sourceLoc);
  return fDesc.createEvaluatorFactory(
      new IScalarEvaluatorFactory[] { recordEvalFactory, fldNameEvalFactory });
fDesc.setSourceLocation(sourceLoc);
fDesc.setImmutableStates(recType, fldName);
return fDesc.createEvaluatorFactory(new IScalarEvaluatorFactory[] { recordEvalFactory });
origin: apache/asterixdb

@Test
public void testCastLax() throws Exception {
  IFunctionDescriptor funcDesc = CastTypeLaxDescriptor.FACTORY.createFunctionDescriptor();
  funcDesc.setImmutableStates(targetType, inType);
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  AObjectSerializerDeserializer serDe = AObjectSerializerDeserializer.INSTANCE;
  serDe.serialize(inValue, new DataOutputStream(baos));
  ConstantEvalFactory argEvalFactory = new ConstantEvalFactory(baos.toByteArray());
  IScalarEvaluatorFactory evalFactory =
      funcDesc.createEvaluatorFactory(new IScalarEvaluatorFactory[] { argEvalFactory });
  IHyracksTaskContext ctx = mock(IHyracksTaskContext.class);
  IScalarEvaluator evaluator = evalFactory.createScalarEvaluator(ctx);
  VoidPointable resultPointable = new VoidPointable();
  evaluator.evaluate(null, resultPointable);
  ByteArrayInputStream bais = new ByteArrayInputStream(resultPointable.getByteArray(),
      resultPointable.getStartOffset(), resultPointable.getLength());
  IAObject resultValue = serDe.deserialize(new DataInputStream(bais));
  Assert.assertTrue(String.format("Expected: %s, actual: %s", targetValue, resultValue),
      targetValue.deepEqual(resultValue));
}
origin: apache/asterixdb

private IScalarEvaluatorFactory createScalarFunctionEvaluatorFactory(AbstractFunctionCallExpression expr,
    IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)
    throws AlgebricksException {
  IScalarEvaluatorFactory[] args = codegenArguments(expr, env, inputSchemas, context);
  IFunctionDescriptor fd = expr.getFunctionInfo() instanceof IExternalFunctionInfo
      ? ExternalFunctionDescriptorProvider.getExternalFunctionDescriptor(
          (IExternalFunctionInfo) expr.getFunctionInfo(), (ICcApplicationContext) context.getAppContext())
      : resolveFunction(expr, env, context);
  return fd.createEvaluatorFactory(args);
}
origin: apache/asterixdb

  private IFunctionDescriptor resolveFunction(AbstractFunctionCallExpression expr, IVariableTypeEnvironment env,
      JobGenContext context) throws AlgebricksException {
    FunctionIdentifier fnId = expr.getFunctionIdentifier();
    IFunctionDescriptor fd = functionManager.lookupFunction(fnId);
    fd.setSourceLocation(expr.getSourceLocation());
    IFunctionTypeInferer fnTypeInfer = functionManager.lookupFunctionTypeInferer(fnId);
    if (fnTypeInfer != null) {
      CompilerProperties compilerProps = ((IApplicationContext) context.getAppContext()).getCompilerProperties();
      fnTypeInfer.infer(expr, fd, env, compilerProps);
    }
    return fd;
  }
}
origin: apache/asterixdb

public FunctionManager(FunctionCollection functionCollection) {
  Map<Pair<FunctionIdentifier, Integer>, IFunctionDescriptorFactory> functionsMap = new HashMap<>();
  Map<FunctionIdentifier, IFunctionTypeInferer> typeInferersMap = new HashMap<>();
  for (IFunctionDescriptorFactory descriptorFactory : functionCollection.getFunctionDescriptorFactories()) {
    FunctionIdentifier fid = descriptorFactory.createFunctionDescriptor().getIdentifier();
    functionsMap.put(new Pair<>(fid, fid.getArity()), descriptorFactory);
    IFunctionTypeInferer typeInferer = descriptorFactory.createFunctionTypeInferer();
    if (typeInferer != null) {
      typeInferersMap.put(fid, typeInferer);
    }
  }
  this.functions = functionsMap;
  this.typeInferers = typeInferersMap;
}
origin: apache/asterixdb

@Override
public IRunningAggregateEvaluatorFactory createRunningAggregateFunctionFactory(StatefulFunctionCallExpression expr,
    IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)
    throws AlgebricksException {
  IScalarEvaluatorFactory[] args = codegenArguments(expr, env, inputSchemas, context);
  return resolveFunction(expr, env, context).createRunningAggregateEvaluatorFactory(args);
}
origin: apache/asterixdb

        new ConstantEvalFactory(Arrays.copyOf(abvs.getByteArray(), abvs.getLength()));
    IFunctionDescriptor fDesc = functionManager.lookupFunction(BuiltinFunctions.FIELD_ACCESS_BY_INDEX);
    fDesc.setSourceLocation(sourceLoc);
    fDesc.setImmutableStates(recType);
    IScalarEvaluatorFactory evalFactory = fDesc.createEvaluatorFactory(
        new IScalarEvaluatorFactory[] { recordEvalFactory, fldIndexEvalFactory });
    IFunctionInfo finfoAccess =
fDesc.setSourceLocation(sourceLoc);
fDesc.setImmutableStates(recType, fldName);
IScalarEvaluatorFactory evalFactory =
    fDesc.createEvaluatorFactory(new IScalarEvaluatorFactory[] { recordEvalFactory });
IFunctionInfo finfoAccess = BuiltinFunctions.getAsterixFunctionInfo(BuiltinFunctions.FIELD_ACCESS_NESTED);
origin: apache/asterixdb

protected AlgebricksMetaOperatorDescriptor createCastOp(JobSpecification spec, DatasetType dsType,
    boolean strictCast) throws AlgebricksException {
  int[] outColumns = new int[1];
  int[] projectionList = new int[(dataset.hasMetaPart() ? 2 : 1) + numPrimaryKeys];
  int recordIdx;
  //external datascan operator returns a record as the first field, instead of the last in internal case
  if (dsType == DatasetType.EXTERNAL) {
    recordIdx = 0;
    outColumns[0] = 0;
  } else {
    recordIdx = numPrimaryKeys;
    outColumns[0] = numPrimaryKeys;
  }
  for (int i = 0; i <= numPrimaryKeys; i++) {
    projectionList[i] = i;
  }
  if (dataset.hasMetaPart()) {
    projectionList[numPrimaryKeys + 1] = numPrimaryKeys + 1;
  }
  IScalarEvaluatorFactory[] castEvalFact =
      new IScalarEvaluatorFactory[] { new ColumnAccessEvalFactory(recordIdx) };
  IScalarEvaluatorFactory[] sefs = new IScalarEvaluatorFactory[1];
  sefs[0] = createCastFunction(strictCast).createEvaluatorFactory(castEvalFact);
  AssignRuntimeFactory castAssign = new AssignRuntimeFactory(outColumns, sefs, projectionList);
  castAssign.setSourceLocation(sourceLoc);
  return new AlgebricksMetaOperatorDescriptor(spec, 1, 1, new IPushRuntimeFactory[] { castAssign },
      new RecordDescriptor[] { enforcedRecDesc });
}
origin: apache/asterixdb

  @Override
  public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context,
      CompilerProperties compilerProps) throws AlgebricksException {
    fd.setImmutableStates(context.getType(expr));
  }
};
origin: apache/asterixdb

@Override
protected AlgebricksMetaOperatorDescriptor createCastOp(JobSpecification spec, DatasetType dsType,
    boolean strictCast) throws AlgebricksException {
  int[] outColumns = new int[1];
  // tags(2) + primary keys + record + meta part(?)
  int[] projectionList = new int[NUM_TAG_FIELDS + (dataset.hasMetaPart() ? 2 : 1) + numPrimaryKeys];
  int recordIdx = NUM_TAG_FIELDS + numPrimaryKeys;
  //here we only consider internal dataset
  assert dsType == DatasetType.INTERNAL;
  outColumns[0] = NUM_TAG_FIELDS + numPrimaryKeys;
  int projCount = 0;
  for (int i = 0; i < NUM_TAG_FIELDS; i++) {
    projectionList[projCount++] = i;
  }
  //set primary keys and the record
  for (int i = 0; i <= numPrimaryKeys; i++) {
    projectionList[projCount++] = NUM_TAG_FIELDS + i;
  }
  if (dataset.hasMetaPart()) {
    projectionList[NUM_TAG_FIELDS + numPrimaryKeys + 1] = NUM_TAG_FIELDS + numPrimaryKeys + 1;
  }
  IScalarEvaluatorFactory[] castEvalFact =
      new IScalarEvaluatorFactory[] { new ColumnAccessEvalFactory(recordIdx) };
  IScalarEvaluatorFactory[] sefs = new IScalarEvaluatorFactory[1];
  sefs[0] = createCastFunction(strictCast).createEvaluatorFactory(castEvalFact);
  AssignRuntimeFactory castAssign = new AssignRuntimeFactory(outColumns, sefs, projectionList);
  castAssign.setSourceLocation(sourceLoc);
  return new AlgebricksMetaOperatorDescriptor(spec, 1, 1, new IPushRuntimeFactory[] { castAssign },
      new RecordDescriptor[] { getTaggedRecordDescriptor(enforcedRecDesc) });
}
origin: apache/asterixdb

  @Override
  public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context,
      CompilerProperties compilerProps) {
    fd.setImmutableStates(compilerProps.getStringOffset());
  }
};
origin: apache/asterixdb

  @Override
  public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context,
      CompilerProperties compilerProps) throws AlgebricksException {
    AbstractFunctionCallExpression funCallExpr = (AbstractFunctionCallExpression) expr;
    Object[] sortingParameters = funCallExpr.getOpaqueParameters();
    fd.setImmutableStates(sortingParameters[0], sortingParameters[1]);
  }
};
origin: apache/asterixdb

@Override
public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context,
    CompilerProperties compilerProps) throws AlgebricksException {
  ARecordType rt = (ARecordType) context.getType(expr);
  fd.setImmutableStates(rt, computeOpenFields((AbstractFunctionCallExpression) expr, rt));
}
origin: apache/asterixdb

  @Override
  public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context,
      CompilerProperties compilerProps) throws AlgebricksException {
    AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
    IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
    fd.setImmutableStates(TypeComputeUtils.getActualType(t));
  }
};
origin: apache/asterixdb

  @Override
  public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context,
      CompilerProperties compilerProps) throws AlgebricksException {
    AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
    IAType rt = TypeCastUtils.getRequiredType(funcExpr);
    IAType it = (IAType) context.getType(funcExpr.getArguments().get(0).getValue());
    fd.setImmutableStates(rt, it);
  }
}
org.apache.asterix.om.functionsIFunctionDescriptor

Most used methods

  • createEvaluatorFactory
  • setImmutableStates
  • setSourceLocation
  • getIdentifier
  • createAggregateEvaluatorFactory
  • createRunningAggregateEvaluatorFactory
  • createSerializableAggregateEvaluatorFactory
  • createUnnestingEvaluatorFactory
  • getFunctionDescriptorTag

Popular in Java

  • Making http post requests using okhttp
  • getSystemService (Context)
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • JComboBox (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now