contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java
/* Methods to get the column family schema from Cassandra */
Methods to get the column family schema from Cassandra
Methods to get the column family schema from Cassandra
private void initSchema(String signature)
    {
        UDFContext context = UDFContext.getUDFContext();
        Properties property = context.getUDFProperties(CassandraStorage.class);
        if (!property.containsKey(signature))
        {
            Cassandra.Client client = null;
            try
            {
                client = ConfigHelper.getClientFromInputAddressList(conf);
                CfDef cfDef = null;
                client.set_keyspace(keyspace);
                KsDef ksDef = client.describe_keyspace(keyspace);
                List<CfDef> defs = ksDef.getCf_defs();
                for (CfDef def : defs)
                {
                    if (column_family.equalsIgnoreCase(def.getName()))
                    {
                        cfDef = def;
                        break;
                    }
                }
                property.setProperty(signature, cfdefToString(cfDef));
            }
            catch (TException e)
            {
                throw new RuntimeException(e);
            }
            catch (InvalidRequestException e)
            {
                throw new RuntimeException(e);
            }
            catch (NotFoundException e)
            {
                throw new RuntimeException(e);
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
        }
    }
private void initSchema ( String signature ) { UDFContext context = UDFContext . getUDFContext ( ) ; Properties property = context . getUDFProperties ( CassandraStorage . class ) ; if ( ! property . containsKey ( signature ) ) { Cassandra . Client client = null ; try { client = ConfigHelper . getClientFromInputAddressList ( conf ) ; CfDef cfDef = null ; client . set_keyspace ( keyspace ) ; KsDef ksDef = client . describe_keyspace ( keyspace ) ; List < CfDef > defs = ksDef . getCf_defs ( ) ; for ( CfDef def : defs ) { if ( column_family . equalsIgnoreCase ( def . getName ( ) ) ) { cfDef = def ; break ; } } property . setProperty ( signature , cfdefToString ( cfDef ) ) ; } catch ( TException e ) { throw new RuntimeException ( e ) ; } catch ( InvalidRequestException e ) { throw new RuntimeException ( e ) ; } catch ( NotFoundException e ) { throw new RuntimeException ( e ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } }
Methods to get the column family schema from Cassandra
Methods to get the column family schema from Cassandra
// Only get the schema if we haven't already gotten it