Package org.apache.blur.thrift.generated

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


    record.setColumns(Arrays.asList(columns));
    return record;
  }

  public static Row newRow(String rowId, Record... records) {
    Row row = new Row().setId(rowId);
    for (Record record : records) {
      row.addToRecords(record);
    }
    return row;
  }
View Full Code Here


        String rowId = getRowId(reader, docId);
        Term term = new Term(ROW_ID, rowId);
        if (returnIdsOnly) {
          int recordCount = BlurUtil.countDocuments(reader, term);
          fetchResult.rowResult = new FetchRowResult();
          fetchResult.rowResult.row = new Row(rowId, null, recordCount);
        } else {
          List<Document> docs;
          if (highlightQuery != null && fieldManager != null) {
            HighlightOptions highlightOptions = selector.getHighlightOptions();
            String preTag = highlightOptions.getPreTag();
View Full Code Here

        waitVisiblity = waitToBeVisible;
      }
      RowMutationType type = mutation.rowMutationType;
      switch (type) {
      case REPLACE_ROW:
        Row row = MutationHelper.getRowFromMutations(mutation.rowId, mutation.recordMutations);
        blurIndex.replaceRow(waitVisiblity, mutation.wal, updateMetrics(row));
        break;
      case UPDATE_ROW:
        doUpdateRowMutation(mutation, blurIndex);
        break;
View Full Code Here

    }

    RowMutationType type = mutation.rowMutationType;
    switch (type) {
    case REPLACE_ROW:
      Row row = MutationHelper.getRowFromMutations(mutation.rowId, mutation.recordMutations);
      blurIndex.replaceRow(mutation.waitToBeVisible, mutation.wal, updateMetrics(row));
      break;
    case UPDATE_ROW:
      doUpdateRowMutation(mutation, blurIndex);
      break;
View Full Code Here

  private void doUpdateRowMutation(RowMutation mutation, BlurIndex blurIndex) throws BlurException, IOException {
    FetchResult fetchResult = new FetchResult();
    Selector selector = new Selector();
    selector.setRowId(mutation.rowId);
    fetchRow(mutation.table, selector, fetchResult);
    Row existingRow;
    if (fetchResult.exists) {
      // We will examine the contents of the existing row and add records
      // onto a new replacement row based on the mutation we have been given.
      existingRow = fetchResult.rowResult.row;
    } else {
      // The row does not exist, create empty new row.
      existingRow = new Row().setId(mutation.getRowId());
      existingRow.records = new ArrayList<Record>();
    }
    Row newRow = new Row().setId(existingRow.id);

    // Create a local copy of the mutation we can modify
    RowMutation mutationCopy = mutation.deepCopy();

    // Match existing records against record mutations. Once a record
    // mutation has been processed, remove it from our local copy.
    for (Record existingRecord : existingRow.records) {
      RecordMutation recordMutation = findRecordMutation(mutationCopy, existingRecord);
      if (recordMutation != null) {
        mutationCopy.recordMutations.remove(recordMutation);
        doUpdateRecordMutation(recordMutation, existingRecord, newRow);
      } else {
        // Copy existing records over to the new row unmodified if there
        // is no matching mutation.
        newRow.addToRecords(existingRecord);
      }
    }

    // Examine all remaining record mutations. For any record replacements
    // we need to create a new record in the table even though an existing
    // record did not match. Record deletions are also ok here since the
    // record is effectively already deleted. Other record mutations are
    // an error and should generate an exception.
    for (RecordMutation recordMutation : mutationCopy.recordMutations) {
      RecordMutationType type = recordMutation.recordMutationType;
      switch (type) {
      case DELETE_ENTIRE_RECORD:
        // do nothing as missing record is already in desired state
        break;
      case APPEND_COLUMN_VALUES:
        throw new BException("Mutation cannot append column values to non-existent record", recordMutation);
      case REPLACE_ENTIRE_RECORD:
        newRow.addToRecords(recordMutation.record);
        break;
      case REPLACE_COLUMNS:
        throw new BException("Mutation cannot replace columns in non-existent record", recordMutation);
      default:
        throw new RuntimeException("Unsupported record mutation type [" + type + "]");
View Full Code Here

    while ((buffer = readBuffer(inputStream)) != null) {
      DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(buffer));
      TYPE lookup = TYPE.lookup(dataInputStream.readByte());
      switch (lookup) {
      case ROW:
        Row row = readRow(dataInputStream);
        writer.updateDocuments(createRowId(row.id), getDocs(row, _fieldManager));
        updateCount++;
        continue;
      case DELETE:
        String deleteRowId = readString(dataInputStream);
View Full Code Here

      writeRecord(outputStream, record);
    }
  }

  private static Row readRow(DataInputStream inputStream) throws IOException {
    Row row = new Row();
    row.id = readString(inputStream);
    int size = inputStream.readInt();
    for (int i = 0; i < size; i++) {
      row.addToRecords(readRecord(inputStream));
    }
    return row;
  }
View Full Code Here

      displayRowsPosition = 0;
      final BlurResult result = results.results.get(resultPosition);
      try {
        selector.setRowId(result.getFetchResult().getRowResult().getRow().getId());
        fetchResult = client.fetchRow(tableName, selector);
        Row row = fetchResult.rowResult.row;
        String rowId = row.id;
        List<Record> records = row.records;
        for (Record record : records) {
          displayRows.add(addColumns(result.getScore(), result.getLocationId(), rowId, record.family, record));
        }
View Full Code Here

    result.setRowid(rowId);
    return result;
  }

  public static Row getRow(Iterable<Document> docs) {
    Row row = new Row();
    boolean empty = true;
    if (docs == null) {
      return null;
    }
    for (Document document : docs) {
      empty = false;
      BlurThriftRecord record = new BlurThriftRecord();
      String rowId = readRecord(document, record);
      if (record.getColumns() != null) {
        row.addToRecords(record);
      }
      if (row.id == null) {
        row.setId(rowId);
      }
      row.recordCount++;
    }
    if (empty) {
      return null;
View Full Code Here

  public static String getControllerConnectionStr() {
    return controllerConnectionStr;
  }

  private static void addRow(String table, int i, Iface client) throws BlurException, TException {
    Row row = new Row();
    row.setId(Integer.toString(i));
    Record record = new Record();
    record.setRecordId(Integer.toString(i));
    record.setFamily("test");
    record.addToColumns(new Column("test", Integer.toString(i)));
    row.addToRecords(record);
    RowMutation rowMutation = BlurUtil.toRowMutation(table, row);
    rowMutation.setWal(false);
    client.mutate(rowMutation);
  }
View Full Code Here

TOP

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

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.