use of org.apache.hop.core.row.RowBuffer in project hop by apache.
the class PipelinePainter method drawTransformOutputIndicator.
private void drawTransformOutputIndicator(TransformMeta transformMeta) throws HopException {
if (transformMeta == null) {
return;
}
// draw status indicator
if (pipeline != null) {
Point pt = transformMeta.getLocation();
if (pt == null) {
pt = new Point(50, 50);
}
Point screen = real2screen(pt.x, pt.y);
int x = screen.x;
int y = screen.y;
RowBuffer rowBuffer = outputRowsMap.get(transformMeta.getName());
if (rowBuffer != null && !rowBuffer.isEmpty()) {
int iconWidth = miniIconSize;
int iconX = x + iconSize - (miniIconSize / 2) + 1;
int iconY = y + iconSize - (miniIconSize / 2) + 1;
gc.drawImage(EImage.DATA, iconX, iconY, magnification);
areaOwners.add(new AreaOwner(AreaType.TRANSFORM_OUTPUT_DATA, iconX, iconY, iconWidth, iconWidth, offset, transformMeta, rowBuffer));
}
}
}
use of org.apache.hop.core.row.RowBuffer in project hop by apache.
the class HopGuiPipelineGraph method addRowsSamplerToPipeline.
private void addRowsSamplerToPipeline(IPipelineEngine<PipelineMeta> pipeline) {
if (!(pipeline.getPipelineRunConfiguration().getEngineRunConfiguration() instanceof LocalPipelineRunConfiguration)) {
return;
}
LocalPipelineRunConfiguration lprConfig = (LocalPipelineRunConfiguration) pipeline.getPipelineRunConfiguration().getEngineRunConfiguration();
if (StringUtils.isEmpty(lprConfig.getSampleTypeInGui())) {
return;
}
try {
SampleType sampleType = SampleType.valueOf(lprConfig.getSampleTypeInGui());
if (sampleType == SampleType.None) {
return;
}
final int sampleSize = Const.toInt(pipeline.resolve(lprConfig.getSampleSize()), 100);
if (sampleSize <= 0) {
return;
}
outputRowsMap = new HashMap<>();
final Random random = new Random();
for (final String transformName : pipelineMeta.getTransformNames()) {
IEngineComponent component = pipeline.findComponent(transformName, 0);
if (component != null) {
component.addRowListener(new RowAdapter() {
int nrRows = 0;
@Override
public void rowWrittenEvent(IRowMeta rowMeta, Object[] row) throws HopTransformException {
RowBuffer rowBuffer = outputRowsMap.get(transformName);
if (rowBuffer == null) {
rowBuffer = new RowBuffer(rowMeta);
outputRowsMap.put(transformName, rowBuffer);
//
if (sampleType == SampleType.Last) {
rowBuffer.setBuffer(Collections.synchronizedList(new LinkedList<>()));
} else {
rowBuffer.setBuffer(Collections.synchronizedList(new ArrayList<>()));
}
}
//
if (sampleType != SampleType.None) {
try {
row = rowMeta.cloneRow(row);
} catch (HopValueException e) {
throw new HopTransformException("Error copying row for preview purposes", e);
}
}
switch(sampleType) {
case First:
{
if (rowBuffer.size() < sampleSize) {
rowBuffer.addRow(row);
}
}
break;
case Last:
{
rowBuffer.addRow(0, row);
if (rowBuffer.size() > sampleSize) {
rowBuffer.removeRow(rowBuffer.size() - 1);
}
}
break;
case Random:
{
// Reservoir sampling
//
nrRows++;
if (rowBuffer.size() < sampleSize) {
rowBuffer.addRow(row);
} else {
int randomIndex = random.nextInt(nrRows);
if (randomIndex < sampleSize) {
rowBuffer.setRow(randomIndex, row);
}
}
}
break;
}
}
});
}
}
} catch (Exception e) {
// Ignore : simply not recognized or empty
}
}
use of org.apache.hop.core.row.RowBuffer in project hop by apache.
the class HopGuiPipelineGraph method sniff.
@GuiContextAction(id = "pipeline-graph-transform-12000-sniff-output", parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Info, name = "i18n::HopGuiPipelineGraph.PipelineAction.SniffOutput.Name", tooltip = "i18n::HopGuiPipelineGraph.PipelineAction.SniffOutput.Tooltip", image = "ui/images/preview.svg", category = "Preview", categoryOrder = "3")
public void sniff(HopGuiPipelineTransformContext context) {
TransformMeta transformMeta = context.getTransformMeta();
if (pipeline == null) {
MessageBox messageBox = new MessageBox(hopShell(), SWT.ICON_INFORMATION | SWT.OK);
messageBox.setText(BaseMessages.getString(PKG, "PipelineGraph.SniffTestingAvailableWhenRunning.Title"));
messageBox.setMessage(BaseMessages.getString(PKG, "PipelineGraph.SniffTestingAvailableWhenRunning.Message"));
messageBox.open();
return;
}
if (pipeline.isFinished()) {
// Show collected sample data...
//
} else {
try {
pipeline.retrieveComponentOutput(hopGui.getVariables(), transformMeta.getName(), 0, 50, ((pipelineEngine, rowBuffer) -> hopDisplay().asyncExec(() -> {
PreviewRowsDialog dialog = new PreviewRowsDialog(hopShell(), hopGui.getVariables(), SWT.NONE, transformMeta.getName(), rowBuffer.getRowMeta(), rowBuffer.getBuffer());
dialog.open();
})));
} catch (HopException e) {
new ErrorDialog(hopShell(), "Error", "Error sniffing rows", e);
}
}
}
use of org.apache.hop.core.row.RowBuffer in project hop by apache.
the class HopGuiPipelineGraph method showTransformOutputData.
public boolean showTransformOutputData(AreaOwner areaOwner) {
TransformMeta dataTransform = (TransformMeta) areaOwner.getParent();
RowBuffer rowBuffer = (RowBuffer) areaOwner.getOwner();
return showTransformOutputData(dataTransform, rowBuffer);
}
use of org.apache.hop.core.row.RowBuffer in project hop by apache.
the class HopPluginExplorePerspective method loadPlugin.
private void loadPlugin() {
// First we collect information concerning all the plugin types...
try {
metaMap = new HashMap<>();
dataMap = new HashMap<>();
PluginRegistry registry = PluginRegistry.getInstance();
List<Class<? extends IPluginType>> pluginTypeClasses = registry.getPluginTypes();
for (Class<? extends IPluginType> pluginTypeClass : pluginTypeClasses) {
IPluginType pluginTypeInterface = registry.getPluginType(pluginTypeClass);
if (pluginTypeInterface.isFragment()) {
continue;
}
String name = pluginTypeInterface.getName();
RowBuffer pluginInformation = registry.getPluginInformation(pluginTypeClass);
metaMap.put(name, pluginInformation.getRowMeta());
dataMap.put(name, pluginInformation.getBuffer());
}
this.pluginsType = metaMap.keySet().toArray(new String[metaMap.size()]);
Arrays.sort(pluginsType);
selectedPluginType = "";
if (!metaMap.isEmpty()) {
selectedPluginType = pluginsType[0];
}
} catch (HopPluginException e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "PluginExplorerPerspective.Error.CollectPlugin.Header"), BaseMessages.getString(PKG, "PluginExplorerPerspective.Error.CollectPlugin.Message"), e);
}
}
Aggregations