Package com.cloudera.cdk.data.spi

Examples of com.cloudera.cdk.data.spi.StorageKey


    keys = Lists.newArrayList();
    for (Object year : Arrays.asList(2012, 2013)) {
      for (Object month : Arrays.asList(9, 10, 11, 12)) {
        for (Object day : Arrays.asList(22, 24, 25)) {
          StorageKey k = new StorageKey.Builder(strategy)
              .add("year", year).add("month", month).add("day", day).build();
          keys.add(k);
        }
      }
    }
View Full Code Here


    this.view = view;
    this.partitionStrategy = descriptor.getPartitionStrategy();
    this.maxWriters = Math.min(10, partitionStrategy.getCardinality());
    this.state = ReaderWriterState.NEW;
    this.reusedKey = new StorageKey(partitionStrategy);
  }
View Full Code Here

    reusedKey.reuseFor(entity);

    DatasetWriter<E> writer = cachedWriters.getIfPresent(reusedKey);
    if (writer == null) {
      // get a new key because it is stored in the cache
      StorageKey key = StorageKey.copy(reusedKey);
      try {
        writer = cachedWriters.getUnchecked(key);
      } catch (UncheckedExecutionException ex) {
        // catch & release: the correct exception is that the entity cannot be
        // written because it isn't in the View. But to avoid checking in every
View Full Code Here

    keys = Lists.newArrayList();
    for (Object year : Arrays.asList(2012, 2013)) {
      for (Object month : Arrays.asList(9, 10, 11, 12)) {
        for (Object day : Arrays.asList(22, 24, 25)) {
          StorageKey k = new StorageKey.Builder(strategy)
              .add("year", year).add("month", month).add("day", day).build();
          keys.add(k);
        }
      }
    }
View Full Code Here

        .year("timestamp")
        .month("timestamp")
        .day("timestamp")
        .build();

    StorageKey key = new StorageKey(strategy);
    key.replaceValues((List) Lists.newArrayList(2013, 11, 5));

    Assert.assertEquals(
        new Path("year=2013/month=11/day=05"),
        convert.fromKey(key));
  }
View Full Code Here

        .year("timestamp")
        .month("timestamp")
        .day("timestamp")
        .build();

    StorageKey expected = new StorageKey(strategy);
    expected.replaceValues((List) Lists.newArrayList(2013, 11, 5));

    Assert.assertEquals(expected, convert.toKey(
        new Path("year=2013/month=11/day=5"), new StorageKey(strategy)));
  }
View Full Code Here

  }

  @Override
  public DatasetWriter<E> newWriter() {
    final DatasetWriter<E> wrappedWriter = dataset.getDao().newBatch();
    final StorageKey partitionStratKey = new StorageKey(dataset.getDescriptor().getPartitionStrategy());
    // Return a dataset writer that checks on write that an entity is within the
    // range of the view
    return new DatasetWriter<E>() {
      @Override
      public void open() {
        wrappedWriter.open();
      }

      @Override
      public void write(E entity) {
        StorageKey key = partitionStratKey.reuseFor(entity);
        if (!range.contains(key)) {
          throw new IllegalArgumentException("View does not contain entity: "
              + entity);
        }
        wrappedWriter.write(entity);
View Full Code Here

    private final StorageKey reusableKey;
    private final PathConversion convert;

    public MakeKey(PartitionStrategy strategy) {
      this.partitioners = strategy.getFieldPartitioners();
      this.reusableKey = new StorageKey(strategy);
      this.convert = new PathConversion();
    }
View Full Code Here

TOP

Related Classes of com.cloudera.cdk.data.spi.StorageKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.