Skip to content

Conversation

@BayernMuller
Copy link
Member

@BayernMuller BayernMuller commented Dec 28, 2025

Implement basic query functionality with cardinality-based index selection

Changes

  • DOMQuery 구현: Find(), FindAll() 메서드 추가
  • Cardinality 기반 최적화: 여러 인덱스 중 가장 작은 후보 세트를 선택하여 검색 효율 향상
  • 서브트리 체크: in/out 타임스탬프 기반으로 O(1) 서브트리 판정
  • SetUtils: 벡터/맵 subset 체크를 위한 헬퍼 함수 추가

Key Features

  • Tag, Class, Attribute 인덱스 중 가장 선택적인(크기가 작은) 것을 자동 선택
  • 선택된 후보에 대해서만 나머지 조건 검사로 불필요한 순회 최소화
  • 예: tag(1000개) + class(2개) 조건 시 → class로 2개만 가져와서 tag 체크

TODO

  • DOMIndexer::AddNode에서 class/id/attribute 인덱싱 구현
  • TextQueryCondition 매칭 구현
  • 테스트 케이스 추가

불안한 점

  • text search 를 함께 사용했을 때 문제가 없는 로직인가?
  • indexer 가 attribute 를 저장하고 있는 방식이 정당한가?
  • indexer 에서 값을 요청할 때 NodeList 가 만들어지는데, 불필요한 복사가 이루어지지 않는가?
  • 모든 DOMQuery instance 가 global index 를 가지고있는 현재 구조는 무결한가?

Comment on lines +26 to +30
for (const auto& candidate : candidates) {
if (matchAllConditions(candidate, options)) {
return DOMQuery(*candidate, dom_indexer_);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchCandidatesFromIndexer에서 이미 전체 Dom에 대해 모든 option들에 대한 쿼리를 진행 했는데, 여기서 다시 모든 option에 대한 검사를 중복해서 수행하는게 비효율적으로 보임.

searchCandidatesFromIndexer에서 각 option에 대해 한 번에 할 수 있어보임.

e.g.,

  1. tag 쿼리 결과 NodeList 생성
  2. 1번 결과에서 class에 대한 쿼리 진행 (Dom 전체가 아닌 이전 결과 NodeList에서 걸러내기)
  3. ... 이후 반복

코드가 더러울거 같긴 한데, 조금 다듬어 보면 괜찮게 나올지도?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants