You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the "License"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#frompywy.orchestrator.planimportDescriptorfrompywy.orchestrator.dataquantaimportDataQuantaBuilderimportdatetime# Returns the Sink Executable Dataquanta of a DEMO plandefplan_sort(descriptor):
plan=DataQuantaBuilder(descriptor)
sink_dataquanta= \
plan.source("../test/words.txt") \
.sort(lambdaelem: elem.lower()) \
.sink("../test/output.txt", end="")
returnsink_dataquanta# Returns the Sink Executable Dataquanta of a DEMO plandefplan_sort_filter(descriptor):
plan=DataQuantaBuilder(descriptor)
sink_dataquanta= \
plan.source("../test/words.txt") \
.sort(lambdaelem: elem.lower()) \
.filter(lambdaelem: str(elem).startswith("f")) \
.sink("../test/output.txt", end="")
returnsink_dataquanta# Returns the Sink Executable Dataquanta of a DEMO plandefplan_filter_text(descriptor):
plan=DataQuantaBuilder(descriptor)
sink_dataquanta= \
plan.source("../test/words.txt") \
.filter(lambdaelem: str(elem).startswith("f")) \
.sink("../test/output.txt", end="")
returnsink_dataquanta# Returns the Sink Executable Dataquanta of a DEMO plandefplan_filter(descriptor):
plan=DataQuantaBuilder(descriptor)
sink_dataquanta= \
plan.source("../test/numbers.txt") \
.filter(lambdaelem: int(elem) %2!=0) \
.sink("../test/output.txt", end="")
returnsink_dataquanta# Returns the Sink Executable Dataquanta of a DEMO plandefplan_basic(descriptor):
plan=DataQuantaBuilder(descriptor)
sink_dataquanta= \
plan.source("../test/lines.txt") \
.sink("../test/output.txt", end="")
returnsink_dataquanta# Returns the Sink Executable Dataquanta of a DEMO plandefplan_junction(descriptor):
plan=DataQuantaBuilder(descriptor)
dq_source_a=plan.source("../test/lines.txt")
dq_source_b=plan.source("../test/morelines.txt") \
.filter(lambdaelem: str(elem).startswith("I"))
dq_source_c=plan.source("../test/lastlines.txt") \
.filter(lambdaelem: str(elem).startswith("W"))
sink_dataquanta=dq_source_a.union(dq_source_b) \
.union(dq_source_c) \
.sort(lambdaelem: elem.lower()) \
.sink("../test/output.txt", end="")
returnsink_dataquantadefplan_java_junction(descriptor):
plan=DataQuantaBuilder(descriptor)
dq_source_a=plan.source("../test/lines.txt")
dq_source_b=plan.source("../test/morelines.txt")
sink_dataquanta=dq_source_a.union(dq_source_b) \
.filter(lambdaelem: str(elem).startswith("I")) \
.sort(lambdaelem: elem.lower()) \
.sink("../test/output.txt", end="")
returnsink_dataquantadefplan_tpch_q1(descriptor):
#TODO create reduce byplan=DataQuantaBuilder(descriptor)
defreducer(obj1, obj2):
returnobj1[0]
sink=plan.source("../test/lineitem.txt") \
.map(lambdaelem: elem.split("|")) \
.filter(lambdaelem: datetime.datetime.strptime(elem[10], '%Y-%m-%d') <=datetime.datetime.strptime("1998-09-02", '%Y-%m-%d')) \
.map(lambdaelem:
[elem[8], elem[9], elem[4], elem[5],
float(elem[5]) * (1-float(elem[6])),
float(elem[5]) * (1-float(elem[6])) * (1+float(elem[7])),
elem[4], elem[5],
elem[6], 1]) \
.sink("../test/output.txt", end="")
# .group_by(lambda elem: elem) \# .reduce_by(reducer) \# .flatmap(lambda elem: elem.split("|"))# .map(lambda elem: (elem, elem.split("|"))) \# L_RETURNFLAG 8# L_LINESTATUS 9# L_QUANTITY 4# L_EXTENDEDPRICE 5# discount 6# tax 7returndq_source_bdefplan_full_java(descriptor):
plan=DataQuantaBuilder(descriptor)
dq_source_a=plan.source("../test/lines.txt")
dq_source_b=plan.source("../test/morelines.txt")
sink_dataquanta=dq_source_a.union(dq_source_b) \
.sink("../test/output.txt", end="")
returnsink_dataquantaif__name__=='__main__':
# Plan will contain general info about the Wayang Plan created heredescriptor=Descriptor()
plan_dataquanta_sink=plan_tpch_q1(descriptor)
plan_dataquanta_sink.execute()
16926d90f67151c3107fd7d2574cfdfc9cd017cc
The text was updated successfully, but these errors were encountered:
create reduce by
.reduce_by(reducer) \
.flatmap(lambda elem: elem.split("|"))
.map(lambda elem: (elem, elem.split("|"))) \
L_RETURNFLAG 8
L_LINESTATUS 9
L_QUANTITY 4
L_EXTENDEDPRICE 5
discount 6
tax 7
incubator-wayang/python/old_code/pywayang/src/pywy/orchestrator/execdirectly.py
Line 114 in 11682e6
16926d90f67151c3107fd7d2574cfdfc9cd017cc
The text was updated successfully, but these errors were encountered: