Search in sources :

Example 1 with RowBuffer

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));
        }
    }
}
Also used : HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) RowBuffer(org.apache.hop.core.row.RowBuffer)

Example 2 with 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
    }
}
Also used : IRowMeta(org.apache.hop.core.row.IRowMeta) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) IEngineComponent(org.apache.hop.pipeline.engine.IEngineComponent) RowBuffer(org.apache.hop.core.row.RowBuffer) HopException(org.apache.hop.core.exception.HopException) InvocationTargetException(java.lang.reflect.InvocationTargetException) HopTransformException(org.apache.hop.core.exception.HopTransformException) HopValueException(org.apache.hop.core.exception.HopValueException) LocalPipelineRunConfiguration(org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration) HopValueException(org.apache.hop.core.exception.HopValueException) FileObject(org.apache.commons.vfs2.FileObject) SampleType(org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration.SampleType)

Example 3 with RowBuffer

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);
        }
    }
}
Also used : org.apache.hop.core(org.apache.hop.core) AreaType(org.apache.hop.core.gui.AreaOwner.AreaType) SwtGc(org.apache.hop.ui.hopgui.shared.SwtGc) StringUtils(org.apache.commons.lang.StringUtils) StreamIcon(org.apache.hop.pipeline.transform.stream.StreamIcon) SashForm(org.eclipse.swt.custom.SashForm) org.apache.hop.core.logging(org.apache.hop.core.logging) XmlHandler(org.apache.hop.core.xml.XmlHandler) PipelineDebugMeta(org.apache.hop.pipeline.debug.PipelineDebugMeta) Stream(org.apache.hop.pipeline.transform.stream.Stream) HopException(org.apache.hop.core.exception.HopException) GuiContextActionFilter(org.apache.hop.core.action.GuiContextActionFilter) GC(org.eclipse.swt.graphics.GC) SampleType(org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration.SampleType) LocalPipelineEngine(org.apache.hop.pipeline.engines.local.LocalPipelineEngine) GuiContextAction(org.apache.hop.core.action.GuiContextAction) NotePadDialog(org.apache.hop.ui.hopgui.dialog.NotePadDialog) org.apache.hop.ui.hopgui.file.pipeline.delegates(org.apache.hop.ui.hopgui.file.pipeline.delegates) HopGuiTooltipExtension(org.apache.hop.ui.hopgui.file.shared.HopGuiTooltipExtension) HopGuiPipelineNoteContext(org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineNoteContext) HopGuiPipelineGraphExtension(org.apache.hop.ui.hopgui.file.pipeline.extension.HopGuiPipelineGraphExtension) IGuiRefresher(org.apache.hop.core.gui.plugin.IGuiRefresher) OsHelper(org.apache.hop.ui.core.widget.OsHelper) org.apache.hop.pipeline(org.apache.hop.pipeline) CTabFolder(org.eclipse.swt.custom.CTabFolder) TransformDebugMeta(org.apache.hop.pipeline.debug.TransformDebugMeta) HopNamespace(org.apache.hop.ui.core.gui.HopNamespace) EnterPreviewRowsDialog(org.apache.hop.ui.hopgui.dialog.EnterPreviewRowsDialog) IGuiContextHandler(org.apache.hop.ui.hopgui.context.IGuiContextHandler) HopGuiServerDelegate(org.apache.hop.ui.hopgui.delegates.HopGuiServerDelegate) InvocationTargetException(java.lang.reflect.InvocationTargetException) HopTransformException(org.apache.hop.core.exception.HopTransformException) GuiToolbarElement(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) List(java.util.List) FileName(org.apache.commons.vfs2.FileName) HopValueException(org.apache.hop.core.exception.HopValueException) SWT(org.eclipse.swt.SWT) PipelineDialog(org.apache.hop.ui.pipeline.dialog.PipelineDialog) StreamType(org.apache.hop.pipeline.transform.stream.IStream.StreamType) IPlugin(org.apache.hop.core.plugins.IPlugin) RowBuffer(org.apache.hop.core.row.RowBuffer) Utils(org.apache.hop.core.util.Utils) java.util(java.util) SvgFile(org.apache.hop.core.svg.SvgFile) org.apache.hop.ui.core.dialog(org.apache.hop.ui.core.dialog) BasePropertyHandler(org.apache.hop.laf.BasePropertyHandler) IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) GuiPlugin(org.apache.hop.core.gui.plugin.GuiPlugin) GuiKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiKeyboardShortcut) GuiActionType(org.apache.hop.core.gui.plugin.action.GuiActionType) HopGuiAbstractGraph(org.apache.hop.ui.hopgui.perspective.dataorch.HopGuiAbstractGraph) PipelineDataLineage(org.apache.hop.lineage.PipelineDataLineage) LocalPipelineRunConfiguration(org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration) CheckPipelineProgressDialog(org.apache.hop.ui.hopgui.dialog.CheckPipelineProgressDialog) ConstUi(org.apache.hop.ui.core.ConstUi) org.apache.hop.core.gui(org.apache.hop.core.gui) SwtScrollBar(org.apache.hop.ui.hopgui.shared.SwtScrollBar) PipelineRunConfiguration(org.apache.hop.pipeline.config.PipelineRunConfiguration) ExtensionPointHandler(org.apache.hop.core.extension.ExtensionPointHandler) SearchFieldsProgressDialog(org.apache.hop.ui.hopgui.dialog.SearchFieldsProgressDialog) IEngineComponent(org.apache.hop.pipeline.engine.IEngineComponent) PipelineEngineFactory(org.apache.hop.pipeline.engine.PipelineEngineFactory) OutputStream(java.io.OutputStream) IStream(org.apache.hop.pipeline.transform.stream.IStream) IRowMeta(org.apache.hop.core.row.IRowMeta) org.apache.hop.pipeline.transform(org.apache.hop.pipeline.transform) HopGuiNotePadDelegate(org.apache.hop.ui.hopgui.file.delegates.HopGuiNotePadDelegate) org.eclipse.swt.events(org.eclipse.swt.events) HopVfs(org.apache.hop.core.vfs.HopVfs) BaseMessages(org.apache.hop.i18n.BaseMessages) GuiResource(org.apache.hop.ui.core.gui.GuiResource) FormLayout(org.eclipse.swt.layout.FormLayout) EnvironmentUtils(org.apache.hop.ui.util.EnvironmentUtils) FormData(org.eclipse.swt.layout.FormData) org.eclipse.swt.widgets(org.eclipse.swt.widgets) org.apache.hop.ui.hopgui(org.apache.hop.ui.hopgui) FormAttachment(org.eclipse.swt.layout.FormAttachment) FileObject(org.apache.commons.vfs2.FileObject) IPipelineEngine(org.apache.hop.pipeline.engine.IPipelineEngine) GuiContextUtil(org.apache.hop.ui.hopgui.context.GuiContextUtil) HopGuiPipelineFinishedExtension(org.apache.hop.ui.hopgui.file.pipeline.extension.HopGuiPipelineFinishedExtension) GuiToolbarElementType(org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElementType) PropsUi(org.apache.hop.ui.core.PropsUi) CTabItem(org.eclipse.swt.custom.CTabItem) AuditManager(org.apache.hop.history.AuditManager) GuiOsxKeyboardShortcut(org.apache.hop.core.gui.plugin.key.GuiOsxKeyboardShortcut) PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) HopGuiPipelineContext(org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineContext) HopGuiPipelineHopContext(org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineHopContext) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) GuiToolbarWidgets(org.apache.hop.ui.core.gui.GuiToolbarWidgets) HopGuiPipelineTransformContext(org.apache.hop.ui.hopgui.file.pipeline.context.HopGuiPipelineTransformContext) HopException(org.apache.hop.core.exception.HopException) EnterPreviewRowsDialog(org.apache.hop.ui.hopgui.dialog.EnterPreviewRowsDialog) GuiContextAction(org.apache.hop.core.action.GuiContextAction)

Example 4 with RowBuffer

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);
}
Also used : RowBuffer(org.apache.hop.core.row.RowBuffer)

Example 5 with 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);
    }
}
Also used : IPluginType(org.apache.hop.core.plugins.IPluginType) PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) HopPluginException(org.apache.hop.core.exception.HopPluginException) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) RowBuffer(org.apache.hop.core.row.RowBuffer)

Aggregations

RowBuffer (org.apache.hop.core.row.RowBuffer)11 FileObject (org.apache.commons.vfs2.FileObject)4 HopException (org.apache.hop.core.exception.HopException)4 HopTransformException (org.apache.hop.core.exception.HopTransformException)4 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)4 IRowMeta (org.apache.hop.core.row.IRowMeta)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 HopValueException (org.apache.hop.core.exception.HopValueException)3 IEngineComponent (org.apache.hop.pipeline.engine.IEngineComponent)3 AreaType (org.apache.hop.core.gui.AreaOwner.AreaType)2 PluginRegistry (org.apache.hop.core.plugins.PluginRegistry)2 IValueMeta (org.apache.hop.core.row.IValueMeta)2 LocalPipelineRunConfiguration (org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration)2 SampleType (org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration.SampleType)2 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1 java.util (java.util)1 List (java.util.List)1 ServletException (javax.servlet.ServletException)1