Create a range partition on an {@link AbstractLabel} that will itself be sub-partitioned

@param sqlgGraph
@param abstractLabel
@param name
@param from
@param to
@param partitionType
@param partitionExpression
@return
488667
static Partition createRangePartitionWithSubPartition(
            SqlgGraph sqlgGraph,
            AbstractLabel abstractLabel,
            String name,
            String from,
            String to,
            PartitionType partitionType,
            String partitionExpression) {

        Preconditions.checkArgument(!abstractLabel.getSchema().isSqlgSchema(), "createRangePartitionWithSubPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA);
        Preconditions.checkState(abstractLabel.isRangePartition());
        Partition partition = new Partition(sqlgGraph, abstractLabel, name, from, to, partitionType, partitionExpression);
        partition.createRangePartitionOnDb();
        if (abstractLabel instanceof VertexLabel) {
            TopologyManager.addVertexLabelPartition(
                    sqlgGraph,
                    abstractLabel.getSchema().getName(),
                    abstractLabel.getName(),
                    name,
                    from,
                    to,
                    partitionType,
                    partitionExpression);
        } else {
            TopologyManager.addEdgeLabelPartition(sqlgGraph, abstractLabel, name, from, to, partitionType, partitionExpression);
        }
        partition.committed = false;
        return partition;
    }
1132296
@Override
	public void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists)
		throws TableNotExistException, TableNotPartitionedException, PartitionSpecInvalidException, PartitionAlreadyExistsException, CatalogException {

		validatePartitionSpec(tablePath, partitionSpec);

		if (partitionExists(tablePath, partitionSpec)) {
			if (!ignoreIfExists) {
				throw new PartitionAlreadyExistsException(catalogName, tablePath, partitionSpec);
			}
		} else {
			partitions.get(tablePath).put(partitionSpec, partition.copy());
		}
	}
749087
private DBObject createQueryPartition(MongoPartition partition) {

        QueryBuilder queryBuilderMin = QueryBuilder.start(partition.getKey());
        DBObject bsonObjectMin = queryBuilderMin.greaterThanEquals(partition.splitWrapper().getStartToken()).get();

        QueryBuilder queryBuilderMax = QueryBuilder.start(partition.getKey());
        DBObject bsonObjectMax = queryBuilderMax.lessThan(partition.splitWrapper().getEndToken()).get();

        QueryBuilder queryBuilder = QueryBuilder.start();
        if (partition.splitWrapper().getStartToken() != null) {
            queryBuilder.and(bsonObjectMin);
        }

        if (partition.splitWrapper().getEndToken() != null) {
            queryBuilder.and(bsonObjectMax);
        }

        LOG.debug("mongodb query "+queryBuilder.get());

        return queryBuilder.get();
    }
408925
private static Node createAssignStatementNode(String name, Node expression) {
    // Create 'name = result-expression;' statement.
    // EXPR (ASSIGN (NAME, EXPRESSION))
    Node nameNode = IR.name(name);
    Node assign = IR.assign(nameNode, expression);
    return NodeUtil.newExpr(assign);
  }
741452
@Override
    public Stream partitionAggregate(Fields inputFields, Aggregator agg, Fields functionFields) {
        projectionValidation(inputFields);
        return _topology.addSourcedNode(this,
                new ProcessorNode(_topology.getUniqueStreamId(),
                    _name,
                    functionFields,
                    functionFields,
                    new AggregateProcessor(inputFields, agg)));
    }
555246
public static GeometryCollection createDT(Geometry geometry, int flag) throws SQLException {
        if (geometry != null) {
            DelaunayTriangulationBuilder triangulationBuilder = new DelaunayTriangulationBuilder();
            triangulationBuilder.setSites(geometry);
            if(flag == 0) {
                return getTriangles(geometry.getFactory(), triangulationBuilder);
            } else {
                return (GeometryCollection)triangulationBuilder.getEdges(geometry.getFactory());
            }
        }
        return null;
    }
627904
private Set<Label> scopeTypeLabelsImplicitPlayers(GraqlCompute query) {
        return scopeTypes(query)
                .filter(Concept::isRelationType)
                .map(Concept::asRelationType)
                .filter(RelationType::isImplicit)
                .flatMap(RelationType::roles)
                .flatMap(Role::players)
                .map(SchemaConcept::label)
                .collect(toSet());
    }
768288
@SuppressWarnings({"rawtypes", "unchecked"})
    private static InternalNode<?> joinWithSameLevel(InternalNode n1,
                                                     InternalNode n2) throws MIDDException {
        if (n1.getID() != n2.getID()) {
            throw new IllegalArgumentException("Both params should have the same variable level at their root");
        }

        if (n1.getType() != n2.getType()) {
            throw new IllegalArgumentException("Both IDD roots should have the same data type");
        }

        Partition p1 = PartitionBuilder.createPartition(n1.getIntervals());
        Partition p2 = PartitionBuilder.createPartition(n2.getIntervals());

        // Union two partitions
        Partition<?> p = PartitionBuilder.union(p1, p2);

        if (p.size() == 0) {
            throw new RuntimeException("Empty partition");
        }

        // Clone n1 to n: should combine two internal node states of n1 & n2?
        InternalNode<?> newIDD = NodeUtils.createInternalNode(n1.getID(), n1.getState(), n1.getType());

        for (Interval<?> interval : p.getIntervals()) {
            AbstractNode op1 = n1.getChild(interval);
            AbstractNode op2 = n2.getChild(interval);
            AbstractNode child = null;
            if (op1 != null && op2 != null) {
                child = join(op1, op2);
            } else if (op1 != null || op2 != null) {
                child = GenericUtils.newInstance(op1 != null ? op1 : op2);
            } else {
                throw new RuntimeException("Error joining two partitions, the output partition is incorrect");
            }

            if (child != null) {
                AbstractEdge<?> edge = EdgeUtils.createEdge(interval, newIDD.getType());
                newIDD.addChild(edge, child);
            } else {
                throw new RuntimeException("Empty child");
            }
        }

        return newIDD;
    }
482683
static Partition createListPartition(SqlgGraph sqlgGraph, AbstractLabel abstractLabel, String name, String in) {
        Preconditions.checkArgument(!abstractLabel.getSchema().isSqlgSchema(), "createListPartition may not be called for \"%s\"", Topology.SQLG_SCHEMA);
        Partition partition = new Partition(sqlgGraph, abstractLabel, name, in, PartitionType.NONE, null);
        partition.createListPartitionOnDb();
        if (abstractLabel instanceof VertexLabel) {
            TopologyManager.addVertexLabelPartition(
                    sqlgGraph,
                    abstractLabel.getSchema().getName(),
                    abstractLabel.getName(),
                    name,
                    in,
                    PartitionType.NONE,
                    null);
        } else {
            TopologyManager.addEdgeLabelPartition(sqlgGraph, abstractLabel, name, in, PartitionType.NONE, null);
        }
        partition.committed = false;
        return partition;
    }
196494
private PartitionVertexAggregate<M> getPartitioned(long vertexId) {
        assert idManager.isPartitionedVertex(vertexId);
        vertexId=getCanonicalId(vertexId);
        PartitionVertexAggregate<M> state = partitionVertices.get(vertexId);
        if (state==null) {
            partitionVertices.putIfAbsent(vertexId,new PartitionVertexAggregate<>(previousScopes));
            state = partitionVertices.get(vertexId);
        }
        return state;
    }
272924
public static Region create(String name, String label) {
        Region region = VALUES_BY_NAME.get(name.toLowerCase());
        if (region != null) {
            return region;
        } else {
            return new Region(name, label);
        }
    }
405373
static PartitionInfo fromEdge(ExecutionEdge executionEdge) {
		final InputChannelDeploymentDescriptor inputChannelDeploymentDescriptor = InputChannelDeploymentDescriptor.fromEdge(executionEdge);

		Preconditions.checkState(
			!inputChannelDeploymentDescriptor.getConsumedPartitionLocation().isUnknown(),
			"PartitionInfo contains an unknown partition location.");

		return new PartitionInfo(
			executionEdge.getSource().getIntermediateResult().getId(),
			inputChannelDeploymentDescriptor);
	}
81806
private JComponent createJComponent(final DirectedGraph<Object, JobGraphLink> graph) {
        final int vertexCount = graph.getVertexCount();
        logger.debug("Rendering graph with {} vertices", vertexCount);

        final JobGraphLayoutTransformer layoutTransformer = new JobGraphLayoutTransformer(_analysisJobBuilder, graph);
        final Dimension preferredSize = layoutTransformer.getPreferredSize();

        final StaticLayout<Object, JobGraphLink> layout = new StaticLayout<>(graph, layoutTransformer, preferredSize);

        final Collection<Object> vertices = graph.getVertices();
        for (final Object vertex : vertices) {
            // manually initialize all vertices
            layout.apply(vertex);
        }

        if (!vertices.isEmpty() && !layoutTransformer.isTransformed()) {
            throw new IllegalStateException("Layout transformer was never invoked!");
        }

        final VisualizationViewer<Object, JobGraphLink> visualizationViewer =
                new VisualizationViewer<>(layout, preferredSize);
        visualizationViewer.setTransferHandler(new TransferHandler() {

            private static final long serialVersionUID = 1L;

            public boolean canImport(final TransferSupport support) {
                return support.isDataFlavorSupported(DragDropUtils.MODEL_DATA_FLAVOR);
            }

            public boolean importData(final TransferSupport support) {
                final Transferable transferable = support.getTransferable();

                final Object data;
                try {
                    data = transferable.getTransferData(DragDropUtils.MODEL_DATA_FLAVOR);
                } catch (final Exception ex) {
                    logger.warn("Unexpected error while dropping data", ex);
                    return false;
                }

                if (data == null) {
                    return false;
                }

                final Point dropPoint = support.getDropLocation().getDropPoint();

                if (data instanceof Table) {
                    final Table table = (Table) data;
                    // position the table
                    JobGraphMetadata.setPointForTable(_analysisJobBuilder, table, dropPoint.x, dropPoint.y);
                    _analysisJobBuilder.addSourceColumns(table.getColumns());
                }

                if (data instanceof Column) {
                    final Column column = (Column) data;
                    final Table table = column.getTable();
                    final List<MetaModelInputColumn> columnsOfSameTable =
                            _analysisJobBuilder.getSourceColumnsOfTable(table);
                    if (columnsOfSameTable.isEmpty()) {
                        // the table is new - position it
                        JobGraphMetadata.setPointForTable(_analysisJobBuilder, table, dropPoint.x, dropPoint.y);
                    }
                    _analysisJobBuilder.addSourceColumn(column);
                }

                if (data instanceof ComponentDescriptor<?>) {
                    final ComponentDescriptor<?> descriptor = (ComponentDescriptor<?>) data;
                    final Map<String, String> metadata = JobGraphMetadata.createMetadataProperties(dropPoint);
                    _analysisJobBuilder.addComponent(descriptor, null, null, metadata);
                }
                return true;
            }

        });

        GraphUtils.applyStyles(visualizationViewer);
        visualizationViewer.addPreRenderPaintable(new Paintable() {
            @Override
            public boolean useTransform() {
                return false;
            }

            @Override
            public void paint(final Graphics g) {
                final GradientPaint paint = new GradientPaint(0, 0, WidgetUtils.BG_COLOR_BRIGHTEST, 0,
                        visualizationViewer.getHeight(), WidgetUtils.BG_COLOR_BRIGHTEST);
                if (g instanceof Graphics2D) {
                    final Graphics2D g2d = (Graphics2D) g;
                    g2d.setPaint(paint);
                } else {
                    g.setColor(WidgetUtils.BG_COLOR_BRIGHT);
                }
                g.fillRect(0, 0, visualizationViewer.getWidth(), visualizationViewer.getHeight());

                final Dimension size = _panel.getSize();
                if (size.height < adjuster.adjust(300) || size.width < adjuster.adjust(500)) {
                    // don't show the background hints - it will be too
                    // disturbing
                    return;
                }

                final String showCanvasHints = _userPreferences.getAdditionalProperties()
                        .get(JobGraphTransformers.USER_PREFERENCES_PROPERTY_SHOW_CANVAS_HINTS);
                if ("false".equals(showCanvasHints)) {
                    // don't show the background hints - the user has decided
                    // not to have them.
                    return;
                }

                String title;
                String subTitle;
                String imagePath;

                g.setColor(WidgetUtils.BG_COLOR_MEDIUM);
                if (_analysisJobBuilder.getSourceColumns().size() == 0) {
                    title = "Select source ...";
                    subTitle = "Pick table/columns in the tree to the left.\n"
                            + "You can drag it onto this canvas with your mouse.";
                    imagePath = "images/window/canvas-bg-table.png";
                } else if (_analysisJobBuilder.getComponentCount() == 0) {
                    title = "Start building ...";
                    subTitle = "Add components to your job. Right-click the canvas\n"
                            + "to explore the library of available components.";
                    imagePath = "images/window/canvas-bg-plus.png";
                } else if (graph.getEdgeCount() == 0) {
                    title = "Connect the pieces ...";
                    subTitle = "Right-click the source table and select 'Link to ...'.\n"
                            + "This directs the flow of data to the component.";
                    imagePath = "images/window/canvas-bg-connect.png";
                } else if (_analysisJobBuilder.getResultProducingComponentBuilders().size() == 0
                        && _analysisJobBuilder.getConsumedOutputDataStreamsJobBuilders().size() == 0
                        && _analysisJobBuilder.getComponentCount() <= 3) {
                    title = "Your job is almost ready.";
                    subTitle = "Jobs need to either 'Analyze' or 'Write' something.\n"
                            + "So add one or more such components.";
                    imagePath = "images/window/canvas-bg-plus.png";
                } else {
                    title = null;
                    subTitle = null;
                    imagePath = null;

                    try {
                        if (_analysisJobBuilder.isConfigured(true)) {
                            title = "Ready to execute";
                            subTitle =
                                    "Click the 'Execute' button in the upper-right\ncorner when you're ready to run the job.";
                            imagePath = "images/window/canvas-bg-execute.png";
                            g.drawImage(ImageManager.get().getImage("images/window/canvas-bg-execute-hint.png"),
                                    size.width - adjuster.adjust(175), 0, null);
                        } else {
                            title = "Configure the job ...";
                            subTitle = "Job is not correctly configured";
                            imagePath = "images/window/canvas-bg-error.png";
                        }
                    } catch (final Exception ex) {
                        logger.debug("Job not correctly configured", ex);
                        final String errorMessage;
                        if (ex instanceof UnconfiguredConfiguredPropertyException) {
                            final UnconfiguredConfiguredPropertyException unconfiguredConfiguredPropertyException =
                                    (UnconfiguredConfiguredPropertyException) ex;
                            final ConfiguredPropertyDescriptor configuredProperty =
                                    unconfiguredConfiguredPropertyException.getConfiguredProperty();
                            final ComponentBuilder componentBuilder =
                                    unconfiguredConfiguredPropertyException.getComponentBuilder();
                            title = "Configure " + "'" + LabelUtils.getLabel(componentBuilder) + "' ...";
                            errorMessage = "Please set '" + configuredProperty.getName() + "' to continue";
                        } else {
                            title = "Something went wrong ...";
                            errorMessage = ex.getMessage();
                        }
                        subTitle = errorMessage;
                        imagePath = "images/window/canvas-bg-error.png";
                    }
                }

                final int yOffset = size.height - adjuster.adjust(150);
                final int xOffset = adjuster.adjust(150);

                final float titleFontSize;
                final float subTitleFontSize;
                if (size.width < adjuster.adjust(650)) {
                    titleFontSize = adjuster.adjust(30f);
                    subTitleFontSize = adjuster.adjust(17f);
                } else {
                    titleFontSize = adjuster.adjust(35f);
                    subTitleFontSize = adjuster.adjust(20f);
                }

                if (title != null) {
                    g.setFont(WidgetUtils.FONT_BANNER.deriveFont(titleFontSize));
                    g.drawString(title, xOffset, yOffset);
                }

                if (subTitle != null) {
                    final String[] lines = subTitle.split("\n");
                    g.setFont(WidgetUtils.FONT_BANNER.deriveFont(subTitleFontSize));
                    int y = yOffset + adjuster.adjust(10);
                    for (final String line : lines) {
                        y = y + adjuster.adjust(30);
                        g.drawString(line, xOffset, y);
                    }
                }

                if (imagePath != null) {
                    g.drawImage(ImageManager.get().getImage(imagePath), xOffset - adjuster.adjust(120),
                            yOffset - adjuster.adjust(30), null);
                }
            }
        });

        final JobGraphContext graphContext = new JobGraphContext(this, visualizationViewer, _analysisJobBuilder);

        final JobGraphActions actions = new JobGraphActions(graphContext, _windowContext, _presenterRendererFactory,
                _componentConfigurationDialogs, _tableConfigurationDialogs);
        final JobGraphLinkPainter linkPainter = new JobGraphLinkPainter(graphContext, actions);

        final JobGraphLinkPainterMousePlugin linkPainterMousePlugin =
                new JobGraphLinkPainterMousePlugin(linkPainter, graphContext);
        final GraphMouse graphMouse = visualizationViewer.getGraphMouse();
        if (graphMouse instanceof PluggableGraphMouse) {
            final PluggableGraphMouse pluggableGraphMouse = (PluggableGraphMouse) graphMouse;
            pluggableGraphMouse.add(linkPainterMousePlugin);
        }

        final JobGraphMouseListener graphMouseListener =
                new JobGraphMouseListener(graphContext, linkPainter, actions, _windowContext);

        visualizationViewer.addGraphMouseListener(graphMouseListener);
        visualizationViewer.addMouseListener(graphMouseListener);

        final RenderContext<Object, JobGraphLink> renderContext = visualizationViewer.getRenderContext();

        final JobGraphTransformers transformers = new JobGraphTransformers(graph, _userPreferences, _highlighedVertexes);

        // instrument the render context with all our transformers and stuff
        renderContext.setVertexFontTransformer(transformers.getVertexFontTransformer());
        renderContext.setVertexLabelTransformer(JobGraphTransformers.VERTEX_LABEL_TRANSFORMER);
        renderContext.setEdgeArrowPredicate(JobGraphTransformers.EDGE_ARROW_PREDICATE);
        renderContext.setEdgeArrowTransformer(JobGraphTransformers.EDGE_ARROW_TRANSFORMER);
        renderContext.setEdgeLabelTransformer(JobGraphTransformers.EDGE_LABEL_TRANSFORMER);
        renderContext.setEdgeShapeTransformer(transformers.getEdgeShapeTransformer());
        renderContext.setEdgeLabelClosenessTransformer(JobGraphTransformers.EDGE_LABEL_CLOSENESS_TRANSFORMER);
        renderContext.setEdgeLabelRenderer(transformers.getEdgeLabelRenderer());
        renderContext.setVertexIconTransformer(JobGraphTransformers.VERTEX_ICON_TRANSFORMER);
        renderContext.setVertexShapeTransformer(JobGraphTransformers.VERTEX_SHAPE_TRANSFORMER);

        final JButton graphPreferencesButton = createGraphPreferencesButton();
        visualizationViewer.setLayout(new BorderLayout());
        visualizationViewer.add(DCPanel.flow(Alignment.RIGHT, 0, 0, graphPreferencesButton), BorderLayout.SOUTH);

        // we save the values of the scrollbars in order to allow refreshes to
        // retain scroll position.
        final GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(visualizationViewer);
        scrollPane.setCorner(new DCPanel(WidgetUtils.COLOR_DEFAULT_BACKGROUND));
        if (_scrollHorizontal > 0) {
            setScrollbarValue(scrollPane.getHorizontalScrollBar(), _scrollHorizontal);
        }
        if (_scrollVertical > 0) {
            setScrollbarValue(scrollPane.getVerticalScrollBar(), _scrollVertical);
        }
        final AdjustmentListener adjustmentListener = e -> {
            _scrollHorizontal = scrollPane.getHorizontalScrollBar().getValue();
            _scrollVertical = scrollPane.getVerticalScrollBar().getValue();
        };
        scrollPane.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener);
        scrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener);
        new JobGraphBindingsManager(graphContext, actions, scrollPane).register();

        return scrollPane;
    }
151604
public static void copyCriteriaNoSelection(CriteriaQuery<?> from, CriteriaQuery<?> to) {

        // Copy Roots
        for (Root<?> root : from.getRoots()) {
            Root<?> dest = to.from(root.getJavaType());
            dest.alias(getOrCreateAlias(root));
            copyJoins(root, dest);
        }

        if (from.getGroupList() != null) to.groupBy(from.getGroupList());
        to.distinct(from.isDistinct());
        if (from.getGroupRestriction() != null) to.having(from.getGroupRestriction());
        if (from.getRestriction() != null) to.where(from.getRestriction());
        if (from.getOrderList() != null) to.orderBy(from.getOrderList());
    }
1202933
public static final LCMSRange create(Range<Integer> scanRange, Integer msLevel) {
    return new LCMSRange(scanRange, msLevel, null);
  }
952842
private <K, V> DiffHistoricalTypeState<K, V> createTypeState(Map<K, V> from, Map<K, V> to, boolean isGroupOfObjects) {
        int newCounter = 0;
        int diffCounter = 0;
        int deleteCounter = 0;

        for(K key : from.keySet()) {
            V toValue = to.get(key);

            if(toValue == null) {
                deleteCounter++;
            } else {
                V fromValue = from.get(key);

                if(!checkEquality(toValue, fromValue, isGroupOfObjects)) {
                    diffCounter++;
                }
            }
        }

        for(K key : to.keySet()) {
            if(!from.containsKey(key)) {
                newCounter++;
            }
        }

        OpenAddressingArraySet<K> newSet = new OpenAddressingArraySet<K>();
        OpenAddressingHashMap<K, V> diffMap = new OpenAddressingHashMap<K, V>();
        OpenAddressingHashMap<K, V> deleteMap = new OpenAddressingHashMap<K, V>();

        newSet.builderInit(newCounter);
        diffMap.builderInit(diffCounter);
        deleteMap.builderInit(deleteCounter);

        newCounter = diffCounter = deleteCounter = 0;

        for(K key : from.keySet()) {
            V fromValue = from.get(key);
            V toValue = to.get(key);

            if(toValue == null) {
                deleteMap.builderPut(deleteCounter++, key, fromValue);
            } else {
                if(!checkEquality(toValue, fromValue, isGroupOfObjects)) {
                    diffMap.builderPut(diffCounter++, key, fromValue);
                }
            }
        }

        for(K key : to.keySet()) {
            if(!from.containsKey(key)) {
                newSet.builderSet(newCounter++, key);
            }
        }

        newSet.builderFinish();
        diffMap.builderFinish();
        deleteMap.builderFinish();

        return new DiffHistoricalTypeState<K, V>(newSet, diffMap, deleteMap);
    }
286022
@SuppressWarnings({"unchecked", "rawtypes"})
    private InternalNode<?> combineIDDSameLevel(InternalNode n1,
                                                InternalNode n2) throws MIDDException {
        if (n1.getID() != n2.getID()) {
            throw new IllegalArgumentException("Both params should have the same variable level at their root");
        }

        if (n1.getType() != n2.getType()) {
            throw new IllegalArgumentException("Both IDD roots should have the same data type");
        }

        Partition p1 = PartitionBuilder.createPartition(n1.getIntervals());
        Partition p2 = PartitionBuilder.createPartition(n2.getIntervals());

        Partition<?> p = PartitionBuilder.union(p1, p2);
        if (p.size() == 0) {
            log.error("Empty unioned partition");
            return null;
        }

        InternalNodeState newState = combineIndeterminateStates(n1.getState(), n2.getState());

        InternalNode<?> n = NodeUtils.createInternalNode(n1.getID(), newState, n1.getType());

        for (Interval<?> interval : p.getIntervals()) {
            AbstractNode op1 = n1.getChild(interval);
            AbstractNode op2 = n2.getChild(interval);
            AbstractNode child = null;
            if (op1 != null && op2 != null) {
                child = combine(op1, op2);
            } else if (op1 != null || op2 != null) {
                child = GenericUtils.newInstance(op1 == null ? op2 : op1);
            } else {
                throw new RuntimeException("Error merging two partitions, " +
                        "the output partition has an item not belong to both previous ones");
            }

            if (child != null) {
                AbstractEdge<?> edge = EdgeUtils.createEdge(interval, n.getType());
                if (edge.getIntervals().size() == 0) {
                    throw new RuntimeException("Empty edge");
                }
                n.addChild(edge, child);
            }
        }

        return n;
    }