Skip to content

Commit

Permalink
HBase fetch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin committed Nov 2, 2016
1 parent 32d61fe commit d234848
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class AccumuloAttributeStore(val connector: Connector, val attributeTable: Strin
}

def layerExists(layerId: LayerId): Boolean =
!fetch(Some(layerId), AttributeStore.Fields.metadata).isEmpty
fetch(Some(layerId), AttributeStore.Fields.metadata).nonEmpty

def delete(layerId: LayerId): Unit = delete(layerId, None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ class HBaseAttributeStore(val instance: HBaseInstance, val attributeTable: Strin

private def fetch(layerId: Option[LayerId], attributeName: String): Vector[Result] =
instance.withTableConnectionDo(attributeTableName) { table =>
val scan = new Scan()
layerId.foreach { id =>
scan.setStartRow(layerIdString(id))
scan.setStopRow(stringToBytes(layerIdString(id)) :+ 0.toByte) // add trailing byte, to include stop row
}
scan.addFamily(attributeName)
val scanner = table.getScanner(scan)
try scanner.iterator().toVector finally scanner.close()
if (table.getTableDescriptor.hasFamily(attributeName)) {
val scan = new Scan()
layerId.foreach { id =>
scan.setStartRow(layerIdString(id))
scan.setStopRow(stringToBytes(layerIdString(id)) :+ 0.toByte) // add trailing byte, to include stop row
}
scan.addFamily(attributeName)
val scanner = table.getScanner(scan)
try scanner.iterator().toVector finally scanner.close()
} else Vector()
}


private def delete(layerId: LayerId, attributeName: Option[String]): Unit =
instance.withTableConnectionDo(attributeTableName) { table =>
if (!layerExists(layerId)) throw new LayerNotFoundError(layerId)
Expand Down Expand Up @@ -101,7 +102,7 @@ class HBaseAttributeStore(val instance: HBaseInstance, val attributeTable: Strin
}

def layerExists(layerId: LayerId): Boolean =
!fetch(Some(layerId), AttributeStore.Fields.metadata).isEmpty
fetch(Some(layerId), AttributeStore.Fields.metadata).nonEmpty

def delete(layerId: LayerId): Unit = delete(layerId, None)

Expand Down

0 comments on commit d234848

Please sign in to comment.