updatePeriodTableName.put(updatePeriod, storageTableName); Table storageTable = getTable(storageTableName); if ("true".equalsIgnoreCase(storageTable.getParameters().get(getPartitionTimelineCachePresenceKey()))) { try { loadTimelinesFromTableProperties(updatePeriod, storageTableName, timeLineKey);
updatePeriodTableName.put(updatePeriod, storageTableName); Table storageTable = getTable(storageTableName); if ("true".equalsIgnoreCase(storageTable.getParameters().get(getPartitionTimelineCachePresenceKey()))) { try { loadTimelinesFromTableProperties(updatePeriod, storageTableName, timeLineKey);
/** * store back all timelines of given storage to table properties * * @param timeLineKey key for the time line * @param storageTableName Storage table name * @throws HiveException */ private void alterTablePartitionCache(String timeLineKey, UpdatePeriod updatePeriod, String storageTableName) throws HiveException, LensException { Table table = getTable(storageTableName); Map<String, String> params = table.getParameters(); if (partitionTimelineCache.get(timeLineKey) != null) { for (Map.Entry<String, PartitionTimeline> entry : partitionTimelineCache.get(timeLineKey).get(updatePeriod) .entrySet()) { entry.getValue().updateTableParams(table); } params.put(getPartitionTimelineCachePresenceKey(), "true"); alterHiveTable(storageTableName, table); } }
/** * store back all timelines of given storage to table properties * * @param timeLineKey key for the time line * @param storageTableName Storage table name * @throws HiveException */ private void alterTablePartitionCache(String timeLineKey, UpdatePeriod updatePeriod, String storageTableName) throws HiveException, LensException { Table table = getTable(storageTableName); Map<String, String> params = table.getParameters(); if (partitionTimelineCache.get(timeLineKey) != null) { for (Map.Entry<String, PartitionTimeline> entry : partitionTimelineCache.get(timeLineKey).get(updatePeriod) .entrySet()) { entry.getValue().updateTableParams(table); } params.put(getPartitionTimelineCachePresenceKey(), "true"); alterHiveTable(storageTableName, table); } }
private void assertTestFactTimelineClass(CubeMetastoreClient client) throws Exception { String factName = "testFact"; client.getTimelines(factName, c1, null, null); client.getTimelines(factName, c4, null, null); client.clearHiveTableCache(); CubeFactTable fact = client.getCubeFactTable(factName); Table table = client.getTable(MetastoreUtil.getStorageTableName(fact.getName(), Storage.getPrefix(c1))); assertEquals(table.getParameters().get(MetastoreUtil.getPartitionTimelineCachePresenceKey()), "true"); for (UpdatePeriod period : Lists.newArrayList(MINUTELY, HOURLY, DAILY, MONTHLY, YEARLY, QUARTERLY)) { for (String partCol : Lists.newArrayList("dt")) { assertTimeline(client, fact.getName(), c1, period, partCol, EndsAndHolesPartitionTimeline.class); } } table = client.getTable(MetastoreUtil.getStorageTableName(fact.getName(), Storage.getPrefix(c4))); assertEquals(table.getParameters().get(MetastoreUtil.getPartitionTimelineCachePresenceKey()), "true"); for (UpdatePeriod period : Lists.newArrayList(MINUTELY, HOURLY, DAILY, MONTHLY, YEARLY, QUARTERLY)) { for (String partCol : Lists.newArrayList("ttd", "ttd2")) { assertTimeline(client, fact.getName(), c4, period, partCol, EndsAndHolesPartitionTimeline.class); } } }
client.clearHiveTableCache(); table = client.getTable(MetastoreUtil.getStorageTableName(fact.getName(), Storage.getPrefix(c4))); assertEquals(table.getParameters().get(MetastoreUtil.getPartitionTimelineCachePresenceKey()), "true"); assertTimeline(client, fact.getName(), c4, HOURLY, "ttd", ttdStoreAll); assertTimeline(client, fact.getName(), c4, HOURLY, "ttd2", ttd2StoreAll);
assertSameTimelines(factName, storages, HOURLY, partColNames); assertEquals(Hive.get(client.getConf()).getTable(c1TableName).getParameters().get( getPartitionTimelineCachePresenceKey()), "true"); assertEquals(Hive.get(client.getConf()).getTable(c2TableName).getParameters().get( getPartitionTimelineCachePresenceKey()), "true"); assertSameTimelines(factName, storages, HOURLY, partColNames); assertEquals(Hive.get(client.getConf()).getTable(c1TableName).getParameters().get( getPartitionTimelineCachePresenceKey()), "true"); assertEquals(Hive.get(client.getConf()).getTable(c2TableName).getParameters().get( getPartitionTimelineCachePresenceKey()), "true");