Package io.toro.martini
Class BigtableMethods
- java.lang.Object
-
- io.toro.martini.BigtableMethods
-
public final class BigtableMethods extends Object
-
-
Constructor Summary
Constructors Constructor Description BigtableMethods(io.toro.martini.database.DataSourceManager dataSourceManager, io.toro.martini.gloop.converter.impl.GCRuleConverter grConverter, io.toro.martini.gloop.converter.impl.FilterConverter filterConv)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static GloopModel
addFamily(@NotNull String connectionName, String tableId, String familyId, GloopModel gcRule)
Configures the name of the new ColumnFamily to be createdstatic GloopModel
addFamily(@NotNull String connectionName, String tableId, List<GloopModel> addFamilies)
Configures the names of the new ColumnFamilies with GCRule to be createdstatic void
awaitReplication(@NotNull String connectionName, String tableId)
Blocks the current thread until replication has caught up to the point when this method was called.static GloopCursor
bulkMutationRow(@NotNull String connectionName, @NotNull String tableId, int batchSize, boolean closeClient, GloopExecutionContext context)
Construct a multiple rows in a batch.static boolean
checkAndMutateRow(@NotNull String connectionName, String tableId, String rowKey, GloopModel condition, GloopModel then, GloopModel otherwise)
Convenience method to synchronously mutate a row atomically based on the output of a filter.static GloopModel
createTable(@NotNull String connectionName, String tableId, String familyId)
Create new table that only required input is the family column idstatic GloopModel
createTable(@NotNull String connectionName, String tableId, String familyId, String splitKey, GloopModel gcRule)
Create new table and configure the GCRule of the tablestatic GloopModel
createTable(@NotNull String connectionName, String tableId, List<GloopModel> familyIds, List<String> splitKey)
Create new table with multiple family columns id and split keysstatic boolean
deleteTable(@NotNull String connectionName, String tableId)
Deletes the table specified by the table ID.static void
dropAllRows(@NotNull String connectionName, String tableId)
Drops all data in the table.static GloopModel
dropFamily(@NotNull String connectionName, String tableId, String familyId)
Drops the specified ColumnFamily Sample Codestatic GloopModel
dropFamily(@NotNull String connectionName, String tableId, List<String> familyId)
Drop list of the specified column families Sample Codestatic void
dropRowRange(@NotNull String connectionName, String tableId, String rowKeyPrefix)
Drops rows by the specified row key prefix and table ID.static boolean
exists(@NotNull String connectionName, String tableId)
Check if the table already existedstatic boolean
exists(@NotNull String connectionName, String tableId, String rowKey)
Check if the given row key exists or notstatic GloopModel
getTable(@NotNull String connectionName, String tableId)
Get the details of bigtable table using the tableIdstatic List<String>
listTables(@NotNull String connectionName)
List all tables in a Cloud Bigtable instancestatic void
mutationRow(@NotNull String connectionName, @NotNull String tableId, @NotNull String keyName, List<GloopModel> mutation)
Construct a single row to be inserted to the tablestatic GloopModel
readModifyWriteRow(@NotNull String connectionName, String tableId, String rowKey, GloopModel readModifyWriteRowRequest)
Convenience method that synchronously modifies a row atomically on the server.static GloopModel
readRow(@NotNull String connectionName, String tableId, String rowKey)
Synchronously reading a single rowstatic GloopModel
readRow(@NotNull String connectionName, String tableId, String rowKey, GloopModel filterModel)
Synchronously reading a single row and able to filter the row Sample codestatic GloopCursor
readRows(@NotNull String connectionName, @NotNull String tableId, String rowKey, String prefix, Map<String,String> range, GloopModel filterModel, long limit, GloopExecutionContext context)
Synchronously streaming the results of a Query.static GloopModel
updateFamily(@NotNull String connectionName, String tableId, String familyId, GloopModel gcRule)
Updates the GCRules.GCRule of existing ColumnFamilystatic GloopModel
updateFamily(@NotNull String connectionName, String tableId, List<GloopModel> updateFamilies)
Updates multiple GCRules.GCRule of existing ColumnFamilies
-
-
-
Constructor Detail
-
BigtableMethods
@Autowired public BigtableMethods(io.toro.martini.database.DataSourceManager dataSourceManager, io.toro.martini.gloop.converter.impl.GCRuleConverter grConverter, io.toro.martini.gloop.converter.impl.FilterConverter filterConv)
-
-
Method Detail
-
createTable
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel createTable(@NotNull @NotNull String connectionName, String tableId, String familyId)
Create new table that only required input is the family column id- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablefamilyId
- - The id of the family- Returns:
- GloopModel describe the created table
-
createTable
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel createTable(@NotNull @NotNull String connectionName, String tableId, String familyId, String splitKey, @GloopObjectParameter("gcRule#io.toro.martini.bigtable.GCRule{\n}") GloopModel gcRule)
Create new table and configure the GCRule of the table- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablefamilyId
- - The id of the familygcRule
- - Describe the GCRule object which contain the DurationRule, VersionRule, IntersectionRule, UnionRule- Returns:
- GloopModel describe the created table
-
createTable
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel createTable(@NotNull @NotNull String connectionName, String tableId, @GloopObjectParameter("mapGCRule#io.toro.martini.bigtable.MapGCRule[]{\n}") List<GloopModel> familyIds, List<String> splitKey)
Create new table with multiple family columns id and split keys- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablefamilyIds
- - Configure the name of column family id with GCRule- Returns:
- GloopModel
-
getTable
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel getTable(@NotNull @NotNull String connectionName, String tableId)
Get the details of bigtable table using the tableId- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the table- Returns:
- GloopModel
-
dropRowRange
public static void dropRowRange(@NotNull @NotNull String connectionName, String tableId, String rowKeyPrefix)
Drops rows by the specified row key prefix and table ID.- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablerowKeyPrefix
- - Specify the row key to be dropped
-
dropAllRows
public static void dropAllRows(@NotNull @NotNull String connectionName, String tableId)
Drops all data in the table.- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - Specify the table id to be dropped
-
awaitReplication
public static void awaitReplication(@NotNull @NotNull String connectionName, String tableId)
Blocks the current thread until replication has caught up to the point when this method was called. This allows callers to make sure that their mutations have been replicated across all of their clusters.- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The name of the table
-
deleteTable
public static boolean deleteTable(@NotNull @NotNull String connectionName, String tableId) throws IOException
Deletes the table specified by the table ID.- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - Specify the table id to be deleted- Returns:
- boolean
- Throws:
IOException
-
listTables
public static List<String> listTables(@NotNull @NotNull String connectionName)
List all tables in a Cloud Bigtable instance- Parameters:
connectionName
- - The name of bigtable connection registered in Martini Runtime- Returns:
- List
-
dropFamily
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel dropFamily(@NotNull @NotNull String connectionName, String tableId, String familyId) throws IOException
Drops the specified ColumnFamily Sample CodeBigtableMethods.dropFamily( "bigtableDb", "products", "cf1' );
- Parameters:
connectionName
- - The name of the bigtable connection registered in Martini RuntimetableId
- - The id of the table where the familyId is locatedfamilyId
- - Specify the family id to be dropped- Returns:
- GloopModel
- Throws:
IOException
-
dropFamily
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel dropFamily(@NotNull @NotNull String connectionName, String tableId, List<String> familyId) throws IOException
Drop list of the specified column families Sample CodeBigtableMethods.dropFamily( "bigtableDb", "products", "cf1' );
- Parameters:
connectionName
- - The name of the bigtable connection registered in Martini RuntimetableId
- - The id of the table where the familyIds is locatedfamilyId
- - Specify the list of family ids to be dropped- Returns:
- GloopModel
- Throws:
IOException
-
updateFamily
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel updateFamily(@NotNull @NotNull String connectionName, String tableId, String familyId, @GloopObjectParameter("gcRule#io.toro.martini.bigtable.GCRule{\n}") GloopModel gcRule)
Updates the GCRules.GCRule of existing ColumnFamily- Parameters:
connectionName
- - The name of the bigtable connection registered in Martini RuntimetableId
- - The id of the tablefamilyId
- - The id of the column familygcRule
- - Configure the GCRule of the column family- Returns:
- GloopModel
-
updateFamily
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel updateFamily(@NotNull @NotNull String connectionName, String tableId, @GloopObjectParameter("mapGCRule#io.toro.martini.bigtable.MapGCRule[]{\n}") List<GloopModel> updateFamilies)
Updates multiple GCRules.GCRule of existing ColumnFamilies- Parameters:
connectionName
- - The name of the bigtable connection registered in Martini RuntimetableId
- - The id of the tableupdateFamilies
- -- Returns:
- GloopModel
-
addFamily
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel addFamily(@NotNull @NotNull String connectionName, String tableId, String familyId, @GloopObjectParameter("gcRule#io.toro.martini.bigtable.GCRule{\n}") GloopModel gcRule)
Configures the name of the new ColumnFamily to be created- Parameters:
connectionName
- - The name of the bigtable connection registered in Martini RuntimetableId
- - The id of the tablefamilyId
- - The id of the column familygcRule
- - Configure the GCRule of the column family- Returns:
- GloopModel
-
addFamily
@GloopObjectParameter("output{\ntable#io.toro.martini.bigtable.Table{\n}\n}") public static GloopModel addFamily(@NotNull @NotNull String connectionName, String tableId, @GloopObjectParameter("mapGCRule#io.toro.martini.bigtable.MapGCRule[]{\n}") List<GloopModel> addFamilies)
Configures the names of the new ColumnFamilies with GCRule to be created- Parameters:
connectionName
- - The name of the bigtable connection registered in Martini RuntimetableId
- - The id of the tableaddFamilies
- - Specify the column family ids and the GCRules into Map object to be added- Returns:
- GloopModel
-
exists
public static boolean exists(@NotNull @NotNull String connectionName, String tableId, String rowKey) throws IOException
Check if the given row key exists or not- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablerowKey
- - The name of the row to be checked if existed- Returns:
- Boolean
- Throws:
IOException
-
exists
public static boolean exists(@NotNull @NotNull String connectionName, String tableId) throws IOException
Check if the table already existed- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the table- Returns:
- Boolean
- Throws:
IOException
-
readRow
@GloopObjectParameter("output{\nrow#io.toro.martini.bigtable.Row{\n}\n}") public static GloopModel readRow(@NotNull @NotNull String connectionName, String tableId, String rowKey)
Synchronously reading a single row- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablerowKey
- - The name of the row to be read- Returns:
- GloopModel
-
readRow
@GloopObjectParameter("output{\nrow#io.toro.martini.bigtable.Row{\n}\n}") public static GloopModel readRow(@NotNull @NotNull String connectionName, String tableId, String rowKey, @GloopObjectParameter("condition#io.toro.martini.bigtable.Filter{\n}") GloopModel filterModel)
Synchronously reading a single row and able to filter the row Sample codeBigtableMethods.readRow( "[BIGTABLE DB]", "[TABLE]", "[ROW KEY]", FILTERS.chain().filter(FILTERS.qualifier().regex("prefix.*") .filter(FILTERS.limit().cellsPerRow(10) );
- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablerowKey
- - The name of the row to be readfilterModel
- - Filter when reading the row- Returns:
- GloopModel
-
readRows
@GloopObjectParameter("bigtableReadRowCursor{\n bigtableReadRowCursor[]*{\n }\n}") public static GloopCursor readRows(@NotNull @NotNull String connectionName, @NotNull @NotNull String tableId, String rowKey, String prefix, Map<String,String> range, @GloopObjectParameter("condition#io.toro.martini.bigtable.Filter{\n}") GloopModel filterModel, @GloopParameter(defaultValue="10") long limit, GloopExecutionContext context)
Synchronously streaming the results of a Query. Return a GloopCursor- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - Constructs a new Query object for the specified table idrowKey
- - Adds a key to looked uprange
- - Adds a range to be looked up. Start – The beginning of the range (inclusive). Can be null to represent negative infinity. End – The end of the range (exclusive). Can be null to represent positive infinity.filterModel
- - Sets the filter to apply to each row. Only one filter can be set at a time.- Returns:
- GloopCursor
-
mutationRow
public static void mutationRow(@NotNull @NotNull String connectionName, @NotNull @NotNull String tableId, @NotNull @NotNull String keyName, @GloopObjectParameter("mutation#io.toro.martini.bigtable.Mutation[]{\n}") List<GloopModel> mutation)
Construct a single row to be inserted to the table- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablekeyName
- - The name of the rowmutation
- - Describe the sets of mutation as GloopModel to be applied to a single row
-
bulkMutationRow
@GloopObjectParameter("bigtableMutationRowCursor{\n bigtableMutationRowCursor[]*{\n }\n}") public static GloopCursor bulkMutationRow(@NotNull @NotNull String connectionName, @NotNull @NotNull String tableId, @GloopParameter(defaultValue="10000") int batchSize, @GloopParameter(allowNull=false,defaultValue="false") boolean closeClient, GloopExecutionContext context)
Construct a multiple rows in a batch.- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablebatchSize
- - How many write models to cache before sending them to mongo dbcloseClient
- - A boolean stating whether to close the client once the cursor has been closed- Returns:
- GloopCursor
-
checkAndMutateRow
public static boolean checkAndMutateRow(@NotNull @NotNull String connectionName, String tableId, String rowKey, @GloopObjectParameter("condition#io.toro.martini.bigtable.Filter{\n}") GloopModel condition, @GloopObjectParameter("then#io.toro.martini.bigtable.Mutation{\n}") GloopModel then, @GloopObjectParameter("otherwise#io.toro.martini.bigtable.Mutation{\n}") GloopModel otherwise)
Convenience method to synchronously mutate a row atomically based on the output of a filter.- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablerowKey
- - The name of the rowcondition
- - The filter to be applied to the contents of the specified rowthen
- - Adds changes to be atomically applied to the specified row if the condition yields at least one cell when applied to the rowotherwise
- - Adds changes to be atomically applied to the specified row if the condition does not yields any cells when applied to the row.- Returns:
- boolean
-
readModifyWriteRow
@GloopObjectParameter("output{\nrow#io.toro.martini.bigtable.Row{\n}\n}") public static GloopModel readModifyWriteRow(@NotNull @NotNull String connectionName, String tableId, String rowKey, @GloopObjectParameter("readModifyWriteRow#io.toro.martini.bigtable.ReadModifyWriteRow{\n}") GloopModel readModifyWriteRowRequest)
Convenience method that synchronously modifies a row atomically on the server.- Parameters:
connectionName
- - The name of bigtable connection registered in Martini RuntimetableId
- - The id of the tablerowKey
- - The name of the rowreadModifyWriteRowRequest
- - Describe the ReadModifyWriteRow object as GloopModel- Returns:
- GloopModel
-
-