Error reported when the cli_autoincrement auto-Increment Variable is defined in Fastdb, fastdbcli
I recently tried to use fastdb for development. The test in c ++ version is basically OK. Because the project team adopts C # development, I switched to C # To develop fastdb. The results showed that C # versions were castrated, if the custom variable is auto-incrementing, an error occurs in the type definition. After some tracing, it is found that cli_autoincrement is not defined when the fastdb value is set.
Fastdb processes cli_autoincrement in a way similar to int4, so it performs type conversion similar to int4.
The modification code is as follows:
Protected unsafe virtual Object getValue (Type t ){
Switch (CLI. FieldType) (CLI. UnmanagedBuffer *) buffer. ToPointer ()-> type ){
Case CLI. FieldType. cli_bool:
Case CLI. fieldType. cli_int1: return Convert. changeType (* (sbyte *) (CLI. unmanagedBuffer *) buffer. toPointer ()-> data. toPointer (), t );
Case CLI. fieldType. cli_int2: return Convert. changeType (* (short *) (CLI. unmanagedBuffer *) buffer. toPointer ()-> data. toPointer (), t );
Case CLI. fieldType. cli_oid: return Convert. changeType (* (uint *) (CLI. unmanagedBuffer *) buffer. toPointer ()-> data. toPointer (), t );
Case CLI. fieldType. cli_autoincrement: return Convert. changeType (* (int *) (CLI. unmanagedBuffer *) buffer. toPointer ()-> data. toPointer (), t );
Case CLI. fieldType. cli_int4: return Convert. changeType (* (int *) (CLI. unmanagedBuffer *) buffer. toPointer ()-> data. toPointer (), t );
Case CLI. fieldType. cli_int8: return Convert. changeType (* (Int64 *) (CLI. unmanagedBuffer *) buffer. toPointer ()-> data. toPointer (), t );
Case CLI. fieldType. cli_real4: return Convert. changeType (* (Single *) (CLI. unmanagedBuffer *) buffer. toPointer ()-> data. toPointer (), t );
Case CLI. FieldType. cli_datetime:
Case CLI. fieldType. cli_real8: return Convert. changeType (* (double *) (CLI. unmanagedBuffer *) buffer. toPointer ()-> data. toPointer (), t );
Case CLI. FieldType. cli_asciiz:
Case CLI. FieldType. cli_pasciiz: return Convert. ChangeType (Marshal. PtrToStringAnsi (CLI. UnmanagedBuffer *) buffer. ToPointer ()-> data), t );
Case CLI. FieldType. cli_array_of_int1:
If (t = typeof (byte []) {
Int len = Size;
Byte [] arr = new byte [len];
Byte * src = (byte *) (CLI. UnmanagedBuffer *) buffer. ToPointer ()-> data. ToPointer ();
For (int I = 0; I <len; I ++ ){
Arr [I] = * src ++;
}
Return arr;
} Else {
Throw new CliError ("getValue: Unsupported conversion type! "+ Enum. GetName (typeof (CLI. FieldType), (CLI. UnmanagedBuffer *) buffer. ToPointer ()-> type ));
}
Default: throw new CliError ("getValue: Unsupported type! "+ Enum. GetName (typeof (CLI. FieldType), (CLI. UnmanagedBuffer *) buffer. ToPointer ()-> type ));
}
}
Run again, OK, run through
Personal feeling
Fastdb has too few documents and the Community is inactive. You are welcome to make a positive contribution.
The query speed of fastdb is at the forefront of similar databases.
The C # version of fastdb is the encapsulation of the C ++ version and is not completed. Please use it with caution for commercial development.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.