Package org.kiji.schema

Examples of org.kiji.schema.KijiTableWriter


      final String dog = "dog";
      final String rabbit = "rabbit";
      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, pets, cat, 0L, "Alister");
        writer.put(bob, pets, cat, 0L, "Buffy");
        writer.put(cathy, pets, cat, 0L, "Mr Cat");
        writer.put(david, pets, cat, 0L, "Dash");

        writer.put(alice, pets, dog, 0L, "Amour");
        writer.put(bob, pets, rabbit, 0L, "Bounce");
        writer.put(cathy, pets, fish, 0L, "Catfish");
        writer.put(david, pets, bird, 0L, "Da Bird");
      } finally {
        writer.close();
      }

      final KijiDataRequest dataRequest = KijiDataRequest.builder()
          .addColumns(
              ColumnsDef
View Full Code Here


      final String dog = "dog";
      final String rabbit = "rabbit";
      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, pets, cat, 0L, "Alister");
        writer.put(bob, pets, cat, 0L, "Buffy");
        writer.put(cathy, pets, cat, 0L, "Mr Cat");
        writer.put(david, pets, cat, 0L, "Dash");

        writer.put(alice, pets, dog, 0L, "Amour");
        writer.put(bob, pets, rabbit, 0L, "Bounce");
        writer.put(cathy, pets, fish, 0L, "Catfish");
        writer.put(david, pets, bird, 0L, "Da Bird");
      } finally {
        writer.close();
      }

      final KijiDataRequest dataRequest = KijiDataRequest.builder()
          .addColumns(
              ColumnsDef
View Full Code Here

      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();
View Full Code Here

      // 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.
      try {
        System.out.println("Putting user " + username + " into table.");
        tableWriter.put(entityId, "info", "name", username);
        // Flush the write to the table, since this is a demo and
        // we are not concerned about efficiency, we just want to
        // show that the cell got written successfully.
        tableWriter.flush();
      } finally {
        tableWriter.close();
      }

      // ----- Read a row from the table. -----
      // Get a TableReader for our table.
      KijiTableReader tableReader = table.openTableReader();
View Full Code Here

    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);

        // Writing naked type "string" should work too:
        writer.put(eid, "info", "user", "a string");

        final Schema unionNullString =
            Schema.createUnion(Lists.newArrayList(SCHEMA_NULL, SCHEMA_STRING));
        final List<AvroSchema> expectedIds = Lists.newArrayList(
            AvroSchema.newBuilder()
                .setUid(kiji.getSchemaTable().getOrCreateSchemaId(unionNullString))
                .build());

        final List<AvroSchema> writerSchemaIds =
            table.getLayout().getCellSchema(KijiColumnName.create("info:user")).getWriters();
        Assert.assertEquals(expectedIds, writerSchemaIds);

        final List<AvroSchema> writtenSchemaIds =
            table.getLayout().getCellSchema(KijiColumnName.create("info:user")).getWritten();
        Assert.assertEquals(expectedIds, writtenSchemaIds);

      } finally {
        writer.close();
      }
    } finally {
      table.release();
    }
  }
View Full Code Here

        LOG.info(String.format("  Creating and populating table: %s", tableName));
        kiji.createTable(layout.getDesc());
      }
      final KijiTable kijiTable = kiji.openTable(tableName);
      try {
        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()) {
                final String qualifierName = qualifierEntry.getKey();
                final Map<Long, Object> qualifier = qualifierEntry.getValue();
                for (Map.Entry<Long, Object> valueEntry : qualifier.entrySet()) {
                  final long timestamp = valueEntry.getKey();
                  final Object value = valueEntry.getValue();
                  LOG.info("\tBuilding put: {} -> ({}:{}, {}:{})",
                      entityId, familyName, qualifierName, timestamp, value);
                  writer.put(entityId, familyName, qualifierName, timestamp, value);
                }
              }
            }
          }
        } finally {
          writer.close();
        }
      } finally {
        kijiTable.release();
      }
    }
View Full Code Here

  }

  @Test
  public void testGroupTypeColumnPaging() throws IOException {
    EntityId id = mTable.getEntityId("me");
    final KijiTableWriter writer = mTable.openTableWriter();
    writer.put(id, "info", "name", 1L, "me");
    writer.put(id, "info", "name", 2L, "me-too");
    writer.put(id, "info", "name", 3L, "me-three");
    writer.put(id, "info", "name", 4L, "me-four");
    writer.put(id, "info", "name", 5L, "me-five");
    ResourceUtils.closeOrLog(writer);
    final KijiColumnFilter columnFilter = new KijiPaginationFilter(1);
    final KijiDataRequestBuilder builder = KijiDataRequest.builder();
    builder.newColumnsDef().withMaxVersions(5).withFilter(columnFilter).add("info", "name");
    final KijiDataRequest dataRequest = builder.build();
View Full Code Here

  }

  @Test
  public void testGroupTypeColumnPaging2() throws IOException {
    EntityId id = mTable.getEntityId("me");
    final KijiTableWriter writer = mTable.openTableWriter();
    writer.put(id, "info", "name", 1L, "me");
    writer.put(id, "info", "name", 2L, "me-too");
    writer.put(id, "info", "name", 3L, "me-three");
    writer.put(id, "info", "name", 4L, "me-four");
    writer.put(id, "info", "name", 5L, "me-five");
    ResourceUtils.closeOrLog(writer);
    final KijiColumnFilter columnFilter = new KijiPaginationFilter(1);
    final KijiDataRequestBuilder builder = KijiDataRequest.builder();
    builder.newColumnsDef().withMaxVersions(5).withFilter(columnFilter).add("info", "name");
    final KijiDataRequest dataRequest = builder.build();
View Full Code Here

    assertEquals("me-five", resultMap.get(5L).toString());
  }

  @Test
  public void testMapTypeColumnPaging() throws IOException {
    final KijiTableWriter writer = mTable.openTableWriter();
    EntityId id = mTable.getEntityId("me");
    writer.put(id, "jobs", "e", 1L, "always coming in 5th");
    writer.put(id, "jobs", "d", 2L, "always coming in 4th");
    writer.put(id, "jobs", "c", 3L, "always coming in 3rd");
    writer.put(id, "jobs", "b", 4L, "always coming in 2nd");
    writer.put(id, "jobs", "a", 5L, "always coming in 1st");
    ResourceUtils.closeOrLog(writer);
    final KijiColumnFilter columnFilter = new KijiPaginationFilter(1);
    final KijiDataRequestBuilder builder = KijiDataRequest.builder();
    builder.newColumnsDef().withMaxVersions(5).withFilter(columnFilter).addFamily("jobs");
    final KijiDataRequest dataRequest = builder.build();
View Full Code Here

    assertEquals("always coming in 1st", resultMap.get("a").get(5L).toString());
  }

  @Test
  public void testFilterMergeColumnPaging() throws IOException {
    final KijiTableWriter writer = mTable.openTableWriter();
    EntityId id = mTable.getEntityId("me");
    writer.put(id, "jobs", "b", 1L, "always coming in 5th");
    writer.put(id, "jobs", "b", 2L, "always coming in 4th");
    writer.put(id, "jobs", "b", 3L, "always coming in 3rd");
    writer.put(id, "jobs", "a", 4L, "always coming in 2nd");
    writer.put(id, "jobs", "a", 5L, "always coming in 1st");
    ResourceUtils.closeOrLog(writer);
    final KijiColumnFilter columnFilter =
        new KijiPaginationFilter(new RegexQualifierColumnFilter("b"), 1);
    final KijiDataRequestBuilder builder = KijiDataRequest.builder();
    builder.newColumnsDef().withMaxVersions(5).withFilter(columnFilter).addFamily("jobs");
View Full Code Here

TOP

Related Classes of org.kiji.schema.KijiTableWriter

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.