.table.RelationIdentifier;

@InterfaceAudience.Internal
public class IndexDataMapProvider implements DataMapProvider {

  private DataMapSchemaStorageProvider storageProvider;

  public IndexDataMapProvider(DataMapSchemaStorageProvider storageProvider) {
    this.storageProvider = storageProvider;
  }

  @Override
  public void initMeta(CarbonTable mainTable, DataMapSchema dataMapSchema, String ctasSqlStatement)
      throws MalformedDataMapCommandException, IOException {
    if (mainTable == null) {
      throw new MalformedDataMapCommandException(
          "Parent table is required to create index datamap");
    }
    ArrayList<RelationIdentifier> relationIdentifiers = new ArrayList<>();
    dataMapSchema.setParentTables(relationIdentifiers);
    relationIdentifiers.add(
        new RelationIdentifier(mainTable.getDatabaseName(), mainTable.getTableName(),
            mainTable.getTableInfo().getFactTable().getTableId()));
    DataMapFactory dataMapFactory = createIndexDataMapFactory(dataMapSchema);
    DataMapStoreManager.getInstance().registerDataMap(mainTable, dataMapSchema, dataMapFactory);
    storageProvider.saveSchema(dataMapSchema);
  }

  @Override
  public void initData(CarbonTable mainTable) {
    // Nothing is needed to do by default
  }

  @Override
  public void freeMeta(CarbonTable mainTable, DataMapSchema dataMapSchema) throws IOException {
    storageProvider.dropSchema(dataMapSchema.getDataMapName());
  }

  @Override
  public void freeData(CarbonTable mainTable, DataMapSchema dataMapSchema) {
    DataMapStoreManager.getInstance().clearDataMap(
        mainTable.getAbsoluteTableIdentifier(), dataMapSchema.getDataMapName());
  }

  @Override
  public void rebuild(CarbonTable mainTable, DataMapSchema dataMapSchema) {
    // Nothing is needed to do by default
  }

  @Override public void incrementalBuild(CarbonTable mainTable, DataMapSchema dataMapSchema,
      String[] segmentIds) {
    throw new UnsupportedOperationException();
  }

  private DataMapFactory createIndexDataMapFactory(DataMapSchema dataMapSchema)
      throws MalformedDataMapCommandException {
    DataMapFactory dataMapFactory;
    try {
      // try to create DataMapClassProvider instance by taking providerName as class name
      Class<? extends DataMapFactory> providerClass =
          (Class<? extends DataMapFactory>) Class.forName(dataMapSchema.getProviderName());
      dataMapFactory = providerClass.newInstance();
    } catch (ClassNotFoundException e) {
      // try to create DataMapClassProvider instance by taking providerName as short name
      dataMapFactory = getDataMapFactoryByShortName(dataMapSchema.getProviderName());
    } catch (Throwable e) {
      throw new MetadataProcessException(
          "failed to create DataMapClassProvider '" + dataMapSchema.getProviderName() + "'", e);
    }
    return dataMapFactory;
  }

  private DataMapFactory getDataMapFactoryByShortName(String providerName)
      throws MalformedDataMapCommandException {
    DataMapFactory dataMapFactory;
    String className = DataMapRegistry.getDataMapClassName(providerName);
    if (className!= null) {
      try {
        Class<? extends DataMapFactory> datamapClass =
            (Class<? extends DataMapFactory>) Class.forName(providerName);
        dataMapFactory = datamapClass.newInstance();
      } catch (ClassNotFoundException ex) {
        throw new MalformedDataMapCommandException(
            "DataMap '" + providerName + "' not found", ex);
      } catch (Throwable ex) {
        throw new MetadataProcessException(
            "failed to create DataMap '" + providerName + "'", ex);
      }
    } else {
      throw new MalformedDataMapCommandException(
          "DataMap '" + providerName + "' not found");
    }
    return dataMapFactory;
  }

  @Override public DataMapCatalog createDataMapCatalog() {
    // TODO create abstract class and move the default implementation there.
    return null;
  }
}
Capitalism Sux // I'm Angry
I work in a clothes shop in which the average price of a single item of clothing is around the £70 mark, at an estimate. I talk people into readily dropping triple-figure amounts of money on clothing which I would have to work 10 hours to afford a single item of. The brand then releases a marketing campaign inspired by the founders’ “simple life”; a life of financial security enveloped in an idyllic ~simple existence of seaside walks, expensive artisan coffee and a myriad of other stereotypical upper middle-class creature comforts. Meanwhile, the county they are selling a perfect “simple” lifestyle in has the third highest rate of street homelessness in the UK (2016 figure) and one of the highest rates of young parents, mental health issues and domestic abuse (28,200 cases reported in 2015-16).
Welcome to capitalism.
The minimum wage for a 16-18 year old in the UK is £4.05
The minimum wage for an 18-20 year old in the UK is £5.60
The minimum wage for a 21-24 year old in the UK is £7.05
The minimum wage for a 25+ year old in the UK is £7.50
The minimum apprenticeship wage in the UK is £3.50
(as of April 2017, stats from gov.uk)
The Living Wage campaign estimates that this is a gross underestimate, calculating a more realistic Real Living Wage based on what people need to live; their estimate is £8.75 per hour (£10.20 in London).
What can £7.50 buy you? A very small grocery shop for 1 person. A local train ticket. Not quite two pints of cider.
*
When a company relies on their staff to make them big ££££££, of which they will see only a tiny scrap, where is the incentive to work to the stupid standards that they expect? Where is the incentive to care about the job you are doing? At £7.50 per hour I am not being paid enough to care. I am being paid, poorly, for my presence and for going through the motions. This job won’t contribute to my happiness or my career, but it will enable the founders to go on lining their pockets; why do they place so little value on the time of the actual human beings who bring in the money?
The millions of minimum wage workers in retail and customer service are the gateway between customers and company profit. Without them they don’t make any money; without them it all grinds to a halt. If all the shop staff just decided to not show up one day, they lose an entire day’s worth of sales; thousands of pounds, gone. If we are so crucial to their success, why do they treat us and pay us so poorly for our labour?
Because they can. We’re replaceable. The kind of people who are on minimum wage often can’t afford to be on no wage. They win, whichever way.
*
Oxford recently surpassed London as the least affordable city in the UK. In both cities, the kinds of people who can afford to live centrally are not the kinds of people who work retail jobs; for many minimum wage workers, their commute to work in the city centre costs more than an hour’s pay.
This is no life.
I’d wager it’s no coincidence that Oxford also has one of the most visible and extensive homeless populations that I’ve ever seen in any city. The actual statistics on rough sleeping don’t support this on a purely numerical level, but I’ve never felt the presence of rough sleepers so keenly as I have here. Maybe it’s the contrast between extreme wealth and the perceived pinnacle of opportunity which is wired into the core of the city.
*
When speaking to a friend who works in admin about this, she told me how in December the CEO of her company had instructed her to take the company credit card and fulfil a Christmas shopping list multiple thousands of pounds long, for her daughters and other family members. For many people on the list, she had only assigned a budget and asked my friend to think of something suitable. Firstly this wasn’t within the remit of her role; secondly, throughout the entire ordeal she couldn’t help bitterly reflecting that she didn’t have the time or money to meaningfully purchase presents for her own family, as desperately as she wanted to, yet here she was picking out and wrapping gifts for people she had never and will never meet because her boss couldn’t be bothered. And they say money buys you happiness.
Let’s take a moment here to appreciate a double standard which riles me to my core: a disgustingly rich CEO lavishes thousands of pounds on thoughtless gifts which her children are probably numbed to the novelty of receiving. No commentary. A poor mother on benefits but also working to bring in an income and try to get herself off benefits and pay off her debts manages her money in such a way, and scrup