Class RouterBasedStoreSchemaFetcher
- java.lang.Object
-
- com.linkedin.venice.client.schema.RouterBasedStoreSchemaFetcher
-
- All Implemented Interfaces:
StoreSchemaFetcher
,java.io.Closeable
,java.lang.AutoCloseable
public class RouterBasedStoreSchemaFetcher extends java.lang.Object implements StoreSchemaFetcher
Router based implementation ofStoreSchemaFetcher
. It supports schema look up for key schema, the latest value schema and latest update schema of a provided value schema version. Notice that this class does not contain any caching of schema so each API invocation will send a new request to Venice Router to fetch the desired store schema.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
TYPE_GET_UPDATE_SCHEMA
static java.lang.String
TYPE_KEY_SCHEMA
static java.lang.String
TYPE_LATEST_VALUE_SCHEMA
static java.lang.String
TYPE_VALUE_SCHEMA
-
Constructor Summary
Constructors Constructor Description RouterBasedStoreSchemaFetcher(AbstractAvroStoreClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.util.Map<java.lang.Integer,org.apache.avro.Schema>
getAllValueSchemasWithId()
Returns all value schemas of the store as a map with schema id as the key.org.apache.avro.Schema
getKeySchema()
Returns Key schema of the store.org.apache.avro.Schema
getLatestValueSchema()
Returns the latest available Value schema of the store.SchemaEntry
getLatestValueSchemaEntry()
java.lang.String
getStoreName()
Returns the Venice store name this class is associated with.org.apache.avro.Schema
getUpdateSchema(org.apache.avro.Schema valueSchema)
Returns the Update (Write Compute) schema of the provided Value schema.DerivedSchemaEntry
getUpdateSchemaEntry(int valueSchemaId)
Get the latest derived schema of a value schema.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.linkedin.venice.client.schema.StoreSchemaFetcher
getAllValueSchemas
-
-
-
-
Field Detail
-
TYPE_KEY_SCHEMA
public static final java.lang.String TYPE_KEY_SCHEMA
- See Also:
- Constant Field Values
-
TYPE_VALUE_SCHEMA
public static final java.lang.String TYPE_VALUE_SCHEMA
- See Also:
- Constant Field Values
-
TYPE_GET_UPDATE_SCHEMA
public static final java.lang.String TYPE_GET_UPDATE_SCHEMA
- See Also:
- Constant Field Values
-
TYPE_LATEST_VALUE_SCHEMA
public static final java.lang.String TYPE_LATEST_VALUE_SCHEMA
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RouterBasedStoreSchemaFetcher
public RouterBasedStoreSchemaFetcher(AbstractAvroStoreClient client)
-
-
Method Detail
-
getKeySchema
public org.apache.avro.Schema getKeySchema()
Description copied from interface:StoreSchemaFetcher
Returns Key schema of the store.- Specified by:
getKeySchema
in interfaceStoreSchemaFetcher
-
getLatestValueSchema
public org.apache.avro.Schema getLatestValueSchema()
Description copied from interface:StoreSchemaFetcher
Returns the latest available Value schema of the store. The latest superset schema is: 1. If a superset schema exists for the store, return the superset schema 2. If no superset schema exists for the store, return the value schema with the largest schema id- Specified by:
getLatestValueSchema
in interfaceStoreSchemaFetcher
-
getLatestValueSchemaEntry
public SchemaEntry getLatestValueSchemaEntry()
- Specified by:
getLatestValueSchemaEntry
in interfaceStoreSchemaFetcher
-
getAllValueSchemasWithId
public java.util.Map<java.lang.Integer,org.apache.avro.Schema> getAllValueSchemasWithId()
Description copied from interface:StoreSchemaFetcher
Returns all value schemas of the store as a map with schema id as the key.- Specified by:
getAllValueSchemasWithId
in interfaceStoreSchemaFetcher
-
getUpdateSchemaEntry
public DerivedSchemaEntry getUpdateSchemaEntry(int valueSchemaId)
Description copied from interface:StoreSchemaFetcher
Get the latest derived schema of a value schema. Return the derived schema inDerivedSchemaEntry
format, which contains Schema and protocol ID.- Specified by:
getUpdateSchemaEntry
in interfaceStoreSchemaFetcher
-
getUpdateSchema
public org.apache.avro.Schema getUpdateSchema(org.apache.avro.Schema valueSchema) throws VeniceException
Description copied from interface:StoreSchemaFetcher
Returns the Update (Write Compute) schema of the provided Value schema. The returned schema is used to construct aGenericRecord
that partially updates a record value that is associated with this value schema. This method is expected to throwInvalidVeniceSchemaException
when the provided value schema could not be found in the Venice backend. For other unexpected errors like store is not write-compute enabled or corresponding update schema is not found in the Venice backend, this method will throw generalVeniceException
with corresponding error message.- Specified by:
getUpdateSchema
in interfaceStoreSchemaFetcher
- Throws:
VeniceException
-
getStoreName
public java.lang.String getStoreName()
Description copied from interface:StoreSchemaFetcher
Returns the Venice store name this class is associated with.- Specified by:
getStoreName
in interfaceStoreSchemaFetcher
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-