Package org.kiji.schema

Examples of org.kiji.schema.EntityId


  public void testViewGet(
      final KijiDataRequest request,
      final Iterable<? extends Entry<Long, ?>> expected
  ) throws Exception {
    final EntityId eid = mTable.getEntityId(ROW);
    final KijiResult<Object> view = mReader.getResult(eid, request);
    try {
      testViewGet(view, expected);
    } finally {
      view.close();
View Full Code Here


    KijiDataRequestBuilder builder = KijiDataRequest.builder().addColumns(ColumnsDef.create()
            .withMaxVersions(10)
            .add(PRIMITIVE_STRING, null)
            .add(STRING_MAP_1, null));
    KijiDataRequest request = builder.build();
    final EntityId eid = mTable.getEntityId(ROW);
    KijiResult<Object> view = mReader.getResult(eid, request);
    SortedMap<KijiColumnName, List<KijiCell<Object>>> map =
        KijiResult.Helpers.getMaterializedContents(view);
    for (KijiColumnName col: map.keySet()) {
      KijiResult<Object> newResult = view.narrowView(col);
View Full Code Here

  @Test
  public void testRowScannerWithMultiEntityIDTable() throws Exception {
    final CassandraKijiTable table = mKiji.openTable("table_two_components");
    try {
      // Reuse these entity IDs for puts and for gets.
      final EntityId alice = table.getEntityId("A", "Alice");
      final EntityId bob = table.getEntityId("B", "Bob");
      final EntityId cathy = table.getEntityId("C", "Cathy");
      final EntityId david = table.getEntityId("D", "David");

      final String family = "family";
      final String column = "column";

      final String cat = "cat";
      final String dog = "dog";
      final String fish = "fish";
      final String bird = "bird";

      final KijiTableWriter writer = table.openTableWriter();
      try {
        // Insert some data into the table.  Give various users different pets.
        writer.put(alice, family, column, 0L, cat);
        writer.put(alice, family, column, 1L, cat);
        writer.put(bob, family, column, 0L, dog);
        writer.put(cathy, family, column, 0L, fish);
        writer.put(david, family, column, 0L, bird);
      } finally {
        writer.close();
      }

      final KijiDataRequest dataRequest = KijiDataRequest.create(family, column);
      final CassandraKijiTableReader reader = table.openTableReader();

      try {
        // Fire up a row scanner!
        final KijiRowScanner scanner = reader.getScanner(dataRequest);
        try {
          HashMap<EntityId, KijiRowData> allData = new HashMap<EntityId, KijiRowData>();

          for (KijiRowData row : scanner) {
            EntityId eid = row.getEntityId();
            assert (!allData.containsKey(eid));
            allData.put(eid, row);
          }
          assertEquals(4, allData.size());
        } finally {
View Full Code Here

      // Get a handle to the table.
      KijiTable table = kiji.openTable(tableName);

      // Get the entity ID, according to this table, of the user we are
      // demonstrating with.
      EntityId entityId = table.getEntityId(userId);

      // ----- Write a row to the table. -----
      // Get a TableWriter for our table.
      KijiTableWriter tableWriter = table.openTableWriter();
      // Surround with a try/finally so the tablewriter gets closed.
View Full Code Here

  public void testUnionWriterSchema() throws Exception {
    final Kiji kiji = getKiji();
    kiji.createTable(KijiTableLayouts.getLayout(LAYOUT_UNION_WRITER));
    final KijiTable table = kiji.openTable(TABLE_NAME);
    try {
      final EntityId eid = table.getEntityId("row");
      final KijiTableWriter writer = table.getWriterFactory().openTableWriter();
      try {
        // Writing naked type "null" should work:
        writer.put(eid, "info", "user", null);
View Full Code Here

        final KijiTableWriter writer = kijiTable.openTableWriter();
        try {
          // Build & write rows to the table.
          for (Map.Entry<EntityId, Map<String, Map<String, Map<Long, Object>>>> rowEntry
              : table.entrySet()) {
            final EntityId entityId = rowEntry.getKey();
            final Map<String, Map<String, Map<Long, Object>>> row = rowEntry.getValue();
            for (Map.Entry<String, Map<String, Map<Long, Object>>> familyEntry : row.entrySet()) {
              final String familyName = familyEntry.getKey();
              final Map<String, Map<Long, Object>> family = familyEntry.getValue();
              for (Map.Entry<String, Map<Long, Object>> qualifierEntry : family.entrySet()) {
View Full Code Here

  @Test
  public void testIntForLong() throws Exception {
    final EntityIdFactory factory = EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout
        .getDesc().getKeysFormat());
    final EntityId eid = factory.getEntityId("dummy", "str1", "str2", 5, 10);

    assertEquals(eid, ToolUtils.createEntityIdFromUserInputs("['dummy', 'str1', 'str2', 5, 10]",
        mFormattedLayout));
  }
View Full Code Here

  @Test
  public void testTooFewComponents() throws IOException {
    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());
    final EntityId eid = factory.getEntityId("dummy", "str1", "str2", 5, null);

    assertEquals(eid,
        ToolUtils.createEntityIdFromUserInputs("['dummy', 'str1', 'str2', 5]", mFormattedLayout));
  }
View Full Code Here

  @Test
  public void testEmptyString() throws IOException {
    final EntityIdFactory factory =
      EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());
    final EntityId eid = factory.getEntityId("", "", "", null, null);

    assertEquals(eid,
        ToolUtils.createEntityIdFromUserInputs("['', '', '', null, null]", mFormattedLayout));
  }
View Full Code Here

    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());

    for (byte b = 32; b < 127; b++) {
      for (byte b2 = 32; b2 < 127; b2++) {
        final EntityId eid = factory.getEntityId(String.format(
            "dumm%sy", new String(new byte[]{b, b2}, "Utf-8")), "str1", "str2", 5, 10L);

        assertEquals(eid,
            ToolUtils.createEntityIdFromUserInputs(eid.toShellString(), mFormattedLayout));
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.kiji.schema.EntityId

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.