Exemple #1
0
 private KeyValueSchema(ISchema <K> KeySchema, ISchema <V> ValueSchema, KeyValueEncodingType KeyValueEncodingType)
 {
     _keySchema            = KeySchema;
     _valueSchema          = ValueSchema;
     _keyValueEncodingType = KeyValueEncodingType;
     _schemaInfoProvider   = new InfoSchemaInfoProvider(this);
     // if either key schema or value schema requires fetching schema info,
     // we don't need to configure the key/value schema info right now.
     // defer configuring the key/value schema info until `configureSchemaInfo` is called.
     if (!RequireFetchingSchemaInfo())
     {
         ConfigureKeyValueSchemaInfo();
     }
 }
Exemple #2
0
 public static ISchema <KeyValue <K, V> > Of(ISchema <K> KeySchema, ISchema <V> ValueSchema, KeyValueEncodingType KeyValueEncodingType)
 {
     return(new KeyValueSchema <K, V>(KeySchema, ValueSchema, KeyValueEncodingType));
 }
Exemple #3
0
        /// <summary>
        /// Encode key & value into schema into a KeyValue schema.
        /// </summary>
        /// <param name="schemaName"> the final schema name </param>
        /// <param name="keySchemaInfo"> the key schema info </param>
        /// <param name="valueSchemaInfo"> the value schema info </param>
        /// <param name="keyValueEncodingType"> the encoding type to encode and decode key value pair </param>
        /// <returns> the final schema info </returns>
        public static ISchemaInfo EncodeKeyValueSchemaInfo(string schemaName, ISchemaInfo keySchemaInfo, ISchemaInfo valueSchemaInfo, KeyValueEncodingType keyValueEncodingType)
        {
            Condition.CheckNotNull(keyValueEncodingType, "Null encoding type is provided");

            if (keySchemaInfo == null || valueSchemaInfo == null)
            {
                // schema is not ready
                return(null);
            }

            // process key/value schema data
            byte[] schemaData = KeyValue <ISchemaInfo, ISchemaInfo> .Encode(keySchemaInfo, _schemaInfoWriter, valueSchemaInfo, _schemaInfoWriter);

            // process key/value schema properties
            IDictionary <string, string> Properties = new Dictionary <string, string>();

            EncodeSubSchemaInfoToParentSchemaProperties(keySchemaInfo, KEY_SCHEMA_NAME, KEY_SCHEMA_TYPE, KEY_SCHEMA_PROPS, Properties);

            EncodeSubSchemaInfoToParentSchemaProperties(valueSchemaInfo, VALUE_SCHEMA_NAME, VALUE_SCHEMA_TYPE, VALUE_SCHEMA_PROPS, Properties);
            Properties[KV_ENCODING_TYPE] = keyValueEncodingType.ToString();

            // generate the final schema info
            return(new SchemaInfo
            {
                Name = schemaName,
                Type = SchemaType.KeyValue,
                Schema = schemaData,
                Properties = Properties
            });
        }
Exemple #4
0
 /// <summary>
 /// Encode key & value into schema into a KeyValue schema.
 /// </summary>
 /// <param name="keySchema"> the key schema </param>
 /// <param name="valueSchema"> the value schema </param>
 /// <param name="keyValueEncodingType"> the encoding type to encode and decode key value pair </param>
 /// <returns> the final schema info </returns>
 public static ISchemaInfo EncodeKeyValueSchemaInfo <K, V>(ISchema <K> KeySchema, ISchema <V> ValueSchema, KeyValueEncodingType KeyValueEncodingType)
 {
     return(EncodeKeyValueSchemaInfo("KeyValue", KeySchema, ValueSchema, KeyValueEncodingType));
 }
Exemple #5
0
 /// <summary>
 /// Encode key & value into schema into a KeyValue schema.
 /// </summary>
 /// <param name="schemaName"> the final schema name </param>
 /// <param name="keySchema"> the key schema </param>
 /// <param name="valueSchema"> the value schema </param>
 /// <param name="keyValueEncodingType"> the encoding type to encode and decode key value pair </param>
 /// <returns> the final schema info </returns>
 public static ISchemaInfo EncodeKeyValueSchemaInfo <K, V>(string SchemaName, ISchema <K> KeySchema, ISchema <V> ValueSchema, KeyValueEncodingType KeyValueEncodingType)
 {
     return(EncodeKeyValueSchemaInfo(SchemaName, KeySchema.SchemaInfo, ValueSchema.SchemaInfo, KeyValueEncodingType));
 }
Exemple #6
0
 public abstract ISchema <KeyValue <K, V> > KeyValue <K, V>(ISchema <K> key, ISchema <V> value, KeyValueEncodingType keyValueEncodingType);
Exemple #7
0
 public override ISchema <KeyValue <K, V> > KeyValue <K, V>(ISchema <K> key, ISchema <V> value, KeyValueEncodingType keyValueEncodingType)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Encode key & value into schema into a KeyValue schema.
 /// </summary>
 /// <param name="schemaName"> the final schema name </param>
 /// <param name="keySchema"> the key schema </param>
 /// <param name="valueSchema"> the value schema </param>
 /// <param name="keyValueEncodingType"> the encoding type to encode and decode key value pair </param>
 /// <returns> the final schema info </returns>
 public static ISchemaInfo EncodeKeyValueSchemaInfo <K, V>(string schemaName, ISchema <K> keySchema, ISchema <V> valueSchema, KeyValueEncodingType keyValueEncodingType)
 {
     return(KeyValueSchemaInfo.EncodeKeyValueSchemaInfo(schemaName, keySchema, valueSchema, keyValueEncodingType));
     //return catchExceptions(() => (SchemaInfo)getStaticMethod("org.apache.pulsar.client.impl.schema.KeyValueSchemaInfo", "encodeKeyValueSchemaInfo", typeof(string), typeof(Schema), typeof(Schema), typeof(KeyValueEncodingType)).invoke(null, schemaName, keySchema, valueSchema, keyValueEncodingType));
 }
 public static ISchema <KeyValue <K, V> > NewKeyValueSchema <K, V>(ISchema <K> keySchema, ISchema <V> valueSchema, KeyValueEncodingType keyValueEncodingType)
 {
     return(KeyValueSchema <K, V> .Of(keySchema, valueSchema, keyValueEncodingType));
 }