Package org.kitesdk.data

Examples of org.kitesdk.data.Key


    ds = (DaoDataset) repo.load("default", datasetName);

    // ensure the new entities are what we expect with get operations
    for (int i = 0; i < 10; ++i) {
      String iStr = Long.toString(i);
      Key key = new Key.Builder(ds)
          .add("part1", new Utf8("part1_" + iStr))
          .add("part2", new Utf8("part2_" + iStr)).build();
      compareEntitiesWithUtf8(i, ds.get(key));
    }

    // ensure the new entities are what we expect with scan operations
    int cnt = 0;
    DatasetReader<GenericRecord> reader = ds.newReader();
    assertTrue("Reader should be open initially", reader.isOpen());
    try {
      for (GenericRecord entity : reader) {
        compareEntitiesWithUtf8(cnt, entity);
        cnt++;
      }
      assertEquals(10, cnt);
    } finally {
      reader.close();
      assertFalse("Reader should be closed after calling close", reader.isOpen());
    }

    // test a partial scan
    cnt = 3;
    reader = new DaoView<GenericRecord>(ds, GenericRecord.class)
        .from("part1", new Utf8("part1_3")).from("part2", new Utf8("part2_3"))
        .to("part1", new Utf8("part1_7")).to("part2", new Utf8("part2_7"))
        .newReader();
    try {
      for (GenericRecord entity : reader) {
        compareEntitiesWithUtf8(cnt, entity);
        cnt++;
      }
      assertEquals(8, cnt);
    } finally {
      reader.close();
    }

    Key key = new Key.Builder(ds)
        .add("part1", new Utf8("part1_5"))
        .add("part2", new Utf8("part2_5")).build();

    // test delete
    ds.delete(key);
View Full Code Here


    }

    // ensure the new entities are what we expect with get operations
    for (int i = 0; i < 10; ++i) {
      String iStr = Long.toString(i);
      Key key = new Key.Builder(ds)
          .add("part1", "part1_" + iStr)
          .add("part2", "part2_" + iStr).build();
      compareEntitiesWithString(i, ds.get(key));
    }

    // ensure the new entities are what we expect with scan operations
    int cnt = 0;
    DatasetReader<TestEntity> reader = ds.newReader();
    try {
      for (TestEntity entity : reader) {
        compareEntitiesWithString(cnt, entity);
        cnt++;
      }
      assertEquals(10, cnt);
    } finally {
      reader.close();
    }

    Key key = new Key.Builder(ds)
        .add("part1", "part1_5")
        .add("part2", "part2_5").build();

    // test delete
    ds.delete(key);
View Full Code Here

    // Create a new entity
    ds.put(createGenericEntity(0));

    // Retrieve the entity
    String iStr = Long.toString(0);
    Key key = new Key.Builder(ds)
        .add("part1", "part1_" + iStr)
        .add("part2", "part2_" + iStr).build();
    compareEntitiesWithUtf8(0, ds.get(key));

    // delete dataset
View Full Code Here

    compositeEntity.put("SubEntity2", subEntity2);

    // Test put and get
    ds.put(compositeEntity);

    Key key = new Key.Builder(ds).add("part1", "1").add("part2", "1").build();
    Map<String, SpecificRecord> returnedCompositeEntity = ds.get(key);
    assertNotNull("found entity", returnedCompositeEntity);
    assertEquals("field1_1", ((SubEntity1)returnedCompositeEntity.get("SubEntity1")).getField1());
    assertEquals("field1_2", ((SubEntity1)returnedCompositeEntity.get("SubEntity1")).getField2());
    assertEquals("field2_1", ((SubEntity2)returnedCompositeEntity.get("SubEntity2")).getField1());
View Full Code Here

    // Get the timestamp we'll use to set the value of the profile_updated
    // action.
    long ts = System.currentTimeMillis();

    // Construct the key we'll use to fetch the user.
    Key key = new Key.Builder(userProfileActionsDataset)
        .add("firstName", firstName)
        .add("lastName", lastName)
        .build();

    // Get the profile and actions entity from the composite dao.
View Full Code Here

    // Dataset is named [table].[entity]
    RandomAccessDataset<User> users = Datasets.load(
        "dataset:hbase:quickstart.cloudera/users.User", User.class);

    // Get an accessor for the dataset and look up a user by username
    Key key = new Key.Builder(users).add("username", "bill").build();
    System.out.println(users.get(key));
    System.out.println("----");

    // Get a reader for the dataset and read the users from "bill" onwards
    DatasetReader<User> reader = null;
View Full Code Here

TOP

Related Classes of org.kitesdk.data.Key

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.