public class TableRollingStrategy extends Object
TableRollingStrategy class
is very much optimized for less memory allocation when we need to determine table extension for a given timestamp in
high frequency. So, for high frequency usage, create a single instance of TableRollingStrategy and use that
again and again.| Modifier and Type | Field and Description |
|---|---|
static int |
DAILY
if
tableGenInterval is 1
Each day will have a new table. |
static int |
HOURLY
extension will be
DATE_FORMAT_StartHour_to_EndHour |
static int |
MONTHLY
if
tableGenInterval is 1
Each month will have a new table. |
static int |
WEEKLY
if
tableGenInterval is 1
Each week will have a new table. |
| Constructor and Description |
|---|
TableRollingStrategy(int rollingType,
int tableGenInterval)
Create an instance with rolling type and table gen interval.
|
| Modifier and Type | Method and Description |
|---|---|
List<String> |
getAllExtension(String dateFormat,
String startTime,
String endTime)
Get the list of extensions from the given timestamp range.
|
List<String> |
getAllExtensions(long startTimestamp,
long endTimestamp)
Get the list of extensions from the given timestamp range.
|
List<String> |
getExistingTables(long startTimestamp,
long endTimestamp,
Statement statement,
String baseTable)
Get the list of tables from the given timestamp range.
|
List<String> |
getExistingTables(String dateFormat,
String startTime,
String endTime,
Statement statement,
String baseTable)
Get the list of tables from the given timestamp range.
|
int |
getRollingType() |
String |
getTableExtension(Calendar calendar)
Get the extension string for the given time in the calendar based on this
TableRollingStrategy
Extension can be |
String |
getTableExtension(long timestamp)
Get the extension string for the given time in the calendar based on this
TableRollingStrategy
Extension can be |
int |
getTableGenInterval() |
long |
maximumTimeForTable(String tableExtension)
Get the maximum time in long timestamp format for the given table extension.
|
long |
minimumTimeForTable(String tableExtension)
Get the minimum time in long timestamp format for the given table extension.
|
void |
setRollingType(int rollingType) |
void |
setTableGenInterval(int tableGenInterval) |
public static final int MONTHLY
tableGenInterval is 1
Each month will have a new table.
extension will be MONTH_FORMAT
else if tableGenInterval is greater than 1,
extension will be MONTH_FORMAT_to_MONTH_FORMATpublic static final int WEEKLY
tableGenInterval is 1
Each week will have a new table.
extension will be YEAR_FORMAT_week_weekValue
else if tableGenInterval is greater than 1,
extension will be YEAR_FORMAT_week_weekValueStart_to_YEAR_FORMAT_week_weekValueEndpublic static final int DAILY
tableGenInterval is 1
Each day will have a new table.
extension will be DATE_FORMAT
else if tableGenInterval is greater than 1,
extension will be DATE_FORMAT_to_DATE_FORMATpublic static final int HOURLY
DATE_FORMAT_StartHour_to_EndHourpublic TableRollingStrategy(int rollingType,
int tableGenInterval)
public int getTableGenInterval()
public void setTableGenInterval(int tableGenInterval)
public int getRollingType()
public void setRollingType(int rollingType)
public String getTableExtension(Calendar calendar)
TableRollingStrategy
Extension can becalendar - contains the time which is used to get the extension.public String getTableExtension(long timestamp)
TableRollingStrategy
Extension can betimestamp - the time which is used to get the extension.public List<String> getAllExtensions(long startTimestamp, long endTimestamp)
startTimestamp - Starting timestamp of the range.endTimestamp - End timestamp of the range.public List<String> getAllExtension(String dateFormat, String startTime, String endTime)
dateFormat - start and end time will be parsed using this format.startTime - Starting time in the given format of the range.endTime - End time in the given format of the range.public List<String> getExistingTables(long startTimestamp, long endTimestamp, Statement statement, String baseTable) throws SQLException
Statement's database.startTimestamp - Starting timestamp of the range.endTimestamp - End timestamp of the range.statement - it will be used to check the existence of the tables.baseTable - extension will be appended at the end of this base table name and will be used to check the
existence of the tables.SQLExceptionpublic List<String> getExistingTables(String dateFormat, String startTime, String endTime, Statement statement, String baseTable) throws SQLException
Statement's database.dateFormat - start and end time will be parsed using this format.startTime - Starting time in the given format of the range.endTime - End time in the given format of the range.statement - it will be used to check the existence of the tables.baseTable - extension will be appended at the end of this base table name and will be used to check the
existence of the tables.SQLExceptionpublic long minimumTimeForTable(String tableExtension)
TableRollingStrategytableExtension - only the extension part of the table. Consider that a full tame name is
baseTable_tableExtension. This parameter should be only the part that defines tableExtensionpublic long maximumTimeForTable(String tableExtension)
TableRollingStrategytableExtension - only the extension part of the table. Consider that a full tame name is
baseTable_tableExtension. This parameter should be only the part that defines tableExtensionCopyright © 2023. All rights reserved.