Home > Backend Development > πŸ“š[Backend Development] Path ꡬ쑰의 이해.

πŸ“š[Backend Development] Path ꡬ쑰의 이해.
Backend Ddevelopment

β€œπŸ“š[Backend Development] Path ꡬ쑰의 이해.”

βœ…1️⃣ β€œ00a0z 00002β€μ˜ ν•˜μœ„ λŒ“κΈ€μ€ λ¬΄μ—‡μΌκΉŒμš”?

  • β€œ00a0z 00002β€μ˜ ν•˜μœ„ λŒ“κΈ€μ€ β€œ00a0z 00002 00000” μž…λ‹ˆλ‹€.
  • 즉, β€œ00a0z 00003”이 μ•„λ‹ˆλΌ β€œ00a0z 00002 00000”이 ν•˜μœ„ λŒ“κΈ€μž…λ‹ˆλ‹€.

βœ…2️⃣ ν•˜μœ„ λŒ“κΈ€μ΄ β€œ00a0z 00002 00000”인 이유?

πŸ“Œ1️⃣ Path ꡬ쑰 이해.

  • CommentPathμ—μ„œ λŒ“κΈ€μ˜ pathλŠ” λΆ€λͺ¨ λŒ“κΈ€μ˜ path + ν•˜μœ„ λŒ“κΈ€μ˜ 5자리 λ¬Έμžμ—΄λ‘œ κ΅¬μ„±λ©λ‹ˆλ‹€.
    • 각 λŒ“κΈ€μ˜ pathλŠ” DEPTH_CHUNK_SIZE = 5 κΈ°μ€€μœΌλ‘œ 5μžλ¦¬μ”© μ¦κ°€ν•©λ‹ˆλ‹€.
    • depthκ°€ κΉŠμ–΄μ§ˆμˆ˜λ‘ path λ¬Έμžμ—΄ 길이가 κΈΈμ–΄μ§‘λ‹ˆλ‹€.

πŸ“ μ˜ˆμ‹œ:

λΆ€λͺ¨ λŒ“κΈ€: 00a0z
    -> 첫 번째 ν•˜μœ„ λŒ“κΈ€: 00a0z00000
        -> 두 번째 ν•˜μœ„ λŒ“κΈ€: 00a0z0000000000
  • 즉, ν•˜μœ„ λŒ“κΈ€μ˜ pathλŠ” λΆ€λͺ¨ λŒ“κΈ€ pathλ₯Ό ν¬ν•¨ν•˜λ©°, 5μžλ¦¬μ”© μΆ”κ°€λ©λ‹ˆλ‹€.

πŸ“Œ2️⃣ descendantsTopPath vs childrenTopPath

1️⃣ childrenTopPath (ν˜„μž¬ λŒ“κΈ€μ˜ 직접적인 ν•˜μœ„)

String childrenTopPath = findChildrenTopPath(descendantsTopPath);
private String findChildrenTopPath(String descendantsTopPath) {
    return descendantsTopPath.substring(0, (getDepth() + 1) * DEPTH_CHUNK_SIZE);
}
  • descendantsTopPath = β€œ00a0z0000200000”
  • childrenTopPath = β€œ00a0z00002” (5μžλ¦¬μ”© μžλ¦„)

2️⃣ descendantsTopPath (ν˜„μž¬ λŒ“κΈ€μ˜ λͺ¨λ“  μžμ† 쀑 κ°€μž₯ 큰 path)

  • descendantsTopPathλŠ” ν˜„μž¬ λŒ“κΈ€μ΄ ν¬ν•¨λœ 전체 ν•˜μœ„ νŠΈλ¦¬μ—μ„œ κ°€μž₯ λ§ˆμ§€λ§‰ λŒ“κΈ€μ˜ pathμž…λ‹ˆλ‹€.
  • 즉, 00a0z00002의 λͺ¨λ“  μžμ† λŒ“κΈ€ 쀑 κ°€μž₯ λ§ˆμ§€λ§‰ λŒ“κΈ€μ΄ 00a0z0000200000 μž…λ‹ˆλ‹€.

πŸ“Œ κ²°λ‘ 

  • 00a0z00002의 직접적인 ν•˜μœ„ λŒ“κΈ€μ€ 00a0z0000200000 μž…λ‹ˆλ‹€.
  • 00a0z00003은 00a0z00002와 같은 depthμ—μ„œ 생성될 μƒˆλ‘œμš΄ sibling λŒ“κΈ€μΌ 뿐, 00a0z00002의 ν•˜μœ„ λŒ“κΈ€μ΄ μ•„λ‹™λ‹ˆλ‹€.

πŸš€ 정리.

  • βœ… 00a0z00002의 ν•˜μœ„ λŒ“κΈ€μ€ 00a0z0000200000이닀.
  • βœ… λŒ“κΈ€ κ΅¬μ‘°μ—μ„œ λΆ€λͺ¨ λŒ“κΈ€μ˜ path + 5자리 λ¬Έμžμ—΄μ΄ ν•˜μœ„ λŒ“κΈ€μ˜ pathκ°€ λœλ‹€.
  • βœ… descendantsTopPathλ₯Ό ν™œμš©ν•΄ λͺ¨λ“  μžμ† 쀑 κ°€μž₯ λ§ˆμ§€λ§‰ λŒ“κΈ€μ„ μ°Ύκ³ , 이λ₯Ό 기반으둜 μƒˆλ‘œμš΄ λŒ“κΈ€μ˜ pathλ₯Ό κ²°μ •ν•œλ‹€.
  • βœ… β€œ00a0z00003”은 같은 depth의 sibling(ν˜•μ œ λŒ“κΈ€)이지, ν•˜μœ„ λŒ“κΈ€μ΄ μ•„λ‹ˆλ‹€.