@Override public String getName() { return type.getName(); }
public String createTable(String fromTableName, String joinTableName, String query, BStructureType tableType, BValueArray params) { String newTableName = TableConstants.TABLE_PREFIX + tableType.getName().toUpperCase() + "_" + getTableID(); String sqlStmt = query.replaceFirst(TableConstants.TABLE_NAME_REGEX, fromTableName); if (joinTableName != null && !joinTableName.isEmpty()) { sqlStmt = sqlStmt.replaceFirst(TableConstants.TABLE_NAME_REGEX, joinTableName); } sqlStmt = generateCreateTableStatment(sqlStmt, newTableName); prepareAndExecuteStatement(sqlStmt, params); return newTableName; }
private void updateAttachFunctionInfo(PackageInfo packageInfo, BType attachedType, String funcName, FunctionInfo functionInfo) throws IOException { // Append the receiver type to the parameter types. This is done because in the VM, // first parameter will always be the attached type. These param types will be used // to allocate worker local data. // This is the only place where we append the receiver to the params. BType[] paramTypes = Stream.concat(Stream.of(functionInfo.attachedToType), Stream.of(functionInfo.getParamTypes())) .toArray(BType[]::new); functionInfo.setParamTypes(paramTypes); if (attachedType.getTag() != TypeTags.OBJECT_TYPE_TAG && attachedType.getTag() != TypeTags.RECORD_TYPE_TAG) { return; } //Update the attachedFunctionInfo String objectInit; BStructureType structType = (BStructureType) attachedType; if (attachedType.getTag() == TypeTags.OBJECT_TYPE_TAG) { objectInit = CONSTRUCTOR_FUNCTION_SUFFIX; } else { objectInit = structType.getName() + INIT_FUNCTION_SUFFIX; } StructureTypeInfo typeInfo = (StructureTypeInfo) structType.getTypeInfo(); typeInfo.funcInfoEntries.put(funcName, functionInfo); // Setting the object initializer if (objectInit.equals(funcName)) { typeInfo.initializer = functionInfo; } }
public void addData(BMap<String, BValue> data, Context context) { if (data.getType() != this.constraintType) { throw new BallerinaException("incompatible types: record of type:" + data.getType().getName() + " cannot be added to a table with type:" + this.constraintType.getName()); } tableProvider.insertData(tableName, data); reset(); }
throw new BallerinaException("incompatible types: function with record type:" + functionInputType.getName() + " cannot be used to remove records from a table with type:" + this.constraintType.getName());