static public AFamilyDescriptor hcdToAFD(HColumnDescriptor hcd) throws IOException { AFamilyDescriptor afamily = new AFamilyDescriptor(); afamily.name = ByteBuffer.wrap(hcd.getName()); String compressionAlgorithm = hcd.getCompressionType().getName(); if (compressionAlgorithm == "LZO") { afamily.compression = ACompressionAlgorithm.LZO; } else if (compressionAlgorithm == "GZ") { afamily.compression = ACompressionAlgorithm.GZ; } else { afamily.compression = ACompressionAlgorithm.NONE; } afamily.maxVersions = hcd.getMaxVersions(); afamily.blocksize = hcd.getBlocksize(); afamily.inMemory = hcd.isInMemory(); afamily.timeToLive = hcd.getTimeToLive(); afamily.blockCacheEnabled = hcd.isBlockCacheEnabled(); return afamily; }
static public HColumnDescriptor afdToHCD(AFamilyDescriptor afd) throws IOException { HColumnDescriptor hcd = new HColumnDescriptor(Bytes.toBytes(afd.name)); ACompressionAlgorithm compressionAlgorithm = afd.compression; if (compressionAlgorithm == ACompressionAlgorithm.LZO) { hcd.setCompressionType(Compression.Algorithm.LZO); } else if (compressionAlgorithm == ACompressionAlgorithm.GZ) { hcd.setCompressionType(Compression.Algorithm.GZ); } else { hcd.setCompressionType(Compression.Algorithm.NONE); } if (afd.maxVersions != null) { hcd.setMaxVersions(afd.maxVersions); } if (afd.blocksize != null) { hcd.setBlocksize(afd.blocksize); } if (afd.inMemory != null) { hcd.setInMemory(afd.inMemory); } if (afd.timeToLive != null) { hcd.setTimeToLive(afd.timeToLive); } if (afd.blockCacheEnabled != null) { hcd.setBlockCacheEnabled(afd.blockCacheEnabled); } return hcd; }