Package org.kitesdk.data.spi

Examples of org.kitesdk.data.spi.StorageKey


    PartitionStrategy strategy = new PartitionStrategy.Builder()
        .identity("name")
        .identity("address")
        .build();

    StorageKey key = new StorageKey(strategy);
    key.replaceValues((List) Lists.newArrayList("John Doe", "NY/USA"));

    Assert.assertEquals(
        new Path("name_copy=John+Doe/address_copy=NY%2FUSA"),
        convert.fromKey(key));
  }
View Full Code Here


  public void toDirNameIdentityWithNonString() {
    PartitionStrategy strategy = new PartitionStrategy.Builder()
        .identity("id")
        .build();

    StorageKey expected = new StorageKey(strategy);
    expected.replace(0, 0L);

    Assert.assertEquals("Should convert to schema type",
        expected,
        convert.toKey(new Path("id=0"), new StorageKey(strategy)));
  }
View Full Code Here

    fileSystem = FileSystem.getLocal(new Configuration());
    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

    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

  public static void createExpectedKeys() {
    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

        Dataset<Object> dataset = Datasets.load(datasetUri, Object.class);
        if (dataset.getDescriptor().isPartitioned()) {
          partitionStrategy = dataset.getDescriptor().getPartitionStrategy();
          accessor = DataModelUtil.accessor(
              dataset.getType(), dataset.getDescriptor().getSchema());
          key = new StorageKey(partitionStrategy);
        }
        URL schemaUrl = dataset.getDescriptor().getSchemaUrl();
        if (schemaUrl != null) {
          setAvroSchemaUrl(schemaUrl.toExternalForm());
        }
View Full Code Here

      if (wrappedWriter instanceof InitializeAccessor) {
        ((InitializeAccessor) wrappedWriter).initialize();
      }
      return wrappedWriter;
    }
    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
    AbstractDatasetWriter<E> writer = new AbstractDatasetWriter<E>() {
      private Predicate<StorageKey> keyPredicate = constraints.toKeyPredicate();

      @Override
      public void initialize() {
        if (wrappedWriter instanceof InitializeAccessor) {
          ((InitializeAccessor) wrappedWriter).initialize();
        }
      }

      @Override
      public void write(E entity) {
        StorageKey key = getAccessor().keyFor(entity,
            constraints.getProvidedValues(), partitionStratKey);
        if (!keyPredicate.apply(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, Schema schema) {
      this.partitioners = strategy.getFieldPartitioners();
      this.reusableKey = new StorageKey(strategy);
      this.convert = new PathConversion(schema);
    }
View Full Code Here

TOP

Related Classes of org.kitesdk.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.