forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revise the schema default type not null (apache#3752)
### Motivation Fix apache#3741 ### Modifications Support define not not allow null field in schema ### Verifying this change Add not allow null field schema verify Does this pull request potentially affect one of the following parts: If yes was chosen, please highlight the changes Dependencies (does it add or upgrade a dependency): (no) The public API: (no) The schema: (yes) The default values of configurations: (no) The wire protocol: (no) The rest endpoints: (no) The admin cli options: (no) Anything that affects deployment: (no)
- Loading branch information
1 parent
6e0c11e
commit 1a1c557
Showing
26 changed files
with
868 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/schema/SchemaDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.client.api.schema; | ||
|
||
import org.apache.pulsar.client.internal.DefaultImplementation; | ||
|
||
import java.util.Map; | ||
|
||
|
||
public interface SchemaDefinition<T> { | ||
|
||
/** | ||
* Get a new builder instance that can used to configure and build a {@link SchemaDefinition} instance. | ||
* | ||
* @return the {@link SchemaDefinition} | ||
*/ | ||
static <T> SchemaDefinitionBuilder<T> builder() { | ||
return DefaultImplementation.newSchemaDefinitionBuilder(); | ||
} | ||
|
||
/** | ||
* get schema whether always allow null or not | ||
* | ||
* @return schema always null or not | ||
*/ | ||
public boolean getAlwaysAllowNull(); | ||
|
||
/** | ||
* Get schema class | ||
* | ||
* @return schema class | ||
*/ | ||
public Map<String, String> getProperties(); | ||
|
||
/** | ||
* Get json schema definition | ||
* | ||
* @return schema class | ||
*/ | ||
public String getJsonDef(); | ||
|
||
/** | ||
* Get pojo schema definition | ||
* | ||
* @return pojo schema | ||
*/ | ||
public Class<T> getPojo(); | ||
} |
81 changes: 81 additions & 0 deletions
81
...client-api/src/main/java/org/apache/pulsar/client/api/schema/SchemaDefinitionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.client.api.schema; | ||
|
||
|
||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Builder to build schema definition {@link SchemaDefinition}. | ||
*/ | ||
public interface SchemaDefinitionBuilder<T> { | ||
|
||
/** | ||
* Set schema whether always allow null or not | ||
* | ||
* @param alwaysAllowNull definition null or not | ||
* @return schema definition builder | ||
*/ | ||
SchemaDefinitionBuilder<T> withAlwaysAllowNull(boolean alwaysAllowNull); | ||
|
||
/** | ||
* Set schema info properties | ||
* | ||
* @param properties schema info properties | ||
* @return schema definition builder | ||
*/ | ||
SchemaDefinitionBuilder<T> withProperties(Map<String, String> properties); | ||
|
||
/** | ||
* Set schema info properties | ||
* | ||
* @param key property key | ||
* @param value property value | ||
* | ||
* @return record schema definition | ||
*/ | ||
SchemaDefinitionBuilder<T> addProperty(String key, String value); | ||
|
||
/** | ||
* Set schema of pojo definition | ||
* | ||
* @param pojo pojo schema definition | ||
* | ||
* @return record schema definition | ||
*/ | ||
SchemaDefinitionBuilder<T> withPojo(Class pojo); | ||
|
||
/** | ||
* Set schema of json definition | ||
* | ||
* @param jsonDefinition json schema definition | ||
* | ||
* @return record schema definition | ||
*/ | ||
SchemaDefinitionBuilder<T> withJsonDef(String jsonDefinition); | ||
|
||
/** | ||
* Build the schema definition. | ||
* | ||
* @return the schema definition. | ||
*/ | ||
SchemaDefinition<T> build(); | ||
|
||
} |
Oops, something went wrong.