Using User-Supplied Metadata in Read Operations
You can retrieve the user-supplied metadata with the help of APIs below. For more information, see Using User-Supplied Metadata.
- GetRequest API: You can use the
GetRequestAPI to retrieve the user-supplied metadata of a single row. After executing theGetRequestAPI to retrieve the row, given a table name and primary key, you can retrieve the metadata by calling thegetLastWriteMetadata()method. The operation returns aGetResultobject that contains the retrieved data. If no metadata exists, it returns null.See thereadRowMetadata()in ManageUserSuppliedMetadata.java for more details, available in the examples here./*Method to fetch a user-supplied metadata using GET API*/ private static void readRowMetadata(NoSQLHandle handle, int acctId) throws Exception { GetRequest gr = new GetRequest() .setKey(new MapValue().put("acct_Id", acctId)) //key of the row to fetch .setTableName(tableName); //table name GetResult gres = handle.get(gr); String rm= gres.getLastWriteMetadata(); if (rm != null) { System.out.println("Row metadata for acct_Id " + acctId + ": " + rm); } else { System.out.println("No metadata found for acct_Id " + acctId); } } - QueryRequest API: You can write a SQL
SELECTstatement using theQueryRequestAPI to explicitly fetch user-supplied metadata. This allows metadata to be returned as part of the result set. It's especially helpful when you want to view the user-supplied metadata across multiple rows for data clarification or analysis purposes. See thereadAllRowMetadataViaQuery()in ManageUserSuppliedMetadata.java for more details, available in the examples here.