Package org.apache.blur.thrift.generated

Examples of org.apache.blur.thrift.generated.Record


public class BlurThriftHelperTest {

  @Test
  public void testRecordMatch() {
    Record r1 = BlurThriftHelper.newRecord("test-family", "record-1", BlurThriftHelper.newColumn("a", "b"));
    Record r2 = BlurThriftHelper.newRecord("test-family", "record-1", BlurThriftHelper.newColumn("c", "d"));
    Record r3 = BlurThriftHelper.newRecord("test-family", "record-2", BlurThriftHelper.newColumn("e", "f"));
    Record r4 = BlurThriftHelper.newRecord("test-family-2", "record-1", BlurThriftHelper.newColumn("g", "h"));

    assertTrue("should match with same family and record-id", BlurThriftHelper.match(r1, r2));
    assertFalse("should not match with different record-id", BlurThriftHelper.match(r1, r3));
    assertFalse("should not match with different family", BlurThriftHelper.match(r1, r4));
  }
View Full Code Here


        BlurThriftHelper.newColumn("a", "b"));
    RecordMutation rm2 = BlurThriftHelper.newRecordMutation("test-family", "record-2",
        BlurThriftHelper.newColumn("c", "d"));
    RecordMutation rm3 = BlurThriftHelper.newRecordMutation("test-family-2", "record-1",
        BlurThriftHelper.newColumn("e", "f"));
    Record r = BlurThriftHelper.newRecord("test-family", "record-1", BlurThriftHelper.newColumn("g", "h"));

    assertTrue("should match with same family and record-id", BlurThriftHelper.match(rm1, r));
    assertFalse("should not match with different record-id", BlurThriftHelper.match(rm2, r));
    assertFalse("should not match with different family", BlurThriftHelper.match(rm3, r));
  }
View Full Code Here

    RecordMutation rm2 = BlurThriftHelper.newRecordMutation("test-family", "record-2",
        BlurThriftHelper.newColumn("c", "d"));
    RecordMutation rm3 = BlurThriftHelper.newRecordMutation("test-family-2", "record-1",
        BlurThriftHelper.newColumn("e", "f"));
    RowMutation row = BlurThriftHelper.newRowMutation("test-table", "row-123", rm1, rm2, rm3);
    Record r = BlurThriftHelper.newRecord("test-family", "record-2", BlurThriftHelper.newColumn("g", "h"));
    Record r2 = BlurThriftHelper.newRecord("test-family", "record-99", BlurThriftHelper.newColumn("g", "h"));

    assertEquals("should find record-2", rm2, BlurThriftHelper.findRecordMutation(row, r));
    assertNull("should not find record-99", BlurThriftHelper.findRecordMutation(row, r2));
  }
View Full Code Here

    recordMutation.setRecordMutationType(RecordMutationType.REPLACE_ENTIRE_RECORD);
    return recordMutation;
  }

  private static Record getRecord(int numberOfColumns, int numberOfFamilies, int numberOfWords) {
    Record record = new Record();
    record.setRecordId(getRowId());
    record.setFamily(getFamily(numberOfFamilies));
    for (int i = 0; i < numberOfColumns; i++) {
      record.addToColumns(new Column("col" + i, getWords(numberOfWords)));
    }
    return record;
  }
View Full Code Here

        try {
          FetchRecordResult recordResult = result.getFetchResult().getRecordResult();
          selector.setRowId(recordResult.getRowid());
          selector.setRecordId(recordResult.getRecord().getRecordId());
          fetchResult = client.fetchRow(tableName, selector);
          Record record = fetchResult.recordResult.record;
          if (!record.family.equals(columnFamily)) {
            continue INNER;
          }
          String rowId = fetchResult.recordResult.rowid;
          displayRows.add(addColumns(result.getScore(), result.getLocationId(), rowId, record.family, record));
View Full Code Here

    recordMutation.setRecordMutationType(RecordMutationType.REPLACE_ENTIRE_RECORD);
    return recordMutation;
  }

  private static Record getRecord(int numberOfColumns, int numberOfFamilies, int numberOfWords) {
    Record record = new Record();
    record.setRecordId(getRowId());
    record.setFamily(getFamily(numberOfFamilies));
    for (int i = 0; i < numberOfColumns; i++) {
      record.addToColumns(new Column("col" + i, getWords(numberOfWords)));
    }
    return record;
  }
View Full Code Here

    }
    return mutation;
  }

  public static Record newRecord(String family, String recordId, Column... columns) {
    Record record = new Record();
    record.setRecordId(recordId);
    record.setFamily(family);
    record.setColumns(Arrays.asList(columns));
    return record;
  }
View Full Code Here

    return newRecordMutation(RecordMutationType.REPLACE_ENTIRE_RECORD, family, recordId, columns);
  }

  public static RecordMutation newRecordMutation(RecordMutationType type, String family, String recordId,
      Column... columns) {
    Record record = new Record();
    record.setRecordId(recordId);
    record.setFamily(family);
    for (Column column : columns) {
      record.addToColumns(column);
    }

    RecordMutation mutation = new RecordMutation();
    mutation.setRecordMutationType(type);
    mutation.setRecord(record);
View Full Code Here

    blurIndex.replaceRow(mutation.waitToBeVisible, mutation.wal, updateMetrics(newRow));

  }

  private static void doUpdateRecordMutation(RecordMutation recordMutation, Record existingRecord, Row newRow) {
    Record mutationRecord = recordMutation.record;
    switch (recordMutation.recordMutationType) {
    case DELETE_ENTIRE_RECORD:
      return;
    case APPEND_COLUMN_VALUES:
      for (Column column : mutationRecord.columns) {
        existingRecord.addToColumns(column);
      }
      newRow.addToRecords(existingRecord);
      break;
    case REPLACE_ENTIRE_RECORD:
      newRow.addToRecords(mutationRecord);
      break;
    case REPLACE_COLUMNS:
      Set<String> columnNames = new HashSet<String>();
      for (Column column : mutationRecord.columns) {
        columnNames.add(column.name);
      }

      LOOP: for (Column column : existingRecord.columns) {
        // skip columns in existing record that are contained in the mutation
        // record
        if (columnNames.contains(column.name)) {
          continue LOOP;
        }
        mutationRecord.addToColumns(column);
      }
      newRow.addToRecords(mutationRecord);
      break;
    default:
      break;
View Full Code Here

    writeString(outputStream, row.id);
    List<Record> records = row.records;
    int size = records.size();
    outputStream.writeInt(size);
    for (int i = 0; i < size; i++) {
      Record record = records.get(i);
      writeRecord(outputStream, record);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.blur.thrift.generated.Record

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.