-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
964f014
commit 6c78890
Showing
22 changed files
with
993 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,4 +71,7 @@ drill.exec: { | |
global.max.width: 100, | ||
executor.threads: 4 | ||
} | ||
trace: { | ||
directory: "/var/log/drill" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
exec/java-exec/src/main/java/org/apache/drill/exec/physical/config/Trace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
package org.apache.drill.exec.physical.config; | ||
|
||
import org.apache.drill.exec.physical.OperatorCost; | ||
import org.apache.drill.exec.physical.base.AbstractSingle; | ||
import org.apache.drill.exec.physical.base.PhysicalOperator; | ||
import org.apache.drill.exec.physical.base.PhysicalVisitor; | ||
import org.apache.drill.exec.physical.base.Size; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
|
||
@JsonTypeName("trace") | ||
public class Trace extends AbstractSingle { | ||
|
||
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Trace.class); | ||
|
||
/* Tag associated with each trace operator | ||
* Printed along with trace output to distinguish | ||
* between multiple trace operators within same plan | ||
*/ | ||
public final String traceTag; | ||
|
||
public Trace(@JsonProperty("child") PhysicalOperator child, @JsonProperty("tag") String traceTag) { | ||
super(child); | ||
this.traceTag = traceTag; | ||
} | ||
|
||
@Override | ||
public <T, X, E extends Throwable> T accept(PhysicalVisitor<T, X, E> physicalVisitor, X value) throws E { | ||
return physicalVisitor.visitTrace(this, value); | ||
} | ||
|
||
@Override | ||
public OperatorCost getCost() { | ||
|
||
/* Compute the total size (row count * row size) */ | ||
Size size = child.getSize(); | ||
long diskSize = size.getRecordCount() * size.getRecordSize(); | ||
|
||
return new OperatorCost(0, diskSize, 0, child.getSize().getRecordCount()); | ||
} | ||
|
||
@Override | ||
public Size getSize() { | ||
return child.getSize(); | ||
} | ||
|
||
@Override | ||
protected PhysicalOperator getNewWithChild(PhysicalOperator child) { | ||
return new Trace(child, traceTag); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TraceInjector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
package org.apache.drill.exec.physical.impl; | ||
|
||
import org.apache.drill.common.exceptions.ExecutionSetupException; | ||
import org.apache.drill.exec.ops.FragmentContext; | ||
import org.apache.drill.exec.physical.base.AbstractPhysicalVisitor; | ||
import org.apache.drill.exec.physical.base.FragmentRoot; | ||
import org.apache.drill.exec.physical.base.PhysicalOperator; | ||
import org.apache.drill.exec.physical.config.Trace; | ||
|
||
import java.util.List; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
|
||
public class TraceInjector extends AbstractPhysicalVisitor<PhysicalOperator, FragmentContext, ExecutionSetupException> { | ||
|
||
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TraceInjector.class); | ||
|
||
static int traceTagCount = 0; | ||
|
||
|
||
RootExec root = null; | ||
private ScreenCreator sc = new ScreenCreator(); | ||
|
||
public static PhysicalOperator getExec(FragmentContext context, FragmentRoot root) throws ExecutionSetupException { | ||
TraceInjector tI = new TraceInjector(); | ||
PhysicalOperator newOp = root.accept(tI, context); | ||
|
||
return newOp; | ||
} | ||
|
||
/** | ||
* Traverse the physical plan and inject the trace operator after | ||
* every operator. | ||
* @param op Physical operator under which the trace operator will be injected | ||
* @param context Fragment context | ||
* @return same physical operator as passed in, but its child will be a trace operator | ||
* whose child will be the original child of this operator | ||
* @throws ExecutionSetupException | ||
*/ | ||
@Override | ||
public PhysicalOperator visitOp(PhysicalOperator op, FragmentContext context) throws ExecutionSetupException{ | ||
|
||
List<PhysicalOperator> newChildren = Lists.newArrayList(); | ||
List<PhysicalOperator> list = null; | ||
PhysicalOperator newOp = op; | ||
|
||
/* Get the list of child operators */ | ||
for (PhysicalOperator child : op) | ||
{ | ||
newChildren.add(child.accept(this, context)); | ||
} | ||
|
||
list = Lists.newArrayList(); | ||
|
||
/* For every child operator create a trace operator as its parent */ | ||
for (int i = 0; i < newChildren.size(); i++) | ||
{ | ||
String traceTag = newChildren.toString() + Integer.toString(traceTagCount++); | ||
|
||
/* Trace operator */ | ||
Trace traceOp = new Trace(newChildren.get(i), traceTag); | ||
list.add(traceOp); | ||
} | ||
|
||
/* Inject trace operator */ | ||
if (list.size() > 0) | ||
newOp = op.getNewWithChildren(list); | ||
|
||
return newOp; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
.../java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceBatchCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
package org.apache.drill.exec.physical.impl.trace; | ||
|
||
import org.apache.drill.common.exceptions.ExecutionSetupException; | ||
import org.apache.drill.exec.ops.FragmentContext; | ||
import org.apache.drill.exec.physical.config.Trace; | ||
import org.apache.drill.exec.physical.impl.BatchCreator; | ||
import org.apache.drill.exec.record.RecordBatch; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
import java.util.List; | ||
|
||
public class TraceBatchCreator implements BatchCreator<Trace> { | ||
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TraceBatchCreator.class); | ||
|
||
@Override | ||
public RecordBatch getBatch(FragmentContext context, Trace config, List<RecordBatch> children) throws ExecutionSetupException { | ||
//Preconditions.checkArgument(children.size() == 1); | ||
return new TraceRecordBatch(config, children.iterator().next(), context); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.