static inline size_t bits_to_skip_to_align_to(struct bt_btr *btr, size_t align) { size_t aligned_packet_at; aligned_packet_at = ALIGN(packet_at(btr), align); return aligned_packet_at - packet_at(btr); }
static inline enum bt_btr_status validate_contiguous_bo(struct bt_btr *btr, enum bt_byte_order next_bo) { enum bt_btr_status status = BT_BTR_STATUS_OK; /* Always valid when at a byte boundary */ if (packet_at(btr) % 8 == 0) { goto end; } /* Always valid if last byte order is unknown */ if (btr->last_bo == BT_BYTE_ORDER_UNKNOWN) { goto end; } /* Always valid if next byte order is unknown */ if (next_bo == BT_BYTE_ORDER_UNKNOWN) { goto end; } /* Make sure last byte order is compatible with the next byte order */ switch (btr->last_bo) { case BT_BYTE_ORDER_BIG_ENDIAN: case BT_BYTE_ORDER_NETWORK: if (next_bo != BT_BYTE_ORDER_BIG_ENDIAN && next_bo != BT_BYTE_ORDER_NETWORK) { status = BT_BTR_STATUS_ERROR; } break; case BT_BYTE_ORDER_LITTLE_ENDIAN: if (next_bo != BT_BYTE_ORDER_LITTLE_ENDIAN) { status = BT_BTR_STATUS_ERROR; } break; default: status = BT_BTR_STATUS_ERROR; } end: if (status < 0) { BT_LOGW("Cannot read bit array: two different byte orders not at a byte boundary: " "btr-addr=%p, last-bo=%s, next-bo=%s", btr, bt_byte_order_string(btr->last_bo), bt_byte_order_string(next_bo)); } return status; }
void doRangeSearch(const SortedIndexModule<int64_t,Int64Field>::Index &index, int64_t min, int64_t max) { SortedIndexModule<int64_t,Int64Field> sim(index, min, max); ExtentSeries series; Int64Field packet_at(series, "packet-at"); Int64Field record_id(series, "record-id"); while (true) { boost::shared_ptr<Extent> e(sim.getSharedExtent()); if (!e) { break; } series.setExtent(e); for (; series.morerecords(); ++series) { if (packet_at.val() >= min && packet_at.val() <= max) { std::cout << packet_at.val() << ":\t" << record_id.val() << "\n"; } } } }
void doSearch(const SortedIndexModule<int64_t,Int64Field>::Index &index, int64_t val) { SortedIndexModule<int64_t,Int64Field> sim(index, val); ExtentSeries series; Int64Field packet_at(series, "packet-at"); Int64Field record_id(series, "record-id"); std::cout << val << ": "; while (true) { boost::shared_ptr<Extent> e(sim.getSharedExtent()); if (!e) { break; } series.setExtent(e); for (; series.morerecords(); ++series) { if (packet_at.val() == val) { std::cout << record_id.val() << " "; } } } std::cout << "\n"; }