ANamespaceAccess..::..ImportJsonFile Method
This will import a Json file and convert it into a DB record for update into the DB.
Each line in the file is treated as a new DB record.
Each top-level property in the Json is translated into a bin and value. Json Arrays and embedded objects are transformed into an Aerospike List or Map<string,object>.
Note: If the Json string is a Json Object, the following behavior occurs:
If jsonBinName is provided, the Json object is treated as an Aerospike document which will be associated with that bin.
if jsonBinName is null, each json property in that Json object is treated as a separate bin/value.
You can also insert individual records by calling FromJson(String, String, String, String, WritePolicy, Nullable<(Of <<'(TimeSpan>)>>), Boolean, IList<(Of <<'(ARecord>)>>), Boolean).
Namespace:
Aerospike.Database.LINQPadDriver.ExtensionsAssembly: Aerospike.Database.LINQPadDriver (in Aerospike.Database.LINQPadDriver.dll)
Syntax
public int ImportJsonFile( string importJSONFile, string setName, string pkPropertyName, string jsonBinName, bool writePKPropertyName, WritePolicy writePolicy, Nullable<TimeSpan> ttl, int maxDegreeOfParallelism, BatchPolicy batchPolicy, BatchWritePolicy batchWritePolicy, bool useParallelPuts, bool treatEmptyStrAsNull, CancellationToken cancellationToken )
Parameters
- importJSONFile
- Type: String
The file containing Json value where each line is a separate DB record.
- setName
- Type: String
Set name or null for the null set. This can be a new set that will be created.
- pkPropertyName
- Type: String
The property name used for the primary key. The default is '_id'. If the primary key value is not present, the digest is used. In these cases the property value will be a sub property where that name will be '$oid' and the value is a byte string.
- jsonBinName
- Type: String
If provided, the Json object is placed into this bin. If null (default), the each top level Json property will be associated with a bin. Note, if the property name is greater than the bin name limit, an Aerospike exception will occur during the put.
- writePKPropertyName
- Type: Boolean
If true, the pkPropertyName, is written to the record. If false (default), it will not be written to the set (only used to define the PK).
- writePolicy
- Type: WritePolicy
The write policy. If not provided , the default policy is used.
- maxDegreeOfParallelism
- Type: Int32
The maximum degree of parallelism. MaxDegreeOfParallelism
- batchPolicy
- Type: BatchPolicy
BatchPolicy
- batchWritePolicy
- Type: BatchWritePolicy
BatchWritePolicy
- useParallelPuts
- Type: Boolean
If true, Parallel Put actions are used based on maxDegreeOfParallelism is used instead of batch writes.
- treatEmptyStrAsNull
- Type: Boolean
If true, default, these properties with an empty string value will be considered null (bin not saved). If false, these properties with an empty string value will have a bin value of empty string.
- cancellationToken
- Type: CancellationToken
The CancellationToken associated with this ParallelOptions instance.
Return Value
Number of records inserted.Exceptions
Exception | Condition |
---|---|
InvalidOperationException | Thrown if the cluster is a production cluster. Can disable this by going into the connection properties. |