Show / Hide Table of Contents

Class CogniteUtils

Utility class for configuring a Cognite SDK client

Inheritance
object
CogniteUtils
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Cognite.Extensions
Assembly: Cognite.Extensions.dll
Syntax
public static class CogniteUtils

Fields

| Edit this page View Source

NumericValueMax

Cognite max double value

Declaration
public const double NumericValueMax = 1E+100
Field Value
Type Description
double
| Edit this page View Source

NumericValueMin

Cognite min double value

Declaration
public const double NumericValueMin = -1E+100
Field Value
Type Description
double
| Edit this page View Source

StringLengthMax

Cognite max string length

Declaration
public const int StringLengthMax = 255
Field Value
Type Description
int
| Edit this page View Source

TimestampMax

Cognite max timestamp (2099)

Declaration
public const long TimestampMax = 4102444799999
Field Value
Type Description
long
| Edit this page View Source

TimestampMin

Cognite min timestamp (1900)

Declaration
public const long TimestampMin = -2208988800000
Field Value
Type Description
long

Methods

| Edit this page View Source

EventFromStream(Stream)

Reads a single event from a stream. Encoding: [Id][Start][End][Description][Type][SubType][Source][assetIdCount][dataSetId]{[assetId1]...}[MetaCount]{[key][value]...}

Declaration
public static EventCreate? EventFromStream(Stream stream)
Parameters
Type Name Description
Stream stream

Stream to read from

Returns
Type Description
EventCreate
| Edit this page View Source

EventToStorable(EventCreate)

Transforms a single event into an array of bytes. Encoding: [Id][Start][End][Description][Type][SubType][Source][assetIdCount][dataSetId]{[assetId1]...}[MetaCount]{[key][value]...}

Declaration
public static byte[] EventToStorable(EventCreate evt)
Parameters
Type Name Description
EventCreate evt

Event to write

Returns
Type Description
byte[]

Event serialized as bytes

| Edit this page View Source

ExtractMissingFromResponseException(HashSet<Identity>, ResponseException)

Write missing identities to the provided identity set.

Declaration
public static void ExtractMissingFromResponseException(HashSet<Identity> missing, ResponseException e)
Parameters
Type Name Description
HashSet<Identity> missing

Set to add missing ids to

ResponseException e

Error containing missing ids

| Edit this page View Source

ReadDatapoints(Stream, int)

Transforms binary encoded datapoints in a stream into a dictionary of datapoints. Encoding for one timeseries, ids may repeat: [ushort id-length, 0 if internalId]{Either [long internalId] or [ushort size][string]}[uint count][dp 1]...[dp count]

Declaration
public static IDictionary<Identity, IEnumerable<Datapoint>> ReadDatapoints(Stream stream, int chunkSize = 0)
Parameters
Type Name Description
Stream stream

Stream to read from

int chunkSize

Max number of points to read before returning, reuse the stream to continue reading. 0 means that there is no upper limit. If there are timeseries-chunks larger than the chunk size in the stream, it may be exceeded.

Returns
Type Description
IDictionary<Identity, IEnumerable<Datapoint>>

Read datapoints grouped by identity

| Edit this page View Source

ReadDatapointsAsync(Stream, CancellationToken, int)

Transforms binary encoded datapoints in a stream into a dictionary of datapoints. Encoding for one timeseries, ids may repeat: [ushort id-length, 0 if internalId]{Either [long internalId] or [ushort size][string]}[uint count][dp 1]...[dp count]

Declaration
public static Task<IDictionary<Identity, IEnumerable<Datapoint>>> ReadDatapointsAsync(Stream stream, CancellationToken token, int chunkSize = 0)
Parameters
Type Name Description
Stream stream

Stream to read from

CancellationToken token
int chunkSize

Max number of points to read before returning, reuse the stream to continue reading. 0 means that there is no upper limit. If there are timeseries-chunks larger than the chunk size in the stream, it may be exceeded

Returns
Type Description
Task<IDictionary<Identity, IEnumerable<Datapoint>>>

Read datapoints grouped by identity

| Edit this page View Source

ReadEvents(Stream, int)

Read events from a stream. Encoding: [Id][Start][End][Description][Type][SubType][Source][assetIdCount][dataSetId]{[assetId1]...}[MetaCount]{[key][value]...}

Declaration
public static IEnumerable<EventCreate> ReadEvents(Stream stream, int chunkSize = 0)
Parameters
Type Name Description
Stream stream

Stream to read from

int chunkSize

Maximum number of events to read at a time, reuse the stream to continue reading. If the list is empty, end of file is reached or the file is corrupt

Returns
Type Description
IEnumerable<EventCreate>

A list of created events

| Edit this page View Source

ReadEventsAsync(Stream, CancellationToken, int)

Read events from a stream. Encoding: [Id][Start][End][Description][Type][SubType][Source][assetIdCount][dataSetId]{[assetId1]...}[MetaCount]{[key][value]...}

Declaration
public static Task<IEnumerable<EventCreate>> ReadEventsAsync(Stream stream, CancellationToken token, int chunkSize = 0)
Parameters
Type Name Description
Stream stream

Stream to read from

CancellationToken token
int chunkSize

Maximum number of events to read at a time, reuse the stream to continue reading. If the list is empty, end of file is reached or the file is corrupt

Returns
Type Description
Task<IEnumerable<EventCreate>>

A list of created events

| Edit this page View Source

StringFromStream(Stream, ushort?)

Read a string from given array of bytes, starting from given position. String being read is assumed to be on the format [unsigned short length][string]

Declaration
public static string? StringFromStream(Stream stream, ushort? size = null)
Parameters
Type Name Description
Stream stream

Stream to read from

ushort? size

Optional size, if this is non-null, skip reading size from the stream

Returns
Type Description
string

Resulting parsed string

| Edit this page View Source

StringToStorable(string?)

Turn string into an array of bytes on the format [unsigned short length][string].

Declaration
public static byte[] StringToStorable(string? str)
Parameters
Type Name Description
string str

String to transform

Returns
Type Description
byte[]

Storable bytes

| Edit this page View Source

WriteDatapoints(IDictionary<Identity, IEnumerable<Datapoint>>, Stream)

Write dictionary of datapoints to a stream. Encoding for one timeseries: [ushort id-length, 0 if internalId]{Either [long internalId] or [ushort size][string]}[uint count][dp 1]...[dp count]

Declaration
public static void WriteDatapoints(IDictionary<Identity, IEnumerable<Datapoint>> datapoints, Stream stream)
Parameters
Type Name Description
IDictionary<Identity, IEnumerable<Datapoint>> datapoints

Datapoints to store

Stream stream

Stream to write to

| Edit this page View Source

WriteDatapointsAsync(IDictionary<Identity, IEnumerable<Datapoint>>, Stream, CancellationToken)

Write dictionary of datapoints to a stream. Encoding for one timeseries: [ushort id-length, 0 if internalId]{Either [long internalId] or [ushort size][string]}[uint count][dp 1]...[dp count]

Declaration
public static Task WriteDatapointsAsync(IDictionary<Identity, IEnumerable<Datapoint>> datapoints, Stream stream, CancellationToken token)
Parameters
Type Name Description
IDictionary<Identity, IEnumerable<Datapoint>> datapoints

Datapoints to store

Stream stream

Stream to write to

CancellationToken token
Returns
Type Description
Task
| Edit this page View Source

WriteEvents(IEnumerable<EventCreate>, Stream)

Write events to a stream. Encoding: [Id][Start][End][Description][Type][SubType][Source][assetIdCount][dataSetId]{[assetId1]...}[MetaCount]{[key][value]...}

Declaration
public static void WriteEvents(IEnumerable<EventCreate> events, Stream stream)
Parameters
Type Name Description
IEnumerable<EventCreate> events

Events to write

Stream stream

Stream to write to

| Edit this page View Source

WriteEventsAsync(IEnumerable<EventCreate>, Stream, CancellationToken)

Write events to a stream. Encoding: [Id][Start][End][Description][Type][SubType][Source][assetIdCount][dataSetId]{[assetId1]...}[MetaCount]{[key][value]...}

Declaration
public static Task WriteEventsAsync(IEnumerable<EventCreate> events, Stream stream, CancellationToken token)
Parameters
Type Name Description
IEnumerable<EventCreate> events

Events to write

Stream stream

Stream to write to

CancellationToken token
Returns
Type Description
Task
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX