name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
streampipes_SimpleBlockFusionProcessor_getInstance_rdh
/** * Returns the singleton instance for BlockFusionProcessor. */ public static SimpleBlockFusionProcessor getInstance() { return INSTANCE; }
3.26
streampipes_CanolaExtractor_getInstance_rdh
/** * Returns the singleton instance for {@link CanolaExtractor}. */ public static CanolaExtractor getInstance() { return INSTANCE; }
3.26
streampipes_OpcNode_getQudtURI_rdh
/** * Returns the corresponding QUDT URI if the {@code opcUnitId} is given, * otherwise it returns an empty string. <br> * Currently, there are only two examples added. <br> * Other units have to be added manually, please have a look at the <a href="http://opcfoundation.org/UA/EngineeringUnits/UNECE/UNECE_to_OPCUA.csv"> OPC UA unitID mapping table</a>. <br> * * @return QUDT URI as string of the given unit */public String getQudtURI() { switch (this.opcUnitId) { case 17476 : return "http://qudt.org/vocab/unit#DEG"; case 4408652 : return "http://qudt.org/vocab/unit#DegreeCelsius"; default : return ""; } }
3.26
streampipes_OpcUaTypes_getType_rdh
/** * Maps OPC UA data types to internal StreamPipes data types * * @param o * data type id as UInteger * @return StreamPipes internal data type */ public static Datatypes getType(UInteger o) { if ((((((UInteger.valueOf(4).equals(o) | UInteger.valueOf(5).equals(o)) | UInteger.valueOf(6).equals(o)) | UInteger.valueOf(7).equals(o)) | UInteger.valueOf(8).equals(o)) | UInteger.valueOf(9).equals(o)) | UInteger.valueOf(27).equals(o)) { return Datatypes.Integer; } else if (UInteger.valueOf(8).equals(o)) { return Datatypes.Long; } else if (UInteger.valueOf(11).equals(o)) { return Datatypes.Double;} else if ((UInteger.valueOf(10).equals(o) | UInteger.valueOf(26).equals(o)) | UInteger.valueOf(50).equals(o)) { return Datatypes.Float; } else if (UInteger.valueOf(1).equals(o)) { return Datatypes.Boolean; } else if (UInteger.valueOf(12).equals(o)) { return Datatypes.String; } return Datatypes.String; }
3.26
streampipes_AbstractMigrationManager_performMigration_rdh
/** * Performs the actual migration of a pipeline element. * This includes the communication with the extensions service which runs the migration. * * @param pipelineElement * pipeline element to be migrated * @param migrationConfig * config of the migration to be performed * @param url * url of the migration endpoint at the extensions service * where the migration should be performed * @param <T> * type of the processing element * @return result of the migration */ protected <T extends VersionedNamedStreamPipesEntity> MigrationResult<T> performMigration(T pipelineElement, ModelMigratorConfig migrationConfig, String url) { try { var migrationRequest = new MigrationRequest<>(pipelineElement, migrationConfig); String serializedRequest = JacksonSerializer.getObjectMapper().writeValueAsString(migrationRequest); var migrationResponse = ExtensionServiceExecutions.extServicePostRequest(url, serializedRequest).execute(); TypeReference<MigrationResult<T>> typeReference = new TypeReference<>() {};return JacksonSerializer.getObjectMapper().readValue(migrationResponse.returnContent().asString(), typeReference); } catch (JsonProcessingException e) { LOG.error("Migration of pipeline element failed before sending to the extensions service, " + "pipeline element is not migrated. Serialization of migration request failed: {}", StringUtils.join(e.getStackTrace(), "\n")); } catch (IOException e) { LOG.error("Migration of pipeline element failed at the extensions service, pipeline element is not migrated: {}.", StringUtils.join(e.getStackTrace(), "\n")); } return MigrationResult.failure(pipelineElement, "Internal error during migration at StreamPipes Core"); }
3.26
streampipes_AbstractMigrationManager_performUpdate_rdh
/** * Perform the update of the description based on the given requestUrl * * @param requestUrl * URl that references the description to be updated at the extensions service. */ protected void performUpdate(String requestUrl) { try { var entityPayload = HttpJsonParser.getContentFromUrl(URI.create(requestUrl)); var updateResult = Operations.verifyAndUpdateElement(entityPayload); if (!updateResult.isSuccess()) {LOG.error("Updating the pipeline element description failed: {}", StringUtils.join(updateResult.getNotifications().stream().map(Notification::toString).toList(), "\n")); } } catch (IOException | SepaParseException e) { LOG.error("Updating the pipeline element description failed due to the following exception:\n{}", StringUtils.join(e.getStackTrace(), "\n")); } }
3.26
streampipes_AbstractMigrationManager_updateDescriptions_rdh
/** * Update all descriptions of entities in the Core that are affected by migrations. * * @param migrationConfigs * List of migrations to take in account * @param serviceUrl * Url of the extension service that provides the migrations. */ protected void updateDescriptions(List<ModelMigratorConfig> migrationConfigs, String serviceUrl) { // We only need to update the description once per appId, // because this is directly done with the newest version of the description and // there is iterative migration required. // To avoid unnecessary, multiple updates, // we filter the migration configs such that every appId is unique. // This ensures that every description is only updated once. migrationConfigs.stream().collect(Collectors.toMap(ModelMigratorConfig::targetAppId, Function.identity(), (existing, replacement) -> existing)).values().stream().peek(config -> { var requestUrl = getRequestUrl(config.modelType(), config.targetAppId(), serviceUrl); performUpdate(requestUrl); }).toList(); }
3.26
streampipes_ImageExtractor_getInstance_rdh
/** * Returns the singleton instance of {@link ImageExtractor}. * * @return */ public static ImageExtractor getInstance() { return INSTANCE; }
3.26
streampipes_ImageExtractor_process_rdh
/** * Fetches the given {@link URL} using {@link HTMLFetcher} and processes the retrieved HTML using * the specified {@link BoilerpipeExtractor}. * * @param doc * The processed {@link TextDocument}. * @param is * The original HTML document. * @return A List of enclosed {@link Image}s * @throws BoilerpipeProcessingException */ public List<Image> process(final URL url, final BoilerpipeExtractor extractor) throws IOException, BoilerpipeProcessingException, SAXException { final HTMLDocument htmlDoc = HTMLFetcher.fetch(url); final TextDocument doc = new BoilerpipeSAXInput(htmlDoc.toInputSource()).getTextDocument(); extractor.process(doc); final InputSource is = htmlDoc.toInputSource(); return process(doc, is); }
3.26
streampipes_ExtractorBase_getText_rdh
/** * Extracts text from the given {@link TextDocument} object. * * @param doc * The {@link TextDocument}. * @return The extracted text. * @throws BoilerpipeProcessingException */ public String getText(TextDocument doc) throws BoilerpipeProcessingException { process(doc); return doc.getContent(); }
3.26
streampipes_SpKafkaProducer_createKafkaTopic_rdh
/** * Create a new topic and define number partitions, replicas, and retention time * * @param settings * The settings to connect to a Kafka broker */ private void createKafkaTopic(KafkaTransportProtocol settings) throws ExecutionException, InterruptedException { Properties props = new Properties(); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerUrl); AdminClient adminClient = KafkaAdminClient.create(props); ListTopicsResult topics = adminClient.listTopics(); if (!topicExists(topics)) { Map<String, String> topicConfig = new HashMap<>(); String retentionTime = Environments.getEnvironment().getKafkaRetentionTimeMs().getValueOrDefault(); topicConfig.put(TopicConfig.RETENTION_MS_CONFIG, retentionTime); final NewTopic newTopic = new NewTopic(f0, 1, ((short) (1))); newTopic.configs(topicConfig); final CreateTopicsResult createTopicsResult = adminClient.createTopics(Collections.singleton(newTopic)); createTopicsResult.values().get(f0).get(); LOG.info("Successfully created Kafka topic " + f0); } else { LOG.info(("Topic " + f0) + "already exists in the broker, skipping topic creation"); }}
3.26
streampipes_ZipFileExtractor_extractZipToMap_rdh
// TODO used by export feature - extend this to support binaries public Map<String, byte[]> extractZipToMap() throws IOException { byte[] buffer = new byte[1024]; Map<String, byte[]> entries = new HashMap<>(); ZipInputStream zis = new ZipInputStream(zipInputStream); ZipEntry zipEntry = zis.getNextEntry(); while (zipEntry != null) { ByteArrayOutputStream fos = new ByteArrayOutputStream(); int len; while ((len = zis.read(buffer)) > 0) { fos.write(buffer, 0, len); } entries.put(sanitizeName(zipEntry.getName()), fos.toByteArray()); fos.close(); zipEntry = zis.getNextEntry(); } zis.closeEntry(); zis.close(); return entries;}
3.26
streampipes_DataStreamApi_create_rdh
/** * Directly install a new data stream * * @param stream * The data stream to add */ @Override public void create(SpDataStream stream) { post(StreamPipesApiPath.fromBaseApiPath().addToPath("streams"), stream); }
3.26
streampipes_DataStreamApi_delete_rdh
/** * Delete a data stream * * @param streamId * The elementId of the stream */ @Override public void delete(String streamId) { delete(getBaseResourcePath().addToPath(URLEncoder.encode(streamId)), Message.class); }
3.26
streampipes_DataStreamApi_subscribe_rdh
/** * Subscribe to a data stream * * @param stream * The data stream to subscribe to * @param kafkaConfig * Additional kafka settings which will override the default value (see docs) * @param callback * The callback where events will be received */ @Override public ISubscription subscribe(SpDataStream stream, IBrokerConfigOverride kafkaConfig, EventProcessor callback) { return new SubscriptionManager(kafkaConfig, stream.getEventGrounding(), callback).subscribe(); }
3.26
streampipes_DataStreamApi_all_rdh
/** * Get all available data streams * * @return {@link org.apache.streampipes.model.SpDataStream} A list of all data streams owned by the user. */ @Override public List<SpDataStream> all() { return getAll(getBaseResourcePath()); }
3.26
streampipes_OpcUaUtil_resolveConfiguration_rdh
/** * * * OPC UA specific implementation of * {@link ResolvesContainerProvidedOptions resolveOptions(String, StaticPropertyExtractor)}. * * @param internalName * The internal name of the Static Property * @param parameterExtractor * to extract parameters from the OPC UA config * @return {@code List<Option>} with available node names for the given OPC UA configuration */ public static RuntimeResolvableTreeInputStaticProperty resolveConfiguration(String internalName, IStaticPropertyExtractor parameterExtractor) throws SpConfigurationException { RuntimeResolvableTreeInputStaticProperty config = parameterExtractor.getStaticPropertyByName(internalName, RuntimeResolvableTreeInputStaticProperty.class); // access mode and host/url have to be selected try { parameterExtractor.selectedAlternativeInternalId(OpcUaLabels.OPC_HOST_OR_URL.name()); parameterExtractor.selectedAlternativeInternalId(OpcUaLabels.ACCESS_MODE.name()); } catch (NullPointerException nullPointerException) { return config;} SpOpcUaClient spOpcUaClient = new SpOpcUaClient(SpOpcUaConfigExtractor.extractSharedConfig(parameterExtractor, new OpcUaConfig())); try { spOpcUaClient.connect(); OpcUaNodeBrowser nodeBrowser = new OpcUaNodeBrowser(spOpcUaClient.getClient(), spOpcUaClient.getSpOpcConfig()); var nodes = nodeBrowser.buildNodeTreeFromOrigin(config.getNextBaseNodeToResolve()); if (Objects.isNull(config.getNextBaseNodeToResolve())) { config.setNodes(nodes); } else { config.setLatestFetchedNodes(nodes); } return config; } catch (UaException e) { throw new SpConfigurationException(ExceptionMessageExtractor.getDescription(e), e); } catch (ExecutionException | InterruptedException | URISyntaxException e) { throw new SpConfigurationException("Could not connect to the OPC UA server with the provided settings", e); } finally { if (spOpcUaClient.getClient() != null) { spOpcUaClient.disconnect(); } } }
3.26
streampipes_OpcUaUtil_retrieveDataTypesFromServer_rdh
/** * connects to each node individually and updates the data type in accordance to the data from the server. * * @param opcNodes * List of opcNodes where the data type is not determined appropriately */ public static void retrieveDataTypesFromServer(OpcUaClient client, List<OpcNode> opcNodes) throws AdapterException { for (OpcNode opcNode : opcNodes) { try { UInteger dataTypeId = ((UInteger) (client.getAddressSpace().getVariableNode(opcNode.getNodeId()).getDataType().getIdentifier())); OpcUaTypes.getType(dataTypeId); opcNode.setType(OpcUaTypes.getType(dataTypeId)); } catch (UaException e) { throw new AdapterException("Could not guess schema for opc node! " + e.getMessage()); }} }
3.26
streampipes_OpcUaUtil_formatServerAddress_rdh
/** * * * Ensures server address starts with {@code opc.tcp://} * * @param serverAddress * server address as given by user * @return correctly formated server address */ public static String formatServerAddress(String serverAddress) { if (!serverAddress.startsWith("opc.tcp://")) { serverAddress = "opc.tcp://" + serverAddress; } return serverAddress; }
3.26
streampipes_OpcUaUtil_getSchema_rdh
/** * * * OPC UA specific implementation of * * @param extractor * @return guess schema * @throws AdapterException * @throws ParseException */ public static GuessSchema getSchema(IAdapterParameterExtractor extractor) throws AdapterException, ParseException { var builder = GuessSchemaBuilder.create(); EventSchema eventSchema = new EventSchema(); Map<String, Object> eventPreview = new HashMap<>(); Map<String, FieldStatusInfo> fieldStatusInfos = new HashMap<>(); List<EventProperty> allProperties = new ArrayList<>(); SpOpcUaClient<OpcUaConfig> spOpcUaClient = new SpOpcUaClient<>(SpOpcUaConfigExtractor.extractSharedConfig(extractor.getStaticPropertyExtractor(), new OpcUaConfig())); try { spOpcUaClient.connect(); OpcUaNodeBrowser nodeBrowser = new OpcUaNodeBrowser(spOpcUaClient.getClient(), spOpcUaClient.getSpOpcConfig()); List<OpcNode> selectedNodes = nodeBrowser.findNodes(); if (!selectedNodes.isEmpty()) { for (OpcNode opcNode : selectedNodes) { if (opcNode.hasUnitId()) { allProperties.add(PrimitivePropertyBuilder.create(opcNode.getType(), opcNode.getLabel()).label(opcNode.getLabel()).measurementUnit(new URI(opcNode.getQudtURI())).build()); } else { allProperties.add(PrimitivePropertyBuilder.create(opcNode.getType(), opcNode.getLabel()).label(opcNode.getLabel()).build()); }} } var nodeIds = selectedNodes.stream().map(OpcNode::getNodeId).collect(Collectors.toList()); var v10 = spOpcUaClient.getClient().readValues(0, TimestampsToReturn.Both, nodeIds); var returnValues = v10.get(); makeEventPreview(selectedNodes, eventPreview, fieldStatusInfos, returnValues); } catch (Exception e) { throw new AdapterException("Could not guess schema for opc node: " + e.getMessage(), e); } finally { spOpcUaClient.disconnect(); } eventSchema.setEventProperties(allProperties); builder.properties(allProperties); builder.fieldStatusInfos(fieldStatusInfos); builder.preview(eventPreview); return builder.build(); }
3.26
streampipes_DbDataTypeFactory_getFromObject_rdh
/** * Tries to identify the data type of the object {@code o}. In case it is not supported, it is * interpreted as a String (VARCHAR(255)) * * @param o * The object which should be identified * @return */ public static DbDataTypes getFromObject(final Object o, SupportedDbEngines sqlEngine) { if (o instanceof Integer) { return getInteger(sqlEngine); } else if (o instanceof Long) { return getLong(sqlEngine); } else if (o instanceof Float) { return getFloat(sqlEngine); } else if (o instanceof Double) { return getDouble(sqlEngine); } else if (o instanceof Boolean) { return getBoolean(sqlEngine); } else { return getLongString(sqlEngine); } }
3.26
streampipes_StatementUtils_getStatement_rdh
/** * This method checks if the user input is correct. When not null is returned * * @param s * @return */ public static Statement getStatement(String s) { Statement result = new Statement(); String[] parts = s.split(";"); // default case if (parts.length == 2) { if (parts[0].equals("*")) { result.setOperator(parts[0]); result.setLabel(parts[1]); return result; } else { return null; } } // all other valid cases if (parts.length == 3) { if ((parts[0].equals(">") || parts[0].equals("<")) || parts[0].equals("=")) { result.setOperator(parts[0]); } else { return null; } if (isNumeric(parts[1].replaceAll("-", ""))) { result.setValue(Double.parseDouble(parts[1])); } else { return null; } result.setLabel(parts[2]); return result; } else { return null; } }
3.26
streampipes_StatementUtils_addLabel_rdh
/** * Add a label to the input event according to the provided statements * * @param inputEvent * @param value * @param statements * @return */ public static Event addLabel(Event inputEvent, String labelName, double value, List<Statement> statements) { String label = getLabel(value, statements); if (label != null) { inputEvent.addField(labelName, label); } else { LOG.info("No condition of statements was fulfilled, add a default case (*) to the statements"); } return inputEvent; }
3.26
streampipes_TextBlock_getContainedTextElements_rdh
/** * Returns the containedTextElements BitSet, or <code>null</code>. * * @return */ public BitSet getContainedTextElements() { return containedTextElements; }
3.26
streampipes_TextBlock_hasLabel_rdh
/** * Checks whether this TextBlock has the given label. * * @param label * The label * @return <code>true</code> if this block is marked by the given label. */ public boolean hasLabel(final String label) { return (labels != null) && labels.contains(label); }
3.26
streampipes_TextBlock_m1_rdh
/** * Adds a set of labels to this {@link TextBlock}. <code>null</code>-references are silently * ignored. * * @param l * The labels to be added. */ public void m1(final String... l) { if (l == null) { return;} if (this.labels == null) { this.labels = new HashSet<String>(); } for (final String label : l) { this.labels.add(label); } }
3.26
streampipes_TextBlock_addLabel_rdh
/** * Adds an arbitrary String label to this {@link TextBlock}. * * @param label * The label * @see DefaultLabels */ public void addLabel(final String label) { if (labels == null) { labels = new HashSet<String>(2); } labels.add(label); }
3.26
streampipes_TextBlock_getLabels_rdh
/** * Returns the labels associated to this TextBlock, or <code>null</code> if no such labels exist. * * NOTE: The returned instance is the one used directly in TextBlock. You have full access to the * data structure. However it is recommended to use the label-specific methods in * {@link TextBlock} whenever possible. * * @return Returns the set of labels, or <code>null</code> if no labels was added yet. */ public Set<String> getLabels() { return labels; } /** * Adds a set of labels to this {@link TextBlock}
3.26
streampipes_ProtocolManager_findInputCollector_rdh
// TODO currently only the topic name is used as an identifier for a consumer/producer. Should // be changed by some hashCode implementation in streampipes-model, but this requires changes // in empire serializers public static <T extends TransportProtocol> StandaloneSpInputCollector findInputCollector(T protocol, TransportFormat format, Boolean singletonEngine) throws SpRuntimeException { if (consumers.containsKey(topicName(protocol))) { return consumers.get(topicName(protocol)); } else { consumers.put(topicName(protocol), makeInputCollector(protocol, format, singletonEngine)); LOG.info((("Adding new consumer to consumer map (size=" + consumers.size()) + "): ") + topicName(protocol)); return consumers.get(topicName(protocol)); } }
3.26
streampipes_RuntimeResolvableRequestHandler_handleRuntimeResponse_rdh
// for backwards compatibility public RuntimeOptionsResponse handleRuntimeResponse(ResolvesContainerProvidedOptions resolvesOptions, RuntimeOptionsRequest req) throws SpConfigurationException { List<Option> availableOptions = resolvesOptions.resolveOptions(req.getRequestId(), makeExtractor(req)); SelectionStaticProperty sp = getConfiguredProperty(req); sp.setOptions(availableOptions); return new RuntimeOptionsResponse(req, sp); }
3.26
streampipes_InfluxStore_connect_rdh
/** * Connects to the InfluxDB Server, sets the database and initializes the batch-behaviour * * @throws SpRuntimeException * If not connection can be established or if the database could not * be found */ private void connect(InfluxConnectionSettings settings) throws SpRuntimeException { influxDb = InfluxClientProvider.getInfluxDBClient(settings); // Checking, if server is available var response = influxDb.ping(); if (response.getVersion().equalsIgnoreCase("unknown")) { throw new SpRuntimeException("Could not connect to InfluxDb Server: " + settings.getConnectionUrl()); } String databaseName = settings.getDatabaseName(); // Checking whether the database exists if (!InfluxRequests.databaseExists(influxDb, databaseName)) { LOG.info(("Database '" + databaseName) + "' not found. Gets created ..."); createDatabase(databaseName); } // setting up the database influxDb.setDatabase(databaseName); var batchSize = 2000; var flushDuration = 500; influxDb.enableBatch(batchSize, flushDuration, TimeUnit.MILLISECONDS); }
3.26
streampipes_InfluxStore_createDatabase_rdh
/** * Creates a new database with the given name * * @param dbName * The name of the database which should be created */ private void createDatabase(String dbName) throws SpRuntimeException { if (!dbName.matches("^[a-zA-Z_]\\w*$")) { throw new SpRuntimeException(("Database name '" + dbName) + "' not allowed. Allowed names: ^[a-zA-Z_][a-zA-Z0-9_]*$"); } influxDb.query(new Query(("CREATE DATABASE \"" + dbName) + "\"", "")); }
3.26
streampipes_InfluxStore_close_rdh
/** * Shuts down the connection to the InfluxDB server */ public void close() throws SpRuntimeException { influxDb.flush(); try { Thread.sleep(1000); } catch (InterruptedException e) { throw new SpRuntimeException(e); } influxDb.close(); }
3.26
streampipes_NumWordsRulesExtractor_getInstance_rdh
/** * Returns the singleton instance for {@link NumWordsRulesExtractor}. */ public static NumWordsRulesExtractor getInstance() { return INSTANCE; }
3.26
streampipes_MqttUtils_extractQoSFromString_rdh
// remove non-digits public static QoS extractQoSFromString(String s) { int qos = Integer.parseInt(s.replaceAll("\\D+", "")); switch (qos) { case 0 : return QoS.AT_MOST_ONCE; case 1 : return QoS.AT_LEAST_ONCE; case 2 : return QoS.EXACTLY_ONCE; } throw new SpRuntimeException("Could not retrieve QoS level: QoS " + qos);}
3.26
streampipes_HTMLFetcher_fetch_rdh
/** * Fetches the document at the given URL, using {@link URLConnection}. * * @param url * @return * @throws IOException */ public static HTMLDocument fetch(final URL url) throws IOException { final URLConnection conn = url.openConnection(); final String ct = conn.getContentType(); if ((ct == null) || (!(ct.equals("text/html") || ct.startsWith("text/html;")))) { throw new IOException("Unsupported content type: " + ct); } Charset v2 = Charset.forName("Cp1252"); if (ct != null) { Matcher m = PAT_CHARSET.matcher(ct); if (m.find()) { final String charset = m.group(1); try { v2 = Charset.forName(charset);} catch (UnsupportedCharsetException e) { // keep default } } } InputStream in = conn.getInputStream(); final String encoding = conn.getContentEncoding(); if (encoding != null) { if ("gzip".equalsIgnoreCase(encoding)) { in = new GZIPInputStream(in); } else { System.err.println("WARN: unsupported Content-Encoding: " + encoding); } } ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] v8 = new byte[4096]; int r; while ((r = in.read(v8)) != (-1)) { bos.write(v8, 0, r); } in.close(); final byte[] data = bos.toByteArray();return new HTMLDocument(data, v2); }
3.26
streampipes_EpProperties_stringEp_rdh
/** * Creates a new primitive property of type string and the provided domain property. In addition, the value range * of the property is restricted to the defined {@link org.apache.streampipes.model.schema.Enumeration} * * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperties * The semantics of the list property as a list of URIs. Use one of the vocabularies * provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyPrimitive stringEp(Label label, String runtimeName, List<URI> domainProperties) { return ep(label, XSD.STRING.toString(), runtimeName, domainProperties); }
3.26
streampipes_EpProperties_integerEp_rdh
/** * Creates a new primitive property of type integer and the provided domain properties. In addition, the value range * of the property is restricted to the defined {@link org.apache.streampipes.model.schema.Enumeration} * * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperties * The semantics of the list property as a list of URIs. Use one of the vocabularies * provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyPrimitive integerEp(Label label, String runtimeName, List<URI> domainProperties) { return ep(label, XSD.INTEGER.toString(), runtimeName, domainProperties); }
3.26
streampipes_EpProperties_imageProperty_rdh
/** * Creates a new primitive property of type image (with data type string and domain property image * * @param runtimeName * The field identifier of the event property at runtime. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */public static EventPropertyPrimitive imageProperty(String runtimeName) { EventPropertyPrimitive ep = ep(Labels.from("", "Image", ""), XSD.STRING.toString(), runtimeName, SPSensor.IMAGE); ep.setPropertyScope(PropertyScope.MEASUREMENT_PROPERTY.name()); return ep; }
3.26
streampipes_EpProperties_listStringEp_rdh
/** * Creates a new list-based event property of type string and with the assigned domain property. * * @param label * A human-readable label of the property * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyList listStringEp(Label label, String runtimeName, String domainProperty) { return listEp(label, runtimeName, Datatypes.String, domainProperty); }
3.26
streampipes_EpProperties_listLongEp_rdh
/** * Creates a new list-based event property of type long and with the assigned domain property. * * @param label * A human-readable label of the property * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyList listLongEp(Label label, String runtimeName, String domainProperty) { return listEp(label, runtimeName, Datatypes.Long, domainProperty); }
3.26
streampipes_EpProperties_listIntegerEp_rdh
/** * Creates a new list-based event property of type integer and with the assigned domain property. * * @param label * A human-readable label of the property * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyList listIntegerEp(Label label, String runtimeName, String domainProperty) { return listEp(label, runtimeName, Datatypes.Integer, domainProperty); }
3.26
streampipes_EpProperties_numberEp_rdh
/** * Creates a new primitive property of type number and the provided domain property. * * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyPrimitive numberEp(Label label, String runtimeName, String domainProperty) { return ep(label, SO.NUMBER, runtimeName, domainProperty); } /** * Creates a new primitive property of type string and the provided domain property. * * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive}
3.26
streampipes_EpProperties_timestampProperty_rdh
/** * Creates a new primitive property of type timestamp (with data type long and domain property schema.org/DateTime * * @param runtimeName * The field identifier of the event property at runtime. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyPrimitive timestampProperty(String runtimeName) { // TODO we need a real timestamp property! EventPropertyPrimitive ep = ep(Labels.from("", "Timestamp", "The current timestamp value"), XSD.LONG.toString(), runtimeName, "http://schema.org/DateTime"); ep.setPropertyScope(PropertyScope.HEADER_PROPERTY.name()); return ep; }
3.26
streampipes_EpProperties_longEp_rdh
/** * Creates a new primitive property of type integer and the provided domain property. * * @param label * A human-readable identifier of the property presented to users in the StreamPipes UI. * If you do not want to have a label besides the runtime name, use * {@link org.apache.streampipes.sdk.helpers.Labels} * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyPrimitive longEp(Label label, String runtimeName, String domainProperty) { return ep(label, XSD.LONG.toString(), runtimeName, domainProperty); }
3.26
streampipes_EpProperties_listBooleanEp_rdh
/** * Creates a new list-based event property of type boolean and with the assigned domain property. * * @param label * A human-readable label of the property * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyList listBooleanEp(Label label, String runtimeName, String domainProperty) { return listEp(label, runtimeName, Datatypes.Boolean, domainProperty); }
3.26
streampipes_EpProperties_m0_rdh
/** * Creates a new primitive property of type string and the provided domain property. In addition, the value range * of the property is restricted to the defined {@link org.apache.streampipes.model.schema.Enumeration} * * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @param enumeration * The allowed values of the event property at runtime. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */public static EventPropertyPrimitive m0(Label label, String runtimeName, String domainProperty, Enumeration enumeration) { EventPropertyPrimitive ep = ep(label, XSD.STRING.toString(), runtimeName, domainProperty); ep.setValueSpecification(enumeration); return ep; }
3.26
streampipes_EpProperties_listDoubleEp_rdh
/** * Creates a new list-based event property of type double and with the assigned domain property. * * @param label * A human-readable label of the property * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyList listDoubleEp(Label label, String runtimeName, String domainProperty) { return listEp(label, runtimeName, Datatypes.Double, domainProperty); }
3.26
streampipes_EpProperties_booleanEp_rdh
/** * Creates a new primitive property of type boolean and the provided domain property. * * @param runtimeName * The field identifier of the event property at runtime. * @param domainProperty * The semantics of the list property as a String. The string should correspond to a URI * provided by a vocabulary. Use one of the vocabularies provided in * {@link org.apache.streampipes.vocabulary} or create your own domain-specific vocabulary. * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive} */ public static EventPropertyPrimitive booleanEp(Label label, String runtimeName, String domainProperty) { return ep(label, XSD.BOOLEAN.toString(), runtimeName, domainProperty);}
3.26
streampipes_EpProperties_listEp_rdh
/** * Creates a new list-based event property of the parameter type eventProperty * * @param label * A human-readable label of the property * @param runtimeName * The field identifier of the event property at runtime. * @param eventProperty * The complex type of data in the list * @return {@link org.apache.streampipes.model.schema.EventPropertyList} */ public static EventPropertyList listEp(Label label, String runtimeName, EventProperty eventProperty, String domainProperty) { return getPreparedProperty(label, new EventPropertyList(runtimeName, eventProperty, Utils.createURI(domainProperty)));}
3.26
streampipes_ParserDescriptionBuilder_create_rdh
/** * Creates a new format description using the builder pattern. * * @param id * A unique identifier of the new element, e.g., com.mycompany.sink.mynewdatasink * @param label * A human-readable name of the element. * Will later be shown as the element name in the StreamPipes UI. * @param description * A human-readable description of the element. */ public static ParserDescriptionBuilder create(String id, String label, String description) { return new ParserDescriptionBuilder(id, label, description); }
3.26
streampipes_DataStreamBuilder_create_rdh
/** * Creates a new data stream using the builder pattern. * * @param id * A unique identifier of the new element, e.g., com.mycompany.stream.mynewdatastream * @return a new instance of {@link DataStreamBuilder} */ public static DataStreamBuilder create(String id) { return new DataStreamBuilder(id); }
3.26
streampipes_DataStreamBuilder_properties_rdh
/** * Assigns a list of new event properties to the stream's schema. * * @param properties * The event properties that should be added. * @return this */ public DataStreamBuilder properties(List<EventProperty> properties) { this.f0.addAll(properties); return me(); }
3.26
streampipes_DataStreamBuilder_format_rdh
/** * Assigns a new {@link org.apache.streampipes.model.grounding.TransportFormat} to the stream definition. * * @param format * The transport format of the stream at runtime (e.g., JSON or Thrift). * Use {@link org.apache.streampipes.sdk.helpers.Formats} to use some pre-defined formats * (or create a new format as described in the developer guide). * @return this */ public DataStreamBuilder format(TransportFormat format) { this.eventGrounding.setTransportFormats(Collections.singletonList(format)); return this; }
3.26
streampipes_DataStreamBuilder_property_rdh
/** * Assigns a new event property to the stream's schema. * * @param property * The event property that should be added. * Use {@link org.apache.streampipes.sdk.helpers.EpProperties} * for defining simple property definitions or * {@link org.apache.streampipes.sdk.builder.PrimitivePropertyBuilder} * for defining more complex definitions. * @return this */ public DataStreamBuilder property(EventProperty property) { this.f0.add(property); return me(); }
3.26
streampipes_DataStreamBuilder_protocol_rdh
/** * Assigns a new {@link org.apache.streampipes.model.grounding.TransportProtocol} to the stream definition. * * @param protocol * The transport protocol of the stream at runtime (e.g., Kafka or MQTT). * Use {@link org.apache.streampipes.sdk.helpers.Protocols} to use some pre-defined protocols * (or create a new protocol as described in the developer guide). * @return this */public DataStreamBuilder protocol(TransportProtocol protocol) { this.eventGrounding.setTransportProtocol(protocol); return this; }
3.26
streampipes_DataStreamBuilder_m0_rdh
/** * Creates a new data stream using the builder pattern. * * @param id * A unique identifier of the new element, e.g., com.mycompany.stream.mynewdatastream * @param label * A human-readable name of the element. * Will later be shown as the element name in the StreamPipes UI. * @param description * A human-readable description of the element. * @return a new instance of {@link DataStreamBuilder} */ public static DataStreamBuilder m0(String id, String label, String description) { return new DataStreamBuilder(id, label, description);}
3.26
streampipes_ProcessingElementBuilder_outputStrategy_rdh
/** * Assigns an output strategy to the element which defines the output the data processor produces. * * @param outputStrategy * An {@link org.apache.streampipes.model.output.OutputStrategy}. Use * {@link org.apache.streampipes.sdk.helpers.OutputStrategies} to assign the strategy. * @return {@link ProcessingElementBuilder} */ public ProcessingElementBuilder outputStrategy(OutputStrategy outputStrategy) { this.outputStrategies.add(outputStrategy); return me(); }
3.26
streampipes_ProcessingElementBuilder_create_rdh
/** * Creates a new processing element using the builder pattern. If no label and description is * given * for an element, * {@link org.apache.streampipes.sdk.builder.AbstractProcessingElementBuilder#withLocales(Locales...)} * must be called. * * @param id * A unique identifier of the new element, e.g., com.mycompany.sink.mynewdatasink */ public static ProcessingElementBuilder create(String id, int version) { return new ProcessingElementBuilder(id, version); }
3.26
streampipes_ProcessingElementBuilder_category_rdh
/** * Assigns a category to the element which later serves to categorize data processors in the UI. * * @param epaCategory * The {@link org.apache.streampipes.model.DataProcessorType} of the element. * @return {@link ProcessingElementBuilder} */ public ProcessingElementBuilder category(DataProcessorType... epaCategory) { this.elementDescription.setCategory(Arrays.stream(epaCategory).map(Enum::name).collect(Collectors.toList())); return me(); }
3.26
streampipes_KDTree_createKDTree_rdh
// Only ever goes to log2(items.length) depth so lack of tail recursion is a non-issue private KDNode<T> createKDTree(List<T> items, int depth) { if (items.isEmpty()) { return null; } Collections.sort(items, items.get(0).getComparator(depth % 3)); int currentIndex = items.size() / 2; return new KDNode<T>(createKDTree(new ArrayList<T>(items.subList(0, currentIndex)), depth + 1), createKDTree(new ArrayList<T>(items.subList(currentIndex + 1, items.size())), depth + 1), items.get(currentIndex)); }
3.26
streampipes_JdbcClient_save_rdh
/** * Prepares a statement for the insertion of values or the * * @param event * The event which should be saved to the Postgres table * @throws SpRuntimeException * When there was an error in the saving process */ protected void save(final Event event) throws SpRuntimeException { // TODO: Add batch support (https://stackoverflow.com/questions/3784197/efficient-way-to-do-batch-inserts-with-jdbc) checkConnected(); Map<String, Object> eventMap = event.getRaw(); if (event == null) { throw new SpRuntimeException("event is null"); } if (!this.tableDescription.tableExists()) { // Creates the table createTable();this.tableDescription.setTableExists(); } try { checkConnected(); this.statementHandler.executePreparedStatement(this.dbDescription, this.tableDescription, connection, eventMap); } catch (SQLException e) { if (e.getSQLState().substring(0, 2).equals("42")) { // If the table does not exists (because it got deleted or something, will cause the error // code "42") we will try to create a new one. Otherwise we do not handle the exception. LOG.warn(("Table '" + this.tableDescription.getName()) + "' was unexpectedly not found and gets recreated."); this.tableDescription.setTableMissing(); createTable(); this.tableDescription.setTableExists(); try { checkConnected(); this.statementHandler.executePreparedStatement(this.dbDescription, this.tableDescription, connection, eventMap); } catch (SQLException e1) { throw new SpRuntimeException(e1.getMessage()); } } else { throw new SpRuntimeException(e.getMessage()); } } }
3.26
streampipes_JdbcClient_connectWithSSL_rdh
/** * WIP * * @param host * @param port * @param databaseName * @throws SpRuntimeException */ private void connectWithSSL(String host, int port, String databaseName) throws SpRuntimeException { String url = ((((((((((((("jdbc:" + this.dbDescription.getEngine().getUrlName()) + "://") + host) + ":") + port) + "/") + databaseName) + "?user=") + this.dbDescription.getUsername()) + "&password=") + this.dbDescription.getPassword()) + "&ssl=true&sslfactory=") + this.dbDescription.getSslFactory()) + "&sslmode=require"; try { connection = DriverManager.getConnection(url); ensureDatabaseExists(databaseName); ensureTableExists(url, ""); } catch (SQLException e) { throw new SpRuntimeException("Could not establish a connection with the server: " + e.getMessage()); } }
3.26
streampipes_JdbcClient_closeAll_rdh
/** * Closes all open connections and statements of JDBC */ protected void closeAll() { boolean error = false; try { if (this.statementHandler.statement != null) {this.statementHandler.statement.close();this.statementHandler.statement = null; } } catch (SQLException e) { error = true; LOG.warn("Exception when closing the statement: " + e.getMessage()); } try { if (connection != null) { connection.close(); connection = null; } } catch (SQLException e) { error = true; LOG.warn("Exception when closing the connection: " + e.getMessage()); } try { if (this.statementHandler.preparedStatement != null) { this.statementHandler.preparedStatement.close(); this.statementHandler.preparedStatement = null; } } catch (SQLException e) { error = true; LOG.warn("Exception when closing the prepared statement: " + e.getMessage()); } if (!error) { LOG.info("Shutdown all connections successfully."); } }
3.26
streampipes_JdbcClient_ensureDatabaseExists_rdh
/** * If this method returns successfully a database with the given name exists on the server, specified by the url. * * @param databaseName * The name of the database that should exist * @throws SpRuntimeException * If the database does not exists and could not be created */ protected void ensureDatabaseExists(String databaseName) throws SpRuntimeException { String createStatement = "CREATE DATABASE "; ensureDatabaseExists(createStatement, databaseName); }
3.26
streampipes_JdbcClient_ensureTableExists_rdh
/** * If this method returns successfully a table with the name in * {@link JdbcConnectionParameters#getDbTable()} exists in the database * with the given database name exists on the server, specified by the url. * * @param url * The JDBC url containing the needed information (e.g. "jdbc:iotdb://127.0.0.1:6667/") * @param databaseName * The database in which the table should exist * @throws SpRuntimeException * If the table does not exist and could not be created */ protected void ensureTableExists(String url, String databaseName) throws SpRuntimeException { try { // Database should exist by now so we can establish a connection connection = DriverManager.getConnection(url + databaseName, this.dbDescription.getUsername(), this.dbDescription.getPassword()); this.statementHandler.setStatement(connection.createStatement()); ResultSet rs = connection.getMetaData().getTables(null, null, this.tableDescription.getName(), null); if (rs.next()) { validateTable(); } else { createTable(); } this.tableDescription.setTableExists(); rs.close(); } catch (SQLException e) { closeAll(); throw new SpRuntimeException(e.getMessage()); } }
3.26
streampipes_JdbcClient_connect_rdh
/** * Connects to the SQL database and initializes {@link JdbcClient#connection} * * @throws SpRuntimeException * When the connection could not be established (because of a * wrong identification, missing database etc.) */ private void connect(String host, int port, String databaseName) throws SpRuntimeException { String url = ((((("jdbc:" + this.dbDescription.getEngine().getUrlName()) + "://") + host) + ":") + port) + "/"; try { connection = DriverManager.getConnection(url, this.dbDescription.getUsername(), this.dbDescription.getPassword()); ensureDatabaseExists(databaseName); ensureTableExists(url, databaseName); } catch (SQLException e) { throw new SpRuntimeException("Could not establish a connection with the server: " + e.getMessage()); } }
3.26
streampipes_DataSinkBuilder_create_rdh
/** * Creates a new data sink using the builder pattern. If no label and description is given * for an element, * {@link org.apache.streampipes.sdk.builder.AbstractProcessingElementBuilder#withLocales(Locales...)} * must be called. * * @param id * A unique identifier of the new element, e.g., com.mycompany.sink.mynewdatasink */ public static DataSinkBuilder create(String id) { return new DataSinkBuilder(id); }
3.26
streampipes_MD5_m0_rdh
/** * Encodes a string * * @param str * String to encode * @return Encoded String */ public static String m0(String str) { if ((str == null) || (str.length() == 0)) { throw new IllegalArgumentException("String to encrypt cannot be null or zero length"); } StringBuilder hexString = new StringBuilder(); try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(str.getBytes()); byte[] hash = md.digest(); for (byte b : hash) { if ((0xff & b) < 0x10) { hexString.append("0").append(Integer.toHexString(0xff & b)); } else { hexString.append(Integer.toHexString(0xff & b)); } } } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return hexString.toString(); }
3.26
streampipes_RuntimeTypeAdapterFactory_registerSubtype_rdh
/** * Registers {@code type} identified by its {@link Class#getSimpleName simple * name}. Labels are case sensitive. * * @throws IllegalArgumentException * if either {@code type} or its simple name * have already been registered on this type adapter. */ public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type) { return registerSubtype(type, type.getSimpleName()); }
3.26
streampipes_RuntimeTypeAdapterFactory_of_rdh
/** * Creates a new runtime type adapter for {@code baseType} using {@code "type"} as * the type field name. */ public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType) { return new RuntimeTypeAdapterFactory<>(baseType, "type"); }
3.26
streampipes_Aggregation_process_rdh
// Gets called every time a new event is fired, i.e. when an aggregation has to be calculated protected void process(Iterable<Event> input, Collector<Event> out) { List<Double> values = new ArrayList<>(); Event lastEvent = new Event(); // Adds the values of all recent events in input to aggregate them later // Dumps thereby all previous events and only emits the most recent event in the window with the // aggregated value added for (Event anInput : input) { for (String aggregate : fieldsToAggregate) { values.add(anInput.getFieldBySelector(aggregate).getAsPrimitive().getAsDouble()); lastEvent = anInput; String propertyPrefix = StringUtils.substringAfterLast(aggregate, ":"); String runtimeName = (propertyPrefix + "_") + aggregationType.toString().toLowerCase(); lastEvent.addField(runtimeName, getAggregate(values)); } } out.collect(lastEvent); }
3.26
streampipes_NumWordsRulesClassifier_m0_rdh
/** * Returns the singleton instance for RulebasedBoilerpipeClassifier. */ public static NumWordsRulesClassifier m0() { return INSTANCE; }
3.26
streampipes_SpTrajectoryBuilder_removeOldestPoint_rdh
/** * removes the oldest point (Index 0) from the CoordinateList object. */ private void removeOldestPoint() { coordinateList.remove(0); }
3.26
streampipes_SpTrajectoryBuilder_getDescription_rdh
/** * getter method for description text * * @return description text */ public String getDescription() { return description; }
3.26
streampipes_SpTrajectoryBuilder_createSingleTrajectoryCoordinate_rdh
/** * Creates a Coordinate object with X, Y and M Value to be stored later directly in the trajectory * object. Should be used always used if adding a subpoint to the trajectory list * * @param geom * Point geometry, which coordinates will be added to the trajectory list * @param m * Double M value, which will be used to store as extra parameter in the trajectory list * for additional calculations * @return CoordinateXYM coordinate object */ private Coordinate createSingleTrajectoryCoordinate(Point geom, Double m) { CoordinateXYM coordinate = new CoordinateXYM(geom.getX(), geom.getY(), m); return coordinate; }
3.26
streampipes_SpTrajectoryBuilder_returnAsLineString_rdh
/** * returns a JTS LineString geometry from the trajectory object. LineString only stores the point * geometry without M value. The lineString is oriented to the trajectory direction. This means: the * newest point is always the last point and has the highest subpoint index. The First point is the * oldest point with the lowest index [0] * * @param factory * a Geometry factory for creating the lineString with the same precision and CRS and should be * the factory of the input point geometry * @return JTS LineString JTS LineString */ public LineString returnAsLineString(GeometryFactory factory) { LineString geom; if (coordinateList.size() > 1) { // only linestring if more than 2 points. // reverse output of linestring. so last added point is first geom = factory.createLineString(coordinateList.toCoordinateArray()); } else { geom = factory.createLineString(); } return geom; }
3.26
streampipes_SpTrajectoryBuilder_addPointToTrajectory_rdh
/** * Adds a Point to the trajectory object and also handle removes old point * if {link #numberSubPoints} threshold is exceeded. * * @param point * {@link org.locationtech.jts.geom.Point} * @param m * stores an extra double value to the subpoint of a * trajectory {@link org.locationtech.jts.geom.CoordinateXYM#M} */ public void addPointToTrajectory(Point point, Double m) { coordinateList.add(createSingleTrajectoryCoordinate(point, m)); if (coordinateList.size() > f0) { removeOldestPoint(); } }
3.26
streampipes_StreamRequirementsBuilder_create_rdh
/** * Creates new requirements for a data processor or a data sink. * * @return {@link StreamRequirementsBuilder} */ public static StreamRequirementsBuilder create() { return new StreamRequirementsBuilder();}
3.26
streampipes_StreamRequirementsBuilder_requiredPropertyWithNaryMapping_rdh
/** * Sets a new property requirement and, in addition, adds a * {@link org.apache.streampipes.model.staticproperty.MappingPropertyNary} static property to the pipeline element * definition. * * @param propertyRequirement * The property requirement. * Use {@link org.apache.streampipes.sdk.helpers.EpRequirements} to * create a new requirement. * @param label * The {@link org.apache.streampipes.sdk.helpers.Label} that defines the mapping property. * @param propertyScope * The {@link org.apache.streampipes.model.schema.PropertyScope} of the requirement. * @return this */ public StreamRequirementsBuilder requiredPropertyWithNaryMapping(EventProperty propertyRequirement, Label label, PropertyScope propertyScope) { propertyRequirement.setRuntimeName(label.getInternalId()); this.f0.add(propertyRequirement); MappingPropertyNary mp = new MappingPropertyNary(label.getInternalId(), label.getInternalId(), label.getLabel(), label.getDescription()); mp.setPropertyScope(propertyScope.name()); this.mappingProperties.add(mp); return this; } /** * Finishes the stream requirements definition. * * @return an object of type {@link org.apache.streampipes.sdk.helpers.CollectedStreamRequirements}
3.26
streampipes_StreamRequirementsBuilder_requiredPropertyWithUnaryMapping_rdh
/** * Sets a new property requirement and, in addition, adds a * {@link org.apache.streampipes.model.staticproperty.MappingPropertyUnary} static property to the pipeline element * definition. * * @param propertyRequirement * The property requirement. * Use {@link org.apache.streampipes.sdk.helpers.EpRequirements} to * create a new requirement. * @param label * The {@link org.apache.streampipes.sdk.helpers.Label} that defines the mapping property. * @param propertyScope * The {@link org.apache.streampipes.model.schema.PropertyScope} of the requirement. * @return this */ public StreamRequirementsBuilder requiredPropertyWithUnaryMapping(EventProperty propertyRequirement, Label label, PropertyScope propertyScope) { propertyRequirement.setRuntimeName(label.getInternalId()); this.f0.add(propertyRequirement);MappingPropertyUnary mp = new MappingPropertyUnary(label.getInternalId(), label.getInternalId(), label.getLabel(), label.getDescription()); mp.setPropertyScope(propertyScope.name()); this.mappingProperties.add(mp); return this; }
3.26
streampipes_StreamRequirementsBuilder_any_rdh
/** * Creates a new stream requirement without any further property requirements. * * @return {@link CollectedStreamRequirements} */ public static CollectedStreamRequirements any() { return StreamRequirementsBuilder.create().build(); }
3.26
streampipes_StreamRequirementsBuilder_requiredProperty_rdh
/** * Sets a new property requirement, e.g., a property of a specific data type or with specific semantics * a data stream that is connected to this pipeline element must provide. * * @param propertyRequirement * The property requirement. * Use {@link org.apache.streampipes.sdk.helpers.EpRequirements} to * create a new requirement. * @return this */ public StreamRequirementsBuilder requiredProperty(EventProperty propertyRequirement) { this.f0.add(propertyRequirement); return this; }
3.26
streampipes_TableDescription_createTable_rdh
/** * Creates a table with the name {@link JdbcConnectionParameters#getDbTable()} and the * properties from {@link TableDescription#getEventSchema()}. Calls * {@link SQLStatementUtils#extractEventProperties(List, String, DbDescription)} internally with the * {@link TableDescription#getEventSchema()} to extract all possible columns. * * @throws SpRuntimeException * If the {@link JdbcConnectionParameters#getDbTable()} is not allowed, if * executeUpdate throws an SQLException or if * {@link SQLStatementUtils#extractEventProperties(List, String, DbDescription)} * throws an exception */ public void createTable(String createStatement, StatementHandler statementHandler, DbDescription dbDescription, TableDescription tableDescription) throws SpRuntimeException { SQLStatementUtils.checkRegEx(tableDescription.getName(), "Tablename", dbDescription); StringBuilder statement = new StringBuilder(createStatement); statement.append(this.getName()).append(" ( "); statement.append(SQLStatementUtils.extractEventProperties(this.getEventSchema().getEventProperties(), "", dbDescription)).append(" );"); try { statementHandler.statement.executeUpdate(statement.toString()); } catch (SQLException e) { throw new SpRuntimeException(e.getMessage()); } }
3.26
streampipes_IgnoreBlocksAfterContentFilter_getDefaultInstance_rdh
/** * Returns the singleton instance for DeleteBlocksAfterContentFilter. */ public static IgnoreBlocksAfterContentFilter getDefaultInstance() { return DEFAULT_INSTANCE; }
3.26
streampipes_Networking_getIpAddressForOsx_rdh
/** * this method is a workaround for developers using osx * in OSX InetAddress.getLocalHost().getHostAddress() always returns 127.0.0.1 * as a workaround developers must manually set the SP_HOST environment variable with the actual ip * with this method the IP is set automatically * * @return IP */ private static String getIpAddressForOsx() { Socket socket = new Socket(); String result = DEFAULT_LOCALHOST_IP; try { socket.connect(new InetSocketAddress("streampipes.apache.org", 80)); result = socket.getLocalAddress().getHostAddress(); socket.close();} catch (IOException e) { LOG.error(e.getMessage()); LOG.error("IP address was not set automatically. Use the environment variable SP_HOST to set it manually."); } return result; }
3.26
streampipes_SimpleEstimator_isLowQuality_rdh
/** * Given the statistics of the document before and after applying the {@link BoilerpipeExtractor}, * can we regard the extraction quality (too) low? * * Works well with {@link DefaultExtractor}, {@link ArticleExtractor} and others. * * @param dsBefore * @param dsAfter * @return true if low quality is to be expected. */ public boolean isLowQuality(final TextDocumentStatistics dsBefore, final TextDocumentStatistics dsAfter) { if ((dsBefore.getNumWords() < 90) || (dsAfter.getNumWords() < 70)) { return true; } if (dsAfter.avgNumWords() < 25) { return true; } return false; }
3.26
streampipes_DataLakeMeasure_getTimestampFieldName_rdh
/** * This can be used to get the name of the timestamp property without the stream prefix * * @return the name of the timestamp property */ @TsIgnore @JsonIgnore public String getTimestampFieldName() { return timestampField.split(STREAM_PREFIX_DELIMITER)[1]; }
3.26
streampipes_PrimitivePropertyBuilder_create_rdh
/** * A builder class helping to define advanced primitive properties. For simple property definitions, you can also * use {@link org.apache.streampipes.sdk.helpers.EpProperties}. * * @param datatype * The primitive {@link org.apache.streampipes.sdk.utils.Datatypes} definition of the new property. * @param runtimeName * The name of the property at runtime (e.g., the field name of the JSON primitive. * @return this */ public static PrimitivePropertyBuilder create(Datatypes datatype, String runtimeName) { return new PrimitivePropertyBuilder(datatype, runtimeName); }
3.26
streampipes_PrimitivePropertyBuilder_label_rdh
/** * Assigns a human-readable label to the event property. The label is used in the StreamPipes UI for better * explaining users the meaning of the property. * * @param label * @return this */ public PrimitivePropertyBuilder label(String label) {this.eventProperty.setLabel(label); return this; }
3.26
streampipes_PrimitivePropertyBuilder_description_rdh
/** * Assigns a human-readable description to the event property. The description is used in the StreamPipes UI for * better explaining users the meaning of the property. * * @param description * @return this */ public PrimitivePropertyBuilder description(String description) { this.eventProperty.setDescription(description); return this; }
3.26
streampipes_PrimitivePropertyBuilder_valueSpecification_rdh
/** * Defines the value range in form of an enumeration. The data type of the event property must be of type String * or Number. * * @param label * A human-readable label describing this enumeration. * @param description * A human-readable description of the enumeration. * @param allowedValues * A list of allowed values of the event property at runtime. * @return this */ public PrimitivePropertyBuilder valueSpecification(String label, String description, List<String> allowedValues) { this.eventProperty.setValueSpecification(new Enumeration(label, description, allowedValues)); return this; }
3.26
streampipes_PrimitivePropertyBuilder_scope_rdh
/** * Assigns a property scope to the event property. * * @param propertyScope * The {@link org.apache.streampipes.model.schema.PropertyScope}. * @return this */ public PrimitivePropertyBuilder scope(PropertyScope propertyScope) { this.eventProperty.setPropertyScope(propertyScope.name()); return this; }
3.26
streampipes_PrimitivePropertyBuilder_domainProperty_rdh
/** * Specifies the semantics of the property (e.g., whether a double value stands for a latitude coordinate). * * @param domainProperty * The domain property as a String. The domain property should reflect an URI. Use some * existing vocabulary from {@link org.apache.streampipes.vocabulary} or create your own. * @return */ public PrimitivePropertyBuilder domainProperty(String domainProperty) { this.eventProperty.setDomainProperties(Collections.singletonList(URI.create(domainProperty))); return this; }
3.26
streampipes_FileManager_cleanFile_rdh
/** * Remove Byte Order Mark (BOM) from csv files * * @param fileInputStream * @param filetype * @return */ public static InputStream cleanFile(InputStream fileInputStream, String filetype) { if (Filetypes.CSV.getFileExtensions().contains(filetype.toLowerCase())) { fileInputStream = new BOMInputStream(fileInputStream); } return fileInputStream; }
3.26
streampipes_FileManager_storeFile_rdh
/** * Store a file in the internal file storage. * For csv files the bom is removed * * @param user * who created the file * @param filename * @param fileInputStream * content of file * @return */ public static FileMetadata storeFile(String user, String filename, InputStream fileInputStream) throws IOException { String filetype = filename.substring(filename.lastIndexOf(".") + 1); fileInputStream = cleanFile(fileInputStream, filetype); String internalFilename = m2(filetype); FileMetadata fileMetadata = m1(user, filename, internalFilename, filetype); new FileHandler().storeFile(internalFilename, fileInputStream); storeFileMetadata(fileMetadata); return fileMetadata; }
3.26
streampipes_SplitParagraphBlocksFilter_getInstance_rdh
/** * Returns the singleton instance for TerminatingBlocksFinder. */ public static SplitParagraphBlocksFilter getInstance() { return INSTANCE; }
3.26
streampipes_RosBridgeAdapter_getListOfAllTopics_rdh
// Ignore for now, but is interesting for future implementations private List<String> getListOfAllTopics(Ros ros) { List<String> result = new ArrayList<>(); Service service = new Service(ros, "/rosapi/topics", "rosapi/Topics"); ServiceRequest request = new ServiceRequest(); ServiceResponse response = service.callServiceAndWait(request);JsonObject ob = new JsonParser().parse(response.toString()).getAsJsonObject(); if (ob.has("topics")) { JsonArray topics = ob.get("topics").getAsJsonArray(); for (int i = 0; i < topics.size(); i++) { result.add(topics.get(i).getAsString()); } } return result;}
3.26
streampipes_NetioRestAdapter_pullData_rdh
/** * pullData is called iteratively according to the polling interval defined in getPollInterval. */ @Override public void pullData() { try { NetioAllPowerOutputs allPowerOutputs = requestData(); for (NetioPowerOutput output : allPowerOutputs.getPowerOutputs()) { Map<String, Object> event = NetioUtils.getEvent(allPowerOutputs.getGobalMeasure(), output); collector.collect(event); } }
3.26
streampipes_NetioRestAdapter_applyConfiguration_rdh
/** * Extracts the user configuration from the SpecificAdapterStreamDescription and sets the local variales * * @param extractor * StaticPropertyExtractor */ private void applyConfiguration(IParameterExtractor extractor) { this.ip = extractor.singleValueParameter(NETIO_IP, String.class); this.username = extractor.singleValueParameter(NETIO_USERNAME, String.class); this.password = extractor.secretValue(NETIO_PASSWORD);this.pollingInterval = extractor.singleValueParameter(NETIO_POLLING_INTERVAL, Integer.class); }
3.26